source: src/Actions/MoleculeAction/RotateAroundOriginByAngleAction.cpp@ eaf4ae

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 Candidate_v1.7.0 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 eaf4ae was eaf4ae, checked in by Frederik Heber <heber@…>, 15 years ago

Added two new actions.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * RotateAroundOriginByAngleAction.cpp
3 *
4 * Created on: Aug 06, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Actions/MoleculeAction/RotateAroundOriginByAngleAction.hpp"
11#include "Actions/ActionRegistry.hpp"
12#include "Helpers/Log.hpp"
13#include "Helpers/Verbose.hpp"
14#include "LinearAlgebra/Line.hpp"
15#include "LinearAlgebra/Vector.hpp"
16#include "molecule.hpp"
17
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/****** MoleculeRotateAroundOriginByAngleAction *****/
30
31// memento to remember the state when undoing
32
33//class MoleculeRotateAroundOriginByAngleState : public ActionState {
34//public:
35// MoleculeRotateAroundOriginByAngleState(molecule* _mol,std::string _lastName) :
36// mol(_mol),
37// lastName(_lastName)
38// {}
39// molecule* mol;
40// std::string lastName;
41//};
42
43const char MoleculeRotateAroundOriginByAngleAction::NAME[] = "rotate-origin";
44
45MoleculeRotateAroundOriginByAngleAction::MoleculeRotateAroundOriginByAngleAction() :
46 Action(NAME)
47{}
48
49MoleculeRotateAroundOriginByAngleAction::~MoleculeRotateAroundOriginByAngleAction()
50{}
51
52void MoleculeRotateAroundOriginByAngle(double angle) {
53 ValueStorage::getInstance().setCurrentValue(MoleculeRotateAroundOriginByAngleAction::NAME, angle);
54 ActionRegistry::getInstance().getActionByName(MoleculeRotateAroundOriginByAngleAction::NAME)->call(Action::NonInteractive);
55};
56
57Dialog* MoleculeRotateAroundOriginByAngleAction::fillDialog(Dialog *dialog) {
58 ASSERT(dialog,"No Dialog given when filling action dialog");
59
60 dialog->queryDouble(NAME, MapOfActions::getInstance().getDescription(NAME));
61 dialog->queryVector("position", false, MapOfActions::getInstance().getDescription("position"));
62
63 return dialog;
64}
65
66Action::state_ptr MoleculeRotateAroundOriginByAngleAction::performCall() {
67 molecule *mol = NULL;
68 double alpha = 0.;
69 Vector Axis;
70
71 // obtain axis to rotate to
72 ValueStorage::getInstance().queryCurrentValue(NAME, alpha);
73 ValueStorage::getInstance().queryCurrentValue("position", Axis);
74
75 DoLog(0) && (Log() << Verbose(0) << "Rotate around origin by " << alpha << ", axis from origin to " << Axis << "." << endl);
76 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
77 mol = iter->second;
78
79 // Creation Line that is the rotation axis
80 Line RotationAxis(Vector(0.,0.,0.), Axis);
81
82 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
83 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), alpha);
84 }
85 DoLog(0) && (Log() << Verbose(0) << "done." << endl);
86 }
87 return Action::success;
88}
89
90Action::state_ptr MoleculeRotateAroundOriginByAngleAction::performUndo(Action::state_ptr _state) {
91// MoleculeRotateOriginState *state = assert_cast<MoleculeRotateOriginState*>(_state.get());
92
93// string newName = state->mol->getName();
94// state->mol->setName(state->lastName);
95
96 return Action::failure;
97}
98
99Action::state_ptr MoleculeRotateAroundOriginByAngleAction::performRedo(Action::state_ptr _state){
100 // Undo and redo have to do the same for this action
101 return performUndo(_state);
102}
103
104bool MoleculeRotateAroundOriginByAngleAction::canUndo() {
105 return false;
106}
107
108bool MoleculeRotateAroundOriginByAngleAction::shouldUndo() {
109 return false;
110}
111
112const string MoleculeRotateAroundOriginByAngleAction::getName() {
113 return NAME;
114}
Note: See TracBrowser for help on using the repository browser.