Changes in / [7067bd6:677e13]


Ignore:
Files:
27 added
3 deleted
142 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r7067bd6 r677e13  
    88AC_CONFIG_HEADER([config.h])
    99
    10 AM_INIT_AUTOMAKE(dist-bzip2)
     10AM_INIT_AUTOMAKE(dist-bzip2 parallel-tests)
    1111
    1212# Checks for programs.
  • src/Actions/Action.cpp

    r7067bd6 r677e13  
    1313#include "Actions/ActionRegistry.hpp"
    1414#include "Actions/ActionHistory.hpp"
     15#include "Exceptions/MissingValueException.hpp"
     16#include "UIElements/Dialog.hpp"
    1517#include "Helpers/MemDebug.hpp"
     18
     19#include "log.hpp"
     20#include "verbose.hpp"
    1621
    1722using namespace std;
     
    4045}
    4146
    42 void Action::call(){
     47void Action::call(enum QueryOptions flag){
    4348  if(!isActive()){
    4449    return;
    4550  }
    4651  // forward to private virtual
    47   state_ptr state = performCall();
     52  if (flag == Interactive) {
     53    Dialog* dialog = createDialog();
     54    if (dialog != NULL) {
     55      dialog->display();
     56      delete(dialog);
     57    }
     58  }
     59  state_ptr state = Action::failure;
     60//  try {
     61    state = performCall();
     62//  } catch(MissingValueException&) {
     63//    DoeLog(0) && (eLog() << Verbose(0) << "There is a value missing for action " << getName() << endl);
     64//  };
     65
    4866  if(shouldUndo() && state != failure){
    4967    if(canUndo()){
  • src/Actions/Action.hpp

    r7067bd6 r677e13  
    1616class ActionState;
    1717class ActionSequence;
     18class Dialog;
    1819
    1920/**
     
    4445 * hasRedo() method respectively.
    4546 *
     47 * Note that an Action always has two functions createDialog() and performCall(). The former
     48 * returns a Dialog filled with query...() functions for all information that we need from the
     49 * user. The latter must not contain any interaction but just uses these values (which are
     50 * temporarily stored by class ValueStorage) to perform the Action.
     51 *
     52 * Furthermore, there is a global action function that makes the action callable with already
     53 * present parameters (i.e. without user interaction and for internal use within the code only).
     54 * This function is basically just a macro, that puts the parameters into the ValueStorage and
     55 * calls Action::call(Action::NonInteractive).
     56 *
    4657 * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that
    4758 * some condition necessary for this action to be executed is not currently met. For example the
     
    7889 * Building actions is fairly easy. Simply derive from the abstract Action base class and implement
    7990 * the virtual methods. The main code that needs to be executed upon call() should be implemented in
    80  * the performCall() method. You should also indicate whether the action supports undo by implementing
     91 * the performCall() method. Any user interaction should be placed into the dialog returned by
     92 * createDialog(). You should also indicate whether the action supports undo by implementing
    8193 * the shouldUndo() and canUndo() methods to return the appropriate flags.
     94 *
     95 * Also, create the global function to allow for easy calling of your function internally (i.e.
     96 * without user interaction). It should have the name of the Action class without the suffix Action.
    8297 *
    8398 * The constructor of your derived class also needs to call the Base constructor, passing it the
     
    122137 *  <li/> derive YourAction from Action
    123138 *  <li/> pass name and flag for registry to the base constructor
    124  *  <li/> implement performCall(), performUndo(), performRedo()
     139 *  <li/> implement createDialog(), performCall(), performUndo(), performRedo()
     140 *  <li/> implement the global function call/macro.
    125141 *  <li/> implement the functions that return the flags for the undo mechanism
    126142 *  <li/> Derive YourActionState from ActionState as necessary
     
    130146 *
    131147 * <ul>
     148 *  <li/> createDialog():
     149 *  <ul>
     150 *   <li/> Call makeDialog() from the UIFactory.
     151 *   <li/> Call any needed Dialog->Query...() for the values you need with specific keywords.
     152 *   <li/> if the action needs to save a state return a custom state object
     153 *   <li/> otherwise return Action::success
     154 *  </ul>
    132155 *  <li/> performCall():
    133156 *  <ul>
     157 *   <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching
     158 *         key words from createDialog().
    134159 *   <li/> do whatever is needed to make the action work
    135160 *   <li/> if the action was abborted return Action::failure
     
    256281public:
    257282
     283  enum QueryOptions {Interactive, NonInteractive};
     284
    258285  /**
    259286   * This type is used to store pointers to ActionStates while allowing multiple ownership
     
    278305   * If the call needs to undone you have to use the History, to avoid destroying
    279306   * invariants used by the History.
    280    */
    281   void call();
     307   *
     308   * Note that this call can be Interactive (i.e. a dialog will ask the user for
     309   * necessary information) and NonInteractive (i.e. the information will have to
     310   * be present already within the ValueStorage class or else a MissingArgumentException
     311   * is thrown)
     312   */
     313  void call(enum QueryOptions state = Interactive);
    282314
    283315  /**
     
    339371private:
    340372  /**
    341    * This is called internally when the call is being done. Implement this method to do the actuall
     373   * This creates the dialog requesting the information needed for this action from the user
     374   * via means of the user interface.
     375   */
     376  virtual Dialog * createDialog()=0;
     377
     378  /**
     379   * This is called internally when the call is being done. Implement this method to do the actual
    342380   * work of the Action. Implement this in your Derived classes. Needs to return a state that can be
    343381   * used to undo the action.
  • src/Actions/ActionHistory.cpp

    r7067bd6 r677e13  
    8686}
    8787
     88Dialog* ActionHistory::UndoAction::createDialog(){
     89  return NULL;
     90}
     91
    8892Action::state_ptr ActionHistory::UndoAction::performCall(){
    8993  hist->undoLast();
     
    120124}
    121125
     126Dialog* ActionHistory::RedoAction::createDialog(){
     127  return NULL;
     128}
     129
    122130Action::state_ptr ActionHistory::RedoAction::performCall(){
    123131  hist->redoLast();
  • src/Actions/ActionHistory.hpp

    r7067bd6 r677e13  
    4040
    4141  private:
     42    virtual Dialog * createDialog();
    4243    virtual Action::state_ptr performCall();
    4344    virtual Action::state_ptr performUndo(Action::state_ptr);
     
    5859
    5960  private:
     61    virtual Dialog * createDialog();
    6062    virtual Action::state_ptr performCall();
    6163    virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/ActionSequence.cpp

    r7067bd6 r677e13  
    1010#include "Actions/ActionSequence.hpp"
    1111#include "Actions/Action.hpp"
     12#include "UIElements/Dialog.hpp"
    1213
    1314#include "Helpers/Assert.hpp"
     
    3637    return theAction;
    3738  }
     39}
     40
     41// this method is used outside the ActionModule
     42// Each action registers itself with the history
     43void ActionSequence::callAllDialogs(){
     44  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
     45    // we want to have a global bookkeeping for all actions in the sequence, so
     46    // we bypass the normal call
     47    Dialog * dialog = (*it)->createDialog();
     48    if (dialog != NULL) {
     49      dialog->display();
     50      delete(dialog);
     51    }
     52  }
     53}
     54
     55// This method is used internally when MakroActions are constructed.
     56// In this case only the makro Action should be registered and
     57// handle the states
     58ActionSequence::stateSet ActionSequence::callAllDialogs(bool){
     59  stateSet states;
     60  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
     61    // we want to have a global bookkeeping for all actions in the sequence, so
     62    // we bypass the normal call
     63    (*it)->createDialog()->display();
     64  }
     65  return states;
    3866}
    3967
  • src/Actions/ActionSequence.hpp

    r7067bd6 r677e13  
    3030
    3131  void callAll();
     32  void callAllDialogs();
    3233
    3334  bool canUndo();
     
    3637protected:
    3738  stateSet callAll(bool); // Dummy parameter to allow overloading
     39  stateSet callAllDialogs(bool); // Dummy parameter to allow overloading
    3840  stateSet undoAll(stateSet);
    3941  stateSet redoAll(stateSet);
  • src/Actions/AnalysisAction/MolecularVolumeAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "boundary.hpp"
    1213#include "config.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume";
     
    3536{}
    3637
     38void AnalysisMolecularVolume() {
     39  ActionRegistry::getInstance().getActionByName(AnalysisMolecularVolumeAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog * AnalysisMolecularVolumeAction::createDialog() {
     43  Dialog *dialog = UIFactory::getInstance().makeDialog();
     44
     45  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     46
     47  return dialog;
     48}
     49
    3750Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    39   molecule *mol = NULL;
     51  int molID = -1;
     52  // obtain information
     53  ValueStorage::getInstance().queryCurrentValue(NAME, molID);
    4054
    41   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    42 
    43   if(dialog->display()) {
     55  // execute action
     56  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     57    molecule *mol = iter->second;
    4458    class Tesselation *TesselStruct = NULL;
    4559    const LinkedCell *LCList = NULL;
     
    5771    delete(TesselStruct);
    5872    delete(LCList);
    59     delete dialog;
    60     return Action::success;
    61   } else {
    62     delete dialog;
    63     return Action::failure;
    6473  }
     74  return Action::success;
    6575}
    6676
    6777Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
    68 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    69 
    70   return Action::failure;
    71 //  string newName = state->mol->getName();
    72 //  state->mol->setName(state->lastName);
    73 //
    74 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     78  return Action::success;
    7579}
    7680
    7781Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
    78   return Action::failure;
     82  return Action::success;
    7983}
    8084
    8185bool AnalysisMolecularVolumeAction::canUndo() {
    82   return false;
     86  return true;
    8387}
    8488
    8589bool AnalysisMolecularVolumeAction::shouldUndo() {
    86   return false;
     90  return true;
    8791}
    8892
  • src/Actions/AnalysisAction/MolecularVolumeAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void AnalysisMolecularVolume();
     14
    1315class AnalysisMolecularVolumeAction : public Action {
     16  friend void AnalysisMolecularVolume();
    1417public:
    1518  AnalysisMolecularVolumeAction();
     
    2124  virtual const std::string getName();
    2225private:
     26  virtual Dialog * createDialog();
    2327  virtual Action::state_ptr performCall();
    2428  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/AnalysisAction/PairCorrelationAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "analysis_correlation.hpp"
    1213#include "boundary.hpp"
     
    2728#include "UIElements/UIFactory.hpp"
    2829#include "UIElements/Dialog.hpp"
    29 #include "Actions/MapOfActions.hpp"
     30#include "UIElements/ValueStorage.hpp"
    3031
    3132const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
     
    3839{}
    3940
     41void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
     42  ValueStorage::getInstance().setCurrentValue("elements", elements);
     43  ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
     44  ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
     45  ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
     46  ValueStorage::getInstance().setCurrentValue("output-file", outputname);
     47  ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
     48  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
     49  ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive);
     50};
     51
     52
     53Dialog* AnalysisPairCorrelationAction::createDialog() {
     54  Dialog *dialog = UIFactory::getInstance().makeDialog();
     55
     56  dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
     57  dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
     58  dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
     59  dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
     60  dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
     61  dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
     62  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
     63
     64  return dialog;
     65}
     66
    4067Action::state_ptr AnalysisPairCorrelationAction::performCall() {
    41   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4268  int ranges[3] = {1, 1, 1};
    4369  double BinEnd = 0.;
     
    5480  Vector Point;
    5581  BinPairMap *binmap = NULL;
    56   MoleculeListClass *molecules = World::getInstance().getMolecules();
    5782
    58   // first dialog: Obtain which type of correlation
    59   dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));
    60   if(dialog->display()) {
    61     delete dialog;
    62   } else {
    63     delete dialog;
    64     return Action::failure;
    65   }
     83  // obtain information
     84  ValueStorage::getInstance().queryCurrentValue("elements", elements);
     85  ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
     86  ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
     87  ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
     88  ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
     89  ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
     90  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
    6691
    67   // second dialog: Obtain parameters specific to this type
    68   dialog = UIFactory::getInstance().makeDialog();
    69   if (type == "P")
    70     dialog->queryVector("position", &Point, false, MapOfActions::getInstance().getDescription("position"));
    71   if (type == "S")
    72     dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
    73   dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
    74   dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
    75   dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
    76   dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
    77   dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
    78   dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
    79   dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
    80 
    81   if(dialog->display()) {
    82     output.open(outputname.c_str());
    83     binoutput.open(binoutputname.c_str());
    84     if (type == "E") {
    85       PairCorrelationMap *correlationmap = NULL;
    86       if (periodic)
    87         correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
    88       else
    89         correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
    90       OutputPairCorrelation(&output, correlationmap);
    91       binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
    92       OutputCorrelation ( &binoutput, binmap );
    93       delete(binmap);
    94       delete(correlationmap);
    95     } else if (type == "P")  {
    96       cout << "Point to correlate to is  " << Point << endl;
    97       CorrelationToPointMap *correlationmap = NULL;
    98       if (periodic)
    99         correlationmap  = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
    100       else
    101         correlationmap = CorrelationToPoint(molecules, elements, &Point);
    102       OutputCorrelationToPoint(&output, correlationmap);
    103       binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
    104       OutputCorrelation ( &binoutput, binmap );
    105       delete(binmap);
    106       delete(correlationmap);
    107     } else if (type == "S") {
    108       ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
    109       const double radius = 4.;
    110       double LCWidth = 20.;
    111       if (BinEnd > 0) {
    112         if (BinEnd > 2.*radius)
    113           LCWidth = BinEnd;
    114         else
    115           LCWidth = 2.*radius;
    116       }
    117 
    118       // get the boundary
    119       class Tesselation *TesselStruct = NULL;
    120       const LinkedCell *LCList = NULL;
    121       // find biggest molecule
    122       int counter  = molecules->ListOfMolecules.size();
    123       bool *Actives = new bool[counter];
    124       counter = 0;
    125       for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    126         Actives[counter++] = (*BigFinder)->ActiveFlag;
    127         (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    128       }
    129       LCList = new LinkedCell(Boundary, LCWidth);
    130       FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    131       CorrelationToSurfaceMap *surfacemap = NULL;
    132       if (periodic)
    133         surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
    134       else
    135         surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
    136       delete LCList;
    137       OutputCorrelationToSurface(&output, surfacemap);
    138       // re-set ActiveFlag
    139       counter = 0;
    140       for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    141         (*BigFinder)->ActiveFlag = Actives[counter++];
    142       }
    143       delete[] Actives;
    144       // check whether radius was appropriate
    145       {
    146         double start; double end;
    147         GetMinMax( surfacemap, start, end);
    148         if (LCWidth < end)
    149           DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
    150       }
    151       binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
    152       OutputCorrelation ( &binoutput, binmap );
    153       delete TesselStruct;  // surfacemap contains refs to triangles! delete here, not earlier!
    154       delete(binmap);
    155       delete(surfacemap);
    156     } else {
    157       return Action::failure;
    158     }
    159     output.close();
    160     binoutput.close();
    161     delete dialog;
    162     return Action::success;
    163   } else {
    164     delete dialog;
    165     return Action::failure;
    166   }
     92  // execute action
     93  output.open(outputname.c_str());
     94  binoutput.open(binoutputname.c_str());
     95  PairCorrelationMap *correlationmap = NULL;
     96  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
     97  if (periodic)
     98    correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
     99  else
     100    correlationmap = PairCorrelation(molecules, elements);
     101  OutputPairCorrelation(&output, correlationmap);
     102  binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
     103  OutputCorrelation ( &binoutput, binmap );
     104  delete(binmap);
     105  delete(correlationmap);
     106  output.close();
     107  binoutput.close();
     108  return Action::success;
    167109}
    168110
    169111Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
    170 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    171 
    172   return Action::failure;
    173 //  string newName = state->mol->getName();
    174 //  state->mol->setName(state->lastName);
    175 //
    176 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     112  return Action::success;
    177113}
    178114
    179115Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
    180   return Action::failure;
     116  return Action::success;
    181117}
    182118
    183119bool AnalysisPairCorrelationAction::canUndo() {
    184   return false;
     120  return true;
    185121}
    186122
    187123bool AnalysisPairCorrelationAction::shouldUndo() {
    188   return false;
     124  return true;
    189125}
    190126
  • src/Actions/AnalysisAction/PairCorrelationAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13class element;
     14
     15void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
     16
    1317class AnalysisPairCorrelationAction : public Action {
     18  friend void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    1419public:
    1520  AnalysisPairCorrelationAction();
     
    2025
    2126  virtual const std::string getName();
     27
    2228private:
     29  virtual Dialog * createDialog();
    2330  virtual Action::state_ptr performCall();
    2431  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "molecule.hpp"
    1213#include "log.hpp"
     
    2021#include "UIElements/UIFactory.hpp"
    2122#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
    2324
    2425const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system";
     
    3132{}
    3233
     34void AnalysisPrincipalAxisSystem() {
     35  ActionRegistry::getInstance().getActionByName(AnalysisPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
     36};
     37
     38Dialog* AnalysisPrincipalAxisSystemAction::createDialog() {
     39  Dialog *dialog = UIFactory::getInstance().makeDialog();
     40
     41  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     42
     43  return dialog;
     44}
     45
    3346Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3547  molecule *mol = NULL;
    3648
    37   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    38 
    39   if(dialog->display()) {
    40     DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     49  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
     50  DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     51  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     52    molecule *mol = iter->second;
    4153    mol->PrincipalAxisSystem(false);
    42     delete dialog;
    43     return Action::success;
    44   } else {
    45     delete dialog;
    46     return Action::failure;
    4754  }
     55  return Action::success;
    4856}
    4957
    5058Action::state_ptr AnalysisPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
    51 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    52 
    53   return Action::failure;
    54 //  string newName = state->mol->getName();
    55 //  state->mol->setName(state->lastName);
    56 //
    57 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     59  return Action::success;
    5860}
    5961
    6062Action::state_ptr AnalysisPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
    61   return Action::failure;
     63  return Action::success;
    6264}
    6365
    6466bool AnalysisPrincipalAxisSystemAction::canUndo() {
    65   return false;
     67  return true;
    6668}
    6769
    6870bool AnalysisPrincipalAxisSystemAction::shouldUndo() {
    69   return false;
     71  return true;
    7072}
    7173
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void AnalysisPrincipalAxisSystem();
     14
    1315class AnalysisPrincipalAxisSystemAction : public Action {
     16  friend void AnalysisPrincipalAxisSystem();
     17
    1418public:
    1519  AnalysisPrincipalAxisSystemAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/AtomAction/AddAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/AtomAction/AddAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "element.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char AtomAddAction::NAME[] = "add-atom";
     
    3536{}
    3637
     38void AtomAdd(element *elemental, Vector &position) {
     39  ValueStorage::getInstance().setCurrentValue(AtomAddAction::NAME, elemental);
     40  ValueStorage::getInstance().setCurrentValue("position", elemental);
     41  ActionRegistry::getInstance().getActionByName(AtomAddAction::NAME)->call(Action::NonInteractive);
     42};
     43
     44Dialog * AtomAddAction::createDialog() {
     45  Dialog *dialog = UIFactory::getInstance().makeDialog();
     46
     47  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
     48  dialog->queryVector("position", true, ValueStorage::getInstance().getDescription("position"));
     49
     50  return dialog;
     51}
     52
    3753Action::state_ptr AtomAddAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    39   std::vector<element *> elements;
     54  element * elemental = NULL;
    4055  Vector position;
    4156
    42   dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
    43   dialog->queryVector("position", &position, true, MapOfActions::getInstance().getDescription("position"));
    44   cout << "pre-dialog" << endl;
     57  // obtain information
     58  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
     59  ValueStorage::getInstance().queryCurrentValue("position", position);
    4560
    46   if(dialog->display()) {
    47     cout << "post-dialog" << endl;
    48     delete dialog;
    49     if (elements.size() == 1) {
    50       atom * first = World::getInstance().createAtom();
    51       first->type = *(elements.begin());
    52       first->x = position;
    53       DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
    54       // TODO: remove when all of World's atoms are stored.
    55       std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    56       if (!molecules.empty()) {
    57         std::vector<molecule *>::iterator iter = molecules.begin();
    58         (*iter)->AddAtom(first);
    59       }
    60       return Action::success;
    61     } else {
    62       DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    63       return Action::failure;
    64     }
    65   } else {
    66     delete dialog;
    67     return Action::failure;
     61  // execute action
     62  atom * first = World::getInstance().createAtom();
     63  first->type = elemental;
     64  first->x = position;
     65  DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
     66  // TODO: remove when all of World's atoms are stored.
     67  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
     68  if (!molecules.empty()) {
     69    std::vector<molecule *>::iterator iter = molecules.begin();
     70    (*iter)->AddAtom(first);
    6871  }
    69 
     72  return Action::success;
    7073}
    7174
  • src/Actions/AtomAction/AddAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14class element;
     15
     16void AtomAdd(element *elemental, Vector &position);
    1217
    1318class AtomAddAction : public Action {
     19  friend void AtomAdd(element *elemental, Vector &position);
     20
    1421public:
    1522  AtomAddAction();
     
    2128  virtual const std::string getName();
    2229private:
     30  virtual Dialog * createDialog();
    2331  virtual Action::state_ptr performCall();
    2432  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/AtomAction/ChangeElementAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/AtomAction/ChangeElementAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
     13#include "element.hpp"
    1214#include "log.hpp"
    1315#include "vector.hpp"
     
    2224#include "UIElements/UIFactory.hpp"
    2325#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2527
    2628const char AtomChangeElementAction::NAME[] = "change-element";
     
    3335{}
    3436
     37void AtomChangeElement(element *elemental) {
     38  ValueStorage::getInstance().setCurrentValue(AtomChangeElementAction::NAME, elemental);
     39  ActionRegistry::getInstance().getActionByName(AtomChangeElementAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* AtomChangeElementAction::createDialog() {
     43  Dialog *dialog = UIFactory::getInstance().makeDialog();
     44
     45  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
     46
     47return dialog;
     48}
     49
    3550Action::state_ptr AtomChangeElementAction::performCall() {
    36   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3751  atom *first = NULL;
    38   std::vector<element *> elements;
     52  element *elemental = NULL;
    3953
    40   dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
    41   dialog->queryAtom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id"));
     54  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
    4255
    43   if(dialog->display()) {
    44     delete dialog;
    45     ASSERT(elements.size() == 1, "Unequal to one element specified when changing an atom's element");
    46     ASSERT(first != NULL, "No valid atom specified");
    47     DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elements.at(0) << "." << endl);
    48     if (elements.at(0) != NULL) {
    49       first->type = elements.at(0);
    50       return Action::success;
    51     } else
    52       return Action::failure;
    53   } else {
    54     delete dialog;
    55     return Action::failure;
     56  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
     57    first = iter->second;
     58    DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl);
     59    first->type = elemental;
    5660  }
    57 
     61  return Action::success;
    5862}
    5963
  • src/Actions/AtomAction/ChangeElementAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13class element;
     14
     15void AtomChangeElement(element *elemental);
     16
    1317class AtomChangeElementAction : public Action {
     18  friend void AtomChangeElement(element *elemental);
     19
    1420public:
    1521  AtomChangeElementAction();
     
    2127  virtual const std::string getName();
    2228private:
     29  virtual Dialog * createDialog();
    2330  virtual Action::state_ptr performCall();
    2431  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/AtomAction/RemoveAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/AtomAction/RemoveAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "Descriptors/AtomDescriptor.hpp"
     
    2324#include "UIElements/UIFactory.hpp"
    2425#include "UIElements/Dialog.hpp"
    25 #include "Actions/MapOfActions.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2627
    2728const char AtomRemoveAction::NAME[] = "remove-atom";
     
    3435{}
    3536
     37void AtomRemove() {
     38  ActionRegistry::getInstance().getActionByName(AtomRemoveAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* AtomRemoveAction::createDialog() {
     42  Dialog *dialog = UIFactory::getInstance().makeDialog();
     43
     44  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3649Action::state_ptr AtomRemoveAction::performCall() {
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3850  atom *first = NULL;
    3951
    40   dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME));
    41 
    42   if(dialog->display()) {
    43     delete dialog;
     52  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
     53  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
     54    first = iter->second;
    4455    DoLog(1) && (Log() << Verbose(1) << "Removing atom " << first->getId() << "." << endl);
    4556    // TODO: this is not necessary when atoms and their storing to file are handled by the World
    4657    // simply try to erase in every molecule found
    47     std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    4858    for (std::vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end(); ++iter) {
    4959      (*iter)->erase(first);
    5060    }
    5161    World::getInstance().destroyAtom(first);
    52     return Action::success;
    53   } else {
    54     delete dialog;
    55     return Action::failure;
    5662  }
    57 
     63  return Action::success;
    5864}
    5965
  • src/Actions/AtomAction/RemoveAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void AtomRemove();
     14
    1315class AtomRemoveAction : public Action {
     16  friend void AtomRemove();
     17
    1418public:
    1519  AtomRemoveAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/Calculation.hpp

    r7067bd6 r677e13  
    6464  virtual T* doCalc()=0;
    6565private:
     66  virtual Dialog* createDialog();
    6667  virtual Action::state_ptr performCall();
    6768  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/Calculation_impl.hpp

    r7067bd6 r677e13  
    2727
    2828// methods inherited from Action
     29
     30template<typename T>
     31Dialog* Calculation<T>::createDialog(){
     32  return NULL;
     33}
    2934
    3035template<typename T>
  • src/Actions/CmdAction/BondLengthTableAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/CmdAction/BondLengthTableAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "bondgraph.hpp"
    1213#include "config.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627const char CommandLineBondLengthTableAction::NAME[] = "bond-table";
     
    3334{}
    3435
     36void CommandBondLengthTable(std::string &BondGraphFileName) {
     37  ValueStorage::getInstance().setCurrentValue(CommandLineBondLengthTableAction::NAME, BondGraphFileName);
     38  ActionRegistry::getInstance().getActionByName(CommandLineBondLengthTableAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* CommandLineBondLengthTableAction::createDialog() {
     42  Dialog *dialog = UIFactory::getInstance().makeDialog();
     43
     44  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3549Action::state_ptr CommandLineBondLengthTableAction::performCall() {
    3650  ostringstream usage;
    3751  string BondGraphFileName;
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3952
     53  ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName);
     54  DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    4055  config *configuration = World::getInstance().getConfig();
    41   dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));
    42 
    43   if(dialog->display()) {
    44     DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    45     delete dialog;
    46   } else {
    47     delete dialog;
    48     return Action::failure;
    49   }
    50 
    5156  if (configuration->BG == NULL) {
    5257    configuration->BG = new BondGraph(configuration->GetIsAngstroem());
  • src/Actions/CmdAction/BondLengthTableAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandBondLengthTable(std::string &BondGraphFileName);
     14
    1315class CommandLineBondLengthTableAction : public Action {
     16  friend void CommandBondLengthTable(std::string &BondGraphFileName);
     17
    1418public:
    1519  CommandLineBondLengthTableAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/CmdAction/ElementDbAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/CmdAction/ElementDbAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627const char CommandLineElementDbAction::NAME[] = "element-db";
     
    3334{}
    3435
     36void CommandElementDb(std::string &databasepath) {
     37  ValueStorage::getInstance().setCurrentValue(CommandLineElementDbAction::NAME, databasepath);
     38  ActionRegistry::getInstance().getActionByName(CommandLineElementDbAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* CommandLineElementDbAction::createDialog() {
     42  Dialog *dialog = UIFactory::getInstance().makeDialog();
     43
     44  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3549Action::state_ptr CommandLineElementDbAction::performCall() {
    3650  ostringstream usage;
    3751  string databasepath;
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3952
    4053  // get the path
    4154  // TODO: Make databasepath a std::string
    4255  config *configuration = World::getInstance().getConfig();
    43   dialog->queryString(NAME, &databasepath, MapOfActions::getInstance().getDescription(NAME));
    44 
    45   if(dialog->display()) {
    46     strcpy(configuration->databasepath, databasepath.c_str());
    47     delete dialog;
    48   } else {
    49     delete dialog;
    50     return Action::failure;
    51   }
     56  ValueStorage::getInstance().queryCurrentValue(NAME, databasepath);
     57  strcpy(configuration->databasepath, databasepath.c_str());
    5258
    5359  // load table
  • src/Actions/CmdAction/ElementDbAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandElementDb(std::string &databasepath);
     14
    1315class CommandLineElementDbAction : public Action {
     16  friend void CommandElementDb(std::string &databasepath);
     17
    1418public:
    1519  CommandLineElementDbAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/CmdAction/FastParsingAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/CmdAction/FastParsingAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
     25
     26// memento to remember the state when undoing
     27
     28class CommandLineFastParsingState : public ActionState {
     29public:
     30  CommandLineFastParsingState(bool _bool) :
     31    boolean(_bool)
     32  {}
     33  bool boolean;
     34};
     35
    2436
    2537const char CommandLineFastParsingAction::NAME[] = "fastparsing";
     
    3244{}
    3345
    34 Action::state_ptr CommandLineFastParsingAction::performCall() {
     46void CommandFastParsing(bool fastparsing) {
     47  ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing);
     48  ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive);
     49};
     50
     51Dialog* CommandLineFastParsingAction::createDialog() {
    3552  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3653
     54  dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME));
     55
     56  return dialog;
     57}
     58
     59Action::state_ptr CommandLineFastParsingAction::performCall() {
     60
    3761  config *configuration = World::getInstance().getConfig();
    38   dialog->queryBoolean(NAME, &configuration->FastParsing, MapOfActions::getInstance().getDescription(NAME));
    39 
    40   if(dialog->display()) {
    41     if (configuration->FastParsing)
    42       DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
    43     else
    44       DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
    45     delete dialog;
    46     return Action::success;
    47   } else {
    48     delete dialog;
    49     return Action::failure;
    50   }
     62  ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing);
     63  if (configuration->FastParsing)
     64    DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
     65  else
     66    DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
     67  return Action::success;
    5168}
    5269
    5370Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) {
    54 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     71  CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
    5572
    56   return Action::failure;
    57 //  string newName = state->mol->getName();
    58 //  state->mol->setName(state->lastName);
    59 //
    60 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     73  config *configuration = World::getInstance().getConfig();
     74  configuration->FastParsing = state->boolean;
     75
     76  return Action::state_ptr(new CommandLineFastParsingState(!state->boolean));
    6177}
    6278
    6379Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
    64   return Action::failure;
     80  performUndo(_state);
    6581}
    6682
    6783bool CommandLineFastParsingAction::canUndo() {
    68   return false;
     84  return true;
    6985}
    7086
    7187bool CommandLineFastParsingAction::shouldUndo() {
    72   return false;
     88  return true;
    7389}
    7490
  • src/Actions/CmdAction/FastParsingAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandFastParsing(bool fastparsing);
     14
    1315class CommandLineFastParsingAction : public Action {
     16  friend void CommandFastParsing(bool fastparsing);
     17
    1418public:
    1519  CommandLineFastParsingAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/CmdAction/HelpAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/CmdAction/HelpAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "CommandLineParser.hpp"
    1213
     
    2930{}
    3031
    31 Action::state_ptr CommandLineHelpAction::performCall() {
    32   ostringstream usage;
     32void CommandHelp() {
     33  ActionRegistry::getInstance().getActionByName(CommandLineHelpAction::NAME)->call(Action::NonInteractive);
     34};
     35
     36Dialog* CommandLineHelpAction::createDialog() {
    3337  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3438
     39  ostringstream usage;
    3540  usage << CommandLineParser::getInstance().visible << endl;
    3641  dialog->queryEmpty(NAME, usage.str());
    3742
    38   if(dialog->display()) {
    39     delete dialog;
    40     return Action::success;
    41   } else {
    42     delete dialog;
    43     return Action::failure;
    44   }
     43  return dialog;
     44}
     45
     46Action::state_ptr CommandLineHelpAction::performCall() {
     47  return Action::success;
    4548}
    4649
    4750Action::state_ptr CommandLineHelpAction::performUndo(Action::state_ptr _state) {
    48 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    49 
    50   return Action::failure;
    51 //  string newName = state->mol->getName();
    52 //  state->mol->setName(state->lastName);
    53 //
    54 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     51  return Action::success;
    5552}
    5653
    5754Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){
    58   return Action::failure;
     55  return Action::success;
    5956}
    6057
    6158bool CommandLineHelpAction::canUndo() {
    62   return false;
     59  return true;
    6360}
    6461
    6562bool CommandLineHelpAction::shouldUndo() {
    66   return false;
     63  return true;
    6764}
    6865
  • src/Actions/CmdAction/HelpAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandHelp();
     14
    1315class CommandLineHelpAction : public Action {
     16  friend void CommandHelp();
     17
    1418public:
    1519  CommandLineHelpAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/CmdAction/VerboseAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/CmdAction/VerboseAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "verbose.hpp"
     
    1920#include "UIElements/UIFactory.hpp"
    2021#include "UIElements/Dialog.hpp"
    21 #include "Actions/MapOfActions.hpp"
     22#include "UIElements/ValueStorage.hpp"
     23
     24// memento to remember the state when undoing
     25
     26class CommandLineVerboseState : public ActionState {
     27public:
     28  CommandLineVerboseState(int _verbosity) :
     29    verbosity(_verbosity)
     30  {}
     31  int verbosity;
     32};
     33
    2234
    2335const char CommandLineVerboseAction::NAME[] = "verbose";
     
    3042{}
    3143
     44void CommandVerbose(int verbosity) {
     45  ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity);
     46  ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive);
     47};
     48
     49Dialog* CommandLineVerboseAction::createDialog() {
     50  Dialog *dialog = UIFactory::getInstance().makeDialog();
     51
     52  dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME));
     53
     54  return dialog;
     55}
     56
    3257Action::state_ptr CommandLineVerboseAction::performCall() {
    33   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3458  int verbosity = 2;
    3559
    36   dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));
     60  ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);
    3761
    38   if(dialog->display()) {
    39     setVerbosity(verbosity);
    40     DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    41     delete dialog;
    42     return Action::success;
    43   } else {
    44     delete dialog;
    45     return Action::failure;
    46   }
     62  setVerbosity(verbosity);
     63  DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
     64  return Action::success;
    4765}
    4866
    4967Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) {
    50 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     68  CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get());
    5169
    52   return Action::failure;
    53 //  string newName = state->mol->getName();
    54 //  state->mol->setName(state->lastName);
    55 //
    56 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     70  int verbosity = 2;
     71  ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);
     72
     73  setVerbosity(state->verbosity);
     74  return Action::state_ptr(new CommandLineVerboseState(verbosity));
    5775}
    5876
    5977Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){
    60   return Action::failure;
     78  performUndo(_state);
    6179}
    6280
    6381bool CommandLineVerboseAction::canUndo() {
    64   return false;
     82  return true;
    6583}
    6684
    6785bool CommandLineVerboseAction::shouldUndo() {
    68   return false;
     86  return true;
    6987}
    7088
  • src/Actions/CmdAction/VerboseAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandVerbose(int verbosity);
     14
    1315class CommandLineVerboseAction : public Action {
     16  friend void CommandVerbose(int verbosity);
     17
    1418public:
    1519  CommandLineVerboseAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/CmdAction/VersionAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/CmdAction/VersionAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112
    1213#include <iostream>
     
    1718#include "UIElements/UIFactory.hpp"
    1819#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
     20#include "UIElements/ValueStorage.hpp"
    2021
    2122const char CommandLineVersionAction::NAME[] = "version";
     
    2829{}
    2930
    30 Action::state_ptr CommandLineVersionAction::performCall() {
     31void CommandVersion() {
     32  ActionRegistry::getInstance().getActionByName(CommandLineVersionAction::NAME)->call(Action::NonInteractive);
     33};
     34
     35Dialog* CommandLineVersionAction::createDialog() {
    3136  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3237
    3338  dialog->queryEmpty(NAME, ESPACKVersion);
    3439
    35   if(dialog->display()) {
    36     delete dialog;
    37     return Action::success;
    38   } else {
    39     delete dialog;
    40     return Action::failure;
    41   }
     40  return dialog;
     41}
     42
     43Action::state_ptr CommandLineVersionAction::performCall() {
     44  return Action::success;
    4245}
    4346
    4447Action::state_ptr CommandLineVersionAction::performUndo(Action::state_ptr _state) {
    45 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    46 
    47   return Action::failure;
    48 //  string newName = state->mol->getName();
    49 //  state->mol->setName(state->lastName);
    50 //
    51 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     48  return Action::success;
    5249}
    5350
    5451Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){
    55   return Action::failure;
     52  return Action::success;
    5653}
    5754
    5855bool CommandLineVersionAction::canUndo() {
    59   return false;
     56  return true;
    6057}
    6158
    6259bool CommandLineVersionAction::shouldUndo() {
    63   return false;
     60  return true;
    6461}
    6562
  • src/Actions/CmdAction/VersionAction.hpp

    r7067bd6 r677e13  
    1212#include "version.h"
    1313
     14void CommandVersion();
     15
    1416class CommandLineVersionAction : public Action {
     17  friend void CommandVersion();
     18
    1519public:
    1620  CommandLineVersionAction();
     
    2226  virtual const std::string getName();
    2327private:
     28  virtual Dialog * createDialog();
    2429  virtual Action::state_ptr performCall();
    2530  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/ErrorAction.cpp

    r7067bd6 r677e13  
    2727}
    2828
     29Dialog* ErrorAction::createDialog() {
     30  return NULL;
     31}
     32
    2933Action::state_ptr ErrorAction::performCall() {
    3034  Log() << Verbose(0) << errorMsg << endl;
  • src/Actions/ErrorAction.hpp

    r7067bd6 r677e13  
    2222
    2323private:
    24 
     24  virtual Dialog * createDialog();
    2525  virtual Action::state_ptr performCall();
    2626  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "bondgraph.hpp"
     
    2728#include "UIElements/UIFactory.hpp"
    2829#include "UIElements/Dialog.hpp"
    29 #include "Actions/MapOfActions.hpp"
     30#include "UIElements/ValueStorage.hpp"
    3031
    3132const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
     
    3839{}
    3940
     41void FragmentationDepthFirstSearch(double distance) {
     42  ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance);
     43  ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog* FragmentationDepthFirstSearchAction::createDialog() {
     47  Dialog *dialog = UIFactory::getInstance().makeDialog();
     48
     49  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     50
     51  return dialog;
     52}
     53
    4054Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
    41   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4255  double distance;
    4356
    44   dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));
     57  ValueStorage::getInstance().queryCurrentValue(NAME, distance);
    4558
    46   if(dialog->display()) {
    47     DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    48     molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
    49     MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    50     int *MinimumRingSize = new int[mol->getAtomCount()];
    51     atom **ListOfAtoms = NULL;
    52     class StackClass<bond *> *BackEdgeStack = NULL;
    53     class StackClass<bond *> *LocalBackEdgeStack = NULL;
    54     mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    55     Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    56     if (Subgraphs != NULL) {
    57       int FragmentCounter = 0;
    58       while (Subgraphs->next != NULL) {
    59         Subgraphs = Subgraphs->next;
    60         ListOfAtoms = NULL;
    61         Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
    62         LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
    63         Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
    64         Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    65         delete(LocalBackEdgeStack);
    66         delete(Subgraphs->previous);
    67         delete[](ListOfAtoms);  // and here we remove it
    68         FragmentCounter++;
    69       }
    70       delete(Subgraphs);
     59  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
     60  molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
     61  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
     62  int *MinimumRingSize = new int[mol->getAtomCount()];
     63  atom **ListOfAtoms = NULL;
     64  class StackClass<bond *> *BackEdgeStack = NULL;
     65  class StackClass<bond *> *LocalBackEdgeStack = NULL;
     66  mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     67  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
     68  if (Subgraphs != NULL) {
     69    int FragmentCounter = 0;
     70    while (Subgraphs->next != NULL) {
     71      Subgraphs = Subgraphs->next;
     72      ListOfAtoms = NULL;
     73      Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
     74      LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
     75      Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
     76      Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
     77      delete(LocalBackEdgeStack);
     78      delete(Subgraphs->previous);
     79      delete[](ListOfAtoms);  // and here we remove it
     80      FragmentCounter++;
    7181    }
    72     delete(BackEdgeStack);
    73     delete[](MinimumRingSize);
    74     delete dialog;
    75     return Action::success;
    76   } else {
    77     delete dialog;
    78     return Action::failure;
     82    delete(Subgraphs);
    7983  }
     84  delete(BackEdgeStack);
     85  delete[](MinimumRingSize);
     86  return Action::success;
    8087}
    8188
    8289Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
    83 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    84 
    85   return Action::failure;
    86 //  string newName = state->mol->getName();
    87 //  state->mol->setName(state->lastName);
    88 //
    89 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     90  return Action::success;
    9091}
    9192
    9293Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
    93   return Action::failure;
     94  return Action::success;
    9495}
    9596
    9697bool FragmentationDepthFirstSearchAction::canUndo() {
    97   return false;
     98  return true;
    9899}
    99100
    100101bool FragmentationDepthFirstSearchAction::shouldUndo() {
    101   return false;
     102  return true;
    102103}
    103104
  • src/Actions/FragmentationAction/DepthFirstSearchAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationDepthFirstSearch(double distance);
     14
    1315class FragmentationDepthFirstSearchAction : public Action {
     16  friend void FragmentationDepthFirstSearch(double distance);
     17
    1418public:
    1519  FragmentationDepthFirstSearchAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/FragmentationAction/FragmentationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "bondgraph.hpp"
     
    2526#include "UIElements/UIFactory.hpp"
    2627#include "UIElements/Dialog.hpp"
    27 #include "Actions/MapOfActions.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2829
    2930const char FragmentationFragmentationAction::NAME[] = "fragment-mol";
     
    3637{}
    3738
     39void FragmentationFragmentation(std::string &path, double distance, int order) {
     40  ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path);
     41  ValueStorage::getInstance().setCurrentValue("distance", distance);
     42  ValueStorage::getInstance().setCurrentValue("order", order);
     43  ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog* FragmentationFragmentationAction::createDialog() {
     47  Dialog *dialog = UIFactory::getInstance().makeDialog();
     48
     49  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     50  dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance"));
     51  dialog->queryInt("order", ValueStorage::getInstance().getDescription("order"));
     52
     53  return dialog;
     54}
     55
    3856Action::state_ptr FragmentationFragmentationAction::performCall() {
    39   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4057  clock_t start,end;
    4158  molecule *mol = NULL;
     
    4663  int ExitFlag = 0;
    4764
    48   cout << "pre-dialog"<< endl;
    49   dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME));
    50   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    51   dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance"));
    52   dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order"));
     65  ValueStorage::getInstance().queryCurrentValue(NAME, path);
     66  ValueStorage::getInstance().queryCurrentValue("distance", distance);
     67  ValueStorage::getInstance().queryCurrentValue("order", order);
    5368
    54   if(dialog->display()) {
    55     cout << "POST-dialog"<< endl;
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    5671    ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
    5772    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl);
     
    6681    end = clock();
    6782    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    68     delete dialog;
    69     return Action::success;
    70   } else {
    71     delete dialog;
    72     return Action::failure;
    7383  }
     84  return Action::success;
    7485}
    7586
    7687Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) {
    77 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    78 
    79   return Action::failure;
    80 //  string newName = state->mol->getName();
    81 //  state->mol->setName(state->lastName);
    82 //
    83 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     88  return Action::success;
    8489}
    8590
    8691Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
    87   return Action::failure;
     92  return Action::success;
    8893}
    8994
    9095bool FragmentationFragmentationAction::canUndo() {
    91   return false;
     96  return true;
    9297}
    9398
    9499bool FragmentationFragmentationAction::shouldUndo() {
    95   return false;
     100  return true;
    96101}
    97102
  • src/Actions/FragmentationAction/FragmentationAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationFragmentation(std::string &path, double distance, int order);
     14
    1315class FragmentationFragmentationAction : public Action {
     16  friend void FragmentationFragmentation(std::string &path, double distance, int order);
     17
    1418public:
    1519  FragmentationFragmentationAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/FragmentationAction/SubgraphDissectionAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "config.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect";
     
    3536{}
    3637
    37 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
     38void FragmentationSubgraphDissection() {
     39  ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* FragmentationSubgraphDissectionAction::createDialog() {
    3843  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3944
    4045  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
    4146
    42   if(dialog->display()) {
    43     DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    44     // @TODO rather do the dissection afterwards
    45     MoleculeListClass *molecules = World::getInstance().getMolecules();
    46     molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig());
    47     delete dialog;
    48     return Action::success;
    49   } else {
    50     delete dialog;
    51     return Action::failure;
    52   }
     47  return dialog;
     48}
     49
     50
     51Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
     52  DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
     53  // @TODO rather do the dissection afterwards
     54  MoleculeListClass *molecules = World::getInstance().getMolecules();
     55  molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig());
     56  return Action::success;
    5357}
    5458
  • src/Actions/FragmentationAction/SubgraphDissectionAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationSubgraphDissection();
     14
    1315class FragmentationSubgraphDissectionAction : public Action {
     16  friend void FragmentationSubgraphDissection();
     17
    1418public:
    1519  FragmentationSubgraphDissectionAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/Makefile.am

    r7067bd6 r677e13  
    1717  ${MOLECULEACTIONSOURCE} \
    1818  ${PARSERACTIONSOURCE} \
     19  ${SELECTIONACTIONSOURCE} \
    1920  ${TESSELATIONACTIONSOURCE} \
    2021  ${WORLDACTIONSOURCE} \
     
    2829  ${MOLECULEACTIONHEADER} \
    2930  ${PARSERACTIONHEADER} \
     31  ${SELECTIONACTIONHEADER} \
    3032  ${TESSELATIONACTIONHEADER} \
    3133  ${WORLDACTIONHEADER} \
     
    3638  AnalysisAction/MolecularVolumeAction.cpp \
    3739  AnalysisAction/PairCorrelationAction.cpp \
    38   AnalysisAction/PrincipalAxisSystemAction.cpp
     40  AnalysisAction/PointCorrelationAction.cpp \
     41  AnalysisAction/PrincipalAxisSystemAction.cpp \
     42  AnalysisAction/SurfaceCorrelationAction.cpp
    3943ANALYSISACTIONHEADER = \
    4044  AnalysisAction/MolecularVolumeAction.hpp \
    4145  AnalysisAction/PairCorrelationAction.hpp \
    42   AnalysisAction/PrincipalAxisSystemAction.hpp
     46  AnalysisAction/PointCorrelationAction.hpp \
     47  AnalysisAction/PrincipalAxisSystemAction.hpp \
     48  AnalysisAction/SurfaceCorrelationAction.hpp
    4349
    4450ATOMACTIONSOURCE = \
     
    107113  ParserAction/SaveXyzAction.hpp
    108114
     115SELECTIONACTIONSOURCE = \
     116        SelectionAction/AllAtomsAction.cpp \
     117        SelectionAction/AllMoleculesAction.cpp \
     118        SelectionAction/AtomByIdAction.cpp \
     119        SelectionAction/MoleculeByIdAction.cpp \
     120        SelectionAction/NotAllAtomsAction.cpp \
     121        SelectionAction/NotAllMoleculesAction.cpp \
     122        SelectionAction/NotAtomByIdAction.cpp \
     123        SelectionAction/NotMoleculeByIdAction.cpp
     124SELECTIONACTIONHEADER = \
     125        SelectionAction/AllAtomsAction.hpp \
     126        SelectionAction/AllMoleculesAction.hpp \
     127        SelectionAction/AtomByIdAction.hpp \
     128        SelectionAction/MoleculeByIdAction.hpp \
     129        SelectionAction/NotAllAtomsAction.hpp \
     130        SelectionAction/NotAllMoleculesAction.hpp \
     131        SelectionAction/NotAtomByIdAction.hpp \
     132        SelectionAction/NotMoleculeByIdAction.hpp
     133
    109134TESSELATIONACTIONSOURCE = \
    110135  TesselationAction/ConvexEnvelopeAction.cpp \
  • src/Actions/MakroAction.cpp

    r7067bd6 r677e13  
    4444}
    4545
     46Dialog* MakroAction::createDialog() {
     47  actions->callAllDialogs();
     48}
    4649
    4750Action::state_ptr MakroAction::performCall(){
  • src/Actions/MakroAction.hpp

    r7067bd6 r677e13  
    3030
    3131private:
     32  virtual Dialog * createDialog();
    3233  virtual Action::state_ptr performCall();
    3334  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/ManipulateAtomsProcess.cpp

    r7067bd6 r677e13  
    2626ManipulateAtomsProcess::~ManipulateAtomsProcess()
    2727{}
     28
     29Dialog* ManipulateAtomsProcess::createDialog(){
     30  return NULL;
     31}
    2832
    2933Action::state_ptr ManipulateAtomsProcess::performCall(){
  • src/Actions/ManipulateAtomsProcess.hpp

    r7067bd6 r677e13  
    2929private:
    3030
     31  virtual Dialog* createDialog();
    3132  virtual Action::state_ptr performCall();
    3233  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MapOfActions.cpp

    r7067bd6 r677e13  
    1010using namespace std;
    1111
     12#include "Actions/MapOfActions.hpp"
     13#include "Descriptors/AtomIdDescriptor.hpp"
     14#include "Descriptors/MoleculeIdDescriptor.hpp"
     15#include "Helpers/Assert.hpp"
    1216#include "Patterns/Singleton_impl.hpp"
    13 #include "Actions/MapOfActions.hpp"
    14 #include "Helpers/Assert.hpp"
    1517
    1618#include <boost/lexical_cast.hpp>
     
    2022#include <iostream>
    2123
     24#include "atom.hpp"
     25#include "Box.hpp"
    2226#include "CommandLineParser.hpp"
     27#include "element.hpp"
    2328#include "log.hpp"
     29#include "Matrix.hpp"
     30#include "molecule.hpp"
     31#include "periodentafel.hpp"
     32#include "vector.hpp"
    2433#include "verbose.hpp"
    2534
     
    2736#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
    2837#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     38#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
    2939#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
     40#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
    3041#include "Actions/AtomAction/AddAction.hpp"
    3142#include "Actions/AtomAction/ChangeElementAction.hpp"
     
    5364#include "Actions/ParserAction/LoadXyzAction.hpp"
    5465#include "Actions/ParserAction/SaveXyzAction.hpp"
     66#include "Actions/SelectionAction/AllAtomsAction.hpp"
     67#include "Actions/SelectionAction/AllMoleculesAction.hpp"
     68#include "Actions/SelectionAction/AtomByIdAction.hpp"
     69#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
     70#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
     71#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
     72#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
     73#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
    5574#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
    5675#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
     
    133152  }
    134153  BV.xx = boost::lexical_cast<double>(components.at(0));
    135   BV.xy = boost::lexical_cast<double>(components.at(1));
    136   BV.xz = boost::lexical_cast<double>(components.at(2));
    137   BV.yy = boost::lexical_cast<double>(components.at(3));
    138   BV.yz = boost::lexical_cast<double>(components.at(4));
     154  BV.yx = boost::lexical_cast<double>(components.at(1));
     155  BV.yy = boost::lexical_cast<double>(components.at(2));
     156  BV.zx = boost::lexical_cast<double>(components.at(3));
     157  BV.zy = boost::lexical_cast<double>(components.at(4));
    139158  BV.zz = boost::lexical_cast<double>(components.at(5));
    140159  v = boost::any(BoxValue(BV));
     
    177196  DescriptionMap["output"] = "write output files";
    178197  DescriptionMap["set-output"] = "specify output formats";
    179   DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
     198  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
    180199  DescriptionMap["parse-xyz"] = "parse xyz file into World";
     200  DescriptionMap["point-correlation"] = "pair correlation analysis between element and point";
    181201  DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
    182202  DescriptionMap["remove-atom"] = "remove a specified atom";
     
    189209  DescriptionMap["SaveXyz"] = "save world as xyz file";
    190210  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
     211  DescriptionMap["select-all-atoms"] = "select all atoms";
     212  DescriptionMap["select-all-molecules"] = "select all molecules";
     213  DescriptionMap["select-atom-by-id"] = "select an atom by index";
     214  DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
    191215  DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
    192216  DescriptionMap["set-output"] = "specify output formats";
    193217  DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
     218  DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface";
    194219  DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
    195220  DescriptionMap["translate-mol"] = "translate molecule by given vector";
     221  DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
     222  DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
     223  DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
     224  DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
    196225  DescriptionMap["verbose"] = "set verbosity level";
    197226  DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
    198227  DescriptionMap["version"] = "show version";
    199228  // keys for values
    200   DescriptionMap["atom-by-id"] = "index of an atom";
    201229  DescriptionMap["bin-output-file"] = "name of the bin output file";
    202230  DescriptionMap["bin-end"] = "start of the last bin";
     
    216244  DescriptionMap["MaxDistance"] = "maximum distance in space";
    217245  DescriptionMap["molecule-by-id"] = "index of a molecule";
    218   DescriptionMap["molecule-by-name"] = "name of a molecule";
    219246  DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
    220247  DescriptionMap["order"] = "order of a discretization, dissection, ...";
     
    222249  DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
    223250  DescriptionMap["position"] = "position in R^3 space";
    224   DescriptionMap["sphere-radius"] = "radius of tesselation sphere";
    225251  DescriptionMap["start-step"] = "first or start step";
    226252
     
    246272  ShortFormMap["nonconvex-envelope"] = "N";
    247273//  ShortFormMap["output"] = "o";
    248   ShortFormMap["pair-correlation"] = "C";
     274//  ShortFormMap["pair-correlation"] = "C";
    249275  ShortFormMap["parse-xyz"] = "p";
    250276  ShortFormMap["remove-atom"] = "r";
     
    266292
    267293  // value types for the actions
    268   TypeMap["add-atom"] = Element;
    269   TypeMap["bond-file"] = String;
    270   TypeMap["bond-table"] = String;
    271   TypeMap["boundary"] = Vector;
    272   TypeMap["center-in-box"] = Box;
    273   TypeMap["change-box"] = Box;
    274   TypeMap["change-element"] = Element;
    275   TypeMap["change-molname"] = String;
    276   TypeMap["convex-envelope"] = Molecule;
    277   TypeMap["default-molname"] = String;
    278   TypeMap["depth-first-search"] = Double;
    279   TypeMap["element-db"] = String;
    280   TypeMap["fastparsing"] = Boolean;
    281   TypeMap["fill-molecule"] = String;
    282   TypeMap["fragment-mol"] = String;
    283   TypeMap["input"] = String;
    284   TypeMap["linear-interpolate"] = String;
    285   TypeMap["molecular-volume"] = Molecule;
    286   TypeMap["nonconvex-envelope"] = Molecule;
    287   TypeMap["output"] = None;
    288   TypeMap["parse-xyz"] = String;
    289   TypeMap["pair-correlation"] = String;
    290   TypeMap["principal-axis-system"] = Molecule;
    291   TypeMap["remove-atom"] = Atom;
    292   TypeMap["remove-sphere"] = Double;
    293   TypeMap["repeat-box"] = Vector;
    294   TypeMap["rotate-to-pas"] = Molecule;
    295   TypeMap["save-adjacency"] = String;
    296   TypeMap["save-bonds"] = String;
    297   TypeMap["save-temperature"] = String;
    298   TypeMap["scale-box"] = Vector;
    299   TypeMap["set-basis"] = String;
    300   TypeMap["set-output"] = ListOfString;
    301   TypeMap["subgraph-dissect"] = None;
    302   TypeMap["suspend-in-water"] = Double;
    303   TypeMap["translate-mol"] = Vector;
    304   TypeMap["verlet-integrate"] = String;
    305   TypeMap["verbose"] = Integer;
     294  TypeMap["add-atom"] = &typeid(element);
     295  TypeMap["bond-file"] = &typeid(std::string);
     296  TypeMap["bond-table"] = &typeid(std::string);
     297  TypeMap["boundary"] = &typeid(VectorValue);
     298  TypeMap["center-in-box"] = &typeid(BoxValue);
     299  TypeMap["change-box"] = &typeid(BoxValue);
     300  TypeMap["change-element"] = &typeid(element);
     301  TypeMap["change-molname"] = &typeid(std::string);
     302  TypeMap["convex-envelope"] = &typeid(void);
     303  TypeMap["default-molname"] = &typeid(std::string);
     304  TypeMap["depth-first-search"] = &typeid(double);
     305  TypeMap["element-db"] = &typeid(std::string);
     306  TypeMap["fastparsing"] = &typeid(bool);
     307  TypeMap["fill-molecule"] = &typeid(std::string);
     308  TypeMap["fragment-mol"] = &typeid(std::string);
     309  TypeMap["input"] = &typeid(std::string);
     310  TypeMap["linear-interpolate"] = &typeid(std::string);
     311  TypeMap["molecular-volume"] = &typeid(molecule);
     312  TypeMap["nonconvex-envelope"] = &typeid(double);
     313  TypeMap["output"] = &typeid(void);
     314  TypeMap["parse-xyz"] = &typeid(std::string);
     315  TypeMap["pair-correlation"] = &typeid(void);
     316  TypeMap["point-correlation"] = &typeid(void);
     317  TypeMap["principal-axis-system"] = &typeid(void);
     318  TypeMap["remove-atom"] = &typeid(void);
     319  TypeMap["remove-sphere"] = &typeid(double);
     320  TypeMap["repeat-box"] = &typeid(VectorValue);
     321  TypeMap["rotate-to-pas"] = &typeid(molecule);
     322  TypeMap["save-adjacency"] = &typeid(std::string);
     323  TypeMap["save-bonds"] = &typeid(std::string);
     324  TypeMap["save-temperature"] = &typeid(std::string);
     325  TypeMap["scale-box"] = &typeid(VectorValue);
     326  TypeMap["set-basis"] = &typeid(std::string);
     327  TypeMap["set-output"] = &typeid(std::vector<std::string>);
     328  TypeMap["subgraph-dissect"] = &typeid(void);
     329  TypeMap["surface-correlation"] = &typeid(void);
     330  TypeMap["suspend-in-water"] = &typeid(double);
     331  TypeMap["translate-mol"] = &typeid(VectorValue);
     332  TypeMap["verlet-integrate"] = &typeid(std::string);
     333  TypeMap["verbose"] = &typeid(int);
    306334
    307335  // value types for the values
    308   TypeMap["atom-by-id"] = Atom;
    309   TypeMap["bin-output-file"] = String;
    310   TypeMap["bin-end"] = Double;
    311   TypeMap["bin-start"] = Double;
    312   TypeMap["bin-width"] = Double;
    313   TypeMap["convex-file"] = String;
    314   TypeMap["distance"] = Double;
    315   TypeMap["distances"] = Vector;
    316   TypeMap["DoRotate"] = Boolean;
    317   TypeMap["element"] = Element;
    318   TypeMap["elements"] = ListOfElements;
    319   TypeMap["end-step"] = Integer;
    320   TypeMap["id-mapping"] = Boolean;
    321   TypeMap["length"] = Double;
    322   TypeMap["lengths"] = Vector;
    323   TypeMap["MaxDistance"] = Double;
    324   TypeMap["molecule-by-id"] = Molecule;
    325   TypeMap["molecule-by-name"] = String;
    326   TypeMap["nonconvex-file"] = String;
    327   TypeMap["order"] = Integer;
    328   TypeMap["output-file"] = String;
    329   TypeMap["periodic"] = Boolean;
    330   TypeMap["position"] = Vector;
    331   TypeMap["sphere-radius"] = Double;
    332   TypeMap["start-step"] = Integer;
     336  TypeMap["bin-output-file"] = &typeid(std::string);
     337  TypeMap["bin-end"] = &typeid(double);
     338  TypeMap["bin-start"] = &typeid(double);
     339  TypeMap["bin-width"] = &typeid(double);
     340  TypeMap["convex-file"] = &typeid(std::string);
     341  TypeMap["distance"] = &typeid(double);
     342  TypeMap["distances"] = &typeid(VectorValue);
     343  TypeMap["DoRotate"] = &typeid(bool);
     344  TypeMap["element"] = &typeid(element);
     345  TypeMap["elements"] = &typeid(std::vector<element *>);
     346  TypeMap["end-step"] = &typeid(int);
     347  TypeMap["id-mapping"] = &typeid(bool);
     348  TypeMap["length"] = &typeid(double);
     349  TypeMap["lengths"] = &typeid(VectorValue);
     350  TypeMap["MaxDistance"] = &typeid(double);
     351  TypeMap["molecule-by-id"] = &typeid(molecule);
     352  TypeMap["nonconvex-file"] = &typeid(std::string);
     353  TypeMap["order"] = &typeid(int);
     354  TypeMap["output-file"] = &typeid(std::string);
     355  TypeMap["periodic"] = &typeid(bool);
     356  TypeMap["position"] = &typeid(VectorValue);
     357  TypeMap["select-all-atoms"] = &typeid(void);
     358  TypeMap["select-all-molecules"] = &typeid(void);
     359  TypeMap["select-atom-by-id"] = &typeid(atom);
     360  TypeMap["select-molecule-by-id"] = &typeid(molecule);
     361  TypeMap["start-step"] = &typeid(int);
     362  TypeMap["unselect-all-atoms"] = &typeid(void);
     363  TypeMap["unselect-all-molecules"] = &typeid(void);
     364  TypeMap["unselect-atom-by-id"] = &typeid(atom);
     365  TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
     366
     367  TypeEnumMap[&typeid(void)] = None;
     368  TypeEnumMap[&typeid(bool)] = Boolean;
     369  TypeEnumMap[&typeid(int)] = Integer;
     370  TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
     371  TypeEnumMap[&typeid(double)] = Double;
     372  TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles;
     373  TypeEnumMap[&typeid(std::string)] = String;
     374  TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings;
     375  TypeEnumMap[&typeid(VectorValue)] = Vector;
     376  TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors;
     377  TypeEnumMap[&typeid(BoxValue)] = Box;
     378  TypeEnumMap[&typeid(molecule)] = Molecule;
     379  TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules;
     380  TypeEnumMap[&typeid(atom)] = Atom;
     381  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
     382  TypeEnumMap[&typeid(element)] = Element;
     383  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
    333384
    334385  // default values for any action that needs one (always string!)
    335   DefaultValue["bin-width"] = "0.5";
    336   DefaultValue["fastparsing"] = "0";
    337   DefaultValue["atom-by-id"] = "-1";
    338   DefaultValue["molecule-by-id"] = "-1";
    339   DefaultValue["periodic"] = "0";
     386  CurrentValue["bin-width"] = "0.5";
     387  CurrentValue["fastparsing"] = "0";
     388  CurrentValue["periodic"] = "0";
    340389
    341390  // put action into each menu category
    342391  MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
    343   MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Edit atoms");
    344   MenuDescription["command"] = pair<std::string,std::string>("Configuration", "Configuration");
     392  MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms");
     393  MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options");
    345394  MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
    346   MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Parse files");
    347   MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Edit molecules");
    348   MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselate molecules");
    349   MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Edit world");
     395  MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules");
     396  MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output");
     397  MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection");
     398  MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation");
     399  MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals");
    350400
    351401  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
    352402  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
     403  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") );
     404  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") );
    353405  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
    354406
     
    381433  MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
    382434  MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
     435
     436  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
     437  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
     438  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
     439  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
    383440
    384441  MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
     
    425482        generic.insert("pair-correlation");
    426483        generic.insert("parse-xyz");
     484  generic.insert("point-correlation");
    427485//  generic.insert("principal-axis-system");
    428486  generic.insert("remove-atom");
     
    434492  generic.insert("save-temperature");
    435493  generic.insert("scale-box");
     494  generic.insert("select-all-atoms");
     495  generic.insert("select-all-molecules");
     496  generic.insert("select-atom-by-id");
     497  generic.insert("select-molecule-by-id");
    436498  generic.insert("set-basis");
    437499  generic.insert("set-output");
    438500        generic.insert("subgraph-dissect");
     501  generic.insert("surface-correlation");
    439502  generic.insert("suspend-in-water");
    440503  generic.insert("translate-mol");
     504  generic.insert("unselect-all-atoms");
     505  generic.insert("unselect-all-molecules");
     506  generic.insert("unselect-atom-by-id");
     507  generic.insert("unselect-molecule-by-id");
    441508        generic.insert("verbose");
    442509  generic.insert("verlet-integrate");
     
    445512    // positional arguments
    446513  generic.insert("input");
    447   inputfile.insert("input");
    448514
    449515    // hidden arguments
    450   generic.insert("atom-by-id");
    451   generic.insert("bin-end");
    452   generic.insert("bin-output-file");
    453   generic.insert("bin-start");
    454   generic.insert("bin-width");
    455   generic.insert("convex-file");
    456   generic.insert("distance");
    457   generic.insert("DoRotate");
    458   generic.insert("distances");
    459   generic.insert("element");
    460   generic.insert("elements");
    461   generic.insert("end-step");
    462   generic.insert("id-mapping");
    463   generic.insert("lengths");
    464   generic.insert("MaxDistance");
    465   generic.insert("molecule-by-id");
    466   generic.insert("molecule-by-name");
    467   generic.insert("nonconvex-file");
    468   generic.insert("order");
    469   generic.insert("output-file");
    470   generic.insert("periodic");
    471   generic.insert("position");
    472   generic.insert("sphere-radius");
    473   generic.insert("start-step");
     516  hidden.insert("bin-end");
     517  hidden.insert("bin-output-file");
     518  hidden.insert("bin-start");
     519  hidden.insert("bin-width");
     520  hidden.insert("convex-file");
     521  hidden.insert("distance");
     522  hidden.insert("DoRotate");
     523  hidden.insert("distances");
     524  hidden.insert("element");
     525  hidden.insert("elements");
     526  hidden.insert("end-step");
     527  hidden.insert("id-mapping");
     528  hidden.insert("lengths");
     529  hidden.insert("MaxDistance");
     530  hidden.insert("molecule-by-id");
     531  hidden.insert("nonconvex-file");
     532  hidden.insert("order");
     533  hidden.insert("output-file");
     534  hidden.insert("periodic");
     535  hidden.insert("position");
     536  hidden.insert("start-step");
    474537}
    475538
     
    482545}
    483546
     547void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
     548{
     549  int atomID = -1;
     550  if (typeid( atom ) == *TypeMap[name]) {
     551    if (CurrentValue.find(name) == CurrentValue.end())
     552      throw MissingValueException(__FILE__, __LINE__);
     553    atomID = lexical_cast<int>(CurrentValue[name].c_str());
     554    CurrentValue.erase(name);
     555  } else
     556    throw IllegalTypeException(__FILE__,__LINE__);
     557  _T = World::getInstance().getAtom(AtomById(atomID));
     558}
     559
     560void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
     561  int Z = -1;
     562  if (typeid( element ) == *TypeMap[name]) {
     563    if (CurrentValue.find(name) == CurrentValue.end())
     564      throw MissingValueException(__FILE__, __LINE__);
     565    Z = lexical_cast<int>(CurrentValue[name].c_str());
     566    CurrentValue.erase(name);
     567  } else
     568    throw IllegalTypeException(__FILE__,__LINE__);
     569  _T = World::getInstance().getPeriode()->FindElement(Z);
     570}
     571
     572void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
     573  int molID = -1;
     574  if (typeid( molecule ) == *TypeMap[name]) {
     575    if (CurrentValue.find(name) == CurrentValue.end())
     576      throw MissingValueException(__FILE__, __LINE__);
     577    molID = lexical_cast<int>(CurrentValue[name].c_str());
     578    CurrentValue.erase(name);
     579  } else
     580    throw IllegalTypeException(__FILE__,__LINE__);
     581  _T = World::getInstance().getMolecule(MoleculeById(molID));
     582}
     583
     584void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
     585  Matrix M;
     586  double tmp;
     587  if (typeid( BoxValue ) == *TypeMap[name]) {
     588    if (CurrentValue.find(name) == CurrentValue.end())
     589      throw MissingValueException(__FILE__, __LINE__);
     590    std::istringstream stream(CurrentValue[name]);
     591    stream >> tmp;
     592    M.set(0,0,tmp);
     593    stream >> tmp;
     594    M.set(0,1,tmp);
     595    M.set(1,0,tmp);
     596    stream >> tmp;
     597    M.set(0,2,tmp);
     598    M.set(2,0,tmp);
     599    stream >> tmp;
     600    M.set(1,1,tmp);
     601    stream >> tmp;
     602    M.set(1,2,tmp);
     603    M.set(2,1,tmp);
     604    stream >> tmp;
     605    M.set(2,2,tmp);
     606    _T = M;
     607    CurrentValue.erase(name);
     608  } else
     609    throw IllegalTypeException(__FILE__,__LINE__);
     610}
     611
     612void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
     613  if (typeid( VectorValue ) == *TypeMap[name]) {
     614    std::istringstream stream(CurrentValue[name]);
     615    CurrentValue.erase(name);
     616    stream >> _T[0];
     617    stream >> _T[1];
     618    stream >> _T[2];
     619  } else
     620    throw IllegalTypeException(__FILE__,__LINE__);
     621}
     622
     623void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
     624{
     625  int atomID = -1;
     626  atom *Walker = NULL;
     627  if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
     628    if (CurrentValue.find(name) == CurrentValue.end())
     629      throw MissingValueException(__FILE__, __LINE__);
     630    std::istringstream stream(CurrentValue[name]);
     631    CurrentValue.erase(name);
     632    while (!stream.fail()) {
     633      stream >> atomID >> ws;
     634      Walker = World::getInstance().getAtom(AtomById(atomID));
     635      if (Walker != NULL)
     636        _T.push_back(Walker);
     637      atomID = -1;
     638      Walker = NULL;
     639    }
     640  } else
     641    throw IllegalTypeException(__FILE__,__LINE__);
     642}
     643
     644void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
     645{
     646  int Z = -1;
     647  element *elemental = NULL;
     648  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     649    if (CurrentValue.find(name) == CurrentValue.end())
     650      throw MissingValueException(__FILE__, __LINE__);
     651    std::istringstream stream(CurrentValue[name]);
     652    CurrentValue.erase(name);
     653    while (!stream.fail()) {
     654      stream >> Z >> ws;
     655      elemental = World::getInstance().getPeriode()->FindElement(Z);
     656      if (elemental != NULL)
     657        _T.push_back(elemental);
     658      Z = -1;
     659    }
     660  } else
     661    throw IllegalTypeException(__FILE__,__LINE__);
     662}
     663
     664void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
     665{
     666  int molID = -1;
     667  molecule *mol = NULL;
     668  if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
     669    if (CurrentValue.find(name) == CurrentValue.end())
     670      throw MissingValueException(__FILE__, __LINE__);
     671    std::istringstream stream(CurrentValue[name]);
     672    CurrentValue.erase(name);
     673    while (!stream.fail()) {
     674      stream >> molID >> ws;
     675      mol = World::getInstance().getMolecule(MoleculeById(molID));
     676      if (mol != NULL)
     677        _T.push_back(mol);
     678      molID = -1;
     679      mol = NULL;
     680    }
     681  } else
     682    throw IllegalTypeException(__FILE__,__LINE__);
     683}
     684
     685
     686void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
     687{
     688  if (typeid( atom ) == *TypeMap[name]) {
     689    std::ostringstream stream;
     690    stream << _T->getId();
     691    CurrentValue[name] = stream.str();
     692  } else
     693    throw IllegalTypeException(__FILE__,__LINE__);
     694}
     695
     696void MapOfActions::setCurrentValue(const char * name, class element * &_T)
     697{
     698  if (typeid( element ) == *TypeMap[name]) {
     699    std::ostringstream stream;
     700    stream << _T->Z;
     701    CurrentValue[name] = stream.str();
     702  } else
     703    throw IllegalTypeException(__FILE__,__LINE__);
     704}
     705
     706void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
     707{
     708  if (typeid( molecule ) == *TypeMap[name]) {
     709    std::ostringstream stream;
     710    stream << _T->getId();
     711    CurrentValue[name] = stream.str();
     712  } else
     713    throw IllegalTypeException(__FILE__,__LINE__);
     714}
     715
     716void MapOfActions::setCurrentValue(const char * name, class Box &_T)
     717{
     718  const Matrix &M = _T.getM();
     719  if (typeid( BoxValue ) == *TypeMap[name]) {
     720    std::ostringstream stream;
     721    stream << M.at(0,0) << " ";
     722    stream << M.at(0,1) << " ";
     723    stream << M.at(0,2) << " ";
     724    stream << M.at(1,1) << " ";
     725    stream << M.at(1,2) << " ";
     726    stream << M.at(2,2) << " ";
     727    CurrentValue[name] = stream.str();
     728  } else
     729    throw IllegalTypeException(__FILE__,__LINE__);
     730}
     731
     732void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
     733{
     734  if (typeid( VectorValue ) == *TypeMap[name]){
     735    std::ostringstream stream;
     736    stream << _T[0] << " ";
     737    stream << _T[1] << " ";
     738    stream << _T[2] << " ";
     739    CurrentValue[name] = stream.str();
     740  } else
     741    throw IllegalTypeException(__FILE__,__LINE__);
     742}
     743
     744void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
     745{
     746  if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
     747    std::ostringstream stream;
     748    for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     749      stream << (*iter)->getId() << " ";
     750    }
     751    CurrentValue[name] = stream.str();
     752  } else
     753    throw IllegalTypeException(__FILE__,__LINE__);
     754}
     755
     756void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
     757{
     758  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     759    std::ostringstream stream;
     760    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     761      stream << (*iter)->Z << " ";
     762    }
     763    CurrentValue[name] = stream.str();
     764  } else
     765    throw IllegalTypeException(__FILE__,__LINE__);
     766}
     767
     768void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
     769{
     770  if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
     771    std::ostringstream stream;
     772    for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     773      stream << (*iter)->getId() << " ";
     774    }
     775    CurrentValue[name] = stream.str();
     776  } else
     777    throw IllegalTypeException(__FILE__,__LINE__);
     778}
     779
     780
    484781
    485782void MapOfActions::populateActions()
     
    487784  new AnalysisMolecularVolumeAction();
    488785  new AnalysisPairCorrelationAction();
     786  new AnalysisPointCorrelationAction();
    489787  new AnalysisPrincipalAxisSystemAction();
     788  new AnalysisSurfaceCorrelationAction();
    490789
    491790  new AtomAddAction();
     
    518817  new ParserLoadXyzAction();
    519818  new ParserSaveXyzAction();
     819
     820  new SelectionAllAtomsAction();
     821  new SelectionAllMoleculesAction();
     822  new SelectionAtomByIdAction();
     823  new SelectionMoleculeByIdAction();
     824  new SelectionNotAllAtomsAction();
     825  new SelectionNotAllMoleculesAction();
     826  new SelectionNotAtomByIdAction();
     827  new SelectionNotMoleculeByIdAction();
    520828
    521829  new TesselationConvexEnvelopeAction();
     
    537845}
    538846
    539 
    540847/** Adds all options to the CommandLineParser.
    541848 *
     
    547854    for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
    548855      if (hasValue(*OptionRunner)) {
    549         DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner] << " to CommandLineParser." << endl);
    550            switch((enum OptionTypes) TypeMap[*OptionRunner]) {
     856        DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
     857           switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
    551858          default:
    552859          case None:
     
    558865            ListRunner->second->add_options()
    559866              (getKeyAndShortForm(*OptionRunner).c_str(),
    560                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    561                         po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     867                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     868                        po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    562869                        po::value< bool >(),
    563870                  getDescription(*OptionRunner).c_str())
     
    567874            ListRunner->second->add_options()
    568875              (getKeyAndShortForm(*OptionRunner).c_str(),
    569                   po::value<BoxValue>()->multitoken(),
     876                  po::value<BoxValue>(),
    570877                  getDescription(*OptionRunner).c_str())
    571878              ;
     
    574881            ListRunner->second->add_options()
    575882              (getKeyAndShortForm(*OptionRunner).c_str(),
    576                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    577                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     883                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     884                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    578885                        po::value< int >(),
    579886                  getDescription(*OptionRunner).c_str())
    580887              ;
    581888            break;
    582           case ListOfInts:
     889          case ListOfIntegers:
    583890            ListRunner->second->add_options()
    584891              (getKeyAndShortForm(*OptionRunner).c_str(),
     
    590897            ListRunner->second->add_options()
    591898              (getKeyAndShortForm(*OptionRunner).c_str(),
    592                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    593                         po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
     899                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     900                        po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) :
    594901                        po::value< double >(),
    595902                  getDescription(*OptionRunner).c_str())
     
    606913            ListRunner->second->add_options()
    607914              (getKeyAndShortForm(*OptionRunner).c_str(),
    608                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    609                         po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
     915                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     916                        po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
    610917                        po::value< std::string >(),
    611918                  getDescription(*OptionRunner).c_str())
    612919              ;
    613920            break;
    614           case ListOfString:
     921          case ListOfStrings:
    615922            ListRunner->second->add_options()
    616923              (getKeyAndShortForm(*OptionRunner).c_str(),
     
    619926              ;
    620927            break;
    621           case Axis:
    622             ListRunner->second->add_options()
    623               (getKeyAndShortForm(*OptionRunner).c_str(),
    624                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    625                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     928          case Vector:
     929            ListRunner->second->add_options()
     930              (getKeyAndShortForm(*OptionRunner).c_str(),
     931                  po::value<VectorValue>(),
     932                  getDescription(*OptionRunner).c_str())
     933              ;
     934            break;
     935          case ListOfVectors:
     936            ListRunner->second->add_options()
     937              (getKeyAndShortForm(*OptionRunner).c_str(),
     938                  po::value< vector<VectorValue> >()->multitoken(),
     939                  getDescription(*OptionRunner).c_str())
     940              ;
     941            break;
     942          case Molecule:
     943            ListRunner->second->add_options()
     944              (getKeyAndShortForm(*OptionRunner).c_str(),
     945                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     946                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    626947                        po::value< int >(),
    627948                  getDescription(*OptionRunner).c_str())
    628949              ;
    629950            break;
    630           case Vector:
    631             ListRunner->second->add_options()
    632               (getKeyAndShortForm(*OptionRunner).c_str(),
    633                   po::value<VectorValue>(),
    634                   getDescription(*OptionRunner).c_str())
    635               ;
    636             break;
    637           case Molecule:
    638             ListRunner->second->add_options()
    639               (getKeyAndShortForm(*OptionRunner).c_str(),
    640                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    641                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     951          case ListOfMolecules:
     952            ListRunner->second->add_options()
     953              (getKeyAndShortForm(*OptionRunner).c_str(),
     954                  po::value< vector<int> >()->multitoken(),
     955                  getDescription(*OptionRunner).c_str())
     956              ;
     957            break;
     958          case Atom:
     959            ListRunner->second->add_options()
     960              (getKeyAndShortForm(*OptionRunner).c_str(),
     961                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     962                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    642963                        po::value< int >(),
    643964                  getDescription(*OptionRunner).c_str())
    644965              ;
    645966            break;
    646           case ListOfMolecules:
     967          case ListOfAtoms:
    647968            ListRunner->second->add_options()
    648969              (getKeyAndShortForm(*OptionRunner).c_str(),
     
    651972              ;
    652973            break;
    653           case Atom:
    654             ListRunner->second->add_options()
    655               (getKeyAndShortForm(*OptionRunner).c_str(),
    656                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    657                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
    658                         po::value< int >(),
    659                   getDescription(*OptionRunner).c_str())
    660               ;
    661             break;
    662           case ListOfAtoms:
    663             ListRunner->second->add_options()
    664               (getKeyAndShortForm(*OptionRunner).c_str(),
    665                   po::value< vector<int> >()->multitoken(),
    666                   getDescription(*OptionRunner).c_str())
    667               ;
    668             break;
    669974          case Element:
    670975            ListRunner->second->add_options()
    671976              (getKeyAndShortForm(*OptionRunner).c_str(),
    672                   po::value< vector<int> >(),
     977                  po::value< int >(),
    673978                  getDescription(*OptionRunner).c_str())
    674979              ;
     
    683988        }
    684989      } else {
    685         DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
     990        DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
    686991        ListRunner->second->add_options()
    687992          (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
     
    690995    }
    691996  }
    692   // add positional arguments
    693   for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {
    694     DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);
    695     CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);
    696   }
    697   cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;
    698997}
    699998
     
    7511050 * \return type of the action
    7521051 */
    753 enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
    754 {
    755   return TypeMap[actionname];
     1052std::string MapOfActions::getValueType(string actionname)
     1053{
     1054  return TypeMap[actionname]->name();
    7561055}
    7571056
  • src/Actions/MapOfActions.hpp

    r7067bd6 r677e13  
    99#define MAPOFACTIONS_HPP_
    1010
    11 #include "Helpers/Assert.hpp"
    1211#include <boost/program_options.hpp>
    1312
    1413#include <map>
    1514#include <set>
     15#include <vector>
     16#include <typeinfo>
     17
     18#include "Exceptions/IllegalTypeException.hpp"
     19#include "Exceptions/MissingValueException.hpp"
     20#include "Helpers/Assert.hpp"
     21#include "Patterns/Singleton.hpp"
    1622
    1723class MapOfActionsTest;
    1824
    19 #include "Patterns/Singleton.hpp"
     25class Box;
     26class atom;
     27class element;
     28class molecule;
     29class Vector;
    2030
    2131namespace po = boost::program_options;
     32
     33using boost::lexical_cast;
    2234
    2335/** Central class for adding functionality to the code.
     
    123135  friend class MapOfActionsTest;
    124136public:
    125   enum OptionTypes { None, Boolean, Integer, ListOfInts, Double, ListOfDoubles, String, ListOfString, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
     137  enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
    126138
    127139  // getter for the action descriptions and short forms
     
    136148  bool hasValue(std::string actionname);
    137149  bool isShortFormPresent(std::string shortform);
    138   enum OptionTypes getValueType(std::string actionname);
     150  std::string getValueType(std::string actionname);
    139151
    140152  std::set<std::string> generic;
     
    150162  void populateActions();
    151163
     164  void queryCurrentValue(const char * name, class atom * &_T);
     165  void queryCurrentValue(const char * name, class element * &_T);
     166  void queryCurrentValue(const char * name, class molecule * &_T);
     167  void queryCurrentValue(const char * name, class Box &_T);
     168  void queryCurrentValue(const char * name, class Vector &_T);
     169  void queryCurrentValue(const char * name, std::vector<atom *>&_T);
     170  void queryCurrentValue(const char * name, std::vector<element *>&_T);
     171  void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
     172  template<typename T> void queryCurrentValue(const char * name, T &_T)
     173  {
     174    if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr
     175      if (CurrentValue.find(name) == CurrentValue.end())
     176        throw MissingValueException(__FILE__, __LINE__);
     177      _T = lexical_cast<T>(CurrentValue[name].c_str());
     178      CurrentValue.erase(name);
     179    } else
     180      throw IllegalTypeException(__FILE__,__LINE__);
     181  }
     182  template<typename T> void queryCurrentValue(const char * name, std::vector<T> &_T)
     183  {
     184    T temp;
     185    if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr
     186      if (CurrentValue.find(name) == CurrentValue.end())
     187        throw MissingValueException(__FILE__, __LINE__);
     188      std::istringstream stream(CurrentValue[name]);
     189      CurrentValue.erase(name);
     190      while (!stream.fail()) {
     191        stream >> temp >> std::ws;
     192        _T.push_back(temp);
     193      }
     194    } else
     195      throw IllegalTypeException(__FILE__,__LINE__);
     196  }
     197
     198  void setCurrentValue(const char * name, class atom * &_T);
     199  void setCurrentValue(const char * name, class element * &_T);
     200  void setCurrentValue(const char * name, class molecule * &_T);
     201  void setCurrentValue(const char * name, class Box &_T);
     202  void setCurrentValue(const char * name, class Vector &_T);
     203  void setCurrentValue(const char * name, std::vector<atom *>&_T);
     204  void setCurrentValue(const char * name, std::vector<element *>&_T);
     205  void setCurrentValue(const char * name, std::vector<molecule *>&_T);
     206  template<class T> void setCurrentValue(const char * name, T &_T)
     207  {
     208    std::ostringstream stream;
     209    if (typeid( T ) == *TypeMap[name]) {  // constructor of type_info is private, hence can only store by ref or ptr
     210      stream << _T;
     211      CurrentValue[name] = stream.str();
     212    } else
     213      throw IllegalTypeException(__FILE__,__LINE__);
     214  }
     215  template<class T> void setCurrentValue(const char * name, std::vector<T> &_T)
     216  {
     217    std::ostringstream stream;
     218    if (typeid( std::vector<T> ) == *TypeMap[name]) {  // constructor of type_info is private, hence can only store by ref or ptr
     219      std::ostringstream stream;
     220      for (typename std::vector<T>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     221        stream << (*iter) << " ";
     222      }
     223      CurrentValue[name] = stream.str();
     224    } else
     225      throw IllegalTypeException(__FILE__,__LINE__);
     226  }
     227
     228
    152229private:
    153230  // private constructor and destructor
     
    159236
    160237  // map of the action names and their description
    161   std::map<std::string, std::string> DefaultValue;
     238  std::map<std::string, std::string> CurrentValue;
    162239  std::map<std::string, std::string> DescriptionMap;
    163240  std::map<std::string, std::string> ShortFormMap;
    164   std::map<std::string, enum OptionTypes > TypeMap;
     241  std::map<std::string, const std::type_info * > TypeMap;
     242  std::map<const std::type_info *, enum OptionTypes > TypeEnumMap;
    165243};
    166244
  • src/Actions/MethodAction.cpp

    r7067bd6 r677e13  
    2626{}
    2727
     28Dialog* MethodAction::createDialog() {
     29  return NULL;
     30}
     31
    2832
    2933Action::state_ptr MethodAction::performCall() {
  • src/Actions/MethodAction.hpp

    r7067bd6 r677e13  
    2626
    2727private:
     28  virtual Dialog * createDialog();
    2829  virtual Action::state_ptr performCall();
    2930  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/BondFileAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/BondFileAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2126
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "verbose.hpp"
    27 #include "log.hpp"
    28 #include "molecule.hpp"
    29 #include "vector.hpp"
    30 #include "World.hpp"
    3127
    3228/****** MoleculeBondFileAction *****/
     
    5349{}
    5450
     51void MoleculeBondFile(std::string &bondfile) {
     52  ValueStorage::getInstance().setCurrentValue(MoleculeBondFileAction::NAME, bondfile);
     53  ActionRegistry::getInstance().getActionByName(MoleculeBondFileAction::NAME)->call(Action::NonInteractive);
     54};
     55
     56Dialog* MoleculeBondFileAction::createDialog() {
     57  Dialog *dialog = UIFactory::getInstance().makeDialog();
     58
     59  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     60
     61  return dialog;
     62}
     63
    5564Action::state_ptr MoleculeBondFileAction::performCall() {
    5665  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5866  molecule *mol = NULL;
    5967
    60   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     68  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6269
    63   if(dialog->display()) {
     70  if(World::getInstance().countSelectedMolecules() == 1) {
     71    mol = World::getInstance().beginMoleculeSelection()->second;
    6472    DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << filename << "." << endl);
    6573    ifstream input(filename.c_str());
    6674    mol->CreateAdjacencyListFromDbondFile(&input);
    6775    input.close();
    68     delete dialog;
    6976    return Action::success;
    70   }
    71   delete dialog;
    72   return Action::failure;
     77  } else
     78    return Action::failure;
    7379}
    7480
  • src/Actions/MoleculeAction/BondFileAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeBondFile(std::string &bondfile);
     17
    1618class MoleculeBondFileAction : public Action {
     19  friend void MoleculeBondFile(std::string &bondfile);
     20
    1721public:
    1822  MoleculeBondFileAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/ChangeNameAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/ChangeNameAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "atom.hpp"
     13#include "molecule.hpp"
    1114
    1215#include <iostream>
     
    1720#include "UIElements/UIFactory.hpp"
    1821#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "molecule.hpp"
     22#include "UIElements/ValueStorage.hpp"
    2323
    2424/****** MoleculeChangeNameAction *****/
     
    4545{}
    4646
     47void MoleculeChangeName(std::string &name) {
     48  ValueStorage::getInstance().setCurrentValue(MoleculeChangeNameAction::NAME, name);
     49  ActionRegistry::getInstance().getActionByName(MoleculeChangeNameAction::NAME)->call(Action::NonInteractive);
     50};
     51
     52Dialog* MoleculeChangeNameAction::createDialog() {
     53  Dialog *dialog = UIFactory::getInstance().makeDialog();
     54
     55  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     56
     57  return dialog;
     58}
     59
    4760Action::state_ptr MoleculeChangeNameAction::performCall() {
    4861  string filename;
    4962  molecule *mol = NULL;
    50   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5163
    52   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    53   dialog->queryString("Enter name: ",&filename);
     64  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5465
    55   if(dialog->display()) {
     66  if (World::getInstance().countSelectedMolecules() == 1) {
     67    mol = World::getInstance().beginMoleculeSelection()->second;
    5668    string oldName = mol->getName();
    5769    mol->setName(filename);
    58     delete dialog;
    5970    return Action::state_ptr(new MoleculeChangeNameState(mol,oldName));
    60   }
    61   delete dialog;
    62   return Action::failure;
     71  } else
     72    return Action::failure;
    6373}
    6474
  • src/Actions/MoleculeAction/ChangeNameAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeChangeName(std::string &name);
     17
    1618class MoleculeChangeNameAction : public Action {
     19  friend void MoleculeChangeName(std::string &name);
     20
    1721public:
    1822  MoleculeChangeNameAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/FillWithMoleculeAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "atom.hpp"
     13#include "bondgraph.hpp"
     14#include "boundary.hpp"
     15#include "config.hpp"
     16#include "molecule.hpp"
     17#include "verbose.hpp"
     18#include "World.hpp"
     19
    1120
    1221#include <iostream>
     
    1726#include "UIElements/UIFactory.hpp"
    1827#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "bondgraph.hpp"
    23 #include "boundary.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "molecule.hpp"
    27 #include "periodentafel.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeFillWithMoleculeAction *****/
     
    5351{}
    5452
     53void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeFillWithMoleculeAction::NAME, fillername);
     55  ValueStorage::getInstance().setCurrentValue("distances", distances);
     56  ValueStorage::getInstance().setCurrentValue("lengths", lengths);
     57  ValueStorage::getInstance().setCurrentValue("DoRotate", MaxDistance);
     58  ValueStorage::getInstance().setCurrentValue("MaxDistance", DoRotate);
     59  ActionRegistry::getInstance().getActionByName(MoleculeFillWithMoleculeAction::NAME)->call(Action::NonInteractive);
     60};
     61
     62Dialog* MoleculeFillWithMoleculeAction::createDialog() {
     63  Dialog *dialog = UIFactory::getInstance().makeDialog();
     64
     65  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     66  dialog->queryVector("distances", false, ValueStorage::getInstance().getDescription("distances"));
     67  dialog->queryVector("lengths", false, ValueStorage::getInstance().getDescription("lengths"));
     68  dialog->queryBoolean("DoRotate", ValueStorage::getInstance().getDescription("DoRotate"));
     69  dialog->queryDouble("MaxDistance", ValueStorage::getInstance().getDescription("MaxDistance"));
     70
     71  return dialog;
     72}
     73
    5574Action::state_ptr MoleculeFillWithMoleculeAction::performCall() {
    5675  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5876  Vector distances;
    5977  Vector lengths;
     
    6179  bool DoRotate = false;
    6280
    63   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    64   dialog->queryVector("distances", &distances, false, MapOfActions::getInstance().getDescription("distances"));
    65   dialog->queryVector("lengths", &lengths, false, MapOfActions::getInstance().getDescription("lengths"));
    66   dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate"));
    67   dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance"));
     81  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
     82  ValueStorage::getInstance().queryCurrentValue("distances", distances);
     83  ValueStorage::getInstance().queryCurrentValue("lengths", lengths);
     84  ValueStorage::getInstance().queryCurrentValue("DoRotate", DoRotate);
     85  ValueStorage::getInstance().queryCurrentValue("MaxDistance", MaxDistance);
    6886
    69   if(dialog->display()) {
    70     DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl);
    71     // construct water molecule
    72     molecule *filler = World::getInstance().createMolecule();
    73     if (!filler->AddXYZFile(filename)) {
    74       DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
    75     }
    76     filler->SetNameFromFilename(filename.c_str());
    77     molecule *Filling = NULL;
     87  DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl);
     88  // construct water molecule
     89  molecule *filler = World::getInstance().createMolecule();
     90  if (!filler->AddXYZFile(filename)) {
     91    DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
     92  }
     93  filler->SetNameFromFilename(filename.c_str());
     94  molecule *Filling = NULL;
    7895//    atom *first = NULL, *second = NULL, *third = NULL;
    7996//    first = World::getInstance().createAtom();
     
    91108//    filler->AddBond(first, third, 1);
    92109//    filler->AddBond(second, third, 1);
    93     World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
     110  World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
    94111//    filler->SetNameFromFilename("water");
    95     // call routine
    96     double distance[NDIM];
    97     for (int i=0;i<NDIM;i++)
    98       distance[i] = distances[i];
    99     Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
    100     if (Filling != NULL) {
    101       Filling->ActiveFlag = false;
    102       World::getInstance().getMolecules()->insert(Filling);
    103     }
    104     for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
    105       atom *Walker = *iter;
    106       filler->erase(iter);
    107       World::getInstance().destroyAtom(Walker);
    108     }
    109     World::getInstance().destroyMolecule(filler);
     112  // call routine
     113  double distance[NDIM];
     114  for (int i=0;i<NDIM;i++)
     115    distance[i] = distances[i];
     116  Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
     117  if (Filling != NULL) {
     118    Filling->ActiveFlag = false;
     119    World::getInstance().getMolecules()->insert(Filling);
     120  }
     121  for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
     122    atom *Walker = *iter;
     123    filler->erase(iter);
     124    World::getInstance().destroyAtom(Walker);
     125  }
     126  World::getInstance().destroyMolecule(filler);
    110127
    111     delete dialog;
    112     return Action::success;
    113   }
    114   delete dialog;
    115   return Action::failure;
     128  return Action::success;
    116129}
    117130
  • src/Actions/MoleculeAction/FillWithMoleculeAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212#include "Actions/Process.hpp"
     13#include "vector.hpp"
    1314
    1415class MoleculeListClass;
    1516
     17void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate);
     18
    1619class MoleculeFillWithMoleculeAction : public Action {
     20  friend void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate);
     21
    1722public:
    1823  MoleculeFillWithMoleculeAction();
     
    2429  virtual const std::string getName();
    2530private:
     31  virtual Dialog * createDialog();
    2632  virtual Action::state_ptr performCall();
    2733  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "atom.hpp"
     13#include "defs.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
    1118
    1219#include <iostream>
     
    1825#include "UIElements/UIFactory.hpp"
    1926#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2128
    22 #include "atom.hpp"
    23 #include "defs.hpp"
    24 #include "log.hpp"
    25 #include "molecule.hpp"
    26 #include "verbose.hpp"
    27 #include "World.hpp"
    2829
    2930/****** MoleculeLinearInterpolationofTrajectoriesAction *****/
     
    5051{}
    5152
     53void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeLinearInterpolationofTrajectoriesAction::NAME, filename);
     55  ValueStorage::getInstance().setCurrentValue("start-step", start);
     56  ValueStorage::getInstance().setCurrentValue("end-step", end);
     57  ValueStorage::getInstance().setCurrentValue("id-mapping", IdMapping);
     58  ActionRegistry::getInstance().getActionByName(MoleculeLinearInterpolationofTrajectoriesAction::NAME)->call(Action::NonInteractive);
     59};
     60
     61Dialog* MoleculeLinearInterpolationofTrajectoriesAction::createDialog() {
     62  Dialog *dialog = UIFactory::getInstance().makeDialog();
     63
     64  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     65  dialog->queryInt("start-step", MapOfActions::getInstance().getDescription("start-step"));
     66  dialog->queryInt("end-step", MapOfActions::getInstance().getDescription("end-step"));
     67  dialog->queryBoolean("id-mapping", MapOfActions::getInstance().getDescription("id-mapping"));
     68
     69  return dialog;
     70}
     71
    5272Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() {
    5373  string filename;
    54   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5574  molecule *mol = NULL;
    5675  int start = -1;
     
    5877  bool IdMapping = true;
    5978
     79  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
     80  ValueStorage::getInstance().queryCurrentValue("start-step", start);
     81  ValueStorage::getInstance().queryCurrentValue("end-step", end);
     82  ValueStorage::getInstance().queryCurrentValue("id-mapping", IdMapping);
    6083
    61   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    62   dialog->queryInt("start-step", &start, MapOfActions::getInstance().getDescription("start-step"));
    63   dialog->queryInt("end-step", &end, MapOfActions::getInstance().getDescription("end-step"));
    64   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    65   dialog->queryBoolean("id-mapping", &IdMapping, MapOfActions::getInstance().getDescription("id-mapping"));
    66 
    67   if(dialog->display()) {
     84  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     85    mol = iter->second;
    6886    DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl);
    6987    if (IdMapping)
     
    7391    else
    7492      DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
    75     delete dialog;
    76     return Action::success;
    7793  }
    78   delete dialog;
    79   return Action::failure;
     94  return Action::success;
    8095}
    8196
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping);
     17
    1618class MoleculeLinearInterpolationofTrajectoriesAction : public Action {
     19  friend void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping);
     20
    1721public:
    1822  MoleculeLinearInterpolationofTrajectoriesAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "log.hpp"
    23 #include "molecule.hpp"
    24 #include "verbose.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627/****** MoleculeRotateToPrincipalAxisSystemAction *****/
     
    4748{}
    4849
     50void MoleculeRotateToPrincipalAxisSystem() {
     51  ActionRegistry::getInstance().getActionByName(MoleculeRotateToPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
     52};
     53
     54Dialog* MoleculeRotateToPrincipalAxisSystemAction::createDialog() {
     55  Dialog *dialog = UIFactory::getInstance().makeDialog();
     56
     57  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
     58
     59  return dialog;
     60}
     61
    4962Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
    50   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5163  molecule *mol = NULL;
    5264
    53   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    54 
    55   if(dialog->display()) {
     65  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     66    mol = iter->second;
    5667    DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    5768    mol->PrincipalAxisSystem(true);
    58     delete dialog;
    59     return Action::success;
    6069  }
    61   delete dialog;
    62   return Action::failure;
     70  return Action::success;
    6371}
    6472
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeRotateToPrincipalAxisSystem();
     17
    1618class MoleculeRotateToPrincipalAxisSystemAction : public Action {
     19  friend void MoleculeRotateToPrincipalAxisSystem();
     20
    1721public:
    1822  MoleculeRotateToPrincipalAxisSystemAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/SaveAdjacencyAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "bondgraph.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
     18
    1119
    1220#include <iostream>
     
    1826#include "UIElements/UIFactory.hpp"
    1927#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeSaveAdjacencyAction *****/
     
    5351{}
    5452
     53void MoleculeSaveAdjacency(std::string &adjacencyfile) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeSaveAdjacencyAction::NAME, adjacencyfile);
     55  ActionRegistry::getInstance().getActionByName(MoleculeSaveAdjacencyAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* MoleculeSaveAdjacencyAction::createDialog() {
     59  Dialog *dialog = UIFactory::getInstance().makeDialog();
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5566Action::state_ptr MoleculeSaveAdjacencyAction::performCall() {
    5667  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5868  molecule *mol = NULL;
    5969
    60   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     70  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6271
    63   if(dialog->display()) {
     72  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     73    mol = iter->second;
    6474    DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << filename << "." << endl);
    6575    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    6676    // TODO: sollte stream nicht filename benutzen, besser fuer unit test
    6777    mol->StoreAdjacencyToFile(filename);
    68     delete dialog;
    69     return Action::success;
    7078  }
    71   delete dialog;
    72   return Action::failure;
     79  return Action::success;
    7380}
    7481
  • src/Actions/MoleculeAction/SaveAdjacencyAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeSaveAdjacency(std::string &adjacencyfile);
     17
    1618class MoleculeSaveAdjacencyAction : public Action {
     19  friend void MoleculeSaveAdjacency(std::string &adjacencyfile);
     20
    1721public:
    1822  MoleculeSaveAdjacencyAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/SaveBondsAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/SaveBondsAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "bondgraph.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
     18
    1119
    1220#include <iostream>
     
    1826#include "UIElements/UIFactory.hpp"
    1927#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeSaveBondsAction *****/
     
    5351{}
    5452
     53void MoleculeSaveBonds(std::string &bondsfile) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeSaveBondsAction::NAME, bondsfile);
     55  ActionRegistry::getInstance().getActionByName(MoleculeSaveBondsAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* MoleculeSaveBondsAction::createDialog() {
     59  Dialog *dialog = UIFactory::getInstance().makeDialog();
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5566Action::state_ptr MoleculeSaveBondsAction::performCall() {
    5667  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5868  molecule *mol = NULL;
    5969
    60   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     70  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6271
    63   if(dialog->display()) {
     72  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     73    mol = iter->second;
    6474    DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl);
    6575    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    6676    // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests
    6777    mol->StoreBondsToFile(filename);
    68     delete dialog;
    69     return Action::success;
    7078  }
    71   delete dialog;
    72   return Action::failure;
     79  return Action::success;
    7380}
    7481
  • src/Actions/MoleculeAction/SaveBondsAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeSaveBonds(std::string &bondsfile);
     17
    1618class MoleculeSaveBondsAction : public Action {
     19  friend void MoleculeSaveBonds(std::string &bondsfile);
     20
    1721public:
    1822  MoleculeSaveBondsAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/SaveTemperatureAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "log.hpp"
    24 #include "molecule.hpp"
    25 #include "verbose.hpp"
    26 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2726
    2827/****** MoleculeSaveTemperatureAction *****/
     
    4948{}
    5049
     50void MoleculeSaveTemperature(std::string &temperaturefile) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeSaveTemperatureAction::NAME, temperaturefile);
     52  ActionRegistry::getInstance().getActionByName(MoleculeSaveTemperatureAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeSaveTemperatureAction::createDialog() {
     56  Dialog *dialog = UIFactory::getInstance().makeDialog();
     57
     58  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5163Action::state_ptr MoleculeSaveTemperatureAction::performCall() {
    5264  string filename;
    53   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5465  molecule *mol = NULL;
    5566
    56   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    57   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     67  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5868
    59   if(dialog->display()) {
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    6071    DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
    6172    ofstream output;
     
    6677      DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    6778    output.close();
    68     delete dialog;
    69     return Action::success;
    7079  }
    71   delete dialog;
    72   return Action::failure;
     80  return Action::success;
    7381}
    7482
  • src/Actions/MoleculeAction/SaveTemperatureAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeSaveTemperature(std::string &temperaturefile);
     17
    1618class MoleculeSaveTemperatureAction : public Action {
     19  friend void MoleculeSaveTemperature(std::string &temperaturefile);
     20
    1721public:
    1822  MoleculeSaveTemperatureAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/SuspendInWaterAction.cpp

    r7067bd6 r677e13  
    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 "verbose.hpp"
    25 #include "log.hpp"
    26 #include "config.hpp"
    27 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2826
    2927/****** MoleculeSuspendInWaterAction *****/
     
    5048{}
    5149
     50void MoleculeSuspendInWater(double density) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeSuspendInWaterAction::NAME, density);
     52  ActionRegistry::getInstance().getActionByName(MoleculeSuspendInWaterAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeSuspendInWaterAction::createDialog() {
     56  Dialog *dialog = UIFactory::getInstance().makeDialog();
     57
     58  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5263Action::state_ptr MoleculeSuspendInWaterAction::performCall() {
    5364  molecule *mol = NULL;
    54   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5565  double density;
    5666  double volume = 0.;
    5767
    58   dialog->queryDouble(NAME, &density, MapOfActions::getInstance().getDescription(NAME));
    59   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     68  ValueStorage::getInstance().queryCurrentValue(NAME, density);
    6069
    61   if(dialog->display()) {
     70  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     71    mol = iter->second;
    6272    DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    6373    if (density < 1.0) {
     
    6575    } else {
    6676      PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
    67       delete dialog;
    68       return Action::success;
    6977    }
    7078  }
    71   delete dialog;
    72   return Action::failure;
     79  return Action::success;
    7380}
    7481
  • src/Actions/MoleculeAction/SuspendInWaterAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeSuspendInWater(double density);
     17
    1618class MoleculeSuspendInWaterAction : public Action {
     19  friend void MoleculeSuspendInWater(double density);
     20
    1721public:
    1822  MoleculeSuspendInWaterAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/TranslateAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/TranslateAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "vector.hpp"
     15#include "verbose.hpp"
     16#include "World.hpp"
    1117
    1218#include <iostream>
     
    1824#include "UIElements/UIFactory.hpp"
    1925#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "log.hpp"
    24 #include "molecule.hpp"
    25 #include "verbose.hpp"
    26 #include "World.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2727
    2828/****** MoleculeTranslateAction *****/
     
    4949{}
    5050
     51void MoleculeTranslate(Vector &x, bool periodic) {
     52  ValueStorage::getInstance().setCurrentValue(MoleculeTranslateAction::NAME, x);
     53  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
     54  ActionRegistry::getInstance().getActionByName(MoleculeTranslateAction::NAME)->call(Action::NonInteractive);
     55};
     56
     57Dialog* MoleculeTranslateAction::createDialog() {
     58  Dialog *dialog = UIFactory::getInstance().makeDialog();
     59
     60  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     61  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
     62
     63  return dialog;
     64}
     65
    5166Action::state_ptr MoleculeTranslateAction::performCall() {
    52   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5367  molecule *mol = NULL;
    5468  Vector x;
    5569  bool periodic = false;
    5670
    57   dialog->queryVector(NAME, &x, false, MapOfActions::getInstance().getDescription(NAME));
    58   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    59   dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
    60   cout << "pre-dialog" << endl;
     71  ValueStorage::getInstance().queryCurrentValue(NAME, x);
     72  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
    6173
    62   if(dialog->display()) {
    63     cout << "post-dialog" << endl;
     74  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     75    mol = iter->second;
    6476    DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
    6577    if (periodic)
     
    6779    else
    6880      mol->Translate((const Vector *)&x);
    69     delete dialog;
    70     return Action::success;
    7181  }
    72   delete dialog;
    73   return Action::failure;
     82  return Action::success;
    7483}
    7584
  • src/Actions/MoleculeAction/TranslateAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212#include "Actions/Process.hpp"
     13#include "vector.hpp"
    1314
    1415class MoleculeListClass;
    1516
     17void MoleculeTranslate(Vector &x, bool periodic);
     18
    1619class MoleculeTranslateAction : public Action {
     20  friend void MoleculeTranslate(Vector &x, bool periodic);
     21
    1722public:
    1823  MoleculeTranslateAction();
     
    2429  virtual const std::string getName();
    2530private:
     31  virtual Dialog * createDialog();
    2632  virtual Action::state_ptr performCall();
    2733  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MoleculeAction/VerletIntegrationAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "log.hpp"
    24 #include "molecule.hpp"
    25 #include "verbose.hpp"
    26 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2726
    2827/****** MoleculeVerletIntegrationAction *****/
     
    4948{}
    5049
     50void MoleculeVerletIntegration(std::string &forcesfile) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeVerletIntegrationAction::NAME, forcesfile);
     52  ActionRegistry::getInstance().getActionByName(MoleculeVerletIntegrationAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeVerletIntegrationAction::createDialog() {
     56  Dialog *dialog = UIFactory::getInstance().makeDialog();
     57
     58  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5163Action::state_ptr MoleculeVerletIntegrationAction::performCall() {
    5264  string filename;
    53   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5465  molecule *mol = NULL;
    5566
    56   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    57   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     67  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5868
    59   if(dialog->display()) {
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    6071    DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
    6172    // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test
     
    6677    else
    6778      DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    68 
    69     delete dialog;
    70     return Action::success;
    7179  }
    72   delete dialog;
    73   return Action::failure;
     80  return Action::success;
    7481}
    7582
  • src/Actions/MoleculeAction/VerletIntegrationAction.hpp

    r7067bd6 r677e13  
    1414class MoleculeListClass;
    1515
     16void MoleculeVerletIntegration(std::string &forcesfile);
     17
    1618class MoleculeVerletIntegrationAction : public Action {
     19  friend void MoleculeVerletIntegration(std::string &forcesfile);
     20
    1721public:
    1822  MoleculeVerletIntegrationAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/ParserAction/LoadXyzAction.cpp

    r7067bd6 r677e13  
    1111
    1212#include "Actions/ParserAction/LoadXyzAction.hpp"
     13#include "Actions/ActionRegistry.hpp"
    1314#include "Parser/XyzParser.hpp"
     15#include "atom.hpp"
     16#include "log.hpp"
     17#include "molecule.hpp"
     18#include "verbose.hpp"
     19#include "World.hpp"
    1420
    1521#include <iostream>
     
    1824#include <vector>
    1925
    20 
    2126#include "UIElements/UIFactory.hpp"
    2227#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
    24 
    25 #include "atom.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "verbose.hpp"
    29 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3029
    3130/****** ParserLoadXyzAction *****/
     
    5251{}
    5352
     53void ParserLoadXyz(std::string &filename) {
     54  ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename);
     55  ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* ParserLoadXyzAction::createDialog() {
     59  Dialog *dialog = UIFactory::getInstance().makeDialog();
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5466Action::state_ptr ParserLoadXyzAction::performCall() {
    5567  string filename;
    56   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5768
    58   dialog->queryString(NAME,&filename, NAME);
     69  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5970
    60   if(dialog->display()) {
    61     DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    62     // parse xyz file
    63     ifstream input;
    64     input.open(filename.c_str());
    65     if (!input.fail()) {
    66       // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
    67       set <atom*> UniqueList;
    68       {
    69         vector<atom *> ListBefore = World::getInstance().getAllAtoms();
    70         for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
    71           UniqueList.insert(*runner);
     71  DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
     72  // parse xyz file
     73  ifstream input;
     74  input.open(filename.c_str());
     75  if (!input.fail()) {
     76    // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
     77    set <atom*> UniqueList;
     78    {
     79      vector<atom *> ListBefore = World::getInstance().getAllAtoms();
     80      for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
     81        UniqueList.insert(*runner);
     82    }
     83    XyzParser parser; // briefly instantiate a parser which is removed at end of focus
     84    parser.load(&input);
     85    {
     86      vector<atom *> ListAfter = World::getInstance().getAllAtoms();
     87      pair< set<atom *>::iterator, bool > Inserter;
     88      if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
     89        MoleculeListClass *molecules = World::getInstance().getMolecules();
     90        molecule *mol = World::getInstance().createMolecule();
     91        molecules->insert(mol);
     92        for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
     93          Inserter = UniqueList.insert(*runner);
     94          if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
     95            cout << "Adding new atom " << **runner << " to new mol." << endl;
     96            mol->AddAtom(*runner);
     97          }
     98        }
     99        mol->doCountAtoms();
     100      } else {
     101        cout << "No atoms parsed?" << endl;
    72102      }
    73       XyzParser parser; // briefly instantiate a parser which is removed at end of focus
    74       parser.load(&input);
    75       {
    76         vector<atom *> ListAfter = World::getInstance().getAllAtoms();
    77         pair< set<atom *>::iterator, bool > Inserter;
    78         if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
    79           MoleculeListClass *molecules = World::getInstance().getMolecules();
    80           molecule *mol = World::getInstance().createMolecule();
    81           molecules->insert(mol);
    82           for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
    83             Inserter = UniqueList.insert(*runner);
    84             if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
    85               cout << "Adding new atom " << **runner << " to new mol." << endl;
    86               mol->AddAtom(*runner);
    87             }
    88           }
    89           mol->doCountAtoms();
    90         } else {
    91           cout << "No atoms parsed?" << endl;
    92         }
    93       }
    94     } else {
    95       DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
    96103    }
    97     input.close();
     104  } else {
     105    DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
    98106  }
    99   delete dialog;
    100   return Action::failure;
     107  input.close();
     108  return Action::success;
    101109}
    102110
  • src/Actions/ParserAction/LoadXyzAction.hpp

    r7067bd6 r677e13  
    1212#include "Actions/Process.hpp"
    1313
     14void ParserLoadXyz(std::string &filename);
     15
    1416class ParserLoadXyzAction : public Action {
     17  friend void ParserLoadXyz(std::string &filename);
     18
    1519public:
    1620  ParserLoadXyzAction();
     
    2226  virtual const std::string getName();
    2327private:
     28  virtual Dialog * createDialog();
    2429  virtual Action::state_ptr performCall();
    2530  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/ParserAction/SaveXyzAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/ParserAction/SaveXyzAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "Parser/XyzParser.hpp"
     13#include "atom.hpp"
     14#include "molecule.hpp"
    1215
    1316#include <iostream>
     
    1821#include "UIElements/UIFactory.hpp"
    1922#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
    2124
    22 #include "atom.hpp"
    23 #include "molecule.hpp"
    2425
    2526/****** ParserSaveXyzAction *****/
     
    4647{}
    4748
     49void ParserSaveXyz(std::string &filename) {
     50  ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename);
     51  ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive);
     52};
     53
     54Dialog* ParserSaveXyzAction::createDialog() {
     55  Dialog *dialog = UIFactory::getInstance().makeDialog();
     56
     57  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     58
     59  return dialog;
     60}
     61
    4862Action::state_ptr ParserSaveXyzAction::performCall() {
    4963  string filename;
    5064  XyzParser parser;
    51   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5265
    53   dialog->queryString("filename",&filename, "Filename of the xyz file");
     66  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5467
    55   if(dialog->display()) {
    56     // store xyz file
    57     ofstream output;
    58     output.open(filename.c_str());
    59     if (!output.fail())
    60       parser.save(&output);
    61     output.close();
    62   }
    63   delete dialog;
     68  // store xyz file
     69  ofstream output;
     70  output.open(filename.c_str());
     71  if (!output.fail())
     72    parser.save(&output);
     73  output.close();
    6474  return Action::failure;
    6575}
  • src/Actions/ParserAction/SaveXyzAction.hpp

    r7067bd6 r677e13  
    1212#include "Actions/Process.hpp"
    1313
     14void ParserSaveXyz(std::string &filename);
     15
    1416class ParserSaveXyzAction : public Action {
     17  friend void ParserSaveXyz(std::string &filename);
     18
    1519public:
    1620  ParserSaveXyzAction();
     
    2226  virtual const std::string getName();
    2327private:
     28  virtual Dialog * createDialog();
    2429  virtual Action::state_ptr performCall();
    2530  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/TesselationAction/ConvexEnvelopeAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "boundary.hpp"
     13#include "config.hpp"
     14#include "linkedcell.hpp"
     15#include "log.hpp"
     16#include "molecule.hpp"
     17#include "verbose.hpp"
     18#include "World.hpp"
    1119
    1220#include <iostream>
     
    1725#include "UIElements/UIFactory.hpp"
    1826#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "boundary.hpp"
    23 #include "config.hpp"
    24 #include "linkedcell.hpp"
    25 #include "log.hpp"
    26 #include "molecule.hpp"
    27 #include "verbose.hpp"
    28 #include "World.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2928
    3029/****** TesselationConvexEnvelopeAction *****/
     
    5150{}
    5251
     52void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex) {
     53  ValueStorage::getInstance().setCurrentValue("convex-file", filenameConvex);
     54  ValueStorage::getInstance().setCurrentValue("nonconvex-file", filenameConvex);
     55  ActionRegistry::getInstance().getActionByName(TesselationConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* TesselationConvexEnvelopeAction::createDialog() {
     59  Dialog *dialog = UIFactory::getInstance().makeDialog();
     60
     61  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     62  dialog->queryString("convex-file", ValueStorage::getInstance().getDescription("convex-file"));
     63  dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file"));
     64
     65  return dialog;
     66}
     67
    5368Action::state_ptr TesselationConvexEnvelopeAction::performCall() {
    5469  string filenameConvex;
    5570  string filenameNonConvex;
    56   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5771  molecule * mol = NULL;
    58   bool Success = false;
     72  bool Success = true;
    5973  config *configuration = World::getInstance().getConfig();
    6074
    61   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    62   dialog->queryString("convex-file", &filenameConvex, MapOfActions::getInstance().getDescription("convex-file"));
    63   dialog->queryString("nonconvex-file", &filenameNonConvex, MapOfActions::getInstance().getDescription("nonconvex-file"));
     75  ValueStorage::getInstance().queryCurrentValue("convex-file", filenameConvex);
     76  ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filenameNonConvex);
    6477
    65   if(dialog->display()) {
     78  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     79    mol = iter->second;
    6680    class Tesselation *TesselStruct = NULL;
    6781    const LinkedCell *LCList = NULL;
     
    8195    delete(TesselStruct);
    8296    delete(LCList);
    83     delete dialog;
    84     if (Success)
    85       return Action::success;
    86     else
    87       return Action::failure;
    8897  }
    89   delete dialog;
    90   return Action::failure;
     98  if (Success)
     99    return Action::success;
     100  else
     101    return Action::failure;
    91102}
    92103
  • src/Actions/TesselationAction/ConvexEnvelopeAction.hpp

    r7067bd6 r677e13  
    1414class TesselationListClass;
    1515
     16void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex);
     17
    1618class TesselationConvexEnvelopeAction : public Action {
     19  friend void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex);
     20
    1721public:
    1822  TesselationConvexEnvelopeAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "boundary.hpp"
     13#include "linkedcell.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
    1118
    1219#include <iostream>
     
    1724#include "UIElements/UIFactory.hpp"
    1825#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "boundary.hpp"
    23 #include "linkedcell.hpp"
    24 #include "log.hpp"
    25 #include "molecule.hpp"
    26 #include "verbose.hpp"
    27 #include "World.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2827
    2928/****** TesselationNonConvexEnvelopeAction *****/
     
    5049{}
    5150
     51void TesselationNonConvexEnvelope(double radius, std::string &filename) {
     52  ValueStorage::getInstance().setCurrentValue(TesselationNonConvexEnvelopeAction::NAME, radius);
     53  ValueStorage::getInstance().setCurrentValue("nonconvex-file", filename);
     54  ActionRegistry::getInstance().getActionByName(TesselationNonConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
     55};
     56
     57Dialog* TesselationNonConvexEnvelopeAction::createDialog() {
     58  Dialog *dialog = UIFactory::getInstance().makeDialog();
     59
     60  dialog->queryDouble(NAME, MapOfActions::getInstance().getDescription(NAME));
     61  dialog->queryString("nonconvex-file", MapOfActions::getInstance().getDescription("nonconvex-file"));
     62
     63  return dialog;
     64}
     65
    5266Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() {
    5367  string filename;
    54   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5568  molecule * Boundary = NULL;
    5669  double SphereRadius = 0;
     
    5871  clock_t start,end;
    5972
    60   dialog->queryMolecule(NAME, &Boundary, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryString("nonconvex-file", &filename, MapOfActions::getInstance().getDescription("nonconvex-file"));
    62   dialog->queryDouble("sphere-radius", &SphereRadius, MapOfActions::getInstance().getDescription("sphere-radius"));
     73  ValueStorage::getInstance().queryCurrentValue(NAME, SphereRadius);
     74  ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filename);
    6375
    64   if(dialog->display()) {
     76  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     77    Boundary = iter->second;
    6578    class Tesselation *T = NULL;
    6679    const LinkedCell *LCList = NULL;
     
    7689    delete(LCList);
    7790    delete(T);
    78     delete dialog;
    79     if (Success)
    80       return Action::success;
    81     else
    82       return Action::failure;
    8391  }
    84   delete dialog;
    85   return Action::failure;
     92  if (Success)
     93    return Action::success;
     94  else
     95    return Action::failure;
    8696}
    8797
  • src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp

    r7067bd6 r677e13  
    1414class TesselationListClass;
    1515
     16void TesselationNonConvexEnvelope(double radius, std::string &filename);
     17
    1618class TesselationNonConvexEnvelopeAction : public Action {
     19  friend void TesselationNonConvexEnvelope(double radius, std::string &filename);
     20
    1721public:
    1822  TesselationNonConvexEnvelopeAction();
     
    2428  virtual const std::string getName();
    2529private:
     30  virtual Dialog * createDialog();
    2631  virtual Action::state_ptr performCall();
    2732  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/Values.hpp

    r7067bd6 r677e13  
    1919{
    2020  double xx;
    21   double xy;
    22   double xz;
     21  double yx;
    2322  double yy;
    24   double yz;
     23  double zx;
     24  double zy;
    2525  double zz;
    2626};
  • src/Actions/WorldAction/AddEmptyBoundaryAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526#include "Helpers/Assert.hpp"
    2627
     
    3435{}
    3536
     37void WorldAddEmptyBoundary(Vector &boundary) {
     38  ValueStorage::getInstance().setCurrentValue(WorldAddEmptyBoundaryAction::NAME, boundary);
     39  ActionRegistry::getInstance().getActionByName(WorldAddEmptyBoundaryAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* WorldAddEmptyBoundaryAction::createDialog() {
     43  Dialog *dialog = UIFactory::getInstance().makeDialog();
     44
     45  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     46
     47  return dialog;
     48}
     49
    3650Action::state_ptr WorldAddEmptyBoundaryAction::performCall() {
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3851  Vector boundary;
    3952  Vector Min;
     
    4154  int j=0;
    4255
    43   dialog->queryVector(NAME, &boundary, false, MapOfActions::getInstance().getDescription(NAME));
     56  ValueStorage::getInstance().queryCurrentValue(NAME, boundary);
    4457
    45   if(dialog->display()) {
    46     // get maximum and minimum
    47     vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    48     ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
    49     vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    50     Min = (*AtomRunner)->x;
    51     Max = (*AtomRunner)->x;
    52     for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
    53       for (int i=0;i<NDIM;i++) {
    54         if ((*AtomRunner)->x[i] > Max[i])
    55           Max[i] = (*AtomRunner)->x[i];
    56         if ((*AtomRunner)->x[i] < Min[i])
    57           Min[i] = (*AtomRunner)->x[i];
    58       }
     58  // get maximum and minimum
     59  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
     60  ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
     61  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     62  Min = (*AtomRunner)->x;
     63  Max = (*AtomRunner)->x;
     64  for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
     65    for (int i=0;i<NDIM;i++) {
     66      if ((*AtomRunner)->x[i] > Max[i])
     67        Max[i] = (*AtomRunner)->x[i];
     68      if ((*AtomRunner)->x[i] < Min[i])
     69        Min[i] = (*AtomRunner)->x[i];
    5970    }
    60     // set new box size
    61     double * const cell_size = new double[6];
    62     for (j=0;j<6;j++)
    63       cell_size[j] = 0.;
    64     j=-1;
    65     for (int i=0;i<NDIM;i++) {
    66       j += i+1;
    67       cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);
    68     }
    69     World::getInstance().setDomain(cell_size);
    70     delete[] cell_size;
    71     // translate all atoms, such that Min is aty (0,0,0)
    72     AtomRunner = AllAtoms.begin();
    73     for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
    74       (*AtomRunner)->x -= Min - boundary;
    75     delete dialog;
    76     return Action::success;
    77   } else {
    78     delete dialog;
    79     return Action::failure;
    8071  }
     72  // set new box size
     73  double * const cell_size = new double[6];
     74  for (j=0;j<6;j++)
     75    cell_size[j] = 0.;
     76  j=-1;
     77  for (int i=0;i<NDIM;i++) {
     78    j += i+1;
     79    cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);
     80  }
     81  World::getInstance().setDomain(cell_size);
     82  delete[] cell_size;
     83  // translate all atoms, such that Min is aty (0,0,0)
     84  AtomRunner = AllAtoms.begin();
     85  for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
     86    (*AtomRunner)->x -= Min - boundary;
     87  return Action::success;
    8188}
    8289
  • src/Actions/WorldAction/AddEmptyBoundaryAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14void WorldAddEmptyBoundary(Vector &boundary);
    1215
    1316class WorldAddEmptyBoundaryAction : public Action {
     17  friend void WorldAddEmptyBoundary(Vector &boundary);
     18
    1419public:
    1520  WorldAddEmptyBoundaryAction();
     
    2126  virtual const std::string getName();
    2227private:
     28  virtual Dialog * createDialog();
    2329  virtual Action::state_ptr performCall();
    2430  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/BoundInBoxAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/BoundInBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "molecule.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
    2425
    2526const char WorldBoundInBoxAction::NAME[] = "bound-in-box";
     
    3233{}
    3334
    34 Action::state_ptr WorldBoundInBoxAction::performCall() {
     35void WorldBoundInBox() {
     36  ActionRegistry::getInstance().getActionByName(WorldBoundInBoxAction::NAME)->call(Action::NonInteractive);
     37};
     38
     39Dialog* WorldBoundInBoxAction::createDialog() {
    3540  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3641
    37   dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
     42  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
    3843
    39   if(dialog->display()) {
    40     // center
    41     vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    42     for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    43       (*MolRunner)->BoundInBox();
    44     }
    45     delete dialog;
    46     return Action::success;
    47   } else {
    48     delete dialog;
    49     return Action::failure;
     44  return dialog;
     45}
     46
     47Action::state_ptr WorldBoundInBoxAction::performCall() {
     48
     49  // center
     50  vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
     51  for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     52    (*MolRunner)->BoundInBox();
    5053  }
     54  return Action::success;
    5155}
    5256
  • src/Actions/WorldAction/BoundInBoxAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldBoundInBox();
     14
    1315class WorldBoundInBoxAction : public Action {
     16  friend void WorldBoundInBox();
     17
    1418public:
    1519  WorldBoundInBoxAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/CenterInBoxAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/CenterInBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "Box.hpp"
    1113#include "log.hpp"
    1214#include "molecule.hpp"
     
    2022#include "UIElements/UIFactory.hpp"
    2123#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
    2325
    2426const char WorldCenterInBoxAction::NAME[] = "center-in-box";
     
    3133{}
    3234
    33 Action::state_ptr WorldCenterInBoxAction::performCall() {
     35void WorldCenterInBox(Box &_box) {
     36  ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box);
     37  ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive);
     38};
     39
     40Dialog* WorldCenterInBoxAction::createDialog() {
    3441  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3542
     43  dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
     44
     45  return dialog;
     46}
     47
     48Action::state_ptr WorldCenterInBoxAction::performCall() {
     49
    3650  Box& cell_size = World::getInstance().getDomain();
    37   dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME));
     51  ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
     52  World::getInstance().setDomain(cell_size.getM());
    3853
    39   if(dialog->display()) {
    40     // center
    41     vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
    42     for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    43       (*MolRunner)->CenterInBox();
    44     }
    45     delete dialog;
    46     return Action::success;
    47   } else {
    48     delete dialog;
    49     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();
    5058  }
     59  return Action::success;
    5160}
    5261
  • src/Actions/WorldAction/CenterInBoxAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "Box.hpp"
     13
     14void WorldCenterInBox(Box &_box);
    1215
    1316class WorldCenterInBoxAction : public Action {
     17  friend void WorldCenterInBox(Box &_box);
     18
    1419public:
    1520  WorldCenterInBoxAction();
     
    2126  virtual const std::string getName();
    2227private:
     28  virtual Dialog * createDialog();
    2329  virtual Action::state_ptr performCall();
    2430  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/CenterOnEdgeAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526#include "Helpers/Assert.hpp"
    2627
     
    3435{}
    3536
     37void WorldCenterOnEdge() {
     38  ActionRegistry::getInstance().getActionByName(WorldCenterOnEdgeAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* WorldCenterOnEdgeAction::createDialog() {
     42  Dialog *dialog = UIFactory::getInstance().makeDialog();
     43
     44  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3649Action::state_ptr WorldCenterOnEdgeAction::performCall() {
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3850  Vector Min;
    3951  Vector Max;
    4052
    41   dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
     53  // get maximum and minimum
     54  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
     55  ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present.");
     56  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     57  Min = (*AtomRunner)->x;
     58  Max = (*AtomRunner)->x;
     59  for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
     60    for (int i=0;i<NDIM;i++) {
     61      if ((*AtomRunner)->x[i] > Max[i])
     62        Max[i] = (*AtomRunner)->x[i];
     63      if ((*AtomRunner)->x[i] < Min[i])
     64        Min[i] = (*AtomRunner)->x[i];
     65    }
     66  }
     67  // set new box size
     68  Matrix domain;
     69  for (int i=0;i<NDIM;i++) {
     70    double tmp = Max[i]-Min[i];
     71    tmp = fabs(tmp)>=1. ? tmp : 1.0;
     72    domain.at(i,i) = tmp;
     73  }
     74  World::getInstance().setDomain(domain);
     75  // translate all atoms, such that Min is aty (0,0,0)
     76  for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner)
     77    (*AtomRunner)->x -= Min;
    4278
    43   if(dialog->display()) {
    44     // get maximum and minimum
    45     vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    46     ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present.");
    47     vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    48     Min = (*AtomRunner)->x;
    49     Max = (*AtomRunner)->x;
    50     for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
    51       for (int i=0;i<NDIM;i++) {
    52         if ((*AtomRunner)->x[i] > Max[i])
    53           Max[i] = (*AtomRunner)->x[i];
    54         if ((*AtomRunner)->x[i] < Min[i])
    55           Min[i] = (*AtomRunner)->x[i];
    56       }
    57     }
    58     // set new box size
    59     Matrix domain;
    60     for (int i=0;i<NDIM;i++) {
    61       double tmp = Max[i]-Min[i];
    62       tmp = fabs(tmp)>=1. ? tmp : 1.0;
    63       domain.at(i,i) = tmp;
    64     }
    65     World::getInstance().setDomain(domain);
    66     // translate all atoms, such that Min is aty (0,0,0)
    67     for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner)
    68       (*AtomRunner)->x -= Min;
    69     delete dialog;
    70     return Action::success;
    71   } else {
    72     delete dialog;
    73     return Action::failure;
    74   }
     79  return Action::success;
    7580}
    7681
  • src/Actions/WorldAction/CenterOnEdgeAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldCenterOnEdge();
     14
    1315class WorldCenterOnEdgeAction : public Action {
     16  friend void WorldCenterOnEdge();
     17
    1418public:
    1519  WorldCenterOnEdgeAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/ChangeBoxAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/ChangeBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "verbose.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627const char WorldChangeBoxAction::NAME[] = "change-box";
     
    3334{}
    3435
    35 Action::state_ptr WorldChangeBoxAction::performCall() {
     36void WorldChangeBox(Box &_box) {
     37  ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box);
     38  ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* WorldChangeBoxAction::createDialog() {
    3642  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3743
    38   Box& cell_size = World::getInstance().getDomain();
    39   dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME));
     44  dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
    4045
    41   if(dialog->display()) {
    42     DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size.getM() << endl);
    43     World::getInstance().setDomain(cell_size.getM());
    44     delete dialog;
    45     return Action::success;
    46   } else {
    47     delete dialog;
    48     return Action::failure;
    49   }
     46  return dialog;
     47}
     48
     49Action::state_ptr WorldChangeBoxAction::performCall() {
     50
     51  Box cell_size;
     52  ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
     53  World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd.
     54
     55  DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl);
     56  return Action::success;
    5057}
    5158
  • src/Actions/WorldAction/ChangeBoxAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "Box.hpp"
     13
     14void WorldChangeBox(Box &_box);
    1215
    1316class WorldChangeBoxAction : public Action {
     17  friend void WorldChangeBox(Box &_box);
     18
    1419public:
    1520  WorldChangeBoxAction();
     
    2126  virtual const std::string getName();
    2227private:
     28  virtual Dialog * createDialog();
    2329  virtual Action::state_ptr performCall();
    2430  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/InputAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/InputAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "molecule.hpp"
     
    2324#include "UIElements/UIFactory.hpp"
    2425#include "UIElements/Dialog.hpp"
    25 #include "Actions/MapOfActions.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2627
    2728const char WorldInputAction::NAME[] = "input";
     
    3435{}
    3536
     37void WorldInput(std::string &filename) {
     38  ValueStorage::getInstance().setCurrentValue(WorldInputAction::NAME, filename);
     39  ActionRegistry::getInstance().getActionByName(WorldInputAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* WorldInputAction::createDialog() {
     43  Dialog *dialog = UIFactory::getInstance().makeDialog();
     44
     45  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     46
     47  return dialog;
     48}
     49
    3650Action::state_ptr WorldInputAction::performCall() {
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3851  MoleculeListClass *molecules = World::getInstance().getMolecules();
    3952  molecule *mol = NULL;
     
    4154  std::ifstream test;
    4255
    43   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
     56  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    4457
    45   if(dialog->display()) {
    46     DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
    47     if (filename.find('.') != string::npos) {
    48       std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.'));
    49       std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length());
    50       DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
    51       test.open(filename.c_str());
    52       if (test == NULL) {
    53         DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
    54       } else {
    55         DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    56         FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
    57         test.close();
    58       }
    59       FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
    60       // set mol to first active molecule
    61       if (molecules->ListOfMolecules.size() != 0) {
    62         for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    63           if ((*ListRunner)->ActiveFlag) {
    64             mol = *ListRunner;
    65             break;
    66           }
    67       }
    68       if (mol == NULL) {
    69         mol = World::getInstance().createMolecule();
    70         mol->ActiveFlag = true;
    71         molecules->insert(mol);
    72       }
    73       mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str());
     58  DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
     59  if (filename.find('.') != string::npos) {
     60    std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.'));
     61    std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length());
     62    DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
     63    test.open(filename.c_str());
     64    if (test == NULL) {
     65      DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
    7466    } else {
    75       DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
     67      DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
     68      FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
     69      test.close();
    7670    }
    77     delete dialog;
    78     return Action::success;
     71    FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
     72    // set mol to first active molecule
     73    if (molecules->ListOfMolecules.size() != 0) {
     74      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     75        if ((*ListRunner)->ActiveFlag) {
     76          mol = *ListRunner;
     77          break;
     78        }
     79    }
     80    if (mol == NULL) {
     81      mol = World::getInstance().createMolecule();
     82      mol->ActiveFlag = true;
     83      molecules->insert(mol);
     84    }
     85    mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str());
    7986  } else {
    80     delete dialog;
    81     return Action::failure;
     87    DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
    8288  }
     89  return Action::success;
    8390}
    8491
  • src/Actions/WorldAction/InputAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldInput(std::string &filename);
     14
    1315class WorldInputAction : public Action {
     16  friend void WorldInput(std::string &filename);
     17
    1418public:
    1519  WorldInputAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/OutputAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/OutputAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "Parser/ChangeTracker.hpp"
    1213#include "log.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
    2425
    2526const char WorldOutputAction::NAME[] = "output";
     
    3233{}
    3334
    34 Action::state_ptr WorldOutputAction::performCall() {
     35void WorldOutput() {
     36  ActionRegistry::getInstance().getActionByName(WorldOutputAction::NAME)->call(Action::NonInteractive);
     37};
     38
     39Dialog* WorldOutputAction::createDialog() {
    3540  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3641
    37   dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
     42  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
    3843
    39   if(dialog->display()) {
    40     DoLog(0) && (Log() << Verbose(0) << "Saving world to files." << endl);
    41     ChangeTracker::getInstance().saveStatus();
    42     delete dialog;
    43     return Action::success;
    44   } else {
    45     delete dialog;
    46     return Action::failure;
    47   }
     44  return dialog;
     45}
     46
     47Action::state_ptr WorldOutputAction::performCall() {
     48
     49  DoLog(0) && (Log() << Verbose(0) << "Saving world to files." << endl);
     50  ChangeTracker::getInstance().saveStatus();
     51  return Action::success;
    4852}
    4953
  • src/Actions/WorldAction/OutputAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldOutput();
     14
    1315class WorldOutputAction : public Action {
     16  friend void WorldOutput();
     17
    1418public:
    1519  WorldOutputAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "Descriptors/AtomDescriptor.hpp"
    1113#include "atom.hpp"
    12 #include "Descriptors/AtomDescriptor.hpp"
    1314#include "log.hpp"
    1415#include "molecule.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char WorldRemoveSphereOfAtomsAction::NAME[] = "remove-sphere";
     
    3536{}
    3637
     38void WorldRemoveSphereOfAtoms(double radius, Vector &point) {
     39  ValueStorage::getInstance().setCurrentValue(WorldRemoveSphereOfAtomsAction::NAME, radius);
     40  ValueStorage::getInstance().setCurrentValue("position", point);
     41  ActionRegistry::getInstance().getActionByName(WorldRemoveSphereOfAtomsAction::NAME)->call(Action::NonInteractive);
     42};
     43
     44Dialog* WorldRemoveSphereOfAtomsAction::createDialog() {
     45  Dialog *dialog = UIFactory::getInstance().makeDialog();
     46
     47  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     48  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
     49
     50  return dialog;
     51}
     52
    3753Action::state_ptr WorldRemoveSphereOfAtomsAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3954  double radius = 0.;
    4055  Vector point;
    4156
    42   dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME));
    43   dialog->queryVector("position", &point, false, MapOfActions::getInstance().getDescription("position"));
     57  ValueStorage::getInstance().queryCurrentValue(NAME, radius);
     58  ValueStorage::getInstance().queryCurrentValue("position", point);
    4459
    45   if(dialog->display()) {
    46     delete dialog;
    47     DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
    48     vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
    49     vector<molecule *> molecules = World::getInstance().getAllMolecules();
    50     for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
    51       if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ...
    52         // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save)
    53         for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter)
    54           (*iter)->erase(*AtomRunner);
    55         World::getInstance().destroyAtom(*AtomRunner);
    56       }
     60  DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
     61  vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
     62  vector<molecule *> molecules = World::getInstance().getAllMolecules();
     63  for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
     64    if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ...
     65      // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save)
     66      for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter)
     67        (*iter)->erase(*AtomRunner);
     68      World::getInstance().destroyAtom(*AtomRunner);
    5769    }
    58     return Action::success;
    59   } else {
    60     delete dialog;
    61     return Action::failure;
    6270  }
    63 
     71  return Action::success;
    6472}
    6573
  • src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14
     15void WorldRemoveSphereOfAtoms(double radius, Vector &point);
    1216
    1317class WorldRemoveSphereOfAtomsAction : public Action {
     18  friend void WorldRemoveSphereOfAtoms(double radius, Vector &point);
     19
    1420public:
    1521  WorldRemoveSphereOfAtomsAction();
     
    2127  virtual const std::string getName();
    2228private:
     29  virtual Dialog * createDialog();
    2330  virtual Action::state_ptr performCall();
    2431  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/RepeatBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    2526#include "UIElements/UIFactory.hpp"
    2627#include "UIElements/Dialog.hpp"
    27 #include "Actions/MapOfActions.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2829#include "Descriptors/MoleculeDescriptor.hpp"
    2930#include "Descriptors/MoleculePtrDescriptor.hpp"
     
    3839{}
    3940
     41void WorldRepeatBox(Vector &Repeater) {
     42  ValueStorage::getInstance().setCurrentValue(WorldRepeatBoxAction::NAME, Repeater);
     43  ActionRegistry::getInstance().getActionByName(WorldRepeatBoxAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog * WorldRepeatBoxAction::createDialog() {
     47  Dialog *dialog = UIFactory::getInstance().makeDialog();
     48
     49  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     50
     51  return dialog;
     52}
     53
    4054Action::state_ptr WorldRepeatBoxAction::performCall() {
    41   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4255  Vector Repeater;
    4356  int count;
     
    4861  MoleculeListClass *molecules = World::getInstance().getMolecules();
    4962
    50   dialog->queryVector(NAME, &Repeater, false, MapOfActions::getInstance().getDescription(NAME));
    51   //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id"));
     63  ValueStorage::getInstance().queryCurrentValue(NAME, Repeater);
     64
    5265  vector<molecule *> AllMolecules;
    5366  if (mol != NULL) {
     
    5972  }
    6073
    61   if(dialog->display()) {
    62     (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
    63     Matrix M = World::getInstance().getDomain().getM();
    64     Matrix newM = M;
    65     Vector x,y;
    66     int n[NDIM];
    67     Matrix repMat;
    68     for (int axis = 0; axis < NDIM; axis++) {
    69       Repeater[axis] = floor(Repeater[axis]);
    70       if (Repeater[axis] < 1) {
    71         DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
    72         Repeater[axis] = 1;
    73       }
    74       repMat.at(axis,axis) = Repeater[axis];
     74  (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
     75  Matrix M = World::getInstance().getDomain().getM();
     76  Matrix newM = M;
     77  Vector x,y;
     78  int n[NDIM];
     79  Matrix repMat;
     80  for (int axis = 0; axis < NDIM; axis++) {
     81    Repeater[axis] = floor(Repeater[axis]);
     82    if (Repeater[axis] < 1) {
     83      DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
     84      Repeater[axis] = 1;
    7585    }
    76     newM *= repMat;
    77     World::getInstance().setDomain(newM);
     86    repMat.at(axis,axis) = Repeater[axis];
     87  }
     88  newM *= repMat;
     89  World::getInstance().setDomain(newM);
    7890
    79     molecule *newmol = NULL;
    80     Vector ** vectors = NULL;
    81     for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
    82       y[0] = n[0];
    83       for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
    84         y[1] = n[1];
    85         for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
    86           y[2] = n[2];
    87           if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
    88             continue;
    89           for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    90             mol = *MolRunner;
    91             DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
    92             count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
    93             if (count != 0) {  // if there is more than none
    94               Elements = new const element *[count];
    95               vectors = new Vector *[count];
    96               j = 0;
    97               for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
    98                 Elements[j] = (*AtomRunner)->type;
    99                 vectors[j] = &(*AtomRunner)->x;
    100                 j++;
    101               }
    102               if (count != j)
    103                 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    104               x = y;
    105               x *= M;
    106               newmol = World::getInstance().createMolecule();
    107               molecules->insert(newmol);
    108               for (int k=count;k--;) { // go through every atom of the original cell
    109                 Walker = World::getInstance().createAtom(); // create a new body
    110                 Walker->x = (*vectors[k]) + x;
    111                 Walker->type = Elements[k];  // insert original element
    112                 cout << "new atom is " << *Walker << endl;
    113                 newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    114               }
    115               // free memory
    116               delete[](Elements);
    117               delete[](vectors);
    118             } else {
    119               DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
     91  molecule *newmol = NULL;
     92  Vector ** vectors = NULL;
     93  for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
     94    y[0] = n[0];
     95    for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
     96      y[1] = n[1];
     97      for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
     98        y[2] = n[2];
     99        if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
     100          continue;
     101        for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     102          mol = *MolRunner;
     103          DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
     104          count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
     105          if (count != 0) {  // if there is more than none
     106            Elements = new const element *[count];
     107            vectors = new Vector *[count];
     108            j = 0;
     109            for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
     110              Elements[j] = (*AtomRunner)->type;
     111              vectors[j] = &(*AtomRunner)->x;
     112              j++;
    120113            }
     114            if (count != j)
     115              DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
     116            x = y;
     117            x *= M;
     118            newmol = World::getInstance().createMolecule();
     119            molecules->insert(newmol);
     120            for (int k=count;k--;) { // go through every atom of the original cell
     121              Walker = World::getInstance().createAtom(); // create a new body
     122              Walker->x = (*vectors[k]) + x;
     123              Walker->type = Elements[k];  // insert original element
     124              cout << "new atom is " << *Walker << endl;
     125              newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     126            }
     127            // free memory
     128            delete[](Elements);
     129            delete[](vectors);
     130          } else {
     131            DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
    121132          }
    122133        }
    123134      }
    124135    }
    125     delete dialog;
    126     return Action::success;
    127   } else {
    128     delete dialog;
    129     return Action::failure;
    130136  }
     137  return Action::success;
    131138}
    132139
  • src/Actions/WorldAction/RepeatBoxAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14void WorldRepeatBox(Vector &Repeater);
    1215
    1316class WorldRepeatBoxAction : public Action {
     17  friend void WorldRepeatBox(Vector &Repeater);
     18
    1419public:
    1520  WorldRepeatBoxAction();
     
    2126  virtual const std::string getName();
    2227private:
     28  virtual Dialog * createDialog();
    2329  virtual Action::state_ptr performCall();
    2430  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/ScaleBoxAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/ScaleBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char WorldScaleBoxAction::NAME[] = "scale-box";
     
    3536{}
    3637
     38void WorldScaleBox(Vector &Scaler) {
     39  ValueStorage::getInstance().setCurrentValue(WorldScaleBoxAction::NAME, Scaler);
     40  ActionRegistry::getInstance().getActionByName(WorldScaleBoxAction::NAME)->call(Action::NonInteractive);
     41};
     42
     43Dialog* WorldScaleBoxAction::createDialog() {
     44  Dialog *dialog = UIFactory::getInstance().makeDialog();
     45
     46  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     47
     48  return dialog;
     49}
     50
    3751Action::state_ptr WorldScaleBoxAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3952  Vector Scaler;
    4053  double x[NDIM];
    4154
    42   dialog->queryVector(NAME, &Scaler, false, MapOfActions::getInstance().getDescription(NAME));
     55  ValueStorage::getInstance().queryCurrentValue(NAME, Scaler);
    4356
    44   if(dialog->display()) {
    45     DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
    46     for (int i=0;i<NDIM;i++)
    47       x[i] = Scaler[i];
    48     vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
    49     for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
    50       (*AtomRunner)->x.ScaleAll(x);
    51     }
     57  DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
     58  for (int i=0;i<NDIM;i++)
     59    x[i] = Scaler[i];
     60  vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
     61  for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
     62    (*AtomRunner)->x.ScaleAll(x);
     63  }
    5264
    53     Matrix M = World::getInstance().getDomain().getM();
    54     Matrix scale;
     65  Matrix M = World::getInstance().getDomain().getM();
     66  Matrix scale;
    5567
    56     for (int i=0;i<NDIM;i++) {
    57       scale.at(i,i) = x[i];
    58     }
    59     M *= scale;
    60     World::getInstance().setDomain(M);
     68  for (int i=0;i<NDIM;i++) {
     69    scale.at(i,i) = x[i];
     70  }
     71  M *= scale;
     72  World::getInstance().setDomain(M);
    6173
    62     delete dialog;
    63     return Action::success;
    64   } else {
    65     delete dialog;
    66     return Action::failure;
    67   }
     74  return Action::success;
    6875}
    6976
  • src/Actions/WorldAction/ScaleBoxAction.hpp

    r7067bd6 r677e13  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14void WorldScaleBox(Vector &Scaler);
    1215
    1316class WorldScaleBoxAction : public Action {
     17  friend void WorldScaleBox(Vector &Scaler);
     18
    1419public:
    1520  WorldScaleBoxAction();
     
    2126  virtual const std::string getName();
    2227private:
     28  virtual Dialog * createDialog();
    2329  virtual Action::state_ptr performCall();
    2430  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/SetDefaultNameAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/SetDefaultNameAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "verbose.hpp"
     
    2021#include "UIElements/UIFactory.hpp"
    2122#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
     24
     25
     26// memento to remember the state when undoing
     27
     28class WorldSetDefaultNameState : public ActionState {
     29public:
     30  WorldSetDefaultNameState(std::string _lastName) :
     31    lastName(_lastName)
     32  {}
     33  std::string lastName;
     34};
    2335
    2436const char WorldSetDefaultNameAction::NAME[] = "default-molname";
     
    3143{}
    3244
     45void WorldSetDefaultName(std::string &defaultname) {
     46  ValueStorage::getInstance().setCurrentValue(WorldSetDefaultNameAction::NAME, defaultname);
     47  ActionRegistry::getInstance().getActionByName(WorldSetDefaultNameAction::NAME)->call(Action::NonInteractive);
     48};
     49
     50Dialog* WorldSetDefaultNameAction::createDialog() {
     51  Dialog *dialog = UIFactory::getInstance().makeDialog();
     52
     53  string defaultname = World::getInstance().getDefaultName();
     54  ValueStorage::getInstance().setCurrentValue(NAME, defaultname);
     55  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     56
     57  return dialog;
     58}
     59
    3360Action::state_ptr WorldSetDefaultNameAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3561  string defaultname;
    3662
    3763  defaultname = World::getInstance().getDefaultName();
    38   dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME));
     64  ValueStorage::getInstance().queryCurrentValue(NAME, defaultname);
    3965
    40   if(dialog->display()) {
    41     World::getInstance().setDefaultName(defaultname);
    42     DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
    43     delete dialog;
    44     return Action::success;
    45   } else {
    46     delete dialog;
    47     return Action::failure;
    48   }
     66  World::getInstance().setDefaultName(defaultname);
     67  DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
     68  return Action::success;
    4969}
    5070
    5171Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) {
    52 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     72  WorldSetDefaultNameState *state = assert_cast<WorldSetDefaultNameState*>(_state.get());
    5373
    54   return Action::failure;
    55 //  string newName = state->mol->getName();
    56 //  state->mol->setName(state->lastName);
    57 //
    58 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     74  string newName = World::getInstance().getDefaultName();
     75  World::getInstance().setDefaultName(state->lastName);
     76
     77  return Action::state_ptr(new WorldSetDefaultNameState(newName));
    5978}
    6079
    6180Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){
    62   return Action::failure;
     81  performUndo(_state);
    6382}
    6483
    6584bool WorldSetDefaultNameAction::canUndo() {
    66   return false;
     85  return true;
    6786}
    6887
    6988bool WorldSetDefaultNameAction::shouldUndo() {
    70   return false;
     89  return true;
    7190}
    7291
  • src/Actions/WorldAction/SetDefaultNameAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldSetDefaultName(std::string &defaultname);
     14
    1315class WorldSetDefaultNameAction : public Action {
     16  friend void WorldSetDefaultName(std::string &defaultname);
     17
    1418public:
    1519  WorldSetDefaultNameAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/SetGaussianBasisAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
     25
     26
     27// memento to remember the state when undoing
     28
     29class WorldSetGaussianBasisState : public ActionState {
     30public:
     31  WorldSetGaussianBasisState(std::string _lastName) :
     32    lastName(_lastName)
     33  {}
     34  std::string lastName;
     35};
     36
    2437
    2538const char WorldSetGaussianBasisAction::NAME[] = "set-basis";
     
    3245{}
    3346
     47void WorldSetGaussianBasis(std::string &basisname) {
     48  ValueStorage::getInstance().setCurrentValue(WorldSetGaussianBasisAction::NAME, basisname);
     49  ActionRegistry::getInstance().getActionByName(WorldSetGaussianBasisAction::NAME)->call(Action::NonInteractive);
     50};
     51
     52Dialog* WorldSetGaussianBasisAction::createDialog() {
     53  Dialog *dialog = UIFactory::getInstance().makeDialog();
     54
     55  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     56
     57  return dialog;
     58}
     59
    3460Action::state_ptr WorldSetGaussianBasisAction::performCall() {
    35   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3661  config *configuration = World::getInstance().getConfig();
    37   dialog->queryString(NAME, &(configuration->basis), MapOfActions::getInstance().getDescription(NAME));
    3862
    39   if(dialog->display()) {
    40     DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
    41     delete dialog;
    42     return Action::success;
    43   } else {
    44     delete dialog;
    45     return Action::failure;
    46   }
     63  string lastname = configuration->basis;
     64  ValueStorage::getInstance().queryCurrentValue(NAME, configuration->basis);
     65
     66  DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
     67  return Action::success;
    4768}
    4869
    4970Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) {
    50 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     71  WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get());
    5172
    52   return Action::failure;
    53 //  string newName = state->mol->getName();
    54 //  state->mol->setName(state->lastName);
    55 //
    56 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     73  config *configuration = World::getInstance().getConfig();
     74  string newName = configuration->basis;
     75  configuration->basis = state->lastName;
     76
     77  return Action::state_ptr(new WorldSetGaussianBasisState(newName));
    5778}
    5879
    5980Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){
    60   return Action::failure;
     81  performUndo(_state);
    6182}
    6283
    6384bool WorldSetGaussianBasisAction::canUndo() {
    64   return false;
     85  return true;
    6586}
    6687
    6788bool WorldSetGaussianBasisAction::shouldUndo() {
    68   return false;
     89  return true;
    6990}
    7091
  • src/Actions/WorldAction/SetGaussianBasisAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldSetGaussianBasis(std::string &basisname);
     14
    1315class WorldSetGaussianBasisAction : public Action {
     16  friend void WorldSetGaussianBasis(std::string &basisname);
     17
    1418public:
    1519  WorldSetGaussianBasisAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/WorldAction/SetOutputFormatsAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "Parser/ChangeTracker.hpp"
    1213#include "Parser/FormatParserStorage.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627const char WorldSetOutputFormatsAction::NAME[] = "set-output";
     
    3334{}
    3435
     36void WorldSetOutputFormats(vector<std::string> &FormatList) {
     37  ValueStorage::getInstance().setCurrentValue(WorldSetOutputFormatsAction::NAME, FormatList);
     38  ActionRegistry::getInstance().getActionByName(WorldSetOutputFormatsAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* WorldSetOutputFormatsAction::createDialog() {
     42  Dialog *dialog = UIFactory::getInstance().makeDialog();
     43
     44  dialog->queryStrings(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3549Action::state_ptr WorldSetOutputFormatsAction::performCall() {
    36   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3750  vector<std::string> FormatList;
    3851
    39   dialog->queryStrings(NAME, &FormatList, MapOfActions::getInstance().getDescription(NAME));
     52  ValueStorage::getInstance().queryCurrentValue(NAME, FormatList);
    4053
    41   if(dialog->display()) {
    42     for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
    43       if (*iter == "mpqc") {
    44         FormatParserStorage::getInstance().addMpqc();
    45         DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
    46       } else if (*iter == "pcp") {
    47         FormatParserStorage::getInstance().addPcp();
    48         DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
    49       } else if (*iter == "tremolo") {
    50         FormatParserStorage::getInstance().addTremolo();
    51         DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
    52       } else if (*iter == "xyz") {
    53         FormatParserStorage::getInstance().addXyz();
    54         DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
    55       } else {
    56         DoeLog(1) && (eLog() << Verbose(1) << "Unknown format." << endl);
    57       }
     54  for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
     55    if (*iter == "mpqc") {
     56      FormatParserStorage::getInstance().addMpqc();
     57      DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
     58    } else if (*iter == "pcp") {
     59      FormatParserStorage::getInstance().addPcp();
     60      DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
     61    } else if (*iter == "tremolo") {
     62      FormatParserStorage::getInstance().addTremolo();
     63      DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
     64    } else if (*iter == "xyz") {
     65      FormatParserStorage::getInstance().addXyz();
     66      DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
     67    } else {
     68      DoeLog(1) && (eLog() << Verbose(1) << "Unknown format:" << *iter << endl);
    5869    }
    59     ChangeTracker::getInstance().saveStatus();
    60     delete dialog;
    61     return Action::success;
    62   } else {
    63     delete dialog;
    64     return Action::failure;
    6570  }
     71  ChangeTracker::getInstance().saveStatus();
     72  return Action::success;
    6673}
    6774
  • src/Actions/WorldAction/SetOutputFormatsAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13#include <vector>
     14
     15void WorldSetOutputFormats(std::vector<std::string> &FormatList);
     16
    1317class WorldSetOutputFormatsAction : public Action {
     18  friend void WorldSetOutputFormats(std::vector<std::string> &FormatList);
     19
    1420public:
    1521  WorldSetOutputFormatsAction();
     
    2127  virtual const std::string getName();
    2228private:
     29  virtual Dialog * createDialog();
    2330  virtual Action::state_ptr performCall();
    2431  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Box.cpp

    r7067bd6 r677e13  
    6868  return translateIn(helper);
    6969}
     70
     71bool Box::isInside(const Vector &point) const
     72{
     73  bool result = true;
     74  Vector tester = (*Minv) * point;
     75
     76  for(int i=0;i<NDIM;i++)
     77    result = result && ((tester[i] >= -MYEPSILON) && ((tester[i] - 1.) < MYEPSILON));
     78
     79  return result;
     80}
     81
    7082
    7183VECTORSET(std::list) Box::explode(const Vector &point,int n) const{
  • src/Box.hpp

    r7067bd6 r677e13  
    6464
    6565  /**
     66   * Checks whether a given vector is inside the box.
     67   */
     68  bool isInside(const Vector &point) const;
     69
     70  /**
    6671   * Produce corresponding points in several adjacent boxes.
    6772   *
  • src/CommandLineParser.cpp

    r7067bd6 r677e13  
    4141void CommandLineParser::Parse()
    4242{
    43   po::store(po::command_line_parser(argc,argv).options(cmdline_options).options(visible).run(), vm);
     43  po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm);
    4444  ifstream input;
    4545  input.open("example.cfg");
  • src/Makefile.am

    r7067bd6 r677e13  
    7979EXCEPTIONSOURCE = \
    8080  Exceptions/CustomException.cpp \
     81  Exceptions/IllegalTypeException.cpp \
    8182  Exceptions/LinearDependenceException.cpp \
    8283  Exceptions/MathException.cpp \
     84  Exceptions/MissingValueException.cpp \
    8385  Exceptions/NotInvertibleException.cpp \
    8486  Exceptions/ParseError.cpp \
     
    8890EXCEPTIONHEADER = \
    8991  Exceptions/CustomException.hpp \
     92  Exceptions/IllegalTypeException.hpp \
    9093  Exceptions/LinearDependenceException.hpp \
    9194  Exceptions/MathException.hpp \
     95  Exceptions/MissingValueException.hpp \
    9296  Exceptions/NotInvertibleException.hpp \
    9397  Exceptions/ParseError.hpp \
     
    131135
    132136QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
    133                                  UIElements/QT4/QTMainWindow.hpp \
    134                                  UIElements/Menu/QT4/QTMenu.hpp \
    135                                  UIElements/Views/QT4/QTWorldView.hpp \
    136                                  UIElements/Views/QT4/GLMoleculeView.hpp \
    137                                  UIElements/Views/QT4/QTMoleculeView.hpp \
    138                                  UIElements/Views/QT4/QTStatusBar.hpp
     137        UIElements/QT4/QTMainWindow.hpp \
     138        UIElements/Menu/QT4/QTMenu.hpp \
     139        UIElements/Views/QT4/QTWorldView.hpp \
     140        UIElements/Views/QT4/GLMoleculeView.hpp \
     141        UIElements/Views/QT4/QTMoleculeView.hpp \
     142        UIElements/Views/QT4/QTStatusBar.hpp
    139143 
    140144QTUIMOC_TARGETS = QTMainWindow.moc.cpp \
    141                       QTMenu.moc.cpp\
    142                       QTDialog.moc.cpp \
    143                       QTWorldView.moc.cpp \
    144                       GLMoleculeView.moc.cpp \
    145                       QTMoleculeView.moc.cpp \
    146                       QTStatusBar.moc.cpp
     145        QTMenu.moc.cpp\
     146        QTDialog.moc.cpp \
     147        QTWorldView.moc.cpp \
     148        GLMoleculeView.moc.cpp \
     149        QTMoleculeView.moc.cpp \
     150        QTStatusBar.moc.cpp
    147151
    148152DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
     
    170174                                 
    171175QTUISOURCE = ${QTUIMOC_TARGETS} \
    172                          UIElements/QT4/QTMainWindow.cpp \
    173                          UIElements/QT4/QTDialog.cpp \
    174                          UIElements/QT4/QTUIFactory.cpp \
    175                          UIElements/Menu/QT4/QTMenu.cpp \
    176                          UIElements/Views/QT4/QTWorldView.cpp \
    177                          UIElements/Views/QT4/GLMoleculeView.cpp \
    178                          UIElements/Views/QT4/QTMoleculeView.cpp \
    179                          UIElements/Views/QT4/QTStatusBar.cpp
     176        UIElements/QT4/QTMainWindow.cpp \
     177        UIElements/QT4/QTDialog.cpp \
     178        UIElements/QT4/QTUIFactory.cpp \
     179        UIElements/Menu/QT4/QTMenu.cpp \
     180        UIElements/Views/QT4/QTWorldView.cpp \
     181        UIElements/Views/QT4/GLMoleculeView.cpp \
     182        UIElements/Views/QT4/QTMoleculeView.cpp \
     183        UIElements/Views/QT4/QTStatusBar.cpp
    180184             
    181185QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    r7067bd6 r677e13  
    2424#include "defs.hpp"
    2525#include "log.hpp"
     26#include "Matrix.hpp"
    2627#include "periodentafel.hpp"
    2728#include "verbose.hpp"
     
    5051}
    5152
    52 void CommandLineDialog::queryInt(const char* title, int* target, string _description){
    53   registerQuery(new IntCommandLineQuery(title,target, _description));
    54 }
    55 
    56 void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
    57   registerQuery(new BooleanCommandLineQuery(title,target, _description));
    58 }
    59 
    60 void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
    61   registerQuery(new DoubleCommandLineQuery(title,target, _description));
    62 }
    63 
    64 void CommandLineDialog::queryString(const char* title, string* target, string _description){
    65   registerQuery(new StringCommandLineQuery(title,target, _description));
    66 }
    67 
    68 void CommandLineDialog::queryStrings(const char* title, vector<string> * target, string _description){
    69   registerQuery(new StringsCommandLineQuery(title,target, _description));
    70 }
    71 
    72 void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
    73   registerQuery(new AtomCommandLineQuery(title,target, _description));
    74 }
    75 
    76 void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
    77   registerQuery(new MoleculeCommandLineQuery(title,target, _description));
    78 }
    79 
    80 void CommandLineDialog::queryVector(const char* title, Vector *target, bool check, string _description) {
    81   registerQuery(new VectorCommandLineQuery(title,target,check, _description));
    82 }
    83 
    84 void CommandLineDialog::queryBox(const char* title, Box* cellSize, string _description) {
    85   registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
    86 }
    87 
    88 void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){
    89   registerQuery(new ElementCommandLineQuery(title,target, _description));
     53void CommandLineDialog::queryInt(const char* title, string _description){
     54  registerQuery(new IntCommandLineQuery(title, _description));
     55}
     56
     57void CommandLineDialog::queryInts(const char* title, string _description){
     58  registerQuery(new IntsCommandLineQuery(title, _description));
     59}
     60
     61void CommandLineDialog::queryBoolean(const char* title, string _description){
     62  registerQuery(new BooleanCommandLineQuery(title, _description));
     63}
     64
     65void CommandLineDialog::queryDouble(const char* title, string _description){
     66  registerQuery(new DoubleCommandLineQuery(title, _description));
     67}
     68
     69void CommandLineDialog::queryDoubles(const char* title, string _description){
     70  registerQuery(new DoublesCommandLineQuery(title, _description));
     71}
     72
     73void CommandLineDialog::queryString(const char* title, string _description){
     74  registerQuery(new StringCommandLineQuery(title, _description));
     75}
     76
     77void CommandLineDialog::queryStrings(const char* title, string _description){
     78  registerQuery(new StringsCommandLineQuery(title, _description));
     79}
     80
     81void CommandLineDialog::queryAtom(const char* title, string _description) {
     82  registerQuery(new AtomCommandLineQuery(title, _description));
     83}
     84
     85void CommandLineDialog::queryAtoms(const char* title, string _description) {
     86  registerQuery(new AtomsCommandLineQuery(title, _description));
     87}
     88
     89void CommandLineDialog::queryMolecule(const char* title, string _description) {
     90  registerQuery(new MoleculeCommandLineQuery(title, _description));
     91}
     92
     93void CommandLineDialog::queryMolecules(const char* title, string _description) {
     94  registerQuery(new MoleculesCommandLineQuery(title, _description));
     95}
     96
     97void CommandLineDialog::queryVector(const char* title, bool check, string _description) {
     98  registerQuery(new VectorCommandLineQuery(title,check, _description));
     99}
     100
     101void CommandLineDialog::queryVectors(const char* title, bool check, string _description) {
     102  registerQuery(new VectorsCommandLineQuery(title,check, _description));
     103}
     104
     105void CommandLineDialog::queryBox(const char* title, string _description) {
     106  registerQuery(new BoxCommandLineQuery(title,_description));
     107}
     108
     109void CommandLineDialog::queryElement(const char* title, string _description){
     110  registerQuery(new ElementCommandLineQuery(title, _description));
     111}
     112
     113void CommandLineDialog::queryElements(const char* title, string _description){
     114  registerQuery(new ElementsCommandLineQuery(title, _description));
    90115}
    91116
     
    103128}
    104129
    105 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
    106     Dialog::IntQuery(title,_target, _description)
     130CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
     131    Dialog::IntQuery(title, _description)
    107132{}
    108133
     
    119144}
    120145
    121 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
    122     Dialog::BooleanQuery(title,_target, _description)
     146CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
     147    Dialog::IntsQuery(title, _description)
     148{}
     149
     150CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
     151
     152bool CommandLineDialog::IntsCommandLineQuery::handle() {
     153  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     154    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     155    return true;
     156  } else {
     157    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl);
     158    return false;
     159  }
     160}
     161
     162CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
     163    Dialog::BooleanQuery(title, _description)
    123164{}
    124165
     
    135176}
    136177
    137 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
    138     Dialog::StringQuery(title,_target, _description)
     178CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
     179    Dialog::StringQuery(title, _description)
    139180{}
    140181
     
    151192}
    152193
    153 CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title,vector<string> *_target, string _description) :
    154     Dialog::StringsQuery(title,_target, _description)
     194CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
     195    Dialog::StringsQuery(title, _description)
    155196{}
    156197
     
    162203    return true;
    163204  } else {
    164     DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
    165     return false;
    166   }
    167 }
    168 
    169 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
    170     Dialog::DoubleQuery(title,_target, _description)
     205    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl);
     206    return false;
     207  }
     208}
     209
     210CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) :
     211    Dialog::DoubleQuery(title, _description)
    171212{}
    172213
     
    183224}
    184225
    185 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
    186     Dialog::AtomQuery(title,_target, _description)
     226CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
     227    Dialog::DoublesQuery(title, _description)
     228{}
     229
     230CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
     231
     232bool CommandLineDialog::DoublesCommandLineQuery::handle() {
     233  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     234    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >();
     235    return true;
     236  } else {
     237    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl);
     238    return false;
     239  }
     240}
     241
     242CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
     243    Dialog::AtomQuery(title, _description)
    187244{}
    188245
     
    201258}
    202259
    203 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
    204     Dialog::MoleculeQuery(title,_target, _description)
     260CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
     261    Dialog::AtomsQuery(title, _description)
     262{}
     263
     264CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
     265
     266bool CommandLineDialog::AtomsCommandLineQuery::handle() {
     267  std::vector<int> IdxOfAtom;
     268  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     269    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     270    for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) {
     271      temp = World::getInstance().getAtom(AtomById(*iter));
     272      if (temp)
     273        tmp.push_back(temp);
     274    }
     275    return true;
     276  } else {
     277    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl);
     278    return false;
     279  }
     280}
     281
     282CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
     283    Dialog::MoleculeQuery(title, _description)
    205284{}
    206285
     
    211290  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    212291    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    213     cout << "IdxOfMol " << IdxOfMol << endl;
    214     if (IdxOfMol >= 0)
    215       tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
    216     else
    217       tmp = NULL;
     292    tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
    218293    return true;
    219294  } else {
     
    223298}
    224299
    225 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, bool _check, string _description) :
    226     Dialog::VectorQuery(title,_target,_check, _description)
     300CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
     301    Dialog::MoleculesQuery(title, _description)
     302{}
     303
     304CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
     305
     306bool CommandLineDialog::MoleculesCommandLineQuery::handle() {
     307  std::vector<int> IdxOfMol;
     308  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     309    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     310    for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) {
     311      temp = World::getInstance().getMolecule(MoleculeById(*iter));
     312      if (temp)
     313        tmp.push_back(temp);
     314    }
     315    return true;
     316  } else {
     317    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl);
     318    return false;
     319  }
     320}
     321
     322CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) :
     323    Dialog::VectorQuery(title,_check, _description)
    227324{}
    228325
     
    234331  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    235332    temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
    236     tmp->at(0) = temp.x;
    237     tmp->at(1) = temp.y;
    238     tmp->at(2) = temp.z;
     333    tmp[0] = temp.x;
     334    tmp[1] = temp.y;
     335    tmp[2] = temp.z;
     336    if ((check) && (!World::getInstance().getDomain().isInside(tmp))) {
     337      DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl);
     338      return false;
     339    }
    239340    return true;
    240341  } else {
     
    244345}
    245346
    246 
    247 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, Box* _cellSize, string _description) :
    248     Dialog::BoxQuery(title,_cellSize, _description)
     347CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
     348    Dialog::VectorsQuery(title,_check, _description)
     349{}
     350
     351CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
     352{}
     353
     354bool CommandLineDialog::VectorsCommandLineQuery::handle() {
     355  std::vector<VectorValue> temporary;
     356  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     357    temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >();
     358    for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
     359      temp[0] = (*iter).x;
     360      temp[1] = (*iter).y;
     361      temp[2] = (*iter).z;
     362      if ((!check) || (World::getInstance().getDomain().isInside(temp)))
     363        tmp.push_back(temp);
     364      else
     365        DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl);
     366    }
     367    return true;
     368  } else {
     369    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl);
     370    return false;
     371  }
     372}
     373
     374CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
     375    Dialog::BoxQuery(title, _description)
    249376{}
    250377
     
    256383  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    257384    temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
    258     tmp[0] = temp.xx;
    259     tmp[1] = temp.xy;
    260     tmp[2] = temp.xz;
    261     tmp[3] = temp.yy;
    262     tmp[4] = temp.yz;
    263     tmp[5] = temp.zz;
     385    Matrix M;
     386    M.set(0,0, temp.xx);
     387    M.set(0,1, temp.yx);
     388    M.set(0,2, temp.zx);
     389    M.set(1,0, temp.yx);
     390    M.set(1,1, temp.yy);
     391    M.set(1,2, temp.zy);
     392    M.set(2,0, temp.zx);
     393    M.set(2,1, temp.zy);
     394    M.set(2,2, temp.zz);
     395    tmp.setM(M);
    264396    return true;
    265397  } else {
     
    269401}
    270402
    271 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
    272     Dialog::ElementQuery(title,target, _description)
     403CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) :
     404    Dialog::ElementQuery(title, _description)
    273405{}
    274406
     
    279411  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    280412  periodentafel *periode = World::getInstance().getPeriode();
    281   element *elemental = NULL;
     413  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     414    int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >();
     415    tmp = periode->FindElement(Z);
     416    ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery");
     417    return true;
     418  } else {
     419    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
     420    return false;
     421  }
     422}
     423
     424CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
     425    Dialog::ElementsQuery(title, _description)
     426{}
     427
     428CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
     429{}
     430
     431bool CommandLineDialog::ElementsCommandLineQuery::handle() {
     432  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
     433  periodentafel *periode = World::getInstance().getPeriode();
    282434  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    283435    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
    284436    for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
    285       elemental = periode->FindElement(*ZRunner);
    286       ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery");
    287       elements.push_back(elemental);
     437      temp = periode->FindElement(*ZRunner);
     438      ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
     439      tmp.push_back(temp);
    288440    }
    289441    return true;
    290442  } else {
    291     DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
    292     return false;
    293   }
    294 }
     443    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl);
     444    return false;
     445  }
     446}
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    r7067bd6 r677e13  
    2828
    2929  virtual void queryEmpty(const char *, std::string = "");
    30   virtual void queryInt(const char *, int *, std::string = "");
    31   virtual void queryBoolean(const char *, bool *, std::string = "");
    32   virtual void queryString(const char*, std::string *, std::string = "");
    33   virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "");
    34   virtual void queryDouble(const char*, double*, std::string = "");
    35   virtual void queryAtom(const char*,atom**, std::string = "");
    36   virtual void queryMolecule(const char*,molecule**,std::string = "");
    37   virtual void queryVector(const char*,Vector *,bool, std::string = "");
    38   virtual void queryBox(const char*,Box *, std::string = "");
    39   virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
     30  virtual void queryInt(const char *, std::string = "");
     31  virtual void queryInts(const char *, std::string = "");
     32  virtual void queryBoolean(const char *, std::string = "");
     33  virtual void queryString(const char*, std::string = "");
     34  virtual void queryStrings(const char*, std::string = "");
     35  virtual void queryDouble(const char*, std::string = "");
     36  virtual void queryDoubles(const char*, std::string = "");
     37  virtual void queryAtom(const char*, std::string = "");
     38  virtual void queryAtoms(const char*, std::string = "");
     39  virtual void queryMolecule(const char*, std::string = "");
     40  virtual void queryMolecules(const char*, std::string = "");
     41  virtual void queryVector(const char*, bool, std::string = "");
     42  virtual void queryVectors(const char*, bool, std::string = "");
     43  virtual void queryBox(const char*, std::string = "");
     44  virtual void queryElement(const char*, std::string = "");
     45  virtual void queryElements(const char*, std::string = "");
    4046
    4147protected:
     
    5056  class IntCommandLineQuery : public Dialog::IntQuery {
    5157  public:
    52     IntCommandLineQuery(std::string title, int *_target, std::string _description = "");
     58    IntCommandLineQuery(std::string title, std::string _description = "");
    5359    virtual ~IntCommandLineQuery();
     60    virtual bool handle();
     61  };
     62
     63  class IntsCommandLineQuery : public Dialog::IntsQuery {
     64  public:
     65    IntsCommandLineQuery(std::string title, std::string _description = "");
     66    virtual ~IntsCommandLineQuery();
    5467    virtual bool handle();
    5568  };
     
    5770  class BooleanCommandLineQuery : public Dialog::BooleanQuery {
    5871  public:
    59     BooleanCommandLineQuery(std::string title, bool *_target, std::string _description = "");
     72    BooleanCommandLineQuery(std::string title, std::string _description = "");
    6073    virtual ~BooleanCommandLineQuery();
    6174    virtual bool handle();
     
    6477  class DoubleCommandLineQuery : public Dialog::DoubleQuery {
    6578  public:
    66     DoubleCommandLineQuery(std::string title, double *_target, std::string _description = "");
     79    DoubleCommandLineQuery(std::string title, std::string _description = "");
    6780    virtual ~DoubleCommandLineQuery();
     81    virtual bool handle();
     82  };
     83
     84  class DoublesCommandLineQuery : public Dialog::DoublesQuery {
     85  public:
     86    DoublesCommandLineQuery(std::string title, std::string _description = "");
     87    virtual ~DoublesCommandLineQuery();
    6888    virtual bool handle();
    6989  };
     
    7191  class StringCommandLineQuery : public Dialog::StringQuery {
    7292  public:
    73     StringCommandLineQuery(std::string title, std::string *_target, std::string _description = "");
     93    StringCommandLineQuery(std::string title, std::string _description = "");
    7494    virtual ~StringCommandLineQuery();
    7595    virtual bool handle();
     
    7898  class StringsCommandLineQuery : public Dialog::StringsQuery {
    7999  public:
    80     StringsCommandLineQuery(std::string title, std::vector<std::string> *_target, std::string _description = "");
     100    StringsCommandLineQuery(std::string title, std::string _description = "");
    81101    virtual ~StringsCommandLineQuery();
    82102    virtual bool handle();
     
    85105  class AtomCommandLineQuery : public Dialog::AtomQuery {
    86106  public:
    87     AtomCommandLineQuery(std::string title, atom **_target, std::string _description = "");
     107    AtomCommandLineQuery(std::string title, std::string _description = "");
    88108    virtual ~AtomCommandLineQuery();
     109    virtual bool handle();
     110  };
     111
     112  class AtomsCommandLineQuery : public Dialog::AtomsQuery {
     113  public:
     114    AtomsCommandLineQuery(std::string title, std::string _description = "");
     115    virtual ~AtomsCommandLineQuery();
    89116    virtual bool handle();
    90117  };
     
    92119  class MoleculeCommandLineQuery : public Dialog::MoleculeQuery {
    93120  public:
    94     MoleculeCommandLineQuery(std::string title, molecule **_target, std::string _description = "");
     121    MoleculeCommandLineQuery(std::string title, std::string _description = "");
    95122    virtual ~MoleculeCommandLineQuery();
     123    virtual bool handle();
     124  };
     125
     126  class MoleculesCommandLineQuery : public Dialog::MoleculesQuery {
     127  public:
     128    MoleculesCommandLineQuery(std::string title, std::string _description = "");
     129    virtual ~MoleculesCommandLineQuery();
    96130    virtual bool handle();
    97131  };
     
    99133  class VectorCommandLineQuery : public Dialog::VectorQuery {
    100134  public:
    101     VectorCommandLineQuery(std::string title,Vector *_target,bool _check, std::string _description = "");
     135    VectorCommandLineQuery(std::string title,bool _check, std::string _description = "");
    102136    virtual ~VectorCommandLineQuery();
     137    virtual bool handle();
     138  };
     139
     140  class VectorsCommandLineQuery : public Dialog::VectorsQuery {
     141  public:
     142    VectorsCommandLineQuery(std::string title,bool _check, std::string _description = "");
     143    virtual ~VectorsCommandLineQuery();
    103144    virtual bool handle();
    104145  };
     
    106147  class BoxCommandLineQuery : public Dialog::BoxQuery {
    107148  public:
    108     BoxCommandLineQuery(std::string title,Box* _cellSize, std::string _description = "");
     149    BoxCommandLineQuery(std::string title, std::string _description = "");
    109150    virtual ~BoxCommandLineQuery();
    110151    virtual bool handle();
     
    113154  class ElementCommandLineQuery : public Dialog::ElementQuery {
    114155  public:
    115     ElementCommandLineQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
     156    ElementCommandLineQuery(std::string title, std::string _description = "");
    116157    virtual ~ElementCommandLineQuery();
     158    virtual bool handle();
     159  };
     160
     161  class ElementsCommandLineQuery : public Dialog::ElementsQuery {
     162  public:
     163    ElementsCommandLineQuery(std::string title, std::string _description = "");
     164    virtual ~ElementsCommandLineQuery();
    117165    virtual bool handle();
    118166  };
  • src/UIElements/Dialog.cpp

    r7067bd6 r677e13  
    99
    1010#include "Dialog.hpp"
     11#include "ValueStorage.hpp"
    1112
    1213#include "verbose.hpp"
     
    9798// Int Queries
    9899
    99 Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
    100     Query(title, description), target(_target)
     100Dialog::IntQuery::IntQuery(string title, std::string description) :
     101    Query(title, description)
    101102{}
    102103
     
    104105
    105106void Dialog::IntQuery::setResult() {
    106   *target = tmp;
    107 }
    108 
    109 // Int Queries
    110 
    111 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
    112     Query(title, description), target(_target)
     107  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     108}
     109
     110// Ints Queries
     111
     112Dialog::IntsQuery::IntsQuery(string title, std::string description) :
     113    Query(title, description)
     114{}
     115
     116Dialog::IntsQuery::~IntsQuery() {}
     117
     118void Dialog::IntsQuery::setResult() {
     119  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     120}
     121
     122// Bool Queries
     123
     124Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
     125    Query(title, description)
    113126{}
    114127
     
    116129
    117130void Dialog::BooleanQuery::setResult() {
    118   *target = tmp;
     131  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    119132}
    120133
    121134// String Queries
    122135
    123 Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
    124     Query(title, _description), target(_target)
     136Dialog::StringQuery::StringQuery(string title,std::string _description) :
     137    Query(title, _description)
    125138{}
    126139
     
    128141
    129142void Dialog::StringQuery::setResult() {
    130   *target = tmp;
     143  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    131144}
    132145
    133146// Strings Queries
    134147
    135 Dialog::StringsQuery::StringsQuery(string title,vector<string> *_target, std::string _description) :
    136     Query(title, _description), target(_target)
     148Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
     149    Query(title, _description)
    137150{}
    138151
     
    140153
    141154void Dialog::StringsQuery::setResult() {
    142   *target = tmp;
     155  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    143156}
    144157
    145158// Double Queries
    146159
    147 Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
    148     Query(title, _description), target(_target)
     160Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
     161    Query(title, _description)
    149162{}
    150163
     
    152165
    153166void Dialog::DoubleQuery::setResult() {
    154   *target = tmp;
     167  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     168}
     169
     170// Doubles Queries
     171
     172Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
     173    Query(title, _description)
     174{}
     175
     176Dialog::DoublesQuery::~DoublesQuery() {};
     177
     178void Dialog::DoublesQuery::setResult() {
     179  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    155180}
    156181
     
    158183// Atom Queries
    159184
    160 Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
    161     Query(title, _description),
    162     tmp(0),
    163     target(_target)
    164 
     185Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
     186    Query(title, _description),
     187    tmp(0)
    165188{}
    166189
     
    168191
    169192void Dialog::AtomQuery::setResult() {
    170   *target = tmp;
     193  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     194}
     195
     196// Atoms Queries
     197
     198Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
     199    Query(title, _description),
     200    tmp(0)
     201{}
     202
     203Dialog::AtomsQuery::~AtomsQuery() {}
     204
     205void Dialog::AtomsQuery::setResult() {
     206  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    171207}
    172208
    173209// Molecule Queries
    174210
    175 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
    176     Query(title, _description),
    177     tmp(0),
    178     target(_target)
    179 
     211Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
     212    Query(title, _description),
     213    tmp(0)
    180214{}
    181215
     
    183217
    184218void Dialog::MoleculeQuery::setResult() {
    185   *target = tmp;
     219  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     220}
     221
     222// Molecules Queries
     223
     224Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
     225    Query(title, _description),
     226    tmp(0)
     227{}
     228
     229Dialog::MoleculesQuery::~MoleculesQuery() {}
     230
     231void Dialog::MoleculesQuery::setResult() {
     232  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    186233}
    187234
    188235// Vector Queries
    189236
    190 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,bool _check, std::string _description) :
     237Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
    191238  Query(title, _description),
    192   check(_check),
    193   target(_target)
    194 {
    195   tmp = new Vector();
    196 }
     239  check(_check)
     240{}
    197241
    198242Dialog::VectorQuery::~VectorQuery()
    199 {
    200   delete tmp;
    201 }
     243{}
    202244
    203245void Dialog::VectorQuery::setResult() {
    204   *target = *tmp;
     246  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     247}
     248
     249// Vectors Queries
     250
     251Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
     252  Query(title, _description),
     253  check(_check)
     254{}
     255
     256Dialog::VectorsQuery::~VectorsQuery()
     257{}
     258
     259void Dialog::VectorsQuery::setResult() {
     260  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    205261}
    206262
    207263// Box Queries
    208264
    209 Dialog::BoxQuery::BoxQuery(std::string title, Box* _cellSize, std::string _description) :
    210   Query(title, _description),
    211   target(_cellSize)
    212 {
    213     tmp = new double[6];
    214 }
     265Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
     266  Query(title, _description)
     267{}
    215268
    216269Dialog::BoxQuery::~BoxQuery()
    217 {
    218   delete[] tmp;
    219 }
     270{}
    220271
    221272void Dialog::BoxQuery::setResult() {
    222   (*target)= ReturnFullMatrixforSymmetric(tmp);
     273  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    223274}
    224275
    225276// Element Queries
    226 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
    227   Query(title, _description),
    228   target(_target)
     277Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
     278  Query(title, _description)
    229279  {}
    230280
     
    232282
    233283void Dialog::ElementQuery::setResult(){
    234   *target=elements;
    235 }
     284  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     285}
     286
     287// Elements Queries
     288Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
     289  Query(title, _description)
     290  {}
     291
     292Dialog::ElementsQuery::~ElementsQuery(){}
     293
     294void Dialog::ElementsQuery::setResult(){
     295  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     296}
  • src/UIElements/Dialog.hpp

    r7067bd6 r677e13  
    1313#include<vector>
    1414
     15#include "Box.hpp"
     16#include "vector.hpp"
     17
    1518class atom;
    1619class Box;
    1720class element;
    1821class molecule;
    19 class Vector;
    2022
    2123
     
    3739
    3840  virtual void queryEmpty(const char *, std::string = "")=0;
    39   virtual void queryBoolean(const char *, bool *, std::string = "")=0;
    40   virtual void queryInt(const char *, int *, std::string = "")=0;
    41   virtual void queryDouble(const char*,double *, std::string = "")=0;
    42   virtual void queryString(const char*, std::string *, std::string = "")=0;
    43   virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "")=0;
    44   virtual void queryAtom(const char*,atom**,std::string = "")=0;
    45   virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
    46   virtual void queryVector(const char*,Vector *,bool, std::string = "")=0;
    47   virtual void queryBox(const char*,Box*, std::string = "")=0;
    48   virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
     41  virtual void queryBoolean(const char *, std::string = "")=0;
     42  virtual void queryInt(const char *, std::string = "")=0;
     43  virtual void queryInts(const char *, std::string = "")=0;
     44  virtual void queryDouble(const char*, std::string = "")=0;
     45  virtual void queryDoubles(const char*, std::string = "")=0;
     46  virtual void queryString(const char*, std::string = "")=0;
     47  virtual void queryStrings(const char*, std::string = "")=0;
     48  virtual void queryAtom(const char*,std::string = "")=0;
     49  virtual void queryAtoms(const char*,std::string = "")=0;
     50  virtual void queryMolecule(const char*, std::string = "")=0;
     51  virtual void queryMolecules(const char*, std::string = "")=0;
     52  virtual void queryVector(const char*,bool, std::string = "")=0;
     53  virtual void queryVectors(const char*,bool, std::string = "")=0;
     54  virtual void queryBox(const char*, std::string = "")=0;
     55  virtual void queryElement(const char*, std::string = "")=0;
     56  virtual void queryElements(const char*, std::string = "")=0;
    4957
    5058  virtual bool display();
     
    92100  class BooleanQuery : public Query {
    93101  public:
    94     BooleanQuery(std::string title,bool *_target, std::string _description = "");
     102    BooleanQuery(std::string title, std::string _description = "");
    95103    virtual ~BooleanQuery();
    96104    virtual bool handle()=0;
     
    98106  protected:
    99107    bool tmp;
    100   private:
    101     bool *target;
    102108  };
    103109
    104110  class IntQuery : public Query {
    105111  public:
    106     IntQuery(std::string title,int *_target, std::string _description = "");
     112    IntQuery(std::string title, std::string _description = "");
    107113    virtual ~IntQuery();
    108114    virtual bool handle()=0;
     
    110116  protected:
    111117    int tmp;
    112   private:
    113     int *target;
     118  };
     119
     120  class IntsQuery : public Query {
     121  public:
     122    IntsQuery(std::string title, std::string _description = "");
     123    virtual ~IntsQuery();
     124    virtual bool handle()=0;
     125    virtual void setResult();
     126  protected:
     127    int temp;
     128    std::vector<int> tmp;
    114129  };
    115130
    116131  class DoubleQuery : public Query {
    117132  public:
    118     DoubleQuery(std::string title,double *_target, std::string _description = "");
     133    DoubleQuery(std::string title, std::string _description = "");
    119134    virtual ~DoubleQuery();
    120135    virtual bool handle()=0;
     
    122137  protected:
    123138    double tmp;
    124   private:
    125     double *target;
     139  };
     140
     141  class DoublesQuery : public Query {
     142  public:
     143    DoublesQuery(std::string title, std::string _description = "");
     144    virtual ~DoublesQuery();
     145    virtual bool handle()=0;
     146    virtual void setResult();
     147  protected:
     148    double temp;
     149    std::vector<double> tmp;
    126150  };
    127151
    128152  class StringQuery : public Query {
    129153  public:
    130     StringQuery(std::string title,std::string *_target, std::string _description = "");
     154    StringQuery(std::string title, std::string _description = "");
    131155    virtual ~StringQuery();
    132156    virtual bool handle()=0;
     
    134158  protected:
    135159    std::string tmp;
    136   private:
    137     std::string *target;
    138160  };
    139161
    140162  class StringsQuery : public Query {
    141163  public:
    142     StringsQuery(std::string title,std::vector<std::string> *_target, std::string _description = "");
     164    StringsQuery(std::string title, std::string _description = "");
    143165    virtual ~StringsQuery();
    144166    virtual bool handle()=0;
     
    147169    std::string temp;
    148170    std::vector<std::string> tmp;
    149   private:
    150     std::vector<std::string> *target;
    151171  };
    152172
    153173  class MoleculeQuery : public Query {
    154174  public:
    155     MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
     175    MoleculeQuery(std::string title, std::string _description = "");
    156176    virtual ~MoleculeQuery();
    157177    virtual bool handle()=0;
     
    159179  protected:
    160180    molecule *tmp;
    161   private:
    162     molecule **target;
     181  };
     182
     183  class MoleculesQuery : public Query {
     184  public:
     185    MoleculesQuery(std::string title, std::string _description = "");
     186    virtual ~MoleculesQuery();
     187    virtual bool handle()=0;
     188    virtual void setResult();
     189  protected:
     190    molecule * temp;
     191    std::vector<molecule *> tmp;
    163192  };
    164193
    165194  class AtomQuery : public Query {
    166195  public:
    167     AtomQuery(std::string title, atom **_target, std::string _description = "");
     196    AtomQuery(std::string title, std::string _description = "");
    168197    virtual ~AtomQuery();
    169198    virtual bool handle()=0;
     
    171200  protected:
    172201    atom *tmp;
    173   private:
    174     atom **target;
     202  };
     203
     204  class AtomsQuery : public Query {
     205  public:
     206    AtomsQuery(std::string title, std::string _description = "");
     207    virtual ~AtomsQuery();
     208    virtual bool handle()=0;
     209    virtual void setResult();
     210  protected:
     211    atom *temp;
     212    std::vector<atom *> tmp;
    175213  };
    176214
    177215  class VectorQuery : public Query {
    178216  public:
    179       VectorQuery(std::string title,Vector *_target,bool _check, std::string _description = "");
     217      VectorQuery(std::string title,bool _check, std::string _description = "");
    180218      virtual ~VectorQuery();
    181219      virtual bool handle()=0;
    182220      virtual void setResult();
    183221    protected:
    184       Vector *tmp;
     222      Vector tmp;
    185223      bool check;
    186     private:
    187       Vector *target;
     224  };
     225
     226  class VectorsQuery : public Query {
     227  public:
     228      VectorsQuery(std::string title,bool _check, std::string _description = "");
     229      virtual ~VectorsQuery();
     230      virtual bool handle()=0;
     231      virtual void setResult();
     232    protected:
     233      Vector temp;
     234      std::vector<Vector> tmp;
     235      bool check;
    188236  };
    189237
    190238  class BoxQuery : public Query {
    191239  public:
    192       BoxQuery(std::string title,Box *_cellSize, std::string _description = "");
     240      BoxQuery(std::string title, std::string _description = "");
    193241      virtual ~BoxQuery();
    194242      virtual bool handle()=0;
    195243      virtual void setResult();
    196244    protected:
    197       double* tmp;
    198     private:
    199       Box* target;
     245      Box tmp;
    200246  };
    201247
    202248  class ElementQuery : public Query {
    203249  public:
    204     ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
     250    ElementQuery(std::string title, std::string _description = "");
    205251    virtual ~ElementQuery();
    206252    virtual bool handle()=0;
    207253    virtual void setResult();
    208254  protected:
    209     std::vector<element *> elements;
    210   private:
    211     std::vector<element *> * const target;
     255    element * tmp;
     256  };
     257
     258  class ElementsQuery : public Query {
     259  public:
     260    ElementsQuery(std::string title, std::string _description = "");
     261    virtual ~ElementsQuery();
     262    virtual bool handle()=0;
     263    virtual void setResult();
     264  protected:
     265    element *temp;
     266    std::vector<element *> tmp;
    212267  };
    213268
  • src/UIElements/Makefile.am

    r7067bd6 r677e13  
    4646  Dialog.cpp \
    4747  MainWindow.cpp \
    48   UIFactory.cpp
     48  UIFactory.cpp \
     49  ValueStorage.cpp
    4950 
    5051UIHEADER = \
     
    5657  Dialog.hpp \
    5758  MainWindow.hpp \
    58   UIFactory.hpp
     59  UIFactory.hpp \
     60  ValueStorage.hpp
    5961
    6062TEXTUISOURCE = \
  • src/UIElements/Menu/TextMenu.cpp

    r7067bd6 r677e13  
    127127}
    128128
     129Dialog* TextMenu::LeaveAction::createDialog(){
     130}
     131
     132
    129133Action::state_ptr TextMenu::LeaveAction::performCall(){
    130134  menu->doQuit();
  • src/UIElements/Menu/TextMenu.hpp

    r7067bd6 r677e13  
    3636
    3737  private:
     38    virtual Dialog* createDialog();
    3839    virtual Action::state_ptr performCall();
    3940    virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/UIElements/QT4/QTDialog.cpp

    r7067bd6 r677e13  
    1717#include <QtGui/QDoubleSpinBox>
    1818#include <Qt/qlineedit.h>
     19#include <Qt/qlistwidget.h>
    1920#include <Qt/qdialogbuttonbox.h>
    2021#include <Qt/qpushbutton.h>
     
    2829#include "element.hpp"
    2930#include "molecule.hpp"
     31#include "Descriptors/AtomIdDescriptor.hpp"
    3032#include "Descriptors/MoleculeIdDescriptor.hpp"
    3133#include "Matrix.hpp"
     
    8587}
    8688
    87 void QTDialog::queryBoolean(char const*, bool*,string){
     89void QTDialog::queryBoolean(char const*,string){
    8890  // TODO
    8991  ASSERT(false, "Not implemented yet");
    9092}
    9193
    92 void QTDialog::queryAtom(char const*, atom**, string){
     94void QTDialog::queryAtom(char const*, string){
    9395  // TODO
    9496  ASSERT(false, "Not implemented yet");
    9597}
    9698
    97 void QTDialog::queryBox(char const*, Box*, string){
     99void QTDialog::queryAtoms(char const*, string){
    98100  // TODO
    99101  ASSERT(false, "Not implemented yet");
    100102}
    101103
    102 
    103 void QTDialog::queryInt(const char *title, int *target,string)
    104 {
    105   registerQuery(new IntQTQuery(title,target,inputLayout,this));
    106 }
    107 
    108 void QTDialog::queryDouble(const char* title, double* target,string){
    109   registerQuery(new DoubleQTQuery(title,target,inputLayout,this));
    110 }
    111 
    112 void QTDialog::queryString(const char* title, std::string *target,string)
    113 {
    114   registerQuery(new StringQTQuery(title,target,inputLayout,this));
    115 }
    116 
    117 void QTDialog::queryStrings(const char* title, std::vector<std::string> *target,string)
    118 {
    119   registerQuery(new StringsQTQuery(title,target,inputLayout,this));
    120 }
    121 
    122 void QTDialog::queryMolecule(const char *title,molecule **target,string)
    123 {
    124   registerQuery(new MoleculeQTQuery(title,target,inputLayout,this));
    125 }
    126 
    127 void QTDialog::queryVector(const char* title, Vector *target, bool check,string) {
    128   registerQuery(new VectorQTQuery(title,target,check,inputLayout,this));
    129 }
    130 
    131 void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){
    132   registerQuery(new ElementQTQuery(title,target,inputLayout,this));
     104void QTDialog::queryBox(char const*, string){
     105  // TODO
     106  ASSERT(false, "Not implemented yet");
     107}
     108
     109
     110void QTDialog::queryInt(const char *title,string)
     111{
     112  registerQuery(new IntQTQuery(title,inputLayout,this));
     113}
     114
     115void QTDialog::queryInts(const char *title,string)
     116{
     117  registerQuery(new IntsQTQuery(title,inputLayout,this));
     118}
     119
     120void QTDialog::queryDouble(const char* title,string){
     121  registerQuery(new DoubleQTQuery(title,inputLayout,this));
     122}
     123
     124void QTDialog::queryDoubles(const char* title,string){
     125  registerQuery(new DoublesQTQuery(title,inputLayout,this));
     126}
     127
     128void QTDialog::queryString(const char* title,string)
     129{
     130  registerQuery(new StringQTQuery(title,inputLayout,this));
     131}
     132
     133void QTDialog::queryStrings(const char* title,string)
     134{
     135  registerQuery(new StringsQTQuery(title,inputLayout,this));
     136}
     137
     138void QTDialog::queryMolecule(const char *title,string)
     139{
     140  registerQuery(new MoleculeQTQuery(title,inputLayout,this));
     141}
     142
     143void QTDialog::queryMolecules(const char *title,string)
     144{
     145  // TODO
     146  ASSERT(false, "Not implemented yet");
     147}
     148
     149void QTDialog::queryVector(const char* title, bool check,string) {
     150  registerQuery(new VectorQTQuery(title,check,inputLayout,this));
     151}
     152
     153void QTDialog::queryVectors(const char* title, bool check,string) {
     154  // TODO
     155  ASSERT(false, "Not implemented yet");
     156}
     157
     158void QTDialog::queryElement(const char* title, string){
     159  registerQuery(new ElementQTQuery(title,inputLayout,this));
     160}
     161
     162void QTDialog::queryElements(const char* title, string){
     163  // TODO
     164  ASSERT(false, "Not implemented yet");
    133165}
    134166
    135167/************************** Query Objects *******************************/
    136168
    137 QTDialog::IntQTQuery::IntQTQuery(string _title,int *_target,QBoxLayout *_parent,QTDialog *_dialog) :
    138     Dialog::IntQuery(_title,_target),
     169QTDialog::IntQTQuery::IntQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
     170    Dialog::IntQuery(_title),
    139171    parent(_parent)
    140172{
     
    157189}
    158190
    159 // Handling is easy since the GUI makes it impossible to enter invalid values
    160 bool QTDialog::IntQTQuery::handle()
    161 {
    162   return true;
    163 }
    164 
    165 QTDialog::DoubleQTQuery::DoubleQTQuery(string title,double *_target,QBoxLayout *_parent,QTDialog *_dialog) :
    166     Dialog::DoubleQuery(title,_target),
     191bool QTDialog::IntQTQuery::handle() {
     192  return true;
     193}
     194
     195
     196QTDialog::IntsQTQuery::IntsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
     197    Dialog::IntsQuery(_title),
     198    parent(_parent)
     199{
     200  QHBoxLayout * thisHLayout = new QHBoxLayout();
     201  QVBoxLayout * thisV1Layout = new QVBoxLayout();
     202  QVBoxLayout * thisV2Layout = new QVBoxLayout();
     203
     204  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
     205  QLabel *inputLabel = new QLabel("Enter to add");
     206  QListWidget* inputList = new QListWidget();
     207  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
     208  QLineEdit* inputBox = new QLineEdit();
     209  inputLabel->setBuddy(inputBox);
     210  titleLabel->setBuddy(inputList);
     211  QPushButton* AddButton = new QPushButton("Add");
     212  AddButton->setEnabled(false);
     213  QPushButton* RemoveButton = new QPushButton("Remove");
     214  RemoveButton->setEnabled(false);
     215
     216  thisV1Layout->addWidget(titleLabel);
     217  thisV1Layout->addWidget(inputList);
     218  thisV2Layout->addWidget(inputLabel);
     219  thisV2Layout->addWidget(inputBox);
     220  thisV2Layout->addWidget(AddButton);
     221  thisV2Layout->addWidget(RemoveButton);
     222  parent->addLayout(thisHLayout);
     223  thisHLayout->addLayout(thisV1Layout);
     224  thisHLayout->addLayout(thisV2Layout);
     225
     226  pipe = new QTQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
     227  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
     228  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
     229  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
     230  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));
     231}
     232
     233QTDialog::IntsQTQuery::~IntsQTQuery()
     234{
     235  delete pipe;
     236}
     237
     238bool QTDialog::IntsQTQuery::handle() {
     239  return true;
     240}
     241
     242
     243QTDialog::DoubleQTQuery::DoubleQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) :
     244    Dialog::DoubleQuery(title),
    167245    parent(_parent)
    168246{
     
    192270
    193271
    194 QTDialog::StringQTQuery::StringQTQuery(string _title,string *_target,QBoxLayout *_parent,QTDialog *_dialog) :
    195     Dialog::StringQuery(_title,_target),
     272QTDialog::DoublesQTQuery::DoublesQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) :
     273    Dialog::DoublesQuery(title),
     274    parent(_parent)
     275{
     276  QHBoxLayout * thisHLayout = new QHBoxLayout();
     277  QVBoxLayout * thisV1Layout = new QVBoxLayout();
     278  QVBoxLayout * thisV2Layout = new QVBoxLayout();
     279
     280  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
     281  QLabel *inputLabel = new QLabel("Enter to add");
     282  QListWidget* inputList = new QListWidget();
     283  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
     284  QLineEdit* inputBox = new QLineEdit();
     285  inputLabel->setBuddy(inputBox);
     286  titleLabel->setBuddy(inputList);
     287  QPushButton* AddButton = new QPushButton("Add");
     288  AddButton->setEnabled(false);
     289  QPushButton* RemoveButton = new QPushButton("Remove");
     290  RemoveButton->setEnabled(false);
     291
     292  thisV1Layout->addWidget(titleLabel);
     293  thisV1Layout->addWidget(inputList);
     294  thisV2Layout->addWidget(inputLabel);
     295  thisV2Layout->addWidget(inputBox);
     296  thisV2Layout->addWidget(AddButton);
     297  thisV2Layout->addWidget(RemoveButton);
     298  parent->addLayout(thisHLayout);
     299  thisHLayout->addLayout(thisV1Layout);
     300  thisHLayout->addLayout(thisV2Layout);
     301
     302  pipe = new QTQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
     303  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
     304  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
     305  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
     306  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
     307
     308QTDialog::DoublesQTQuery::~DoublesQTQuery()
     309{
     310  delete pipe;
     311}
     312
     313bool QTDialog::DoublesQTQuery::handle() {
     314  return true;
     315}
     316
     317
     318QTDialog::StringQTQuery::StringQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
     319    Dialog::StringQuery(_title),
    196320    parent(_parent)
    197321{
     
    219343}
    220344
    221 QTDialog::StringsQTQuery::StringsQTQuery(string _title,vector<string> *_target,QBoxLayout *_parent,QTDialog *_dialog) :
    222     Dialog::StringsQuery(_title,_target),
    223     parent(_parent)
    224 {
    225   thisLayout = new QHBoxLayout();
    226   titleLabel = new QLabel(QString(getTitle().c_str()));
    227   inputBox = new QLineEdit();
    228   parent->addLayout(thisLayout);
    229   thisLayout->addWidget(titleLabel);
    230   thisLayout->addWidget(inputBox);
    231 
    232   pipe = new StringQTQueryPipe(&temp,_dialog);
    233   pipe->update(inputBox->text());
    234   connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
    235 }
     345QTDialog::StringsQTQuery::StringsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
     346    Dialog::StringsQuery(_title),
     347    parent(_parent)
     348{
     349  QHBoxLayout * thisHLayout = new QHBoxLayout();
     350  QVBoxLayout * thisV1Layout = new QVBoxLayout();
     351  QVBoxLayout * thisV2Layout = new QVBoxLayout();
     352
     353  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
     354  QLabel *inputLabel = new QLabel("Enter to add");
     355  QListWidget* inputList = new QListWidget();
     356  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
     357  QLineEdit* inputBox = new QLineEdit();
     358  inputLabel->setBuddy(inputBox);
     359  titleLabel->setBuddy(inputList);
     360  QPushButton* AddButton = new QPushButton("Add");
     361  AddButton->setEnabled(false);
     362  QPushButton* RemoveButton = new QPushButton("Remove");
     363  RemoveButton->setEnabled(false);
     364
     365  thisV1Layout->addWidget(titleLabel);
     366  thisV1Layout->addWidget(inputList);
     367  thisV2Layout->addWidget(inputLabel);
     368  thisV2Layout->addWidget(inputBox);
     369  thisV2Layout->addWidget(AddButton);
     370  thisV2Layout->addWidget(RemoveButton);
     371  parent->addLayout(thisHLayout);
     372  thisHLayout->addLayout(thisV1Layout);
     373  thisHLayout->addLayout(thisV2Layout);
     374
     375  pipe = new QTQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
     376  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
     377  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
     378  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
     379  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
    236380
    237381QTDialog::StringsQTQuery::~StringsQTQuery()
     
    257401}
    258402
    259 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog) :
    260     Dialog::MoleculeQuery(_title,_target),
     403QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) :
     404    Dialog::MoleculeQuery(_title),
    261405    parent(_parent)
    262406{
     
    293437}
    294438
    295 QTDialog::VectorQTQuery::VectorQTQuery(std::string title, Vector *_target, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
    296     Dialog::VectorQuery(title,_target,_check),
     439QTDialog::MoleculesQTQuery::MoleculesQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) :
     440    Dialog::MoleculesQuery(_title),
     441    parent(_parent)
     442{
     443  thisLayout = new QHBoxLayout();
     444  titleLabel = new QLabel(QString(getTitle().c_str()));
     445  inputBox = new QComboBox();
     446  // add all molecules to the combo box
     447  vector<molecule*> molecules = World::getInstance().getAllMolecules();
     448  for(vector<molecule*>::iterator iter  = molecules.begin();
     449      iter != molecules.end();
     450      ++iter) {
     451    stringstream sstr;
     452    sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
     453    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
     454  }
     455  parent->addLayout(thisLayout);
     456  thisLayout->addWidget(titleLabel);
     457  thisLayout->addWidget(inputBox);
     458
     459  pipe = new MoleculesQTQueryPipe(&tmp,_dialog,inputBox);
     460  pipe->update(inputBox->currentIndex());
     461  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     462}
     463
     464QTDialog::MoleculesQTQuery::~MoleculesQTQuery()
     465{
     466  delete pipe;
     467}
     468
     469// Handling is easy, since the GUI makes it impossible to select invalid values
     470bool QTDialog::MoleculesQTQuery::handle()
     471{
     472  return true;
     473}
     474
     475QTDialog::VectorQTQuery::VectorQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
     476    Dialog::VectorQuery(title,_check),
    297477    parent(_parent)
    298478{
     
    304484  subLayout = new QVBoxLayout();
    305485  mainLayout->addLayout(subLayout);
    306   for(int i=0; i<3; i++) {
    307     coordLayout[i] = new QHBoxLayout();
    308     subLayout->addLayout(coordLayout[i]);
    309     coordLabel[i] = new QLabel(QString(coords[i]));
    310     coordLayout[i]->addWidget(coordLabel[i]);
    311     coordInput[i] = new QDoubleSpinBox();
    312     coordInput[i]->setRange(0,M.at(i,i));
    313     coordInput[i]->setDecimals(3);
    314     coordLayout[i]->addWidget(coordInput[i]);
    315     pipe[i] = new DoubleQTQueryPipe(&((*tmp)[i]),_dialog);
    316     pipe[i]->update(coordInput[i]->value());
    317     connect(coordInput[i],SIGNAL(valueChanged(double)),pipe[i],SLOT(update(double)));
    318 
    319   }
     486  QComboBox* inputBox = new QComboBox();
     487  coordLayout = new QHBoxLayout();
     488  subLayout->addLayout(coordLayout);
     489  coordLabel = new QLabel(QString("x,y,z"));
     490  coordLayout->addWidget(coordLabel);
     491  coordInput = new QDoubleSpinBox();
     492//  coordInput->setRange(0,M.at(i,i));
     493  coordInput->setDecimals(3);
     494  coordLayout->addWidget(coordInput);
     495  pipe = new VectorQTQueryPipe(&(tmp),_dialog,inputBox);
     496  //pipe->update(coordInput->value());
     497  connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
    320498  parent->addLayout(mainLayout);
    321499}
     
    329507
    330508
    331 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) :
    332     Dialog::ElementQuery(_title,_target),
     509QTDialog::VectorsQTQuery::VectorsQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
     510    Dialog::VectorsQuery(title,_check),
     511    parent(_parent)
     512{
     513  const Matrix& M = World::getInstance().getDomain().getM();
     514  const char *coords[3] = {"x:","y:","z:"};
     515  mainLayout= new QHBoxLayout();
     516  titleLabel = new QLabel(QString(getTitle().c_str()));
     517  mainLayout->addWidget(titleLabel);
     518  subLayout = new QVBoxLayout();
     519  mainLayout->addLayout(subLayout);
     520  QComboBox* inputBox = new QComboBox();
     521  coordLayout = new QHBoxLayout();
     522  subLayout->addLayout(coordLayout);
     523  coordLabel = new QLabel(QString("x,y,z"));
     524  coordLayout->addWidget(coordLabel);
     525  coordInput = new QDoubleSpinBox();
     526//  coordInput->setRange(0,M.at(i,i));
     527  coordInput->setDecimals(3);
     528  coordLayout->addWidget(coordInput);
     529  pipe = new VectorsQTQueryPipe(&(tmp),_dialog,inputBox);
     530  //pipe->update(coordInput->value());
     531  connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
     532  parent->addLayout(mainLayout);
     533}
     534
     535QTDialog::VectorsQTQuery::~VectorsQTQuery()
     536{}
     537
     538bool QTDialog::VectorsQTQuery::handle() {
     539  return true;
     540}
     541
     542
     543QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) :
     544    Dialog::ElementQuery(_title),
    333545    parent(_parent)
    334546{
     
    349561  thisLayout->addWidget(inputBox);
    350562
    351   pipe = new ElementQTQueryPipe(&elements,_dialog,inputBox);
     563  pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox);
    352564  pipe->update(inputBox->currentIndex());
    353565  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     
    363575}
    364576
     577
     578QTDialog::ElementsQTQuery::ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) :
     579    Dialog::ElementsQuery(_title),
     580    parent(_parent)
     581{
     582  periodentafel *periode = World::getInstance().getPeriode();
     583  thisLayout = new QHBoxLayout();
     584  titleLabel = new QLabel(QString(getTitle().c_str()));
     585  inputBox = new QComboBox();
     586  for(periodentafel::const_iterator iter = periode->begin();
     587      iter!=periode->end();
     588      ++iter)
     589  {
     590    stringstream sstr;
     591    sstr << (*iter).first << "\t" << (*iter).second->name;
     592    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
     593  }
     594  parent->addLayout(thisLayout);
     595  thisLayout->addWidget(titleLabel);
     596  thisLayout->addWidget(inputBox);
     597
     598  pipe = new ElementsQTQueryPipe(&tmp,_dialog,inputBox);
     599  pipe->update(inputBox->currentIndex());
     600  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     601}
     602
     603QTDialog::ElementsQTQuery::~ElementsQTQuery()
     604{
     605  delete pipe;
     606}
     607
     608bool QTDialog::ElementsQTQuery::handle(){
     609  return true;
     610}
     611
    365612/*************************** Plumbing *******************************/
     613
     614
     615template<typename T> QTQueryListPipe<T>::QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) :
     616  content(_content),
     617  dialog(_dialog),
     618  inputBox(_inputBox),
     619  inputList(_inputList),
     620  AddButton(_AddButton),
     621  RemoveButton(_RemoveButton)
     622{}
     623
     624template<typename T> QTQueryListPipe<T>::~QTQueryListPipe()
     625{}
     626
     627template<typename T> void QTQueryListPipe<T>::IntegerEntered(const QString&)
     628{
     629  AddButton->setEnabled(true);
     630}
     631
     632template<typename T> void QTQueryListPipe<T>::IntegerSelected()
     633{
     634  if (inputList->selectedItems().empty())
     635    RemoveButton->setEnabled(false);
     636  else
     637    RemoveButton->setEnabled(true);
     638}
     639
     640template<typename T> void QTQueryListPipe<T>::AddInteger() {
     641  // type-check
     642  std::string text = inputBox->text().toStdString();
     643  int number = 0;
     644  try {
     645    number = boost::lexical_cast<int>(text);
     646  } catch (boost::bad_lexical_cast&) {
     647    return;
     648  };
     649  // add item to both
     650  inputList->addItem(QString(number));
     651  AddValue(number);
     652}
     653
     654template<typename T> void QTQueryListPipe<T>::AddValue(T item) {
     655  content->push_back(item);
     656
     657  dialog->update();
     658}
     659
     660template<typename T> void QTQueryListPipe<T>::RemoveInteger() {
     661  QList<QListWidgetItem *> items = inputList->selectedItems();
     662  for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) {
     663    // obtain which position item has (by making it current item)
     664    inputList->setCurrentItem(*iter);
     665    // remove
     666    QTQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call
     667    inputList->removeItemWidget(*iter);
     668  }
     669}
     670
     671template<typename T> void QTQueryListPipe<T>::RemoveRow(int row) {
     672  int counter = 0;
     673  typename std::vector<T>::iterator iter = content->begin();
     674  for (; iter != content->end(); ++iter)
     675    if (counter++ == row)
     676      break;
     677  if (iter != content->end())
     678      content->erase(iter);
     679}
     680
    366681
    367682StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) :
     
    403718  dialog->update();
    404719}
     720
     721VectorQTQueryPipe::VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox) :
     722  content(_content),
     723  dialog(_dialog),
     724  theBox(_theBox)
     725{}
     726
     727VectorQTQueryPipe::~VectorQTQueryPipe()
     728{}
     729
     730void VectorQTQueryPipe::update() {
     731  dialog->update();
     732}
     733
     734VectorsQTQueryPipe::VectorsQTQueryPipe(std::vector<Vector> *_content, QTDialog *_dialog, QComboBox *_theBox) :
     735  content(_content),
     736  dialog(_dialog),
     737  theBox(_theBox)
     738{}
     739
     740VectorsQTQueryPipe::~VectorsQTQueryPipe()
     741{}
     742
     743void VectorsQTQueryPipe::update() {
     744  dialog->update();
     745}
     746
     747AtomQTQueryPipe::AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox) :
     748  content(_content),
     749  dialog(_dialog),
     750  theBox(_theBox)
     751{}
     752
     753AtomQTQueryPipe::~AtomQTQueryPipe()
     754{}
     755
     756void AtomQTQueryPipe::update(int newIndex) {
     757  QVariant data = theBox->itemData(newIndex);
     758  int idx = data.toInt();
     759  (*content) = World::getInstance().getAtom(AtomById(idx));
     760  dialog->update();
     761}
     762
     763
     764AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
     765  content(_content),
     766  dialog(_dialog),
     767  theBox(_theBox)
     768{}
     769
     770AtomsQTQueryPipe::~AtomsQTQueryPipe()
     771{}
     772
     773void AtomsQTQueryPipe::update(int newIndex) {
     774  QVariant data = theBox->itemData(newIndex);
     775  int idx = data.toInt();
     776  atom *Walker = World::getInstance().getAtom(AtomById(idx));
     777  if (Walker)
     778    (*content).push_back(Walker) ;
     779  dialog->update();
     780}
     781
    405782
    406783MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) :
     
    420797}
    421798
    422 ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) :
     799
     800MoleculesQTQueryPipe::MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
    423801  content(_content),
    424802  dialog(_dialog),
    425803  theBox(_theBox)
    426 {
    427   content->resize(1);
    428 }
     804{}
     805
     806MoleculesQTQueryPipe::~MoleculesQTQueryPipe()
     807{}
     808
     809void MoleculesQTQueryPipe::update(int newIndex) {
     810  QVariant data = theBox->itemData(newIndex);
     811  int idx = data.toInt();
     812  molecule *mol = World::getInstance().getMolecule(MoleculeById(idx));
     813  if (mol)
     814    (*content).push_back(mol);
     815  dialog->update();
     816}
     817
     818ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) :
     819  content(_content),
     820  dialog(_dialog),
     821  theBox(_theBox)
     822{}
    429823
    430824ElementQTQueryPipe::~ElementQTQueryPipe()
     
    434828  QVariant data = theBox->itemData(newIndex);
    435829  int idx = data.toInt();
    436   (*content)[0] = World::getInstance().getPeriode()->FindElement(idx);
    437   dialog->update();
    438 }
    439 
     830  *content = World::getInstance().getPeriode()->FindElement(idx);
     831  dialog->update();
     832}
     833
     834ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
     835  content(_content),
     836  dialog(_dialog),
     837  theBox(_theBox)
     838{}
     839
     840ElementsQTQueryPipe::~ElementsQTQueryPipe()
     841{}
     842
     843void ElementsQTQueryPipe::update(int newIndex) {
     844  QVariant data = theBox->itemData(newIndex);
     845  int idx = data.toInt();
     846  element *elemental = World::getInstance().getPeriode()->FindElement(idx);
     847  if(elemental)
     848    (*content).push_back(elemental);
     849  dialog->update();
     850}
     851
     852
  • src/UIElements/QT4/QTDialog.hpp

    r7067bd6 r677e13  
    1717class QDoubleSpinBox;
    1818class QLineEdit;
     19class QListWidget;
    1920class QComboBox;
    2021class QDialogButtonBox;
     
    2223
    2324// Forward declarations for plumbing
     25template<typename T> class QTQueryListPipe;
    2426class StringQTQueryPipe;
     27class StringsQTQueryPipe;
    2528class IntQTQueryPipe;
    2629class DoubleQTQueryPipe;
     30class DoublesQTQueryPipe;
     31class AtomQTQueryPipe;
     32class AtomsQTQueryPipe;
    2733class MoleculeQTQueryPipe;
     34class MoleculesQTQueryPipe;
    2835class ElementQTQueryPipe;
     36class ElementsQTQueryPipe;
     37class VectorQTQueryPipe;
     38class VectorsQTQueryPipe;
    2939
    3040class QTDialog : public QDialog, public Dialog
     
    3646
    3747  virtual void queryEmpty(const char*, std::string);
    38   virtual void queryBoolean(const char *, bool *, std::string = "");
    39   virtual void queryInt(const char *, int *,std::string = "");
    40   virtual void queryDouble(const char*,double *,std::string = "");
    41   virtual void queryString(const char*, std::string *,std::string = "");
    42   virtual void queryStrings(const char*, std::vector<std::string> *,std::string = "");
    43   virtual void queryAtom(const char*,atom**,std::string = "");
    44   virtual void queryMolecule(const char*,molecule**,std::string = "");
    45   virtual void queryVector(const char*,Vector *,bool,std::string = "");
    46   virtual void queryBox(const char*,Box*, std::string = "");
    47   virtual void queryElement(const char*,std::vector<element *> *_target,std::string = "");
     48  virtual void queryBoolean(const char *, std::string = "");
     49  virtual void queryInt(const char *,std::string = "");
     50  virtual void queryInts(const char *,std::string = "");
     51  virtual void queryDouble(const char*,std::string = "");
     52  virtual void queryDoubles(const char*,std::string = "");
     53  virtual void queryString(const char*,std::string = "");
     54  virtual void queryStrings(const char*,std::string = "");
     55  virtual void queryAtom(const char*,std::string = "");
     56  virtual void queryAtoms(const char*,std::string = "");
     57  virtual void queryMolecule(const char*,std::string = "");
     58  virtual void queryMolecules(const char*,std::string = "");
     59  virtual void queryVector(const char*,bool,std::string = "");
     60  virtual void queryVectors(const char*,bool,std::string = "");
     61  virtual void queryBox(const char*, std::string = "");
     62  virtual void queryElement(const char*,std::string = "");
     63  virtual void queryElements(const char*,std::string = "");
    4864
    4965  virtual bool display();
     
    5470  class IntQTQuery : public Dialog::IntQuery {
    5571    public:
    56       IntQTQuery(std::string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog);
     72      IntQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog);
    5773      virtual ~IntQTQuery();
    5874      virtual bool handle();
     
    6682    };
    6783
     84  class IntsQTQuery : public Dialog::IntsQuery {
     85    public:
     86      IntsQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog);
     87      virtual ~IntsQTQuery();
     88      virtual bool handle();
     89      void IntegerEntered(const QString&);
     90      void IntegerSelected();
     91      void AddInteger();
     92      void RemoveInteger();
     93    private:
     94      QBoxLayout *parent;
     95      QBoxLayout *thisLayout;
     96      QLabel *titleLabel;
     97
     98      QTQueryListPipe<int> *pipe;
     99    };
     100
    68101    class DoubleQTQuery : public Dialog::DoubleQuery {
    69102    public:
    70       DoubleQTQuery(std::string title, double *_target,QBoxLayout *_parent,QTDialog *_dialog);
     103      DoubleQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog);
    71104      virtual ~DoubleQTQuery();
    72105      virtual bool handle();
     
    80113    };
    81114
     115    class DoublesQTQuery : public Dialog::DoublesQuery {
     116    public:
     117      DoublesQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog);
     118      virtual ~DoublesQTQuery();
     119      virtual bool handle();
     120    private:
     121      QBoxLayout *parent;
     122      QBoxLayout *thisLayout;
     123      QLabel *titleLabel;
     124      QDoubleSpinBox *inputBox;
     125
     126      QTQueryListPipe<double> *pipe;
     127    };
     128
    82129    class StringQTQuery : public Dialog::StringQuery {
    83130    public:
    84       StringQTQuery(std::string _title, std::string *_target, QBoxLayout *_parent,QTDialog *_dialog);
     131      StringQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
    85132      virtual ~StringQTQuery();
    86133      virtual bool handle();
     
    96143    class StringsQTQuery : public Dialog::StringsQuery {
    97144    public:
    98       StringsQTQuery(std::string _title, std::vector<std::string> *_target, QBoxLayout *_parent,QTDialog *_dialog);
     145      StringsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
    99146      virtual ~StringsQTQuery();
    100147      virtual bool handle();
     
    105152      QLineEdit *inputBox;
    106153
    107       StringQTQueryPipe *pipe;
     154      QTQueryListPipe<std::string> *pipe;
     155    };
     156
     157    class AtomQTQuery : public Dialog::AtomQuery {
     158    public:
     159      AtomQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
     160      virtual ~AtomQTQuery();
     161      virtual bool handle();
     162    private:
     163      QBoxLayout *parent;
     164      QBoxLayout *thisLayout;
     165      QLabel *titleLabel;
     166      QComboBox *inputBox;
     167
     168      AtomQTQueryPipe *pipe;
     169    };
     170
     171    class AtomsQTQuery : public Dialog::AtomsQuery {
     172    public:
     173      AtomsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
     174      virtual ~AtomsQTQuery();
     175      virtual bool handle();
     176    private:
     177      QBoxLayout *parent;
     178      QBoxLayout *thisLayout;
     179      QLabel *titleLabel;
     180      QComboBox *inputBox;
     181
     182      AtomsQTQueryPipe *pipe;
    108183    };
    109184
    110185    class MoleculeQTQuery : public Dialog::MoleculeQuery {
    111186    public:
    112       MoleculeQTQuery(std::string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog);
     187      MoleculeQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
    113188      virtual ~MoleculeQTQuery();
    114189      virtual bool handle();
     
    122197    };
    123198
     199    class MoleculesQTQuery : public Dialog::MoleculesQuery {
     200    public:
     201      MoleculesQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
     202      virtual ~MoleculesQTQuery();
     203      virtual bool handle();
     204    private:
     205      QBoxLayout *parent;
     206      QBoxLayout *thisLayout;
     207      QLabel *titleLabel;
     208      QComboBox *inputBox;
     209
     210      MoleculesQTQueryPipe *pipe;
     211    };
     212
    124213    class VectorQTQuery : public Dialog::VectorQuery {
    125214    public:
    126       VectorQTQuery(std::string title,Vector *_target,bool _check,QBoxLayout *,QTDialog *);
     215      VectorQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *);
    127216      virtual ~VectorQTQuery();
    128217      virtual bool handle();
     
    132221      QLabel *titleLabel;
    133222      QBoxLayout *subLayout;
    134       QBoxLayout *coordLayout[3];
    135       QLabel *coordLabel[3];
    136       QDoubleSpinBox *coordInput[3];
    137 
    138       DoubleQTQueryPipe *pipe[3];
     223      QBoxLayout *coordLayout;
     224      QLabel *coordLabel;
     225      QDoubleSpinBox *coordInput;
     226
     227      VectorQTQueryPipe *pipe;
     228    };
     229
     230    class VectorsQTQuery : public Dialog::VectorsQuery {
     231    public:
     232      VectorsQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *);
     233      virtual ~VectorsQTQuery();
     234      virtual bool handle();
     235    private:
     236      QBoxLayout *parent;
     237      QBoxLayout *mainLayout;
     238      QLabel *titleLabel;
     239      QBoxLayout *subLayout;
     240      QBoxLayout *coordLayout;
     241      QLabel *coordLabel;
     242      QDoubleSpinBox *coordInput;
     243
     244      VectorsQTQueryPipe *pipe;
    139245    };
    140246
    141247    class ElementQTQuery : public Dialog::ElementQuery {
    142248    public:
    143       ElementQTQuery(std::string _title, std::vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog);
     249      ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
    144250      virtual ~ElementQTQuery();
    145251      virtual bool handle();
     
    151257
    152258      ElementQTQueryPipe *pipe;
     259    };
     260
     261    class ElementsQTQuery : public Dialog::ElementsQuery {
     262    public:
     263      ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
     264      virtual ~ElementsQTQuery();
     265      virtual bool handle();
     266    private:
     267      QBoxLayout *parent;
     268      QBoxLayout *thisLayout;
     269      QLabel *titleLabel;
     270      QComboBox *inputBox;
     271
     272      ElementsQTQueryPipe *pipe;
    153273    };
    154274
     
    164284// since MOC doesn't like nested classes
    165285
     286
     287template<typename T> class QTQueryListPipe : public QWidget {
     288  public:
     289    QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton);
     290    virtual ~QTQueryListPipe();
     291    void AddInteger();
     292    void RemoveInteger();
     293    void IntegerSelected();
     294    void IntegerEntered(const QString&);
     295
     296  private:
     297    void AddValue(T item);
     298    void RemoveRow(int row);
     299
     300    std::vector<T> *content;
     301    QTDialog *dialog;
     302    QLineEdit *inputBox;
     303    QListWidget *inputList;
     304    QPushButton *AddButton;
     305    QPushButton *RemoveButton;
     306};
     307
     308
    166309class StringQTQueryPipe : public QWidget {
    167310  Q_OBJECT
     
    194337};
    195338
     339
    196340class DoubleQTQueryPipe : public QWidget {
    197341  Q_OBJECT
     
    209353};
    210354
     355class AtomQTQueryPipe : public QWidget {
     356  Q_OBJECT
     357public:
     358  AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox);
     359  virtual ~AtomQTQueryPipe();
     360
     361public slots:
     362  void update(int);
     363
     364private:
     365  atom **content;
     366  QTDialog *dialog;
     367  QComboBox *theBox;
     368
     369};
     370
     371
     372class AtomsQTQueryPipe : public QWidget {
     373  Q_OBJECT
     374public:
     375  AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox);
     376  virtual ~AtomsQTQueryPipe();
     377
     378public slots:
     379  void update(int);
     380
     381private:
     382  std::vector<atom *>*content;
     383  QTDialog *dialog;
     384  QComboBox *theBox;
     385
     386};
     387
    211388class MoleculeQTQueryPipe : public QWidget {
    212389  Q_OBJECT
     
    225402};
    226403
     404class MoleculesQTQueryPipe : public QWidget {
     405  Q_OBJECT
     406public:
     407  MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox);
     408  virtual ~MoleculesQTQueryPipe();
     409
     410public slots:
     411  void update(int);
     412
     413private:
     414  std::vector<molecule *>*content;
     415  QTDialog *dialog;
     416  QComboBox *theBox;
     417
     418};
     419
     420class VectorQTQueryPipe : public QWidget {
     421  Q_OBJECT
     422public:
     423  VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox);
     424  virtual ~VectorQTQueryPipe();
     425
     426public slots:
     427  void update();
     428
     429private:
     430  Vector *content;
     431  QTDialog *dialog;
     432  QComboBox *theBox;
     433};
     434
     435class VectorsQTQueryPipe : public QWidget {
     436  Q_OBJECT
     437public:
     438  VectorsQTQueryPipe(std::vector<Vector>*_content, QTDialog *_dialog, QComboBox *_theBox);
     439  virtual ~VectorsQTQueryPipe();
     440
     441public slots:
     442  void update();
     443
     444private:
     445  std::vector<Vector> *content;
     446  QTDialog *dialog;
     447  QComboBox *theBox;
     448};
     449
    227450class ElementQTQueryPipe : public QWidget {
    228451  Q_OBJECT
    229452public:
    230   ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox);
     453  ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox);
    231454  virtual ~ElementQTQueryPipe();
    232455
     
    235458
    236459private:
    237   std::vector<element *> *content;
     460  element **content;
     461  QTDialog *dialog;
     462  QComboBox *theBox;
     463};
     464
     465class ElementsQTQueryPipe : public QWidget {
     466  Q_OBJECT
     467public:
     468  ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
     469  virtual ~ElementsQTQueryPipe();
     470
     471public slots:
     472  void update(int);
     473
     474private:
     475  std::vector<element *>*content;
    238476  QTDialog *dialog;
    239477  QComboBox *theBox;
  • src/UIElements/TextUI/TextDialog.cpp

    r7067bd6 r677e13  
    3030using namespace std;
    3131
     32using boost::lexical_cast;
     33using boost::bad_lexical_cast;
     34
    3235
    3336TextDialog::TextDialog()
     
    4447}
    4548
    46 void TextDialog::queryBoolean(const char* title, bool* target, string description){
    47   registerQuery(new BooleanTextQuery(title,target,description));
    48 }
    49 
    50 void TextDialog::queryInt(const char* title, int* target, string description){
    51   registerQuery(new IntTextQuery(title,target,description));
    52 }
    53 
    54 void TextDialog::queryDouble(const char* title, double* target, string description){
    55   registerQuery(new DoubleTextQuery(title,target,description));
    56 }
    57 
    58 void TextDialog::queryString(const char* title, string* target, string description){
    59   registerQuery(new StringTextQuery(title,target,description));
    60 }
    61 
    62 void TextDialog::queryStrings(const char* title, vector<string>* target, string description){
    63   registerQuery(new StringsTextQuery(title,target,description));
    64 }
    65 
    66 void TextDialog::queryAtom(const char* title, atom **target, string description) {
    67   registerQuery(new AtomTextQuery(title,target,description));
    68 }
    69 
    70 void TextDialog::queryMolecule(const char* title, molecule **target, string description) {
    71   registerQuery(new MoleculeTextQuery(title,target,description));
    72 }
    73 
    74 void TextDialog::queryVector(const char* title, Vector *target, bool check, string description) {
    75   registerQuery(new VectorTextQuery(title,target,check,description));
    76 }
    77 
    78 void TextDialog::queryBox(const char* title,Box* cellSize, string description) {
    79   registerQuery(new BoxTextQuery(title,cellSize,description));
    80 }
    81 
    82 void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){
    83   registerQuery(new ElementTextQuery(title,target,description));
     49void TextDialog::queryBoolean(const char* title, string description){
     50  registerQuery(new BooleanTextQuery(title,description));
     51}
     52
     53void TextDialog::queryInt(const char* title, string description){
     54  registerQuery(new IntTextQuery(title,description));
     55}
     56
     57void TextDialog::queryInts(const char* title, string description){
     58  registerQuery(new IntsTextQuery(title,description));
     59}
     60
     61void TextDialog::queryDouble(const char* title, string description){
     62  registerQuery(new DoubleTextQuery(title,description));
     63}
     64
     65void TextDialog::queryDoubles(const char* title, string description){
     66  registerQuery(new DoublesTextQuery(title,description));
     67}
     68
     69void TextDialog::queryString(const char* title, string description){
     70  registerQuery(new StringTextQuery(title,description));
     71}
     72
     73void TextDialog::queryStrings(const char* title, string description){
     74  registerQuery(new StringsTextQuery(title,description));
     75}
     76
     77void TextDialog::queryAtom(const char* title, string description) {
     78  registerQuery(new AtomTextQuery(title,description));
     79}
     80
     81void TextDialog::queryAtoms(const char* title, string description) {
     82  registerQuery(new AtomsTextQuery(title,description));
     83}
     84
     85void TextDialog::queryMolecule(const char* title, string description) {
     86  registerQuery(new MoleculeTextQuery(title,description));
     87}
     88
     89void TextDialog::queryMolecules(const char* title, string description) {
     90  registerQuery(new MoleculesTextQuery(title,description));
     91}
     92
     93void TextDialog::queryVector(const char* title, bool check, string description) {
     94  registerQuery(new VectorTextQuery(title,check,description));
     95}
     96
     97void TextDialog::queryVectors(const char* title, bool check, string description) {
     98  registerQuery(new VectorsTextQuery(title,check,description));
     99}
     100
     101void TextDialog::queryBox(const char* title, string description) {
     102  registerQuery(new BoxTextQuery(title,description));
     103}
     104
     105void TextDialog::queryElement(const char* title, string description){
     106  registerQuery(new ElementTextQuery(title,description));
     107}
     108
     109void TextDialog::queryElements(const char* title, string description){
     110  registerQuery(new ElementsTextQuery(title,description));
    84111}
    85112
     
    97124}
    98125
    99 TextDialog::IntTextQuery::IntTextQuery(string title, int * _target, std::string _description) :
    100     Dialog::IntQuery(title,_target,_description)
     126TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) :
     127    Dialog::IntQuery(title,_description)
    101128{}
    102129
     
    121148}
    122149
    123 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, bool * _target, std::string _description) :
    124     Dialog::BooleanQuery(title,_target,_description)
     150TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) :
     151    Dialog::IntsQuery(title,_description)
     152{}
     153
     154TextDialog::IntsTextQuery::~IntsTextQuery() {}
     155
     156bool TextDialog::IntsTextQuery::handle() {
     157  Log() << Verbose(0) << getTitle();
     158  std::string line;
     159  getline(cin,line);
     160  // dissect by " "
     161  string::iterator olditer = line.begin();
     162  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     163    if (*iter == ' ') {
     164      std::istringstream stream(string(iter, olditer));
     165      stream >> temp;
     166      tmp.push_back(temp);
     167      olditer = iter;
     168    }
     169  }
     170  if (olditer != line.begin()) { // insert last part also
     171    std::istringstream stream(string(olditer, line.end()));
     172    stream >> temp;
     173    tmp.push_back(temp);
     174  }
     175
     176  return true;
     177}
     178
     179TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) :
     180    Dialog::BooleanQuery(title,_description)
    125181{}
    126182
     
    150206}
    151207
    152 TextDialog::StringTextQuery::StringTextQuery(string title,string *_target, std::string _description) :
    153     Dialog::StringQuery(title,_target,_description)
     208TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) :
     209    Dialog::StringQuery(title,_description)
    154210{}
    155211
     
    162218}
    163219
    164 TextDialog::StringsTextQuery::StringsTextQuery(string title,vector<string> *_target, std::string _description) :
    165     Dialog::StringsQuery(title,_target,_description)
     220TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) :
     221    Dialog::StringsQuery(title,_description)
    166222{}
    167223
     
    171227  Log() << Verbose(0) << getTitle();
    172228  getline(cin,temp);
    173   // dissect by ","
     229  // dissect by " "
    174230  string::iterator olditer = temp.begin();
    175231  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
     
    185241}
    186242
    187 TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target, std::string _description) :
    188     Dialog::DoubleQuery(title,_target,_description)
     243TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) :
     244    Dialog::DoubleQuery(title,_description)
    189245{}
    190246
     
    208264}
    209265
    210 TextDialog::AtomTextQuery::AtomTextQuery(string title, atom **_target, std::string _description) :
    211     Dialog::AtomQuery(title,_target,_description)
     266
     267TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) :
     268    Dialog::DoublesQuery(title,_description)
     269{}
     270
     271TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
     272
     273bool TextDialog::DoublesTextQuery::handle() {
     274  Log() << Verbose(0) << getTitle();
     275  std::string line;
     276  getline(cin,line);
     277  // dissect by " "
     278  string::iterator olditer = line.begin();
     279  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     280    if (*iter == ' ') {
     281      std::istringstream stream(string(iter, olditer));
     282      stream >> temp;
     283      tmp.push_back(temp);
     284      olditer = iter;
     285    }
     286  }
     287  if (olditer != line.begin()) { // insert last part also
     288    std::istringstream stream(string(olditer, line.end()));
     289    stream >> temp;
     290    tmp.push_back(temp);
     291  }
     292
     293  return true;
     294}
     295
     296TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) :
     297    Dialog::AtomQuery(title,_description)
    212298{}
    213299
     
    215301
    216302bool TextDialog::AtomTextQuery::handle() {
    217   int idxOfAtom=0;
     303  int idxOfAtom=-1;
    218304  bool badInput = false;
    219305  do{
     
    231317    tmp = World::getInstance().getAtom(AtomById(idxOfAtom));
    232318    if(!tmp && idxOfAtom!=-1){
    233       Log() << Verbose(0) << "Invalid Atom Index" << endl;
     319      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
    234320      badInput = true;
    235321    }
     
    240326}
    241327
    242 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, std::string _description) :
    243     Dialog::MoleculeQuery(title,_target,_description)
     328
     329TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) :
     330    Dialog::AtomsQuery(title,_description)
     331{}
     332
     333TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
     334
     335bool TextDialog::AtomsTextQuery::handle() {
     336  int idxOfAtom=-1;
     337  Log() << Verbose(0) << getTitle();
     338  std::string line;
     339  getline(cin,line);
     340  // dissect by " "
     341  string::iterator olditer = line.begin();
     342  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     343    if (*iter == ' ') {
     344      std::istringstream stream(string(iter, olditer));
     345      stream >> idxOfAtom;
     346      temp = World::getInstance().getAtom(AtomById(idxOfAtom));
     347      if(!temp && idxOfAtom!=-1){
     348        Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     349        break;
     350      }
     351      tmp.push_back(temp);
     352      olditer = iter;
     353    }
     354  }
     355  if (olditer != line.begin()) { // insert last part also
     356    std::istringstream stream(string(olditer, line.end()));
     357    stream >> idxOfAtom;
     358    temp = World::getInstance().getAtom(AtomById(idxOfAtom));
     359    if(!temp && idxOfAtom!=-1) {
     360      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     361      tmp.push_back(temp);
     362    }
     363  }
     364
     365  return (idxOfAtom!=-1);
     366}
     367
     368TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) :
     369    Dialog::MoleculeQuery(title,_description)
    244370{}
    245371
     
    272398}
    273399
    274 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, bool _check, std::string _description) :
    275     Dialog::VectorQuery(title,_target,_check,_description)
     400
     401TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) :
     402    Dialog::MoleculesQuery(title,_description)
     403{}
     404
     405TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
     406
     407bool TextDialog::MoleculesTextQuery::handle() {
     408  int idxOfMol=-1;
     409  Log() << Verbose(0) << getTitle();
     410  std::string line;
     411  getline(cin,line);
     412  // dissect by " "
     413  string::iterator olditer = line.begin();
     414  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     415    if (*iter == ' ') {
     416      std::istringstream stream(string(iter, olditer));
     417      stream >> idxOfMol;
     418      temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     419      if(!temp && idxOfMol!=-1){
     420        Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
     421        break;
     422      }
     423      tmp.push_back(temp);
     424      olditer = iter;
     425    }
     426  }
     427  if (olditer != line.begin()) { // insert last part also
     428    std::istringstream stream(string(olditer, line.end()));
     429    stream >> idxOfMol;
     430    temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     431    if(!temp && idxOfMol!=-1){
     432      Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
     433      tmp.push_back(temp);
     434    }
     435  }
     436
     437  return (idxOfMol!=-1);
     438}
     439
     440TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) :
     441    Dialog::VectorQuery(title,_check,_description)
    276442{}
    277443
     
    280446
    281447bool TextDialog::VectorTextQuery::handle() {
    282   Log() << Verbose(0) << getTitle();
    283 
     448  std::cout << getTitle();
    284449  const Matrix &M = World::getInstance().getDomain().getM();
    285   char coords[3] = {'x','y','z'};
    286   for (int i=0;i<3;i++) {
    287     do {
    288       Log() << Verbose(0) << coords[i] << "[0.." << M.at(i,i) << "]: ";
    289       cin >> (*tmp)[i];
    290     } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= M.at(i,i))) && (check));
    291   }
    292   return true;
    293 }
    294 
    295 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, Box* _cellSize, std::string _description) :
    296     Dialog::BoxQuery(title,_cellSize,_description)
     450  char coords[3] = {'x', 'y', 'z'};
     451  for (int i=0;i<3;i++)
     452    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     453
     454  std::string line;
     455  getline(cin,line);
     456
     457  // dissect by ","
     458  double coord = 0.;
     459  int counter = 0;
     460  string::iterator olditer = line.begin();
     461  for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
     462    if (*iter == ',') {
     463      std::istringstream stream(string(iter, olditer));
     464      stream >> coord;
     465      tmp[counter++] = coord;
     466      olditer = iter;
     467    }
     468  }
     469  if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
     470    std::istringstream stream(string(olditer, line.end()));
     471    stream >> coord;
     472    tmp[counter++] = coord;
     473  }
     474
     475  // check vector
     476  return World::getInstance().getDomain().isInside(tmp);
     477}
     478
     479TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) :
     480    Dialog::VectorsQuery(title,_check,_description)
     481{}
     482
     483TextDialog::VectorsTextQuery::~VectorsTextQuery()
     484{}
     485
     486bool TextDialog::VectorsTextQuery::handle() {
     487  std::cout << getTitle();
     488  char coords[3] = {'x', 'y', 'z'};
     489  const Matrix &M = World::getInstance().getDomain().getM();
     490  for (int i=0;i<3;i++)
     491    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     492
     493  std::string line;
     494  getline(cin,line);
     495
     496  // dissect by ","
     497  double coord = 0.;
     498  string::iterator olditerspace = line.begin();
     499  string::iterator olditercomma = line.begin();
     500  int counter = 0;
     501  for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
     502    if (*vectoriter == ',')
     503      counter++;
     504    if ((*vectoriter == ' ') && (counter == 2)) {
     505      counter = 0;
     506      for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) {
     507        if (*componentiter == ',') {
     508          std::istringstream stream(string(componentiter, olditercomma));
     509          stream >> coord;
     510          temp[counter++] = coord;
     511          olditercomma = componentiter;
     512        }
     513      }
     514      if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also
     515        std::istringstream stream(string(olditercomma, vectoriter));
     516        stream >> coord;
     517        temp[counter++] = coord;
     518      }
     519      if (World::getInstance().getDomain().isInside(temp))
     520        tmp.push_back(temp);
     521      olditerspace = vectoriter;
     522    }
     523  }
     524}
     525
     526TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) :
     527    Dialog::BoxQuery(title,_description)
    297528{}
    298529
     
    303534  Log() << Verbose(0) << getTitle();
    304535
    305   std::string coords[6] = {"xx","xy","xz", "yy", "yz", "zz"};
     536  double temp[6];
     537  std::string coords[6] = {"xx","yx","yy", "zx", "zy", "zz"};
    306538  for (int i=0;i<6;i++) {
    307539    Log() << Verbose(0) << coords[i] << ": ";
    308     cin >> tmp[i];
    309   }
    310   return true;
    311 }
    312 
    313 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) :
    314     Dialog::ElementQuery(title,_target,_description)
     540    cin >> temp[i];
     541  }
     542  Matrix M;
     543  M.set(0,0, temp[0]);
     544  M.set(0,1, temp[1]);
     545  M.set(0,2, temp[2]);
     546  M.set(1,0, temp[1]);
     547  M.set(1,1, temp[3]);
     548  M.set(1,2, temp[4]);
     549  M.set(2,0, temp[2]);
     550  M.set(2,1, temp[4]);
     551  M.set(2,2, temp[5]);
     552  tmp.setM(M);
     553  return true;
     554}
     555
     556TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) :
     557    Dialog::ElementQuery(title,_description)
    315558{}
    316559
     
    321564  bool badInput=false;
    322565  bool aborted = false;
    323   element * tmp = NULL;
     566  element * temp = NULL;
    324567  do{
    325568    badInput = false;
     
    334577      }
    335578      else{
    336         tmp = World::getInstance().getPeriode()->FindElement(Z);
    337         if(!tmp){
     579        temp = World::getInstance().getPeriode()->FindElement(Z);
     580        if(!temp){
    338581          Log() << Verbose(0) << "No element with this atomic number!" << endl;
    339582          badInput = true;
    340         } else {
    341           elements.push_back(tmp);
    342583        }
    343584      }
     
    358599      }
    359600      else{
    360         tmp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
    361         if(!tmp){
     601        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     602        if(!temp){
    362603          Log() << Verbose(0) << "No element with this shorthand!" << endl;
    363604          badInput = true;
    364         } else {
    365           elements.push_back(tmp);
    366605        }
    367606      }
     
    378617  return !aborted;
    379618}
     619
     620TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) :
     621    Dialog::ElementsQuery(title,_description)
     622{}
     623
     624TextDialog::ElementsTextQuery::~ElementsTextQuery()
     625{}
     626
     627bool TextDialog::ElementsTextQuery::handle() {
     628  std::string shorthand;
     629  int Z=-1;
     630  Log() << Verbose(0) << getTitle();
     631  std::string line;
     632  getline(cin,line);
     633  // dissect by " "
     634  string::iterator olditer = line.begin();
     635  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     636    if (*iter == ' ') {
     637      std::istringstream stream(string(iter, olditer));
     638      stream >> shorthand;
     639      try {
     640        Z = lexical_cast<int>(shorthand);
     641        temp = World::getInstance().getPeriode()->FindElement(Z);
     642      } catch (bad_lexical_cast) {
     643        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     644      };
     645      if(!temp && Z!=-1){
     646        Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
     647        break;
     648      }
     649      tmp.push_back(temp);
     650      olditer = iter;
     651    }
     652  }
     653  if (olditer != line.begin()) { // insert last part also
     654    std::istringstream stream(string(olditer, line.end()));
     655    stream >> shorthand;
     656    try {
     657      Z = lexical_cast<int>(shorthand);
     658      temp = World::getInstance().getPeriode()->FindElement(Z);
     659    } catch (bad_lexical_cast) {
     660      temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     661    };
     662    if(!temp && Z!=-1) {
     663      Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
     664      tmp.push_back(temp);
     665    }
     666  }
     667
     668  return (Z!=-1);
     669}
  • src/UIElements/TextUI/TextDialog.hpp

    r7067bd6 r677e13  
    2525
    2626  virtual void queryEmpty(const char *, std::string = "");
    27   virtual void queryBoolean(const char *, bool *, std::string = "");
    28   virtual void queryInt(const char *, int *, std::string = "");
    29   virtual void queryString(const char*, std::string *, std::string = "");
    30   virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "");
    31   virtual void queryDouble(const char*, double*, std::string = "");
    32   virtual void queryAtom(const char*,atom**,std::string = "");
    33   virtual void queryMolecule(const char*,molecule**,std::string = "");
    34   virtual void queryVector(const char*,Vector *,bool, std::string = "");
    35   virtual void queryBox(const char*,Box*, std::string = "");
    36   virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
     27  virtual void queryBoolean(const char *, std::string = "");
     28  virtual void queryInt(const char *, std::string = "");
     29  virtual void queryInts(const char *, std::string = "");
     30  virtual void queryString(const char*, std::string = "");
     31  virtual void queryStrings(const char*, std::string = "");
     32  virtual void queryDouble(const char*, std::string = "");
     33  virtual void queryDoubles(const char*, std::string = "");
     34  virtual void queryAtom(const char*,std::string = "");
     35  virtual void queryAtoms(const char*,std::string = "");
     36  virtual void queryMolecule(const char*,std::string = "");
     37  virtual void queryMolecules(const char*,std::string = "");
     38  virtual void queryVector(const char*,bool, std::string = "");
     39  virtual void queryVectors(const char*,bool, std::string = "");
     40  virtual void queryBox(const char*, std::string = "");
     41  virtual void queryElement(const char*, std::string = "");
     42  virtual void queryElements(const char*, std::string = "");
    3743
    3844protected:
     
    4753  class BooleanTextQuery : public Dialog::BooleanQuery {
    4854  public:
    49     BooleanTextQuery(std::string title, bool *_target, std::string _description = NULL);
     55    BooleanTextQuery(std::string title, std::string _description = NULL);
    5056    virtual ~BooleanTextQuery();
    5157    virtual bool handle();
     
    5460  class IntTextQuery : public Dialog::IntQuery {
    5561  public:
    56     IntTextQuery(std::string title, int *_target, std::string _description = NULL);
     62    IntTextQuery(std::string title, std::string _description = NULL);
    5763    virtual ~IntTextQuery();
     64    virtual bool handle();
     65  };
     66
     67  class IntsTextQuery : public Dialog::IntsQuery {
     68  public:
     69    IntsTextQuery(std::string title, std::string _description = NULL);
     70    virtual ~IntsTextQuery();
    5871    virtual bool handle();
    5972  };
     
    6174  class DoubleTextQuery : public Dialog::DoubleQuery {
    6275  public:
    63     DoubleTextQuery(std::string title, double *_target, std::string _description = NULL);
     76    DoubleTextQuery(std::string title, std::string _description = NULL);
    6477    virtual ~DoubleTextQuery();
     78    virtual bool handle();
     79  };
     80
     81  class DoublesTextQuery : public Dialog::DoublesQuery {
     82  public:
     83    DoublesTextQuery(std::string title, std::string _description = NULL);
     84    virtual ~DoublesTextQuery();
    6585    virtual bool handle();
    6686  };
     
    6888  class StringTextQuery : public Dialog::StringQuery {
    6989  public:
    70     StringTextQuery(std::string title, std::string *_target, std::string _description = NULL);
     90    StringTextQuery(std::string title, std::string _description = NULL);
    7191    virtual ~StringTextQuery();
    7292    virtual bool handle();
     
    7595  class StringsTextQuery : public Dialog::StringsQuery {
    7696  public:
    77     StringsTextQuery(std::string title, std::vector<std::string> *_target, std::string _description = NULL);
     97    StringsTextQuery(std::string title, std::string _description = NULL);
    7898    virtual ~StringsTextQuery();
    7999    virtual bool handle();
     
    82102  class AtomTextQuery : public Dialog::AtomQuery {
    83103  public:
    84     AtomTextQuery(std::string title, atom **_target, std::string _description = NULL);
     104    AtomTextQuery(std::string title, std::string _description = NULL);
    85105    virtual ~AtomTextQuery();
     106    virtual bool handle();
     107  };
     108
     109  class AtomsTextQuery : public Dialog::AtomsQuery {
     110  public:
     111    AtomsTextQuery(std::string title, std::string _description = NULL);
     112    virtual ~AtomsTextQuery();
    86113    virtual bool handle();
    87114  };
     
    89116  class MoleculeTextQuery : public Dialog::MoleculeQuery {
    90117  public:
    91     MoleculeTextQuery(std::string title, molecule **_target, std::string _description = NULL);
     118    MoleculeTextQuery(std::string title, std::string _description = NULL);
    92119    virtual ~MoleculeTextQuery();
     120    virtual bool handle();
     121  };
     122
     123  class MoleculesTextQuery : public Dialog::MoleculesQuery {
     124  public:
     125    MoleculesTextQuery(std::string title, std::string _description = NULL);
     126    virtual ~MoleculesTextQuery();
    93127    virtual bool handle();
    94128  };
     
    96130  class VectorTextQuery : public Dialog::VectorQuery {
    97131  public:
    98     VectorTextQuery(std::string title,Vector *_target,bool _check, std::string _description = NULL);
     132    VectorTextQuery(std::string title,bool _check, std::string _description = NULL);
    99133    virtual ~VectorTextQuery();
     134    virtual bool handle();
     135  };
     136
     137  class VectorsTextQuery : public Dialog::VectorsQuery {
     138  public:
     139    VectorsTextQuery(std::string title,bool _check, std::string _description = NULL);
     140    virtual ~VectorsTextQuery();
    100141    virtual bool handle();
    101142  };
     
    103144  class BoxTextQuery : public Dialog::BoxQuery {
    104145  public:
    105     BoxTextQuery(std::string title,Box* _cellSize, std::string _description = NULL);
     146    BoxTextQuery(std::string title, std::string _description = NULL);
    106147    virtual ~BoxTextQuery();
    107148    virtual bool handle();
     
    110151  class ElementTextQuery : public Dialog::ElementQuery {
    111152  public:
    112     ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description = NULL);
     153    ElementTextQuery(std::string title, std::string _description = NULL);
    113154    virtual ~ElementTextQuery();
     155    virtual bool handle();
     156  };
     157
     158  class ElementsTextQuery : public Dialog::ElementsQuery {
     159  public:
     160    ElementsTextQuery(std::string title, std::string _description = NULL);
     161    virtual ~ElementsTextQuery();
    114162    virtual bool handle();
    115163  };
  • src/World.cpp

    r7067bd6 r677e13  
    558558}
    559559
     560size_t World::countSelectedAtoms() const {
     561  size_t count = 0;
     562  for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
     563    count++;
     564  return count;
     565}
     566
     567bool World::isSelected(atom *atom) const {
     568  return selectedAtoms.find(atom->getId()) != selectedAtoms.end();
     569}
     570
     571const std::vector<atom *> World::getSelectedAtoms() const {
     572  std::vector<atom *> returnAtoms;
     573  returnAtoms.resize(countSelectedAtoms());
     574  int count = 0;
     575  for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
     576    returnAtoms[count++] = iter->second;
     577  return returnAtoms;
     578}
     579
     580
    560581// Molecules
    561582
     
    574595}
    575596
    576 void World::selectAllMoleculess(MoleculeDescriptor descr){
     597void World::selectAllMolecules(MoleculeDescriptor descr){
    577598  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
    578599  internal_MoleculeIterator end = moleculeEnd_internal();
     
    605626}
    606627
    607 void World::unselectAllMoleculess(MoleculeDescriptor descr){
     628void World::unselectAllMolecules(MoleculeDescriptor descr){
    608629  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
    609630  internal_MoleculeIterator end = moleculeEnd_internal();
     
    624645  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
    625646  unselectMoleculeOfAtom(atoms[id]);
     647}
     648
     649size_t World::countSelectedMolecules() const {
     650  size_t count = 0;
     651  for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
     652    count++;
     653  return count;
     654}
     655
     656bool World::isSelected(molecule *mol) const {
     657  return selectedMolecules.find(mol->getId()) != selectedMolecules.end();
     658}
     659
     660const std::vector<molecule *> World::getSelectedMolecules() const {
     661  std::vector<molecule *> returnMolecules;
     662  returnMolecules.resize(countSelectedMolecules());
     663  int count = 0;
     664  for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
     665    returnMolecules[count++] = iter->second;
     666  return returnMolecules;
    626667}
    627668
  • src/World.hpp

    r7067bd6 r677e13  
    265265  void unselectAtomsOfMolecule(molecule*);
    266266  void unselectAtomsOfMolecule(moleculeId_t);
     267  size_t countSelectedAtoms() const;
     268  bool isSelected(atom *_atom) const;
     269  const std::vector<atom *> getSelectedAtoms() const;
    267270
    268271  void clearMoleculeSelection();
    269272  void selectMolecule(molecule*);
    270273  void selectMolecule(moleculeId_t);
    271   void selectAllMoleculess(MoleculeDescriptor);
     274  void selectAllMolecules(MoleculeDescriptor);
    272275  void selectMoleculeOfAtom(atom*);
    273276  void selectMoleculeOfAtom(atomId_t);
    274277  void unselectMolecule(molecule*);
    275278  void unselectMolecule(moleculeId_t);
    276   void unselectAllMoleculess(MoleculeDescriptor);
     279  void unselectAllMolecules(MoleculeDescriptor);
    277280  void unselectMoleculeOfAtom(atom*);
    278281  void unselectMoleculeOfAtom(atomId_t);
     282  size_t countSelectedMolecules() const;
     283  bool isSelected(molecule *_mol) const;
     284  const std::vector<molecule *> getSelectedMolecules() const;
    279285
    280286  /******************** Iterators to selections *****************/
  • src/analysis_correlation.cpp

    r7067bd6 r677e13  
    2828/** Calculates the pair correlation between given elements.
    2929 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    30  * \param *molecules list of molecules structure
     30 * \param *molecules vector of molecules
    3131 * \param &elements vector of elements to correlate
    3232 * \return Map of doubles with values the pair of the two atoms.
    3333 */
    34 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements)
     34PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements)
    3535{
    3636  Info FunctionInfo(__func__);
     
    3939  Box &domain = World::getInstance().getDomain();
    4040
    41   if (molecules->ListOfMolecules.empty()) {
     41  if (molecules.empty()) {
    4242    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    4343    return outmap;
    4444  }
    45   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     45  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    4646    (*MolWalker)->doCountAtoms();
    4747
     
    6464
    6565  outmap = new PairCorrelationMap;
    66   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    67     if ((*MolWalker)->ActiveFlag) {
    68       DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    69       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    70       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    71         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    72         for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    73           if ((*MolOtherWalker)->ActiveFlag) {
    74             DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    75             for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    76               DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    77               if ((*iter)->getId() < (*runner)->getId()){
    78                 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    79                   if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    80                     distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
    81                     //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    82                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    83                   }
     66  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
     67    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     68    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     69      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     70      for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
     71        DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     72        for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     73          DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     74          if ((*iter)->getId() < (*runner)->getId()){
     75            for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     76              if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     77                distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
     78                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     79                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    8480              }
    85             }
    8681          }
    8782        }
     
    9994 * \return Map of doubles with values the pair of the two atoms.
    10095 */
    101 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
     96PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
    10297{
    10398  Info FunctionInfo(__func__);
     
    111106  Vector periodicOtherX;
    112107
    113   if (molecules->ListOfMolecules.empty()) {
     108  if (molecules.empty()) {
    114109    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    115110    return outmap;
    116111  }
    117   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     112  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    118113    (*MolWalker)->doCountAtoms();
    119114
     
    136131
    137132  outmap = new PairCorrelationMap;
    138   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    139     if ((*MolWalker)->ActiveFlag) {
    140       Matrix FullMatrix = World::getInstance().getDomain().getM();
    141       Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    142       DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    143       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    144       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    145         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    146         periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
    147         // go through every range in xyz and get distance
    148         for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    149           for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    150             for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    151               checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
    152               for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    153                 if ((*MolOtherWalker)->ActiveFlag) {
    154                   DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    155                   for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    156                     DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    157                     if ((*iter)->getId() < (*runner)->getId()){
    158                       for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    159                         if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    160                           periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3
    161                           // go through every range in xyz and get distance
    162                           for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
    163                             for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
    164                               for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
    165                                 checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX);
    166                                 distance = checkX.distance(checkOtherX);
    167                                 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    168                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    169                               }
    170                         }
     133  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
     134    Matrix FullMatrix = World::getInstance().getDomain().getM();
     135    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     136    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     137    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     138      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     139      periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     140      // go through every range in xyz and get distance
     141      for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     142        for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     143          for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     144            checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
     145            for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
     146                DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     147                for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     148                  DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     149                  if ((*iter)->getId() < (*runner)->getId()){
     150                    for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     151                      if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     152                        periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3
     153                        // go through every range in xyz and get distance
     154                        for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
     155                          for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
     156                            for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
     157                              checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX);
     158                              distance = checkX.distance(checkOtherX);
     159                              //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     160                              outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
     161                            }
     162                      }
    171163                    }
    172164                  }
    173165                }
    174               }
    175             }
    176166      }
    177167    }
     
    187177 * \return Map of dobules with values as pairs of atom and the vector
    188178 */
    189 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
     179CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point )
    190180{
    191181  Info FunctionInfo(__func__);
     
    194184  Box &domain = World::getInstance().getDomain();
    195185
    196   if (molecules->ListOfMolecules.empty()) {
     186  if (molecules.empty()) {
    197187    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    198188    return outmap;
    199189  }
    200   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     190  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    201191    (*MolWalker)->doCountAtoms();
    202192  outmap = new CorrelationToPointMap;
    203   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    204     if ((*MolWalker)->ActiveFlag) {
    205       DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    206       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    207         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    208         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    209           if ((*type == NULL) || ((*iter)->type == *type)) {
    210             distance = domain.periodicDistance(*(*iter)->node,*point);
    211             DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    212             outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    213           }
    214       }
    215     }
     193  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     194    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     195    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     196      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     197      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     198        if ((*type == NULL) || ((*iter)->type == *type)) {
     199          distance = domain.periodicDistance(*(*iter)->node,*point);
     200          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     201          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
     202        }
     203    }
     204  }
    216205
    217206  return outmap;
     
    225214 * \return Map of dobules with values as pairs of atom and the vector
    226215 */
    227 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
     216CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
    228217{
    229218  Info FunctionInfo(__func__);
     
    234223  Vector checkX;
    235224
    236   if (molecules->ListOfMolecules.empty()) {
     225  if (molecules.empty()) {
    237226    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    238227    return outmap;
    239228  }
    240   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     229  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    241230    (*MolWalker)->doCountAtoms();
    242231  outmap = new CorrelationToPointMap;
    243   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    244     if ((*MolWalker)->ActiveFlag) {
    245       Matrix FullMatrix = World::getInstance().getDomain().getM();
    246       Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    247       DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    248       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    249         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    250         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    251           if ((*type == NULL) || ((*iter)->type == *type)) {
    252             periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
    253             // go through every range in xyz and get distance
    254             for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    255               for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    256                 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    257                   checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
    258                   distance = checkX.distance(*point);
    259                   DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    260                   outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
    261                 }
    262           }
    263       }
    264     }
     232  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     233    Matrix FullMatrix = World::getInstance().getDomain().getM();
     234    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     235    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     236    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     237      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     238      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     239        if ((*type == NULL) || ((*iter)->type == *type)) {
     240          periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     241          // go through every range in xyz and get distance
     242          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     243            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     244              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     245                checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
     246                distance = checkX.distance(*point);
     247                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     248                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
     249              }
     250        }
     251    }
     252  }
    265253
    266254  return outmap;
     
    274262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    275263 */
    276 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
     264CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
    277265{
    278266  Info FunctionInfo(__func__);
     
    282270  Vector centroid;
    283271
    284   if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
     272  if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
    285273    DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    286274    return outmap;
    287275  }
    288   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     276  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    289277    (*MolWalker)->doCountAtoms();
    290278  outmap = new CorrelationToSurfaceMap;
    291   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    292     if ((*MolWalker)->ActiveFlag) {
    293       DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    294       if ((*MolWalker)->empty())
    295         DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
    296       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    297         DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
    298         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    299           if ((*type == NULL) || ((*iter)->type == *type)) {
    300             TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
    301             distance = Intersections.GetSmallestDistance();
    302             triangle = Intersections.GetClosestTriangle();
    303             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
    304           }
    305       }
    306     } else {
    307       DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
    308     }
     279  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     280    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << (*MolWalker)->name << "." << endl);
     281    if ((*MolWalker)->empty())
     282      DoLog(2) && (2) && (Log() << Verbose(2) << "\t is empty." << endl);
     283    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     284      DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
     285      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     286        if ((*type == NULL) || ((*iter)->type == *type)) {
     287          TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     288          distance = Intersections.GetSmallestDistance();
     289          triangle = Intersections.GetClosestTriangle();
     290          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
     291        }
     292    }
     293  }
    309294
    310295  return outmap;
     
    323308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    324309 */
    325 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     310CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    326311{
    327312  Info FunctionInfo(__func__);
     
    334319  Vector checkX;
    335320
    336   if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
     321  if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
    337322    DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    338323    return outmap;
    339324  }
    340   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     325  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    341326    (*MolWalker)->doCountAtoms();
    342327  outmap = new CorrelationToSurfaceMap;
    343328  double ShortestDistance = 0.;
    344329  BoundaryTriangleSet *ShortestTriangle = NULL;
    345   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    346     if ((*MolWalker)->ActiveFlag) {
    347       Matrix FullMatrix = World::getInstance().getDomain().getM();
    348       Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    349       DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    350       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    351         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    352         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    353           if ((*type == NULL) || ((*iter)->type == *type)) {
    354             periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
    355             // go through every range in xyz and get distance
    356             ShortestDistance = -1.;
    357             for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    358               for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    359                 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    360                   checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
    361                   TriangleIntersectionList Intersections(&checkX,Surface,LC);
    362                   distance = Intersections.GetSmallestDistance();
    363                   triangle = Intersections.GetClosestTriangle();
    364                   if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    365                     ShortestDistance = distance;
    366                     ShortestTriangle = triangle;
    367                   }
     330  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     331    Matrix FullMatrix = World::getInstance().getDomain().getM();
     332    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     333    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     334    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     335      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     336      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     337        if ((*type == NULL) || ((*iter)->type == *type)) {
     338          periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     339          // go through every range in xyz and get distance
     340          ShortestDistance = -1.;
     341          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     342            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     343              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     344                checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
     345                TriangleIntersectionList Intersections(&checkX,Surface,LC);
     346                distance = Intersections.GetSmallestDistance();
     347                triangle = Intersections.GetClosestTriangle();
     348                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
     349                  ShortestDistance = distance;
     350                  ShortestTriangle = triangle;
    368351                }
    369             // insert
    370             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
    371             //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    372           }
    373       }
    374     }
     352              }
     353          // insert
     354          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
     355          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     356        }
     357    }
     358  }
    375359
    376360  return outmap;
  • src/analysis_correlation.hpp

    r7067bd6 r677e13  
    2222// STL headers
    2323#include <map>
     24#include <vector>
    2425
    2526#include "defs.hpp"
     
    3334class element;
    3435class LinkedCell;
    35 class MoleculeListClass;
    3636class Tesselation;
    3737class Vector;
     
    4646/********************************************** declarations *******************************/
    4747
    48 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements);
    49 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point );
    50 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
    51 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
    52 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
    53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
     48PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements);
     49CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point );
     50CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
     51PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
     52CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
     53CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
    5454int GetBin ( const double value, const double BinWidth, const double BinStart );
    5555void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
  • src/unittests/ActionSequenceTest.cpp

    r7067bd6 r677e13  
    3333  virtual ~canUndoActionStub(){}
    3434
     35  virtual Dialog* createDialog(){
     36    return NULL;
     37  }
     38
    3539  virtual Action::state_ptr performCall(){
    3640    return Action::success;
     
    5559  cannotUndoActionStub() : Action("cannotUndoActionStub",false){}
    5660  virtual ~cannotUndoActionStub(){}
     61
     62  virtual Dialog* createDialog(){
     63    return NULL;
     64  }
    5765
    5866  virtual Action::state_ptr performCall(){
     
    8290  virtual ~wasCalledActionStub(){}
    8391
     92  virtual Dialog* createDialog(){
     93    return NULL;
     94  }
    8495  virtual Action::state_ptr performCall(){
    8596    called = true;
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r7067bd6 r677e13  
    1616#include "analysis_correlation.hpp"
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
     18
     19#include "Descriptors/MoleculeDescriptor.hpp"
    1820
    1921#include "atom.hpp"
     
    3840
    3941  // init private all pointers to zero
    40   TestList = NULL;
    4142  TestMolecule = NULL;
    4243  pointmap = NULL;
     
    7172  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7273
    73   TestList = World::getInstance().getMolecules();
    74   TestList->insert(TestMolecule);
    7574  TestMolecule->ActiveFlag = true;
    7675
     
    7978
    8079  // init maps
    81   pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
     80  World::getInstance().selectAllMolecules(AllMolecules());
     81  allMolecules = World::getInstance().getSelectedMolecules();
     82  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
     83  pointmap = CorrelationToPoint( allMolecules, elements, (const Vector *)point );
    8284  binmap = NULL;
    8385
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    r7067bd6 r677e13  
    3535private:
    3636
    37       MoleculeListClass *TestList;
     37      std::vector<molecule *> allMolecules;
    3838      molecule *TestMolecule;
    3939      element *hydrogen;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r7067bd6 r677e13  
    1616#include "analysis_correlation.hpp"
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
     18
     19#include "Descriptors/MoleculeDescriptor.hpp"
    1820
    1921#include "atom.hpp"
     
    4547
    4648  // init private all pointers to zero
    47   TestList = NULL;
    4849  TestSurfaceMolecule = NULL;
    4950  surfacemap = NULL;
     
    8384  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
    8485
    85   TestList = World::getInstance().getMolecules();
    8686  TestSurfaceMolecule->ActiveFlag = true;
    87   TestList->insert(TestSurfaceMolecule);
    8887
    8988  // init tesselation and linked cell
     
    116115  TestSurfaceMolecule->AddAtom(Walker);
    117116
    118   TestSurfaceMolecule->ActiveFlag = true;
    119   TestList->insert(TestSurfaceMolecule);
     117  World::getInstance().selectAllMolecules(AllMolecules());
     118  allMolecules = World::getInstance().getSelectedMolecules();
     119  CPPUNIT_ASSERT_EQUAL( (size_t) 2, allMolecules.size());
    120120
    121121  // init maps
     
    146146{
    147147  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
    148   CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
     148  CPPUNIT_ASSERT_EQUAL( (size_t)2, allMolecules.size() );
    149149  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
    150150  CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
     
    156156  // do the pair correlation
    157157  elements.push_back(hydrogen);
    158   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     158  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    159159//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    160160  CPPUNIT_ASSERT( surfacemap != NULL );
     
    166166  BinPairMap::iterator tester;
    167167  elements.push_back(hydrogen);
    168   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     168  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    169169  // put pair correlation into bins and check with no range
    170170//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
     
    182182  BinPairMap::iterator tester;
    183183  elements.push_back(hydrogen);
    184   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     184  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    185185//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    186186  // ... and check with [0., 2.] range
     
    201201  BinPairMap::iterator tester;
    202202  elements.push_back(carbon);
    203   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     203  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    204204//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    205205  // put pair correlation into bins and check with no range
     
    221221  BinPairMap::iterator tester;
    222222  elements.push_back(carbon);
    223   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     223  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    224224//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    225225  // ... and check with [0., 2.] range
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r7067bd6 r677e13  
    4343private:
    4444
    45       MoleculeListClass *TestList;
     45      std::vector<molecule *> allMolecules;
    4646      molecule *TestSurfaceMolecule;
    4747      element *hydrogen;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r7067bd6 r677e13  
    1616#include "analysis_correlation.hpp"
    1717#include "AnalysisPairCorrelationUnitTest.hpp"
     18
     19#include "Descriptors/MoleculeDescriptor.hpp"
    1820
    1921#include "World.hpp"
     
    4244
    4345  // init private all pointers to zero
    44   TestList = NULL;
    4546  TestMolecule = NULL;
    4647  correlationmap = NULL;
     
    7677  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7778
    78   TestList = World::getInstance().getMolecules();
    79   TestMolecule->ActiveFlag = true;
    80   TestList->insert(TestMolecule);
    81 
    8279  // init maps
    83   correlationmap = PairCorrelation( TestList, elements);
     80  World::getInstance().selectAllMolecules(AllMolecules());
     81  allMolecules = World::getInstance().getSelectedMolecules();
     82  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
     83  correlationmap = PairCorrelation( allMolecules, elements);
    8484  binmap = NULL;
    8585
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    r7067bd6 r677e13  
    3535private:
    3636
    37       MoleculeListClass *TestList;
     37      std::vector<molecule *> allMolecules;
    3838      molecule *TestMolecule;
    3939      element *hydrogen;
  • test_all.sh

    r7067bd6 r677e13  
    2121outfile="test.log";
    2222logfile="full.log";
     23noprocs=1;
    2324docheck=0;
    2425docheck_mem=0;
     
    4041  echo "  -o <outfile>          Outfile to use for test results";
    4142  echo "  -f <logfile>          File to use for output from commands";
     43  echo "  -j <no_proc>          Parallel compiling and tests";
    4244  echo "  -s                    Short tests (no memcheck)";
    4345  echo "  -c                    Only configure and compile (implies -s)";
    4446  echo "  -O <opt-level>        Only compile this optimization level";
    4547  echo "  -t <tmpDir>           Use tmpDir as temporary directory";
    46   echo "  -p <prefix>           Prefix to use for directory names (standart MolecuilderTest)";
    47 }
    48 
    49 while getopts “ho:f:scO:t:p:” OPTION
     48  echo "  -p <prefix>           Prefix to use for directory names (standard MolecuilderTest)";
     49}
     50
     51while getopts “ho:f:j:scO:t:p:” OPTION
    5052do
    5153  case $OPTION in
     
    6062     logfile="$OPTARG";
    6163     ;;
     64   j)
     65     noprocs=("$OPTARG");
     66     ;;
    6267   s)
    6368     docheck_mem=1;
     
    105110function compile(){
    106111  echo "Making";
    107   make all install >>$logfile 2>&1;
     112  if [ $noprocs -gt 1 ]; then
     113    make -j$noprocs all install >>$logfile 2>&1;
     114  else
     115    make all install >>$logfile 2>&1;
     116  fi
    108117}
    109118
    110119function check(){
    111120  echo "Checking";
    112   make check >> $logfile 2>&1;
     121  if [ $noprocs -gt 1 ]; then
     122    make -j$noprocs check >> $logfile 2>&1;
     123  else
     124    make check >> $logfile 2>&1;
     125  fi
    113126}
    114127
  • tests/Tesselations/defs.in

    r7067bd6 r677e13  
    5454        #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
    5555        if [ -e $mol.dbond ]; then
    56                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
     56                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    5757        else
    58                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
     58                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    5959        fi
    6060        #echo "Molecuilder done with exitcode $exitcode."
  • tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat

    r7067bd6 r677e13  
    881.2492 0.921941 -0.849545 18.7222
    991.2492 0.921941 0.930455 18.7222
    10 -2.4985 -1.22006 -0.849545 27.4727
     10-2.4985 -1.22006 -0.849545 19.9769
    1111-2.4985 -1.22006 0.930455 19.9769
    12122.4985 -1.22006 0.930455 27.4727
    13 2.4985 -1.22006 -0.849545 19.9769
     132.4985 -1.22006 -0.849545 27.4727
    1414-4.6377 -0.336759 0.0404545 21.541
    1515-3.7477 0.921941 0.930455 18.8853
     
    2121-1.2492 0.292641 0.0404545 23.0167
    22221.2492 0.292641 0.0404545 23.0172
    23 -2.4985 -0.590759 0.0404545 18.9798
    24 2.4985 -0.590759 0.0404545 18.9798
     23-2.4985 -0.590759 0.0404545 21.8516
     242.4985 -0.590759 0.0404545 16.0669
    2525-3.7477 0.292641 0.0404545 39.5267
    26263.7477 0.292641 0.0404545 20.5497
     
    80801 2 17
    81811 2 17
    82 2 17 21
    83 2 10 21
     8210 17 21
     832 10 17
    84841 17 20
    85851 8 20
     
    88888 11 20
    89897 11 20
    90 7 17 20
    91 2 7 17
     902 17 20
     912 7 20
  • tests/regression/testsuite-analysis.at

    r7067bd6 r677e13  
    44AT_KEYWORDS([analysis])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/pre/test.conf .], 0)
    6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
    77AT_CHECK([fgrep "Begin of PairCorrelation" stdout], 0, [ignore], [ignore])
    88#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/post/$file], 0, [ignore], [ignore])
     
    1414AT_KEYWORDS([analysis])
    1515AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/pre/test.conf .], 0)
    16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])
     16AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])
    1717#AT_CHECK([file=output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    1818AT_CHECK([file=bin_output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    19 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])
     19AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])
    2020#AT_CHECK([file=output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    2121AT_CHECK([file=bin_output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    22 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])
     22AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])
    2323#AT_CHECK([file=output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    2424AT_CHECK([file=bin_output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
     
    2929AT_KEYWORDS([analysis])
    3030AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/pre/test.conf .], 0)
    31 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 -C P --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
     31AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 --select-all-molecules --point-correlation --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
    3232AT_CHECK([fgrep "Begin of CorrelationToPoint" stdout], 0, [ignore], [ignore])
    3333#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/post/$file], 0, [ignore], [ignore])
     
    3939AT_KEYWORDS([analysis])
    4040AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/pre/test.conf .], 0)
    41 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I -C S --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr])
     41AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --select-all-molecules --unselect-molecule-by-id 207 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr])
    4242AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore])
    4343#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore])
  • tests/regression/testsuite-filling.at

    r7067bd6 r677e13  
    1818AT_KEYWORDS([filling])
    1919AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/pre/test.conf .], 0)
    20 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -u 1.3 --molecule-by-id 0], 0, [stdout], [stderr])
     20AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr])
    2121#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/post/$file], 0, [ignore], [ignore])
    2222AT_CLEANUP
  • tests/regression/testsuite-fragmentation.at

    r7067bd6 r677e13  
    1212AT_SETUP([Fragmentation - Fragmentation])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/2/pre/test.conf .], 0)
    14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id 0 --distance 1.55 --order 2], 0, [ignore], [ignore])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
    1515AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5
    1616], [ignore])
     
    2121AT_SETUP([Fragmentation - BROKEN: Fragmentation is at MaxOrder])
    2222AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/3/pre/test.conf .], 0)
    23 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id 0 --distance 1.55 --order 2], 0, [ignore], [ignore])
    24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id 0 --distance 1.55 --order 2], [ignore], [ignore], [ignore])
     23AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
     24AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], [ignore], [ignore], [ignore])
    2525AT_CLEANUP
  • tests/regression/testsuite-molecules.at

    r7067bd6 r677e13  
    44AT_KEYWORDS([Molecules])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/1/pre/test.* .], 0)
    6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 -A test.dbond --molecule-by-id 0], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 --select-molecule-by-id 0 -A test.dbond], 0, [stdout], [stderr])
    77AT_CHECK([fgrep "Looking for atoms 2 and 9." stdout], 0, [ignore], [ignore])
    88AT_CLEANUP
     
    1212AT_KEYWORDS([Molecules])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/pre/test.conf .], 0)
    14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -j test.dbond --molecule-by-id 0], 0, [stdout], [stderr])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -j test.dbond], 0, [stdout], [stderr])
    1515AT_CHECK([file=test.dbond; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
    16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -J test.adj --molecule-by-id 0], 0, [stdout], [stderr])
     16AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -J test.adj], 0, [stdout], [stderr])
    1717AT_CHECK([file=test.adj; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
    1818AT_CLEANUP
     
    2222AT_KEYWORDS([Molecules])
    2323AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/pre/test.conf .], 0)
    24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -S test.ekin --molecule-by-id 0], 0, [stdout], [stderr])
     24AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -S test.ekin], 0, [stdout], [stderr])
    2525AT_CHECK([file=test.ekin; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/post/$file], 0, [ignore], [ignore])
    2626AT_CLEANUP
     
    3030AT_KEYWORDS([Molecules])
    3131AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/4/pre/test.conf .], 0)
    32 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -L teststep --start-step 0 --end-step 1 --molecule-by-id 0 --id-mapping 1], 0, [stdout], [stderr])
     32AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -L teststep --start-step 0 --end-step 1 --id-mapping 1], 0, [stdout], [stderr])
    3333AT_CLEANUP
    3434
     
    3737AT_KEYWORDS([Molecules])
    3838AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/pre/test.* .], 0)
    39 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -P test.forces --molecule-by-id 0], 0, [stdout], [stderr])
     39AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -P test.forces], 0, [stdout], [stderr])
    4040#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/post/$file], 0, [ignore], [ignore])
    4141AT_CLEANUP
     
    4545AT_KEYWORDS([Molecules])
    4646AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test.* .], 0)
    47 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t "1., 1., 1." --molecule-by-id 0 --periodic 0], 0, [stdout], [stderr])
     47AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "1., 1., 1." --periodic 0], 0, [stdout], [stderr])
    4848AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore])
    4949AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test2.* .], 0)
    50 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -t "-1., -1., -1." --molecule-by-id 0 --periodic 0], 0, [stdout], [stderr])
     50AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "-1., -1., -1." --periodic 0], 0, [stdout], [stderr])
    5151AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore])
    5252AT_CLEANUP
     
    5656AT_KEYWORDS([Molecules])
    5757AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/pre/test.* .], 0)
    58 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t "12., 12., 12." --molecule-by-id 0 --periodic 1], 0, [stdout], [stderr])
     58AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "12., 12., 12." --periodic 1], 0, [stdout], [stderr])
    5959AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/post/$file], 0, [ignore], [ignore])
    6060AT_CLEANUP
     
    6464AT_KEYWORDS([Molecules])
    6565AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0)
    66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -m 0], 0, [stdout], [stderr])
     66AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m 0], 0, [stdout], [stderr])
    6767#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
    6868AT_CLEANUP
  • tests/regression/testsuite-simple_configuration.at

    r7067bd6 r677e13  
    2929AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
    3030AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
    31 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 0, [ignore], [ignore])
    32 AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
    33 AT_CHECK([file=test2.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
    34 AT_CHECK([file=test2.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
     31AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 134, [ignore], [ignore])
    3532AT_CLEANUP
    3633
     
    3936AT_KEYWORDS([configuration])
    4037AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0)
    41 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ -E 6 --atom-by-id 0], 0, [ignore], [ignore])
     38AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 ], 0, [ignore], [ignore])
    4239AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])
    4340AT_CLEANUP
     
    4744AT_KEYWORDS([configuration])
    4845AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0)
    49 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -r 0], 0, [ignore], [ignore])
     46AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz --select-atom-by-id 0 -r], 0, [ignore], [ignore])
    5047AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
    5148AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
  • tests/regression/testsuite-tesselation.at

    r7067bd6 r677e13  
    44AT_KEYWORDS([Tesselation])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/pre/* .], 0)
    6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
    77AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
    88#AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
     
    1212AT_SETUP([Tesselation - Convex Envelope])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/pre/* .], 0)
    14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --convex-envelope 0 --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
    1515AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
    1616#AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
     
    2222AT_SETUP([Tesselation - Big non-Convex Envelope])
    2323AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/pre/* .], 0)
    24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
     24AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
    2525AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
    2626#AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
     
    3030#AT_SETUP([Tesselation - big convex Envelope])
    3131#AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/pre/* .], 0)
    32 #AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])
     32#AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])
    3333#AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
    3434#AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
Note: See TracChangeset for help on using the changeset viewer.