| [97ebf8] | 1 | /*
 | 
|---|
 | 2 |  * ChangeBoxAction.cpp
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  *  Created on: May 8, 2010
 | 
|---|
 | 5 |  *      Author: heber
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
| [112b09] | 8 | #include "Helpers/MemDebug.hpp"
 | 
|---|
 | 9 | 
 | 
|---|
| [97ebf8] | 10 | #include "Actions/WorldAction/ChangeBoxAction.hpp"
 | 
|---|
| [0430e3] | 11 | #include "Actions/ActionRegistry.hpp"
 | 
|---|
| [952f38] | 12 | #include "Helpers/Log.hpp"
 | 
|---|
 | 13 | #include "Helpers/Verbose.hpp"
 | 
|---|
| [97ebf8] | 14 | #include "World.hpp"
 | 
|---|
| [84c494] | 15 | #include "Box.hpp"
 | 
|---|
| [57f243] | 16 | #include "LinearAlgebra/Matrix.hpp"
 | 
|---|
| [97ebf8] | 17 | 
 | 
|---|
 | 18 | #include <iostream>
 | 
|---|
 | 19 | #include <string>
 | 
|---|
 | 20 | 
 | 
|---|
 | 21 | using namespace std;
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | #include "UIElements/UIFactory.hpp"
 | 
|---|
 | 24 | #include "UIElements/Dialog.hpp"
 | 
|---|
| [861874] | 25 | #include "Actions/ValueStorage.hpp"
 | 
|---|
| [97ebf8] | 26 | 
 | 
|---|
 | 27 | const char WorldChangeBoxAction::NAME[] = "change-box";
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | WorldChangeBoxAction::WorldChangeBoxAction() :
 | 
|---|
 | 30 |   Action(NAME)
 | 
|---|
 | 31 | {}
 | 
|---|
 | 32 | 
 | 
|---|
 | 33 | WorldChangeBoxAction::~WorldChangeBoxAction()
 | 
|---|
 | 34 | {}
 | 
|---|
 | 35 | 
 | 
|---|
| [a8f6ae] | 36 | void WorldChangeBox(Box &_box) {
 | 
|---|
 | 37 |   ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box);
 | 
|---|
 | 38 |   ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive);
 | 
|---|
 | 39 | };
 | 
|---|
 | 40 | 
 | 
|---|
| [047878] | 41 | Dialog* WorldChangeBoxAction::fillDialog(Dialog *dialog) {
 | 
|---|
 | 42 |   ASSERT(dialog,"No Dialog given when filling action dialog");
 | 
|---|
| [97ebf8] | 43 | 
 | 
|---|
| [8da96a] | 44 |   dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 |   return dialog;
 | 
|---|
 | 47 | }
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | Action::state_ptr WorldChangeBoxAction::performCall() {
 | 
|---|
 | 50 | 
 | 
|---|
| [3037be] | 51 |   Box cell_size;
 | 
|---|
| [8da96a] | 52 |   ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
 | 
|---|
| [3037be] | 53 |   World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd.
 | 
|---|
| [8da96a] | 54 | 
 | 
|---|
| [3037be] | 55 |   DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl);
 | 
|---|
| [8da96a] | 56 |   return Action::success;
 | 
|---|
| [97ebf8] | 57 | }
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | Action::state_ptr WorldChangeBoxAction::performUndo(Action::state_ptr _state) {
 | 
|---|
 | 60 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 |   return Action::failure;
 | 
|---|
 | 63 | //  string newName = state->mol->getName();
 | 
|---|
 | 64 | //  state->mol->setName(state->lastName);
 | 
|---|
 | 65 | //
 | 
|---|
 | 66 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
 | 
|---|
 | 67 | }
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | Action::state_ptr WorldChangeBoxAction::performRedo(Action::state_ptr _state){
 | 
|---|
 | 70 |   return Action::failure;
 | 
|---|
 | 71 | }
 | 
|---|
 | 72 | 
 | 
|---|
 | 73 | bool WorldChangeBoxAction::canUndo() {
 | 
|---|
 | 74 |   return false;
 | 
|---|
 | 75 | }
 | 
|---|
 | 76 | 
 | 
|---|
 | 77 | bool WorldChangeBoxAction::shouldUndo() {
 | 
|---|
 | 78 |   return false;
 | 
|---|
 | 79 | }
 | 
|---|
 | 80 | 
 | 
|---|
 | 81 | const string WorldChangeBoxAction::getName() {
 | 
|---|
 | 82 |   return NAME;
 | 
|---|
 | 83 | }
 | 
|---|