[97ebf8] | 1 | /*
|
---|
| 2 | * RotateToPrincipalAxisSystemAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 10, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[112b09] | 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
[97ebf8] | 10 | #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
|
---|
| 11 |
|
---|
| 12 | #include <iostream>
|
---|
| 13 | #include <fstream>
|
---|
| 14 | #include <string>
|
---|
| 15 |
|
---|
| 16 | using namespace std;
|
---|
| 17 |
|
---|
| 18 | #include "UIElements/UIFactory.hpp"
|
---|
| 19 | #include "UIElements/Dialog.hpp"
|
---|
[845613] | 20 | #include "UIElements/ValueStorage.hpp"
|
---|
[97ebf8] | 21 |
|
---|
| 22 | #include "log.hpp"
|
---|
| 23 | #include "molecule.hpp"
|
---|
| 24 | #include "verbose.hpp"
|
---|
| 25 |
|
---|
| 26 | /****** MoleculeRotateToPrincipalAxisSystemAction *****/
|
---|
| 27 |
|
---|
| 28 | // memento to remember the state when undoing
|
---|
| 29 |
|
---|
| 30 | //class MoleculeRotateToPrincipalAxisSystemState : public ActionState {
|
---|
| 31 | //public:
|
---|
| 32 | // MoleculeRotateToPrincipalAxisSystemState(molecule* _mol,std::string _lastName) :
|
---|
| 33 | // mol(_mol),
|
---|
| 34 | // lastName(_lastName)
|
---|
| 35 | // {}
|
---|
| 36 | // molecule* mol;
|
---|
| 37 | // std::string lastName;
|
---|
| 38 | //};
|
---|
| 39 |
|
---|
| 40 | const char MoleculeRotateToPrincipalAxisSystemAction::NAME[] = "rotate-to-pas";
|
---|
| 41 |
|
---|
| 42 | MoleculeRotateToPrincipalAxisSystemAction::MoleculeRotateToPrincipalAxisSystemAction() :
|
---|
| 43 | Action(NAME)
|
---|
| 44 | {}
|
---|
| 45 |
|
---|
| 46 | MoleculeRotateToPrincipalAxisSystemAction::~MoleculeRotateToPrincipalAxisSystemAction()
|
---|
| 47 | {}
|
---|
| 48 |
|
---|
[845613] | 49 | Dialog* MoleculeRotateToPrincipalAxisSystemAction::createDialog() {
|
---|
[97ebf8] | 50 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
| 51 |
|
---|
[845613] | 52 | dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
|
---|
| 53 |
|
---|
| 54 | return dialog;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
|
---|
| 58 | molecule *mol = NULL;
|
---|
[97ebf8] | 59 |
|
---|
[845613] | 60 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
---|
| 61 | mol = iter->second;
|
---|
[97ebf8] | 62 | DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
|
---|
| 63 | mol->PrincipalAxisSystem(true);
|
---|
| 64 | }
|
---|
[845613] | 65 | return Action::success;
|
---|
[97ebf8] | 66 | }
|
---|
| 67 |
|
---|
| 68 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
|
---|
| 69 | // MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
|
---|
| 70 |
|
---|
| 71 | // string newName = state->mol->getName();
|
---|
| 72 | // state->mol->setName(state->lastName);
|
---|
| 73 |
|
---|
| 74 | return Action::failure;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
|
---|
| 78 | // Undo and redo have to do the same for this action
|
---|
| 79 | return performUndo(_state);
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | bool MoleculeRotateToPrincipalAxisSystemAction::canUndo() {
|
---|
| 83 | return false;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | bool MoleculeRotateToPrincipalAxisSystemAction::shouldUndo() {
|
---|
| 87 | return false;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | const string MoleculeRotateToPrincipalAxisSystemAction::getName() {
|
---|
| 91 | return NAME;
|
---|
| 92 | }
|
---|