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