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

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 c89fb4 was c89fb4, checked in by Frederik Heber <heber@…>, 14 years ago

FIX: Some Actions still accessed MapOfActions instead of ValueStorage.

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