source: src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp@ bf3817

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since bf3817 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * LinearInterpolationofTrajectoriesAction.cpp
3 *
4 * Created on: May 10, 2010
5 * Author: heber
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
16#include "Actions/ActionRegistry.hpp"
17#include "atom.hpp"
18#include "defs.hpp"
19#include "Helpers/Log.hpp"
20#include "molecule.hpp"
21#include "Helpers/Verbose.hpp"
22#include "World.hpp"
23
24#include <iostream>
25#include <fstream>
26#include <string>
27
28using namespace std;
29
30#include "UIElements/UIFactory.hpp"
31#include "UIElements/Dialog.hpp"
32#include "Actions/ValueStorage.hpp"
33
34
35/****** MoleculeLinearInterpolationofTrajectoriesAction *****/
36
37// memento to remember the state when undoing
38
39//class MoleculeLinearInterpolationofTrajectoriesState : public ActionState {
40//public:
41// MoleculeLinearInterpolationofTrajectoriesState(molecule* _mol,std::string _lastName) :
42// mol(_mol),
43// lastName(_lastName)
44// {}
45// molecule* mol;
46// std::string lastName;
47//};
48
49const char MoleculeLinearInterpolationofTrajectoriesAction::NAME[] = "linear-interpolate";
50
51MoleculeLinearInterpolationofTrajectoriesAction::MoleculeLinearInterpolationofTrajectoriesAction() :
52 Action(NAME)
53{}
54
55MoleculeLinearInterpolationofTrajectoriesAction::~MoleculeLinearInterpolationofTrajectoriesAction()
56{}
57
58void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping) {
59 ValueStorage::getInstance().setCurrentValue(MoleculeLinearInterpolationofTrajectoriesAction::NAME, filename);
60 ValueStorage::getInstance().setCurrentValue("start-step", start);
61 ValueStorage::getInstance().setCurrentValue("end-step", end);
62 ValueStorage::getInstance().setCurrentValue("id-mapping", IdMapping);
63 ActionRegistry::getInstance().getActionByName(MoleculeLinearInterpolationofTrajectoriesAction::NAME)->call(Action::NonInteractive);
64};
65
66Dialog* MoleculeLinearInterpolationofTrajectoriesAction::fillDialog(Dialog *dialog) {
67 ASSERT(dialog,"No Dialog given when filling action dialog");
68
69 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
70 dialog->queryInt("start-step", ValueStorage::getInstance().getDescription("start-step"));
71 dialog->queryInt("end-step", ValueStorage::getInstance().getDescription("end-step"));
72 dialog->queryBoolean("id-mapping", ValueStorage::getInstance().getDescription("id-mapping"));
73
74 return dialog;
75}
76
77Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() {
78 string filename;
79 molecule *mol = NULL;
80 int start = -1;
81 int end = -1;
82 bool IdMapping = true;
83
84 ValueStorage::getInstance().queryCurrentValue(NAME, filename);
85 ValueStorage::getInstance().queryCurrentValue("start-step", start);
86 ValueStorage::getInstance().queryCurrentValue("end-step", end);
87 ValueStorage::getInstance().queryCurrentValue("id-mapping", IdMapping);
88
89 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
90 mol = iter->second;
91 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl);
92 if (IdMapping)
93 DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
94 if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping))
95 DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl);
96 else
97 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
98 }
99 return Action::success;
100}
101
102Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performUndo(Action::state_ptr _state) {
103// MoleculeLinearInterpolationofTrajectoriesState *state = assert_cast<MoleculeLinearInterpolationofTrajectoriesState*>(_state.get());
104
105// string newName = state->mol->getName();
106// state->mol->setName(state->lastName);
107
108 return Action::failure;
109}
110
111Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performRedo(Action::state_ptr _state){
112 // Undo and redo have to do the same for this action
113 return performUndo(_state);
114}
115
116bool MoleculeLinearInterpolationofTrajectoriesAction::canUndo() {
117 return false;
118}
119
120bool MoleculeLinearInterpolationofTrajectoriesAction::shouldUndo() {
121 return false;
122}
123
124const string MoleculeLinearInterpolationofTrajectoriesAction::getName() {
125 return NAME;
126}
Note: See TracBrowser for help on using the repository browser.