[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"
|
---|
| 20 | #include "Actions/MapOfActions.hpp"
|
---|
| 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 |
|
---|
| 49 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
|
---|
| 50 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
| 51 | molecule *mol = NULL;
|
---|
| 52 |
|
---|
| 53 | dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
|
---|
| 54 |
|
---|
| 55 | if(dialog->display()) {
|
---|
| 56 | DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
|
---|
| 57 | mol->PrincipalAxisSystem(true);
|
---|
| 58 | delete dialog;
|
---|
| 59 | return Action::success;
|
---|
| 60 | }
|
---|
| 61 | delete dialog;
|
---|
| 62 | return Action::failure;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
|
---|
| 66 | // MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
|
---|
| 67 |
|
---|
| 68 | // string newName = state->mol->getName();
|
---|
| 69 | // state->mol->setName(state->lastName);
|
---|
| 70 |
|
---|
| 71 | return Action::failure;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
|
---|
| 75 | // Undo and redo have to do the same for this action
|
---|
| 76 | return performUndo(_state);
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | bool MoleculeRotateToPrincipalAxisSystemAction::canUndo() {
|
---|
| 80 | return false;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | bool MoleculeRotateToPrincipalAxisSystemAction::shouldUndo() {
|
---|
| 84 | return false;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | const string MoleculeRotateToPrincipalAxisSystemAction::getName() {
|
---|
| 88 | return NAME;
|
---|
| 89 | }
|
---|