| [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 | * BoundInBoxAction.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/BoundInBoxAction.hpp" | 
|---|
| [0430e3] | 23 | #include "Actions/ActionRegistry.hpp" | 
|---|
| [952f38] | 24 | #include "Helpers/Log.hpp" | 
|---|
| [97ebf8] | 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" | 
|---|
| [861874] | 36 | #include "Actions/ValueStorage.hpp" | 
|---|
| [97ebf8] | 37 |  | 
|---|
|  | 38 | const char WorldBoundInBoxAction::NAME[] = "bound-in-box"; | 
|---|
|  | 39 |  | 
|---|
|  | 40 | WorldBoundInBoxAction::WorldBoundInBoxAction() : | 
|---|
|  | 41 | Action(NAME) | 
|---|
|  | 42 | {} | 
|---|
|  | 43 |  | 
|---|
|  | 44 | WorldBoundInBoxAction::~WorldBoundInBoxAction() | 
|---|
|  | 45 | {} | 
|---|
|  | 46 |  | 
|---|
| [a8f6ae] | 47 | void WorldBoundInBox() { | 
|---|
|  | 48 | ActionRegistry::getInstance().getActionByName(WorldBoundInBoxAction::NAME)->call(Action::NonInteractive); | 
|---|
|  | 49 | }; | 
|---|
|  | 50 |  | 
|---|
| [047878] | 51 | Dialog* WorldBoundInBoxAction::fillDialog(Dialog *dialog) { | 
|---|
|  | 52 | ASSERT(dialog,"No Dialog given when filling action dialog"); | 
|---|
| [97ebf8] | 53 |  | 
|---|
| [805636] | 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(); | 
|---|
| [97ebf8] | 65 | } | 
|---|
| [805636] | 66 | return Action::success; | 
|---|
| [97ebf8] | 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 | } | 
|---|