Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/SuspendInWaterAction.cpp

    r112b09 r047878  
    99
    1010#include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "boundary.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "verbose.hpp"
     16#include "World.hpp"
    1117
    1218#include <iostream>
     
    1723#include "UIElements/UIFactory.hpp"
    1824#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "boundary.hpp"
    23 #include "config.hpp"
    24 #include "log.hpp"
    25 #include "config.hpp"
    26 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2726
    2827/****** MoleculeSuspendInWaterAction *****/
     
    4948{}
    5049
     50void MoleculeSuspendInWater(double density) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeSuspendInWaterAction::NAME, density);
     52  ActionRegistry::getInstance().getActionByName(MoleculeSuspendInWaterAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeSuspendInWaterAction::fillDialog(Dialog *dialog) {
     56  ASSERT(dialog,"No Dialog given when filling action dialog");
     57
     58  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5163Action::state_ptr MoleculeSuspendInWaterAction::performCall() {
    5264  molecule *mol = NULL;
    53   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5465  double density;
    5566  double volume = 0.;
    5667
    57   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    58   dialog->queryDouble("density", &density, MapOfActions::getInstance().getDescription("density"));
     68  ValueStorage::getInstance().queryCurrentValue(NAME, density);
    5969
    60   if(dialog->display()) {
     70  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     71    mol = iter->second;
    6172    DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    6273    if (density < 1.0) {
     
    6475    } else {
    6576      PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
    66       delete dialog;
    67       return Action::success;
    6877    }
    6978  }
    70   delete dialog;
    71   return Action::failure;
     79  return Action::success;
    7280}
    7381
Note: See TracChangeset for help on using the changeset viewer.