[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[97ebf8] | 8 | /*
|
---|
| 9 | * RotateToPrincipalAxisSystemAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 10, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 21 |
|
---|
[ad011c] | 22 | #include "CodePatterns/Log.hpp"
|
---|
| 23 | #include "CodePatterns/Verbose.hpp"
|
---|
[6e5084] | 24 | #include "LinearAlgebra/Line.hpp"
|
---|
[cca9ef] | 25 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[6e5084] | 26 | #include "LinearAlgebra/Vector.hpp"
|
---|
| 27 | #include "element.hpp"
|
---|
| 28 | #include "molecule.hpp"
|
---|
[1a3c26] | 29 |
|
---|
[97ebf8] | 30 |
|
---|
| 31 | #include <iostream>
|
---|
| 32 | #include <fstream>
|
---|
| 33 | #include <string>
|
---|
| 34 |
|
---|
| 35 | using namespace std;
|
---|
| 36 |
|
---|
[1fd675] | 37 | #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
|
---|
[845613] | 38 |
|
---|
[1fd675] | 39 | // and construct the stuff
|
---|
| 40 | #include "RotateToPrincipalAxisSystemAction.def"
|
---|
| 41 | #include "Action_impl_pre.hpp"
|
---|
| 42 | /** =========== define the function ====================== */
|
---|
[845613] | 43 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
|
---|
| 44 | molecule *mol = NULL;
|
---|
[6e5084] | 45 |
|
---|
[1fd675] | 46 | // obtain information
|
---|
| 47 | getParametersfromValueStorage();
|
---|
[97ebf8] | 48 |
|
---|
[845613] | 49 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
---|
| 50 | mol = iter->second;
|
---|
[97ebf8] | 51 | DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
|
---|
[1f91f4] | 52 |
|
---|
| 53 | RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
|
---|
| 54 |
|
---|
| 55 | mol->RotateToPrincipalAxisSystem(params.Axis);
|
---|
[6e5084] | 56 |
|
---|
| 57 | // summing anew for debugging (resulting matrix has to be diagonal!)
|
---|
[1f91f4] | 58 | InertiaTensor = mol->getInertiaTensor();
|
---|
[97ebf8] | 59 | }
|
---|
[845613] | 60 | return Action::success;
|
---|
[97ebf8] | 61 | }
|
---|
| 62 |
|
---|
| 63 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
|
---|
| 64 | // MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
|
---|
| 65 |
|
---|
| 66 | // string newName = state->mol->getName();
|
---|
| 67 | // state->mol->setName(state->lastName);
|
---|
| 68 |
|
---|
| 69 | return Action::failure;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
|
---|
| 73 | // Undo and redo have to do the same for this action
|
---|
| 74 | return performUndo(_state);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | bool MoleculeRotateToPrincipalAxisSystemAction::canUndo() {
|
---|
| 78 | return false;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | bool MoleculeRotateToPrincipalAxisSystemAction::shouldUndo() {
|
---|
| 82 | return false;
|
---|
| 83 | }
|
---|
[1fd675] | 84 | /** =========== end of function ====================== */
|
---|