- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/CenterInBoxAction.cpp
r623e89 r047878 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Actions/WorldAction/CenterInBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "Box.hpp" 9 13 #include "log.hpp" 10 14 #include "molecule.hpp" … … 18 22 #include "UIElements/UIFactory.hpp" 19 23 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 21 25 22 26 const char WorldCenterInBoxAction::NAME[] = "center-in-box"; … … 29 33 {} 30 34 35 void WorldCenterInBox(Box &_box) { 36 ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box); 37 ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive); 38 }; 39 40 Dialog* WorldCenterInBoxAction::fillDialog(Dialog *dialog) { 41 ASSERT(dialog,"No Dialog given when filling action dialog"); 42 43 dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME)); 44 45 return dialog; 46 } 47 31 48 Action::state_ptr WorldCenterInBoxAction::performCall() { 32 Dialog *dialog = UIFactory::getInstance().makeDialog();33 49 34 double * cell_size = World::getInstance().getDomain(); 35 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 50 Box& cell_size = World::getInstance().getDomain(); 51 ValueStorage::getInstance().queryCurrentValue(NAME, cell_size); 52 World::getInstance().setDomain(cell_size.getM()); 36 53 37 if(dialog->display()) { 38 // center 39 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); 40 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 41 (*MolRunner)->CenterInBox(); 42 } 43 delete dialog; 44 return Action::success; 45 } else { 46 delete dialog; 47 return Action::failure; 54 // center 55 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); 56 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 57 (*MolRunner)->CenterInBox(); 48 58 } 59 return Action::success; 49 60 } 50 61
Note:
See TracChangeset
for help on using the changeset viewer.