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