| 1 | /*
|
|---|
| 2 | * ChangeBoxAction.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: May 8, 2010
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include "Helpers/MemDebug.hpp"
|
|---|
| 9 |
|
|---|
| 10 | #include "Actions/WorldAction/ChangeBoxAction.hpp"
|
|---|
| 11 | #include "Actions/ActionRegistry.hpp"
|
|---|
| 12 | #include "log.hpp"
|
|---|
| 13 | #include "verbose.hpp"
|
|---|
| 14 | #include "World.hpp"
|
|---|
| 15 | #include "Box.hpp"
|
|---|
| 16 | #include "Matrix.hpp"
|
|---|
| 17 |
|
|---|
| 18 | #include <iostream>
|
|---|
| 19 | #include <string>
|
|---|
| 20 |
|
|---|
| 21 | using namespace std;
|
|---|
| 22 |
|
|---|
| 23 | #include "UIElements/UIFactory.hpp"
|
|---|
| 24 | #include "UIElements/Dialog.hpp"
|
|---|
| 25 | #include "UIElements/ValueStorage.hpp"
|
|---|
| 26 |
|
|---|
| 27 | const char WorldChangeBoxAction::NAME[] = "change-box";
|
|---|
| 28 |
|
|---|
| 29 | WorldChangeBoxAction::WorldChangeBoxAction() :
|
|---|
| 30 | Action(NAME)
|
|---|
| 31 | {}
|
|---|
| 32 |
|
|---|
| 33 | WorldChangeBoxAction::~WorldChangeBoxAction()
|
|---|
| 34 | {}
|
|---|
| 35 |
|
|---|
| 36 | void WorldChangeBox(Box &_box) {
|
|---|
| 37 | ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box);
|
|---|
| 38 | ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive);
|
|---|
| 39 | };
|
|---|
| 40 |
|
|---|
| 41 | Dialog* WorldChangeBoxAction::createDialog() {
|
|---|
| 42 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
|---|
| 43 |
|
|---|
| 44 | dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
|
|---|
| 45 |
|
|---|
| 46 | return dialog;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | Action::state_ptr WorldChangeBoxAction::performCall() {
|
|---|
| 50 |
|
|---|
| 51 | Box cell_size;
|
|---|
| 52 | ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
|
|---|
| 53 | World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd.
|
|---|
| 54 |
|
|---|
| 55 | DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl);
|
|---|
| 56 | return Action::success;
|
|---|
| 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 | }
|
|---|