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