[bcf653] | 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 |
|
---|
[97ebf8] | 8 | /*
|
---|
| 9 | * CenterInBoxAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 8, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[112b09] | 20 | #include "Helpers/MemDebug.hpp"
|
---|
| 21 |
|
---|
[97ebf8] | 22 | #include "Actions/WorldAction/CenterInBoxAction.hpp"
|
---|
[0430e3] | 23 | #include "Actions/ActionRegistry.hpp"
|
---|
[4aece0] | 24 | #include "Box.hpp"
|
---|
[952f38] | 25 | #include "Helpers/Log.hpp"
|
---|
[97ebf8] | 26 | #include "molecule.hpp"
|
---|
| 27 | #include "World.hpp"
|
---|
| 28 |
|
---|
| 29 | #include <iostream>
|
---|
| 30 | #include <string>
|
---|
| 31 |
|
---|
| 32 | using namespace std;
|
---|
| 33 |
|
---|
| 34 | #include "UIElements/UIFactory.hpp"
|
---|
| 35 | #include "UIElements/Dialog.hpp"
|
---|
[861874] | 36 | #include "Actions/ValueStorage.hpp"
|
---|
[97ebf8] | 37 |
|
---|
| 38 | const char WorldCenterInBoxAction::NAME[] = "center-in-box";
|
---|
| 39 |
|
---|
| 40 | WorldCenterInBoxAction::WorldCenterInBoxAction() :
|
---|
| 41 | Action(NAME)
|
---|
| 42 | {}
|
---|
| 43 |
|
---|
| 44 | WorldCenterInBoxAction::~WorldCenterInBoxAction()
|
---|
| 45 | {}
|
---|
| 46 |
|
---|
[a8f6ae] | 47 | void WorldCenterInBox(Box &_box) {
|
---|
| 48 | ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box);
|
---|
| 49 | ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive);
|
---|
| 50 | };
|
---|
| 51 |
|
---|
[0b2ce9] | 52 | void WorldCenterInBoxAction::getParametersfromValueStorage()
|
---|
| 53 | {};
|
---|
| 54 |
|
---|
[047878] | 55 | Dialog* WorldCenterInBoxAction::fillDialog(Dialog *dialog) {
|
---|
| 56 | ASSERT(dialog,"No Dialog given when filling action dialog");
|
---|
[97ebf8] | 57 |
|
---|
[4aece0] | 58 | dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
|
---|
| 59 |
|
---|
| 60 | return dialog;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | Action::state_ptr WorldCenterInBoxAction::performCall() {
|
---|
| 64 |
|
---|
[84c494] | 65 | Box& cell_size = World::getInstance().getDomain();
|
---|
[4aece0] | 66 | ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
|
---|
| 67 | World::getInstance().setDomain(cell_size.getM());
|
---|
| 68 |
|
---|
| 69 | // center
|
---|
| 70 | vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
|
---|
| 71 | for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
|
---|
| 72 | (*MolRunner)->CenterInBox();
|
---|
[97ebf8] | 73 | }
|
---|
[4aece0] | 74 | return Action::success;
|
---|
[97ebf8] | 75 | }
|
---|
| 76 |
|
---|
| 77 | Action::state_ptr WorldCenterInBoxAction::performUndo(Action::state_ptr _state) {
|
---|
| 78 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
| 79 |
|
---|
| 80 | return Action::failure;
|
---|
| 81 | // string newName = state->mol->getName();
|
---|
| 82 | // state->mol->setName(state->lastName);
|
---|
| 83 | //
|
---|
| 84 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | Action::state_ptr WorldCenterInBoxAction::performRedo(Action::state_ptr _state){
|
---|
| 88 | return Action::failure;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | bool WorldCenterInBoxAction::canUndo() {
|
---|
| 92 | return false;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | bool WorldCenterInBoxAction::shouldUndo() {
|
---|
| 96 | return false;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | const string WorldCenterInBoxAction::getName() {
|
---|
| 100 | return NAME;
|
---|
| 101 | }
|
---|