Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/WorldAction/CenterInBoxAction.cpp

    r623e89 r047878  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Actions/WorldAction/CenterInBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "Box.hpp"
    913#include "log.hpp"
    1014#include "molecule.hpp"
     
    1822#include "UIElements/UIFactory.hpp"
    1923#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
    2125
    2226const char WorldCenterInBoxAction::NAME[] = "center-in-box";
     
    2933{}
    3034
     35void WorldCenterInBox(Box &_box) {
     36  ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box);
     37  ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive);
     38};
     39
     40Dialog* 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
    3148Action::state_ptr WorldCenterInBoxAction::performCall() {
    32   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3349
    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());
    3653
    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();
    4858  }
     59  return Action::success;
    4960}
    5061
Note: See TracChangeset for help on using the changeset viewer.