| 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 |
|
|---|
| 8 | /*
|
|---|
| 9 | * RotateToPrincipalAxisSystemAction.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: May 10, 2010
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "CodePatterns/Log.hpp"
|
|---|
| 23 | #include "CodePatterns/Verbose.hpp"
|
|---|
| 24 | #include "LinearAlgebra/Line.hpp"
|
|---|
| 25 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
|---|
| 26 | #include "LinearAlgebra/Vector.hpp"
|
|---|
| 27 | #include "element.hpp"
|
|---|
| 28 | #include "molecule.hpp"
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | #include <iostream>
|
|---|
| 32 | #include <fstream>
|
|---|
| 33 | #include <string>
|
|---|
| 34 |
|
|---|
| 35 | using namespace std;
|
|---|
| 36 |
|
|---|
| 37 | #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
|
|---|
| 38 |
|
|---|
| 39 | // and construct the stuff
|
|---|
| 40 | #include "RotateToPrincipalAxisSystemAction.def"
|
|---|
| 41 | #include "Action_impl_pre.hpp"
|
|---|
| 42 | /** =========== define the function ====================== */
|
|---|
| 43 | Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
|
|---|
| 44 | molecule *mol = NULL;
|
|---|
| 45 |
|
|---|
| 46 | // obtain information
|
|---|
| 47 | getParametersfromValueStorage();
|
|---|
| 48 |
|
|---|
| 49 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
|---|
| 50 | mol = iter->second;
|
|---|
| 51 | DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
|
|---|
| 52 |
|
|---|
| 53 | RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
|
|---|
| 54 |
|
|---|
| 55 | mol->RotateToPrincipalAxisSystem(params.Axis);
|
|---|
| 56 |
|
|---|
| 57 | // summing anew for debugging (resulting matrix has to be diagonal!)
|
|---|
| 58 | InertiaTensor = mol->getInertiaTensor();
|
|---|
| 59 | }
|
|---|
| 60 | return Action::success;
|
|---|
| 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 | return Action::failure;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | bool MoleculeRotateToPrincipalAxisSystemAction::canUndo() {
|
|---|
| 77 | return true;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | bool MoleculeRotateToPrincipalAxisSystemAction::shouldUndo() {
|
|---|
| 81 | return true;
|
|---|
| 82 | }
|
|---|
| 83 | /** =========== end of function ====================== */
|
|---|