Changes in / [19dfdf:3fa16b]


Ignore:
Files:
246 added
3 deleted
126 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r19dfdf r3fa16b  
    2323        cd doc && $(MAKE) doxygen-doc
    2424
     25guicheck:
     26        cd tests && $(MAKE) guicheck
    2527extracheck:
    2628        cd tests && $(MAKE) extracheck
  • configure.ac

    r19dfdf r3fa16b  
    427427AC_CONFIG_FILES([tests/Fragmentations/molecuilder], [chmod +x tests/Fragmentations/molecuilder])
    428428
     429AC_CONFIG_TESTDIR(tests/GuiChecks)
     430AC_CONFIG_FILES([
     431        tests/GuiChecks/atlocal
     432        tests/GuiChecks/Makefile])
     433AC_CONFIG_FILES([tests/GuiChecks/molecuilder], [chmod +x tests/GuiChecks/molecuilder])
     434AC_CONFIG_FILES([tests/GuiChecks/molecuilderguitest], [chmod +x tests/GuiChecks/molecuilderguitest])
     435
    429436AC_CONFIG_TESTDIR(tests/JobMarket)
    430437AC_CONFIG_FILES([
  • doc/userguide/userguide.xml

    r19dfdf r3fa16b  
    962962        </section>
    963963
     964        <section xml:id='atoms.saturate-atom'>
     965          <title xml:id='atoms.saturate-atom.title'>Saturating atoms</title>
     966
     967          <para>Newly instantiated atoms have no bonds to any other atom. If
     968          you want to fill up their valence by a slew of hydrogen atoms
     969          residing on a sphere around this atom, use this action.</para>
     970
     971          <programlisting>
     972                ... --saturate-atoms
     973          </programlisting>
     974
     975          <para>A number of hydrogen atoms is added. The number corrresponding
     976          to the valence of each selected atom. They are placed in the same
     977          distance to this atom and approximately with same distance to their
     978          nearest neighbors.</para>
     979        </section>
     980
    964981        <section xml:id='atoms.translate-atom'>
    965982          <title xml:id='atoms.translate-atom.title'>Translating atoms</title>
     
    11331150        </section>
    11341151
    1135         <section xml:id='bond.add-bond'>
    1136           <title xml:id='bond.add-bond.title'>Adding a bond manually</title>
     1152        <section xml:id='bond.adds-bond'>
     1153          <title xml:id='bond.adds-bond.title'>Adding a bond manually</title>
    11371154
    11381155          <para>When the automatically created adjacency or bond graph
    11391156          contains faulty bonds or lacks some, you can add them manually.
    1140           First, you must have selected two atoms.</para>
    1141 
    1142           <programlisting>... --add-bond</programlisting>
    1143         </section>
    1144 
    1145         <section xml:id='bond.remove-bond'>
    1146           <title xml:id='bond.remove-bond.title'>Removing a bond manually
     1157          </para>
     1158
     1159          <programlisting>... --add-bonds</programlisting>
     1160
     1161          <para>If two atoms are selected, the single bond in between, if not
     1162          present, is added. If more than two atoms are selected, than the
     1163          bond between any pair of these is added.</para>
     1164         <note><para>This is especially useful in conjunction with the
     1165          fragmentation scheme. If you want to know the contribution from
     1166          certain fragments whose subgraph is not connected you can simply
     1167          make the associated subset of atoms connected by selecting all
     1168          bonds and adding the bonds.</para>
     1169         </note>
     1170        </section>
     1171
     1172        <section xml:id='bond.remove-bonds'>
     1173          <title xml:id='bond.remove-bonds.title'>Removing a bond manually
    11471174          </title>
    11481175
     
    11501177          bond.</para>
    11511178
    1152           <programlisting>... --remove-bond</programlisting>
     1179          <programlisting>... --remove-bonds</programlisting>
     1180
     1181          <para>Similarly, if more than two atoms are selected, then all bonds
     1182          found between any pair of these is removed.</para>
    11531183        </section>
    11541184
     
    25112541          <programlisting>... -v 4</programlisting>
    25122542        </section>
     2543       
     2544        <section xml:id='various.dry-run'>
     2545          <title xml:id='various.dry-run.title'>Dry runs</title>
     2546
     2547          <para>A "dry run" refers to a test run where commands are not
     2548          actually executed. You may bracket a certain set of actions by
     2549          putting --dry-run before and --no-dry-run afterwards. Then, all
     2550          action in between will be looked at but not executed, i.e. they
     2551          make it to the history but nothing is changed in the World.</para>
     2552
     2553          <para>As an example, the following listing contains the adding of a
     2554          hydrogen atom at position (5,5,5) inside the aforementioned dry run
     2555          statements. Hence, no hydrogen atom is added but the add action is
     2556          stored in the history and will make it to a stored session.</para>
     2557
     2558          <programlisting>
     2559          ... --dry-run \
     2560          --add-atom 1 --domain-position "5,5,5"
     2561          --no-dry-run
     2562          </programlisting>
     2563
     2564        </section>
    25132565
    25142566        <section xml:id='various.element-db'>
  • src/Actions/ActionQueue.cpp

    r19dfdf r3fa16b  
    6363    history(new ActionHistory),
    6464#ifndef HAVE_ACTION_THREAD
    65     lastActionOk(true)
     65    lastActionOk(true),
    6666#else
    6767    CurrentAction(0),
    6868    lastActionOk(true),
    6969    run_thread(boost::bind(&ActionQueue::run, this)),
    70     run_thread_isIdle(true)
    71 #endif
     70    run_thread_isIdle(true),
     71#endif
     72    dryrun_flag(false)
    7273{
    7374  // channels of observable
     
    109110#ifndef HAVE_ACTION_THREAD
    110111  try {
    111     newaction->call();
     112    if (!isDryRun(newaction))
     113      newaction->call();
    112114    lastActionOk = true;
    113115  } catch(ActionFailureException &e) {
     
    175177      LOG(0, "Calling Action " << actionqueue[CurrentAction]->getName() << " ... ");
    176178      try {
    177         actionqueue[CurrentAction]->call();
     179        if (!isDryRun(actionqueue[CurrentAction]))
     180          actionqueue[CurrentAction]->call();
    178181        pushStatus("SUCCESS: Action "+actionqueue[CurrentAction]->getName()+" successful.");
    179182        lastActionOk = true;
     
    380383}
    381384
     385bool ActionQueue::isDryRun(const Action *_nextaction) const
     386{
     387  bool status = dryrun_flag;
     388  status &= (_nextaction->getName() != "no-dry-run");
     389  return status;
     390}
    382391
    383392CONSTRUCT_SINGLETON(ActionQueue)
  • src/Actions/ActionQueue.hpp

    r19dfdf r3fa16b  
    4040class ActionRegistry;
    4141class ActionTrait;
     42class DryRunAdvocate;
    4243
    4344namespace Queuedetail {
     
    178179  { return StatusList; }
    179180
     181  /** Getter for isDryRun state flag.
     182   *
     183   * \return true - ActionQueue does not execute Actions but skips, false - else
     184   */
     185  bool getDryRun() const
     186  { return dryrun_flag; }
     187
    180188private:
    181189  //!> grant Action access to internal history functions.
     
    183191  //!> grant CommandLineParser access to stop and clearQueue()
    184192  friend class ::CommandLineParser;
     193  //!> grant Advocate access to setting dryrun
     194  friend class DryRunAdvocate;
    185195
    186196  /** Wrapper function to add state to ActionHistory.
     
    255265  void insertAction(Action *_action, enum Action::QueryOptions state);
    256266
     267  /** Sets the current state of the \a isDryRun flag.
     268   *
     269   * \param _dryrun true - Actions will not get executed anymore, false - else
     270   */
     271  void setDryRun(const bool _dryrun)
     272  { dryrun_flag = _dryrun; }
     273
     274  /** Checks whether next Action should be skipped or not.
     275   *
     276   * \param _nextaction next action to execute to inspect whether it unsets dryrun_flag
     277   * \return true - dryrun_flag set and \a _nextaction is not unsetting dry run
     278   */
     279  bool isDryRun(const Action *_nextaction) const;
     280
    257281private:
    258282  /** Private cstor for ActionQueue.
     
    309333  //!> internal list of status messages from Actions for UIs to display
    310334  ActionStatusList StatusList;
     335
     336  //!> internal flag whether to call or skip actions (i.e. do a dry run)
     337  bool dryrun_flag;
    311338};
    312339namespace Queuedetail {
  • src/Actions/ActionSequence.cpp

    r19dfdf r3fa16b  
    3737#include "Actions/ActionSequence.hpp"
    3838#include "Actions/Action.hpp"
     39#include "Actions/ActionExceptions.hpp"
    3940#include "UIElements/Dialog.hpp"
    4041
     
    5354{
    5455  // we need to override copy cstor as we have pointer referenced objects
    55   for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
     56  for(actionSet::const_iterator it=_other.actions.begin(); it!=_other.actions.end(); it++){
    5657    actions.push_back((*it)->clone());
    5758  }
     
    119120      // we bypass the normal call
    120121      ActionState::ptr state = (*it)->performCall();
     122      if (state == Action::failure)
     123        throw ActionFailureException() << ActionNameString((*it)->getName());
    121124      states.push_back(state);
    122125    }
  • src/Actions/ActionSequence.hpp

    r19dfdf r3fa16b  
    1919#include <deque>
    2020
     21class ActionSequenceTest;
     22
    2123namespace MoleCuilder {
    2224
     
    2729{
    2830  friend class MakroAction;
     31  //!> grant unit test access to private sequence
     32  friend class ::ActionSequenceTest;
    2933public:
    3034  typedef std::deque<Action*> actionSet;
  • src/Actions/Action_impl_pre.hpp

    r19dfdf r3fa16b  
    175175    << "\"" << toPythonString(params. \
    176176        BOOST_PP_SEQ_ELEM(n, paramreferences) \
    177         .get()) \
     177        .getUnvalidated()) \
    178178    << "\"";
    179179
  • src/Actions/BondAction/BondAddAction.cpp

    r19dfdf r3fa16b  
    5757ActionState::ptr BondAddAction::performCall() {
    5858  // check preconditions
    59   if (World::getInstance().countSelectedAtoms() != 2) {
    60     STATUS("Exactly two atoms must be selected for BondAction Add.");
     59  World& world = World::getInstance();
     60  if (world.countSelectedAtoms() <= 1) {
     61    STATUS("There must be at least two atoms selected for BondAction Add.");
    6162    return Action::failure;
    6263  }
    63   const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
    64   if (selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1])) {
    65     STATUS("There already is a bond in between the two selected atoms.");
     64
     65  bondPairIds_t bondPairIds;
     66  for (World::AtomSelectionConstIterator firstiter = world.beginAtomSelection();
     67      firstiter != world.endAtomSelection(); ++firstiter) {
     68    for (World::AtomSelectionConstIterator seconditer = firstiter;
     69        seconditer != world.endAtomSelection(); ++seconditer) {
     70      if (firstiter == seconditer)
     71        continue;
     72      if (!(firstiter->second)->IsBondedTo(WorldTime::getTime(), seconditer->second))
     73        bondPairIds.push_back(
     74            std::make_pair((firstiter->second)->getId(), (seconditer->second)->getId()));
     75    }
     76  }
     77  if (bondPairIds.empty()) {
     78    STATUS("All bonds are already present.");
    6679    return Action::failure;
    6780  }
    6881
    6982  // create undo
    70   BondAddState *UndoState = new BondAddState(selected_atoms[0]->getId(), selected_atoms[1]->getId(), params);
     83  BondAddState *UndoState = new BondAddState(bondPairIds, params);
    7184
    7285  // execute action
    73   selected_atoms[0]->addBond(WorldTime::getTime(), selected_atoms[1]);
    74   ASSERT( selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1]),
     86  for (bondPairIds_t::const_iterator iter = bondPairIds.begin();
     87      iter != bondPairIds.end(); ++iter) {
     88    atom *firstatom = world.getAtom(AtomById(iter->first));
     89    atom *secondatom = world.getAtom(AtomById(iter->second));
     90    ASSERT((firstatom != NULL) && (secondatom != NULL),
     91        "BondAddAction::performCall() - at least one of the ids "
     92        +toString(iter->first)+" or "+toString(iter->second)+" is not present.");
     93    firstatom->addBond(WorldTime::getTime(), secondatom);
     94    ASSERT( firstatom->IsBondedTo(WorldTime::getTime(), secondatom),
    7595      "BondAddAction::performCall() - adding bond in between "
    76       +toString(*selected_atoms[0])+" and "+toString(*selected_atoms[1])+" failed.");
     96      +toString(*firstatom)+" and "+toString(*secondatom)+" failed.");
     97  }
    7798
    7899  return ActionState::ptr(UndoState);
     
    83104
    84105  // check whether bond already existed
    85   atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
    86   atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
    87   ASSERT((first != NULL) && (second != NULL),
    88       "BondAddAction::performUndo() - at least one of the ids "
    89       +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
    90   if (first->IsBondedTo(WorldTime::getTime(), second)) {
    91     first->removeBond(WorldTime::getTime(), second);
    92   } else {
    93     ELOG(2, "There is no bond in between "+toString(state->firstId)
    94         +" and "+toString(state->secondId)+".");
     106  World& world = World::getInstance();
     107  for (bondPairIds_t::const_iterator iter = state->bondPairIds.begin();
     108      iter != state->bondPairIds.end(); ++iter) {
     109    atom *firstatom = world.getAtom(AtomById(iter->first));
     110    atom *secondatom = world.getAtom(AtomById(iter->second));
     111    ASSERT((firstatom != NULL) && (secondatom != NULL),
     112        "BondAddAction::performCall() - at least one of the ids "
     113        +toString(iter->first)+" or "+toString(iter->second)+" is not present.");
     114    if (firstatom->IsBondedTo(WorldTime::getTime(), secondatom)) {
     115      firstatom->removeBond(WorldTime::getTime(), secondatom);
     116    } else {
     117      ELOG(2, "There is no bond in between "+toString(iter->first)
     118          +" and "+toString(iter->second)+".");
     119    }
    95120  }
    96121
     
    102127
    103128  // check whether bond already existed
    104   atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
    105   atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
    106   ASSERT((first != NULL) && (second != NULL),
    107       "BondAddAction::performRedo() - at least one of the ids "
    108       +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
    109   if (!first->IsBondedTo(WorldTime::getTime(), second)) {
    110     first->addBond(WorldTime::getTime(), second);
    111   } else {
    112     ELOG(2, "There is already a bond in between "+toString(state->firstId)
    113         +" and "+toString(state->secondId)+".");
     129  World& world = World::getInstance();
     130  for (bondPairIds_t::const_iterator iter = state->bondPairIds.begin();
     131      iter != state->bondPairIds.end(); ++iter) {
     132    atom * const firstatom = world.getAtom(AtomById(iter->first));
     133    atom * const secondatom = world.getAtom(AtomById(iter->second));
     134    ASSERT((firstatom != NULL) && (secondatom != NULL),
     135        "BondAddAction::performCall() - at least one of the ids "
     136        +toString(iter->first)+" or "+toString(iter->second)+" is not present.");
     137    if (!firstatom->IsBondedTo(WorldTime::getTime(), secondatom)) {
     138      firstatom->addBond(WorldTime::getTime(), secondatom);
     139    } else {
     140      ELOG(2, "There is already a bond in between "+toString(iter->first)
     141          +" and "+toString(iter->second)+".");
     142    }
    114143  }
    115144
  • src/Actions/BondAction/BondAddAction.def

    r19dfdf r3fa16b  
    88// all includes and forward declarations necessary for non-integral types below
    99#include "types.hpp"
     10#include <vector>
     11#include <utility>
     12
     13typedef std::vector<std::pair<atomId_t,atomId_t> > bondPairIds_t;
    1014
    1115// i.e. there is an integer with variable name Z that can be found in
     
    2024#undef paramvalids
    2125
    22 #define statetypes (atomId_t)(atomId_t)
    23 #define statereferences (firstId)(secondId)
     26#define statetypes (bondPairIds_t)
     27#define statereferences (bondPairIds)
    2428
    2529// some defines for all the names, you may use ACTION, STATE and PARAMS
     
    2832#define MENUPOSITION 1
    2933#define ACTIONNAME Add
    30 #define TOKEN "add-bond"
     34#define TOKEN "add-bonds"
    3135
    3236// finally the information stored in the ActionTrait specialization
    33 #define DESCRIPTION "add bond in between two selected atoms"
     37#define DESCRIPTION "add bonds in between any number of selected atoms"
    3438#undef SHORTFORM
  • src/Actions/BondAction/BondRemoveAction.cpp

    r19dfdf r3fa16b  
    5757ActionState::ptr BondRemoveAction::performCall() {
    5858  // check preconditions
    59   if (World::getInstance().countSelectedAtoms() != 2) {
    60     STATUS("Exactly two atoms must be selected for BondAction Remove.");
     59  World& world = World::getInstance();
     60  if (world.countSelectedAtoms() <= 1) {
     61    STATUS("At least two atoms must be selected for BondAction Remove.");
    6162    return Action::failure;
    6263  }
    63   const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
    64   if (!selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1])) {
    65     STATUS("There is no bond in between the two selected atoms.");
     64
     65  bondPairIds_t bondPairIds;
     66  for (World::AtomSelectionConstIterator firstiter = world.beginAtomSelection();
     67      firstiter != world.endAtomSelection(); ++firstiter) {
     68    for (World::AtomSelectionConstIterator seconditer = firstiter;
     69        seconditer != world.endAtomSelection(); ++seconditer) {
     70      if (firstiter == seconditer)
     71        continue;
     72      if ((firstiter->second)->IsBondedTo(WorldTime::getTime(), seconditer->second))
     73        bondPairIds.push_back(
     74            std::make_pair((firstiter->second)->getId(), (seconditer->second)->getId()));
     75    }
     76  }
     77  if (bondPairIds.empty()) {
     78    STATUS("No bonds are present.");
    6679    return Action::failure;
    6780  }
    6881
    6982  // create undo
    70   BondRemoveState *UndoState = new BondRemoveState(selected_atoms[0]->getId(), selected_atoms[1]->getId(), params);
     83  BondRemoveState *UndoState = new BondRemoveState(bondPairIds, params);
    7184
    7285  // execute action
    73   selected_atoms[0]->removeBond(WorldTime::getTime(), selected_atoms[1]);
    74   ASSERT( !selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1]),
    75       "BondRemoveAction::performCall() - removing bond in between "
    76       +toString(*selected_atoms[0])+" and "+toString(*selected_atoms[1])+" failed.");
     86  for (bondPairIds_t::const_iterator iter = bondPairIds.begin();
     87      iter != bondPairIds.end(); ++iter) {
     88    atom *firstatom = world.getAtom(AtomById(iter->first));
     89    atom *secondatom = world.getAtom(AtomById(iter->second));
     90    ASSERT((firstatom != NULL) && (secondatom != NULL),
     91        "BondAddAction::performCall() - at least one of the ids "
     92        +toString(iter->first)+" or "+toString(iter->second)+" is not present.");
     93    firstatom->removeBond(WorldTime::getTime(), secondatom);
     94    ASSERT( !firstatom->IsBondedTo(WorldTime::getTime(), secondatom),
     95      "BondAddAction::performCall() - adding bond in between "
     96      +toString(*firstatom)+" and "+toString(*secondatom)+" failed.");
     97  }
    7798
    7899  return ActionState::ptr(UndoState);
     
    82103  BondRemoveState *state = assert_cast<BondRemoveState*>(_state.get());
    83104
    84   // check whether bond already existed
    85   atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
    86   atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
    87   ASSERT((first != NULL) && (second != NULL),
    88       "BondRemoveAction::performUndo() - at least one of the ids "
    89       +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
    90   if (!first->IsBondedTo(WorldTime::getTime(), second)) {
    91     first->addBond(WorldTime::getTime(), second);
    92   } else {
    93     ELOG(2, "There is already a bond in between "+toString(state->firstId)
    94         +" and "+toString(state->secondId)+".");
     105  World& world = World::getInstance();
     106  for (bondPairIds_t::const_iterator iter = state->bondPairIds.begin();
     107      iter != state->bondPairIds.end(); ++iter) {
     108    atom * const firstatom = world.getAtom(AtomById(iter->first));
     109    atom * const secondatom = world.getAtom(AtomById(iter->second));
     110    ASSERT((firstatom != NULL) && (secondatom != NULL),
     111        "BondAddAction::performCall() - at least one of the ids "
     112        +toString(iter->first)+" or "+toString(iter->second)+" is not present.");
     113    if (!firstatom->IsBondedTo(WorldTime::getTime(), secondatom)) {
     114      firstatom->addBond(WorldTime::getTime(), secondatom);
     115    } else {
     116      ELOG(2, "There is already a bond in between "+toString(iter->first)
     117          +" and "+toString(iter->second)+".");
     118    }
    95119  }
    96120
     
    101125  BondRemoveState *state = assert_cast<BondRemoveState*>(_state.get());
    102126
    103   // check whether bond already existed
    104   atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
    105   atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
    106   ASSERT((first != NULL) && (second != NULL),
    107       "BondRemoveAction::performRedo() - at least one of the ids "
    108       +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
    109   if (first->IsBondedTo(WorldTime::getTime(), second)) {
    110     first->removeBond(WorldTime::getTime(), second);
    111   } else {
    112     ELOG(2, "There is no bond in between "+toString(state->firstId)
    113         +" and "+toString(state->secondId)+".");
     127  World& world = World::getInstance();
     128  for (bondPairIds_t::const_iterator iter = state->bondPairIds.begin();
     129      iter != state->bondPairIds.end(); ++iter) {
     130    atom *firstatom = world.getAtom(AtomById(iter->first));
     131    atom *secondatom = world.getAtom(AtomById(iter->second));
     132    ASSERT((firstatom != NULL) && (secondatom != NULL),
     133        "BondAddAction::performCall() - at least one of the ids "
     134        +toString(iter->first)+" or "+toString(iter->second)+" is not present.");
     135    if (firstatom->IsBondedTo(WorldTime::getTime(), secondatom)) {
     136      firstatom->removeBond(WorldTime::getTime(), secondatom);
     137    } else {
     138      ELOG(2, "There is no bond in between "+toString(iter->first)
     139          +" and "+toString(iter->second)+".");
     140    }
    114141  }
    115142
  • src/Actions/BondAction/BondRemoveAction.def

    r19dfdf r3fa16b  
    77
    88// all includes and forward declarations necessary for non-integral types below
     9#include "types.hpp"
     10#include <vector>
     11#include <utility>
     12
     13typedef std::vector<std::pair<atomId_t,atomId_t> > bondPairIds_t;
    914
    1015// i.e. there is an integer with variable name Z that can be found in
     
    1924#undef paramvalids
    2025
    21 #define statetypes (atomId_t)(atomId_t)
    22 #define statereferences (firstId)(secondId)
     26#define statetypes (bondPairIds_t)
     27#define statereferences (bondPairIds)
    2328
    2429// some defines for all the names, you may use ACTION, STATE and PARAMS
     
    2732#define MENUPOSITION 2
    2833#define ACTIONNAME Remove
    29 #define TOKEN "remove-bond"
     34#define TOKEN "remove-bonds"
    3035
    3136// finally the information stored in the ActionTrait specialization
    32 #define DESCRIPTION "remove the bond in between two selected atoms"
     37#define DESCRIPTION "remove all  bonds present between selected atoms"
    3338#undef SHORTFORM
  • src/Actions/CommandAction/LoadSessionAction.cpp

    r19dfdf r3fa16b  
    5858
    5959#ifdef HAVE_PYTHON
    60   if (executePythonScript(params.filename.get().string()))
     60  if (executePythonScriptFile(params.filename.get()))
    6161    return Action::success;
    6262  else {
  • src/Actions/CommandAction/VerboseAction.cpp

    r19dfdf r3fa16b  
    5252  unsigned int oldverbosity = getVerbosity();
    5353
     54  // prepare undo state
     55  CommandVerboseState *UndoState = new CommandVerboseState(oldverbosity, params);
     56
    5457  if (oldverbosity != params.verbosity.get()) {
    55     // prepare undo state
    56     CommandVerboseState *UndoState = new CommandVerboseState(oldverbosity, params);
    5758    // set new verbosity
    5859    setVerbosity(params.verbosity.get());
    5960    LOG(0, "Setting verbosity from " << oldverbosity << " to " << params.verbosity.get() << ".");
    60     return ActionState::ptr(UndoState);
    6161  } else {
    6262    LOG(0, "Verbosity remains unchanged at " << oldverbosity << ".");
    63     return Action::success;
    6463  }
     64  return ActionState::ptr(UndoState);
    6565}
    6666
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    r19dfdf r3fa16b  
    129129    BondGraph *BG = World::getInstance().getBondGraph();
    130130    World::AtomComposite Set = World::getInstance().getAllAtoms(AtomsBySelection());
    131     BG->CorrectBondDegree(Set);
     131    // check whether bond graph is correct
     132    if (!BG->checkBondDegree(Set))
     133      BG->CorrectBondDegree(Set);
     134    else
     135      LOG(1, "INFO: Bond degrees all valid, not correcting.");
    132136  }
    133137
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    r19dfdf r3fa16b  
    134134    // Phase One: obtain ids
    135135    mpqccontroller.requestIds(NumberJobs);
     136    if (mpqccontroller.getExitflag() != 0)
     137      return Action::failure;
    136138
    137139    // Phase Two: add MPQCJobs and send
     
    159161    wait_thread.join();
    160162    stop();
     163    if (mpqccontroller.getExitflag() != 0)
     164      return Action::failure;
     165
    161166    mpqccontroller.getResults(shortrangedata);
     167    if (mpqccontroller.getExitflag() != 0)
     168      return Action::failure;
    162169
    163170    Exitflag += mpqccontroller.getExitflag();
     
    189196    mpqccontroller.run();
    190197    stop();
     198    if (mpqccontroller.getExitflag() != 0)
     199      return Action::failure;
    191200
    192201    // get back the results and place them in shortrangedata
     
    195204        "FragmentationFragmentationAutomationAction::performCall() - number of converted results "
    196205        +toString(shortrangedata.size())+" and number of jobs "+toString(NumberJobs)+ " differ.");
     206    if (mpqccontroller.getExitflag() != 0)
     207      return Action::failure;
    197208
    198209    Exitflag += mpqccontroller.getExitflag();
     
    234245    const size_t NoJobs = shortrangedata.size()+full_sample.size();
    235246    vmgcontroller.requestIds(2*NoJobs);
     247    if (vmgcontroller.getExitflag() != 0)
     248      return Action::failure;
    236249
    237250    // Phase Five a: create VMGJobs for electronic charge distribution
     
    254267    // Phase Six a: calculate result
    255268    vmgcontroller.waitforResults(NoJobs);
     269    if (vmgcontroller.getExitflag() != 0)
     270      return Action::failure;
    256271    vmgcontroller.getResults(longrangedata);
    257272    ASSERT( NoJobs == longrangedata.size(),
     
    282297      // Phase Six b: calculate result
    283298      vmgcontroller.waitforResults(NoJobs);
     299      if (vmgcontroller.getExitflag() != 0)
     300        return Action::failure;
    284301      vmgcontroller.getResults(longrangedata_both);
    285302      ASSERT( NoJobs == longrangedata_both.size(),
     
    287304          +toString(full_sample.size())+"="+toString(NoJobs)
    288305          +" and second VMGresults "+toString(longrangedata_both.size())+" don't match.");
     306      if (vmgcontroller.getExitflag() != 0)
     307        return Action::failure;
    289308      Exitflag += vmgcontroller.getExitflag();
    290309
  • src/Actions/FragmentationAction/MolecularDynamicsAction.cpp

    r19dfdf r3fa16b  
    5454
    5555// static instances
    56 ActionSequence FragmentationMolecularDynamicsAction::actions;
     56ActionSequence FragmentationMolecularDynamicsAction::prototype_actions;
    5757bool FragmentationMolecularDynamicsAction::isPrepared = false;
    5858
     
    6262  // present. If not, we still copy the position cleanly into a new step where then
    6363  // forces are set according to summed fragmentary contributions. This is much cleaner.
    64   actions.addAction(AR.getActionByName(std::string("verlet-integration")));
    65   actions.addAction(AR.getActionByName(std::string("output")));
    66   actions.addAction(AR.getActionByName(std::string("clear-fragment-results")));
    67   actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
    68   actions.addAction(AR.getActionByName(std::string("create-adjacency")));
    69   actions.addAction(AR.getActionByName(std::string("update-molecules")));
    70   actions.addAction(AR.getActionByName(std::string("fragment-molecule")));
    71   actions.addAction(AR.getActionByName(std::string("fragment-automation")));
    72   actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")));
     64  prototype_actions.addAction(AR.getActionByName(std::string("verlet-integration")));
     65  prototype_actions.addAction(AR.getActionByName(std::string("output")));
     66  prototype_actions.addAction(AR.getActionByName(std::string("clear-fragment-results")));
     67  prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
     68  prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")));
     69  prototype_actions.addAction(AR.getActionByName(std::string("correct-bonddegree")));
     70  prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")));
     71  prototype_actions.addAction(AR.getActionByName(std::string("fragment-molecule")));
     72  prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")));
     73  prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")));
    7374  isPrepared = true;
    7475}
     
    7778{
    7879  // empty sequence
    79   while (actions.removeLastAction() != NULL);
     80  while (prototype_actions.removeLastAction() != NULL);
    8081  isPrepared = false;
    8182}
     
    106107#endif
    107108        removeAction(std::string("create-adjacency"));
     109
     110#ifndef NDEBUG
     111    status &=
     112#endif
     113        removeAction(std::string("correct-bonddegree"));
    108114
    109115#ifndef NDEBUG
  • src/Actions/FragmentationAction/StructuralOptimizationAction.cpp

    r19dfdf r3fa16b  
    5454
    5555// static instances
    56 ActionSequence FragmentationStructuralOptimizationAction::actions;
     56ActionSequence FragmentationStructuralOptimizationAction::prototype_actions;
    5757bool FragmentationStructuralOptimizationAction::isPrepared = false;
    5858
     
    6262  // present. If not, we still copy the position cleanly into a new step where then
    6363  // forces are set according to summed fragmentary contributions. This is much cleaner.
    64   actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
    65   actions.addAction(AR.getActionByName(std::string("create-adjacency")));
    66   actions.addAction(AR.getActionByName(std::string("update-molecules")));
    67   actions.addAction(AR.getActionByName(std::string("fragment-molecule")));
    68   actions.addAction(AR.getActionByName(std::string("fragment-automation")));
    69   actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")));
    70   actions.addAction(AR.getActionByName(std::string("force-annealing")));
    71   actions.addAction(AR.getActionByName(std::string("output")));
    72   actions.addAction(AR.getActionByName(std::string("clear-fragment-results")));
     64  prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
     65  prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")));
     66  prototype_actions.addAction(AR.getActionByName(std::string("correct-bonddegree")));
     67  prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")));
     68  prototype_actions.addAction(AR.getActionByName(std::string("fragment-molecule")));
     69  prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")));
     70  prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")));
     71  prototype_actions.addAction(AR.getActionByName(std::string("force-annealing")));
     72  prototype_actions.addAction(AR.getActionByName(std::string("output")));
     73  prototype_actions.addAction(AR.getActionByName(std::string("clear-fragment-results")));
    7374  isPrepared = true;
    7475}
     
    7778{
    7879  // empty sequence
    79   while (actions.removeLastAction() != NULL);
     80  while (prototype_actions.removeLastAction() != NULL);
    8081  isPrepared = false;
    8182}
     
    106107#endif
    107108        removeAction(std::string("create-adjacency"));
     109
     110#ifndef NDEBUG
     111    status &=
     112#endif
     113        removeAction(std::string("correct-bonddegree"));
    108114
    109115#ifndef NDEBUG
  • src/Actions/GlobalListOfActions.hpp

    r19dfdf r3fa16b  
    3535  (AtomRemove) \
    3636  (AtomRotateAroundOriginByAngle) \
     37  (AtomSaturate) \
    3738  (AtomSaveSelectedAtoms) \
    3839  (AtomTranslate) \
     
    4041  (BondAdd) \
    4142  (BondRemove) \
     43  (CommandDryRun) \
    4244  (CommandElementDb) \
    4345  (CommandBondLengthTable) \
     
    4547  (CommandHelp) \
    4648  (CommandHelpRedistribute) \
     49  (CommandNoDryRun) \
    4750  (CommandSetRandomNumbersEngine) \
    4851  (CommandSetRandomNumbersDistribution) \
  • src/Actions/GraphAction/SubgraphDissectionAction.cpp

    r19dfdf r3fa16b  
    5858
    5959// static instances
    60 ActionSequence GraphSubgraphDissectionAction::actions;
     60ActionSequence GraphSubgraphDissectionAction::prototype_actions;
    6161bool GraphSubgraphDissectionAction::isPrepared = false;
    6262
    6363void GraphSubgraphDissectionAction::prepare(ActionRegistry &AR)
    6464{
    65   actions.addAction(AR.getActionByName(std::string("push-atom-selection")));
    66   actions.addAction(AR.getActionByName(std::string("select-all-atoms")));
    67   actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
    68   actions.addAction(AR.getActionByName(std::string("create-adjacency")));
    69   actions.addAction(AR.getActionByName(std::string("update-molecules")));
    70   actions.addAction(AR.getActionByName(std::string("pop-atom-selection")));
     65  prototype_actions.addAction(AR.getActionByName(std::string("push-atom-selection")));
     66  prototype_actions.addAction(AR.getActionByName(std::string("select-all-atoms")));
     67  prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
     68  prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")));
     69  prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")));
     70  prototype_actions.addAction(AR.getActionByName(std::string("pop-atom-selection")));
    7171  isPrepared = true;
    7272}
     
    7575{
    7676  // empty sequence
    77   while (actions.removeLastAction() != NULL);
     77  while (prototype_actions.removeLastAction() != NULL);
    7878  isPrepared = false;
    7979}
  • src/Actions/Makefile.am

    r19dfdf r3fa16b  
    4141  Actions/Calculation.hpp \
    4242  Actions/Calculation_impl.hpp \
     43  Actions/DryRunAdvocate.hpp \
    4344  Actions/ErrorAction.hpp \
    4445  Actions/GlobalListOfActions.hpp \
     
    150151  Actions/AtomAction/RemoveAction.cpp \
    151152  Actions/AtomAction/RotateAroundOriginByAngleAction.cpp \
     153  Actions/AtomAction/SaturateAction.cpp \
    152154  Actions/AtomAction/SaveSelectedAtomsAction.cpp \
    153155  Actions/AtomAction/TranslateAction.cpp \
     
    159161  Actions/AtomAction/RemoveAction.hpp \
    160162  Actions/AtomAction/RotateAroundOriginByAngleAction.hpp \
     163  Actions/AtomAction/SaturateAction.hpp \
    161164  Actions/AtomAction/SaveSelectedAtomsAction.hpp \
    162165  Actions/AtomAction/TranslateAction.hpp \
     
    168171  Actions/AtomAction/RemoveAction.def \
    169172  Actions/AtomAction/RotateAroundOriginByAngleAction.def \
     173  Actions/AtomAction/SaturateAction.def \
    170174  Actions/AtomAction/SaveSelectedAtomsAction.def \
    171175  Actions/AtomAction/TranslateAction.def \
     
    184188CMDACTIONSOURCE = \
    185189  Actions/CommandAction/BondLengthTableAction.cpp \
     190  Actions/CommandAction/DryRunAction.cpp \
    186191  Actions/CommandAction/ElementDbAction.cpp \
    187192  Actions/CommandAction/FastParsingAction.cpp \
    188193  Actions/CommandAction/HelpAction.cpp \
    189194  Actions/CommandAction/HelpRedistributeAction.cpp \
     195  Actions/CommandAction/NoDryRunAction.cpp \
    190196  Actions/CommandAction/StoreSessionAction.cpp \
    191197  Actions/CommandAction/VerboseAction.cpp \
     
    194200CMDACTIONHEADER = \
    195201  Actions/CommandAction/BondLengthTableAction.hpp \
     202  Actions/CommandAction/DryRunAction.hpp \
    196203  Actions/CommandAction/ElementDbAction.hpp \
    197204  Actions/CommandAction/FastParsingAction.hpp \
    198205  Actions/CommandAction/HelpAction.hpp \
    199206  Actions/CommandAction/HelpRedistributeAction.hpp \
     207  Actions/CommandAction/NoDryRunAction.hpp \
    200208  Actions/CommandAction/StoreSessionAction.hpp \
    201209  Actions/CommandAction/VerboseAction.hpp \
     
    204212CMDACTIONDEFS = \
    205213  Actions/CommandAction/BondLengthTableAction.def \
     214  Actions/CommandAction/DryRunAction.def \
    206215  Actions/CommandAction/ElementDbAction.def \
    207216  Actions/CommandAction/FastParsingAction.def \
    208217  Actions/CommandAction/HelpAction.def \
    209218  Actions/CommandAction/HelpRedistributeAction.def \
     219  Actions/CommandAction/NoDryRunAction.def \
    210220  Actions/CommandAction/StoreSessionAction.def \
    211221  Actions/CommandAction/VerboseAction.def \
  • src/Actions/MakroAction.cpp

    r19dfdf r3fa16b  
    6060  ActionSequence::stateSet states;
    6161};
     62
     63MakroAction::MakroAction(const MakroAction &_instance) :
     64    Action(_instance.Traits),
     65    actions(_instance.actions)
     66{}
    6267
    6368MakroAction::MakroAction(const ActionTrait &_trait,ActionSequence& _actions) :
  • src/Actions/MakroAction.hpp

    r19dfdf r3fa16b  
    1818
    1919#include "Actions/Action.hpp"
     20#include "Actions/ActionSequence.hpp"
     21
     22class ActionSequenceTest;
    2023
    2124namespace MoleCuilder {
    2225  class ActionRegistry;
    23   class ActionSequence;
    2426
    2527/**
     
    3032class MakroAction : public Action
    3133{
     34  //!> grant unit test access to sequence
     35  friend class ::ActionSequenceTest;
    3236public:
     37  MakroAction(const MakroAction &_instance);
    3338  MakroAction(const ActionTrait &_trait,ActionSequence& _actions);
    3439  virtual ~MakroAction();
     
    7883  Dialog *fillDialog(Dialog *dialog);
    7984
     85  //!> this points to the instance of a specific MakroAction, we need to ref for callAll()
    8086  ActionSequence &actions;
    8187};
  • src/Actions/MakroAction_impl_header.hpp

    r19dfdf r3fa16b  
    263263  //!> flag to check whether actions have been prepared
    264264  static bool isPrepared;
    265   //!> sequence of actions for this macro action
    266   static ActionSequence actions;
     265  //!> sequence of prototype actions for this macro action
     266  static ActionSequence prototype_actions;
     267  //!> sequence of actions for this specific instance
     268  ActionSequence actions;
    267269
    268270private:
  • src/Actions/MakroAction_impl_pre.hpp

    r19dfdf r3fa16b  
    263263// =========== constructor ===========
    264264ACTION::ACTION () :
    265   MakroAction(ActionTraits< ACTION >(), actions)
     265  MakroAction(ActionTraits< ACTION >(), actions),
     266  actions(prototype_actions)
    266267{}
    267268
     
    294295Action* ACTION::clone(enum QueryOptions flag) const
    295296{
    296   if (flag == Interactive)
    297     return new ACTION();
    298   else
    299     return new ACTION(*this);
     297  return new ACTION();
    300298}
    301299
  • src/Actions/MoleculeAction/TranslateAction.cpp

    r19dfdf r3fa16b  
    5656
    5757// static instances
    58 ActionSequence MoleculeTranslateAction::actions;
     58ActionSequence MoleculeTranslateAction::prototype_actions;
    5959bool MoleculeTranslateAction::isPrepared = false;
    6060
     
    6363  // we simply have to select all the molecule's atoms and use the respective
    6464  // translate Action
    65   actions.addAction(AR.getActionByName(std::string("push-atom-selection")));
    66   actions.addAction(AR.getActionByName(std::string("select-molecules-atoms")));
    67   actions.addAction(AR.getActionByName(std::string("translate-atoms")));
    68   actions.addAction(AR.getActionByName(std::string("pop-atom-selection")));
     65  prototype_actions.addAction(AR.getActionByName(std::string("push-atom-selection")));
     66  prototype_actions.addAction(AR.getActionByName(std::string("select-molecules-atoms")));
     67  prototype_actions.addAction(AR.getActionByName(std::string("translate-atoms")));
     68  prototype_actions.addAction(AR.getActionByName(std::string("pop-atom-selection")));
    6969  isPrepared = true;
    7070}
     
    7373{
    7474  // empty sequence
    75   while (actions.removeLastAction() != NULL);
     75  while (prototype_actions.removeLastAction() != NULL);
    7676  isPrepared = false;
    7777}
  • src/Actions/ParserAction/SetParserParametersAction.cpp

    r19dfdf r3fa16b  
    6666  // obtain information
    6767  std::stringstream newparamstream;
    68   const std::vector< std::string > keyvalues = params.newparams.get();
     68  const std::vector< KeyValuePair > keyvalues = params.newparams.get();
    6969  std::for_each(keyvalues.begin(), keyvalues.end(), newparamstream << boost::lambda::_1 << ";");
    7070  newparamstream >> *parameters;
     
    9090  FormatParser_Parameters *parser = FormatParserStorage::getInstance().get(type).parameters;
    9191  std::stringstream newparamstream;
    92   const std::vector< std::string > keyvalues = state->params.newparams.get();
     92  const std::vector< KeyValuePair > keyvalues = state->params.newparams.get();
    9393  std::for_each(keyvalues.begin(), keyvalues.end(), newparamstream << boost::lambda::_1 << ";");
    9494  newparamstream >> *parser;
  • src/Actions/ParserAction/SetParserParametersAction.def

    r19dfdf r3fa16b  
    1313#include "Parameters/Validators/Specific/KeyValueValidator.hpp"
    1414#include "Parameters/Validators/Specific/ParserTypeValidator.hpp"
     15#include "Parameters/Specifics/KeyValuePair.hpp"
    1516
    1617// i.e. there is an integer with variable name Z that can be found in
    1718// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1819// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    19 #define paramtypes (std::string)(std::vector<std::string>)
     20#define paramtypes (std::string)(std::vector<KeyValuePair>)
    2021#define paramtokens ("set-parser-parameters")("parser-parameters")
    2122#define paramdescriptions ("name of the parser to change")("parameter (key = value;)")
     
    2425#define paramvalids \
    2526(ParserTypeValidator())\
    26 (STLVectorValidator< std::vector<std::string> >(1, 99, KeyValueValidator()))
     27(STLVectorValidator< std::vector<KeyValuePair> >(1, 99, KeyValueValidator()))
    2728
    2829#define statetypes (std::string)
  • src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.def

    r19dfdf r3fa16b  
    1111#include "Parameters/Validators/Specific/RandomNumberValidators.hpp"
    1212#include "Parameters/Validators/Specific/KeyValueValidator.hpp"
     13#include "Parameters/Specifics/KeyValuePair.hpp"
    1314
    1415// i.e. there is an integer with variable name Z that can be found in
    1516// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1617// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    17 #define paramtypes (std::string)(std::string)
     18#define paramtypes (std::string)(KeyValuePair)
    1819#define paramtokens ("set-random-number-distribution")("random-number-distribution-parameters")
    1920#define paramdescriptions ("name of the distribution from boost::random")("parameter set for requested distribution")
    20 #define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT(std::string("p=-1")))
     21#define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT(KeyValuePair("p=-1")))
    2122#define paramreferences (distribution_type)(parameters)
    2223#define paramvalids \
  • src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.def

    r19dfdf r3fa16b  
    1010#include "Parameters/Validators/Specific/RandomNumberValidators.hpp"
    1111#include "Parameters/Validators/Specific/KeyValueValidator.hpp"
     12#include "Parameters/Specifics/KeyValuePair.hpp"
    1213
    1314// i.e. there is an integer with variable name Z that can be found in
    1415// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1516// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    16 #define paramtypes (std::string)(std::string)
     17#define paramtypes (std::string)(KeyValuePair)
    1718#define paramtokens ("set-random-number-engine")("random-number-engine-parameters")
    1819#define paramdescriptions ("name of the pseudo-random engine from boost::random")("seed of the pseudo-random number sequence")
    19 #define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT(std::string("seed=-1")))
     20#define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT(KeyValuePair("seed=-1")))
    2021#define paramreferences (engine_type)(parameters)
    2122#define paramvalids \
  • src/Actions/SelectionAction/Atoms/PopAtomsAction.cpp

    r19dfdf r3fa16b  
    6363ActionState::ptr SelectionPopAtomsAction::performUndo(ActionState::ptr _state) {
    6464  SelectionPopAtomsState *state = static_cast<SelectionPopAtomsState *>(_state.get());
    65   LOG(1, "Popping atom selection.");
     65  LOG(1, "Pushing atom selection.");
    6666  World::getInstance().pushAtomSelection();
    6767
  • src/Actions/SelectionAction/Atoms/PushAtomsAction.cpp

    r19dfdf r3fa16b  
    5454
    5555ActionState::ptr SelectionPushAtomsAction::performUndo(ActionState::ptr _state) {
    56   LOG(1, "Pushing atom selection.");
     56  LOG(1, "Popping atom selection.");
    5757  World::getInstance().popAtomSelection();
    5858
  • src/Actions/SelectionAction/Molecules/MoleculeOfAtomAction.cpp

    r19dfdf r3fa16b  
    5555ActionState::ptr SelectionMoleculeOfAtomAction::performCall() {
    5656  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
    57   LOG(1, "Selecting molecule to currently selected atoms.");
     57  LOG(1, "Selecting molecule to currently selected atoms: " << World::getInstance().countSelectedAtoms());
    5858  World::getInstance().selectAllMolecules(MoleculesByAtomSelection());
    5959  LOG(0, World::getInstance().countSelectedMolecules() << " molecules selected.");
  • src/Actions/UndoRedoHelpers.cpp

    r19dfdf r3fa16b  
    131131{
    132132  bool status = true;
    133   for(std::vector< BondInfo >::const_iterator iter = bonds.begin();
    134       iter != bonds.end(); ++iter)
    135     if (!(*iter).RecreateBond())
     133  std::vector< BondInfo >::const_iterator iter = bonds.begin();
     134  for(;iter != bonds.end(); ++iter) {
     135    if (!(*iter).RecreateBond()) {
    136136      status = false;
     137      break;
     138    }
     139  }
     140  if (!status) {
     141    // remove all added bonds again
     142    for(std::vector< BondInfo >::const_iterator removeiter = bonds.begin();
     143        removeiter != iter; ++removeiter) {
     144      removeiter->RemoveBond();
     145    }
     146  }
    137147  return status;
    138148}
  • src/Actions/Values.cpp

    r19dfdf r3fa16b  
    3737#include "CodePatterns/Assert.hpp"
    3838
     39#include "Box.hpp"
    3940#include "LinearAlgebra/BoxVector.hpp"
    4041#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4142#include "LinearAlgebra/Vector.hpp"
    42 #include "Box.hpp"
    4343
    4444#include "Values.hpp"
  • src/Actions/Values.hpp

    r19dfdf r3fa16b  
    1515
    1616#include "LinearAlgebra/defs.hpp"
     17
     18#include <string>
    1719
    1820class Box;
     
    4547};
    4648
     49#endif /* VALUES_HPP_ */
    4750
    48 #endif /* VALUES_HPP_ */
  • src/Actions/toCLIString.cpp

    r19dfdf r3fa16b  
    4040#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4141#include "LinearAlgebra/Vector.hpp"
     42#include "Parameters/Specifics/KeyValuePair.hpp"
     43
     44#include "Actions/toPythonString.hpp"
    4245
    4346template <>
     
    6568    << _value.at(2,0) << ","
    6669    << _value.at(2,1) << ","
    67     << _value.at(2,2) << "\"";
     70    << _value.at(2,2)
     71    << "\"";
    6872  return output.str();
    6973}
     
    7377{
    7478  std::stringstream output;
    75   output << "\"" << _value[0] << "," << _value[1] << "," << _value[2] << "\"";
     79  output << "\"" << toPythonString(_value) << "\"";
    7680  return output.str();
    7781}
     
    8488  return output.str();
    8589}
     90
     91template <>
     92const std::string toCLIString( const KeyValuePair& _value)
     93{
     94  std::stringstream output;
     95  output << "\"" << toPythonString(_value) << "\"";
     96  return output.str();
     97}
  • src/Actions/toCLIString.hpp

    r19dfdf r3fa16b  
    2121
    2222class element;
     23struct KeyValuePair;
    2324class RealSpaceMatrix;
    2425class Vector;
     
    7778template <> const std::string toCLIString( const std::string& _value);
    7879
     80template <> const std::string toCLIString( const KeyValuePair& _value);
     81
    7982#endif /* TOCLISTRING_HPP_ */
  • src/Actions/toPythonString.cpp

    r19dfdf r3fa16b  
    4141#include "LinearAlgebra/Vector.hpp"
    4242
     43#include "Parameters/Specifics/KeyValuePair.hpp"
     44
    4345template <>
    4446const std::string toPythonString( const boost::filesystem::path & _value)
     
    5254  std::stringstream output;
    5355  output << _value.getAtomicNumber();
     56  return output.str();
     57}
     58
     59template <>
     60const std::string toPythonString( const KeyValuePair & _value)
     61{
     62  std::stringstream output;
     63  const char semicolon(';');
     64  const size_t semicolon_pos = _value.find_last_of(semicolon, std::string::npos);
     65  const size_t final_equality_pos = _value.find('=', semicolon_pos);
     66  output << _value;
     67  if ((semicolon_pos == std::string::npos)
     68      || (final_equality_pos != std::string::npos))
     69    output << semicolon;
    5470  return output.str();
    5571}
  • src/Actions/toPythonString.hpp

    r19dfdf r3fa16b  
    2121
    2222class element;
     23struct KeyValuePair;
    2324class RealSpaceMatrix;
    2425class Vector;
     
    7172template <> const std::string toPythonString( const boost::filesystem::path & _value);
    7273
     74template <> const std::string toPythonString( const KeyValuePair& _value);
     75
    7376template <> const std::string toPythonString( const RealSpaceMatrix& _value);
    7477
  • src/Actions/unittests/ActionSequenceUnitTest.cpp

    r19dfdf r3fa16b  
    301301  ActionSequence *sequence = new ActionSequence();
    302302  ActionTrait wasCalledTrait("wasCalledActionStub");
    303   wasCalledActionStub *wasCalled1 = new wasCalledActionStub(wasCalledTrait);
    304   wasCalledActionStub *wasCalled2 = new wasCalledActionStub(wasCalledTrait);
    305   sequence->addAction(wasCalled1);
    306   sequence->addAction(wasCalled2);
     303  sequence->addAction(new wasCalledActionStub(wasCalledTrait));
     304  sequence->addAction(new wasCalledActionStub(wasCalledTrait));
    307305
    308306  ActionTrait MakroTrait("Test MakroAction");
    309307  MakroAction act(MakroTrait,*sequence);
     308  wasCalledActionStub *wasCalled1 =
     309      static_cast<wasCalledActionStub *>(act.actions.actions.front());
     310  wasCalledActionStub *wasCalled2 =
     311      static_cast<wasCalledActionStub *>(act.actions.actions.back());
    310312
    311313  act.call();
    312314
    313   CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
    314   CPPUNIT_ASSERT_EQUAL(true,wasCalled2->wasCalled());
     315  CPPUNIT_ASSERT_EQUAL(true,
     316      static_cast<wasCalledActionStub *>(act.actions.actions.front())->wasCalled());
     317  CPPUNIT_ASSERT_EQUAL(true,
     318      static_cast<wasCalledActionStub *>(act.actions.actions.back())->wasCalled());
    315319
    316320  ActionQueue::getInstance().undoLast();
    317321
    318   CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
    319   CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled());
     322  CPPUNIT_ASSERT_EQUAL(false,
     323      static_cast<wasCalledActionStub *>(act.actions.actions.front())->wasCalled());
     324  CPPUNIT_ASSERT_EQUAL(false,
     325      static_cast<wasCalledActionStub *>(act.actions.actions.back())->wasCalled());
    320326
    321327  delete sequence;
  • src/Actions/unittests/stubs/DummyUI.hpp

    r19dfdf r3fa16b  
    4747  virtual void queryFile(Parameter<boost::filesystem::path> &, const std::string ="", const std::string = ""){};
    4848  virtual void queryFiles(Parameter< std::vector<boost::filesystem::path> > &, const std::string ="", const std::string = ""){};
    49   virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const std::string ="", const std::string = ""){};
     49  virtual void queryKeyValuePair(Parameter<KeyValuePair> &, const std::string ="", const std::string = ""){};
     50  virtual void queryKeyValuePairs(Parameter<std::vector<KeyValuePair> > &, const std::string ="", const std::string = ""){};
    5051};
    5152
  • src/Atom/AtomicInfo.cpp

    r19dfdf r3fa16b  
    3434
    3535#include "CodePatterns/MemDebug.hpp"
     36
     37#include "CodePatterns/Log.hpp"
    3638
    3739#include "atom.hpp"
     
    7173      "Atom "+toString(_atom.getId())+" is not associated with any molecule.");
    7274  MolId = mol->getId();
     75  // accumulate bond info
     76  const BondList &ListOfBonds = _atom.getListOfBonds();
     77  bonds.reserve(ListOfBonds.size());
     78  for (BondList::const_iterator bonditer = ListOfBonds.begin();
     79      bonditer != ListOfBonds.end(); ++bonditer) {
     80    const BondInfo bondinfo(*bonditer);
     81    bonds.push_back(bondinfo);
     82    LOG(3, "DEBUG: Storing info for bond " << bondinfo.leftid << "<->" << bondinfo.rightid);
     83  }
    7384}
    7485
     
    101112    }
    102113
     114    // set bonds
     115    for (std::vector<BondInfo>::const_iterator bonditer = bonds.begin();
     116        bonditer != bonds.end(); ++bonditer)
     117      (*bonditer).RecreateBond();
     118
    103119    // setting molecule
    104120    molecule * const _mol = World::getInstance().getMolecule(MoleculeById(MolId));
  • src/Atom/AtomicInfo.hpp

    r19dfdf r3fa16b  
    1616#include "LinearAlgebra/Vector.hpp"
    1717#include "types.hpp"
     18
     19#include <vector>
     20
     21#include "Bond/BondInfo.hpp"
    1822
    1923class atom;
     
    4549  atomId_t Id;
    4650  int Nr;
     51  std::vector<BondInfo> bonds;
    4752};
    4853
  • src/Bond/BondInfo.cpp

    r19dfdf r3fa16b  
    6161  atom * const rightatom = World::getInstance().getAtom(AtomById(rightid));
    6262  if ((leftatom == NULL) || (rightatom == NULL)) {
    63     ELOG(1, "Either of the two atoms " << leftid << " or "
    64         << rightid << " does not exists in the world.");
     63//    LOG(3, "DEBUG: Either of the two atoms " << leftid << " or "
     64//        << rightid << " does not exist in the world.");
    6565    return false;
    6666  }
    6767  const BondList &leftbonds = leftatom->getListOfBonds();
    68   boost::function< bool (const bond::ptr )> predicate =
    69       boost::bind(static_cast<bool (bond::*)(const int) const>(&bond::Contains), _1, rightid);
    70   if (std::find_if(leftbonds.begin(), leftbonds.end(), predicate) != leftbonds.end())
    71     return false;
    72 
    7368  const BondList &rightbonds = rightatom->getListOfBonds();
    74   if (std::find_if(rightbonds.begin(), rightbonds.end(), predicate) != rightbonds.end())
    75     return false;
     69  boost::function< bool (const bond::ptr )> leftpredicate =
     70      boost::bind(static_cast<bool (bond::*)(const atomId_t) const>(&bond::ContainsId), _1, rightid);
     71  boost::function< bool (const bond::ptr )> rightpredicate =
     72      boost::bind(static_cast<bool (bond::*)(const atomId_t) const>(&bond::ContainsId), _1, leftid);
     73  if ((std::find_if(leftbonds.begin(), leftbonds.end(), leftpredicate) != leftbonds.end())
     74      || (std::find_if(rightbonds.begin(), rightbonds.end(), rightpredicate) != rightbonds.end())) {
     75//    LOG(3, "DEBUG: Bond between atoms " << leftid << " or "111
     76//        << rightid << " is already present in the world.");
     77    return true;
     78  }
    7679
    7780  // create bond
     
    8184  return true;
    8285}
     86
     87void BondInfo::RemoveBond() const
     88{
     89  atom * leftatom = World::getInstance().getAtom(AtomById(leftid));
     90  atom * rightatom = World::getInstance().getAtom(AtomById(rightid));
     91  leftatom->removeBond(rightatom);
     92}
  • src/Bond/BondInfo.hpp

    r19dfdf r3fa16b  
    3737  bool RecreateBond() const;
    3838
     39  /** Removes the bond whose state is contained in this BondInfo.
     40   *
     41   */
     42  void RemoveBond() const;
     43
    3944  //!> id of left bond partner
    4045  atomId_t leftid;
  • src/Bond/bond.cpp

    r19dfdf r3fa16b  
    125125 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
    126126 */
    127 bool bond::Contains(const int number) const
     127bool bond::ContainsNr(const int number) const
    128128{
    129129  return ((leftatom->getNr() == number) || (rightatom->getNr() == number));
     130};
     131
     132/** Checks if an atom exists in a bond.
     133 * \param Nr index of atom
     134 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
     135 */
     136bool bond::ContainsId(const atomId_t number) const
     137{
     138  return ((leftatom->getId() == number) || (rightatom->getId() == number));
    130139};
    131140
  • src/Bond/bond.hpp

    r19dfdf r3fa16b  
    1919
    2020#include <boost/shared_ptr.hpp>
     21
     22#include "types.hpp"
    2123
    2224#include "Bond/bond_observable.hpp"
     
    5153
    5254  bool Contains(const ParticleInfo * const ptr) const;
    53   bool Contains(const int nr) const;
     55  bool ContainsNr(const int nr) const;
     56  bool ContainsId(const atomId_t nr) const;
    5457  double GetDistance() const;
    5558  double GetDistanceSquared() const;
  • src/Fragmentation/Automation/MPQCCommandFragmentController.cpp

    r19dfdf r3fa16b  
    5959unsigned int MPQCCommandFragmentController::nextid = 0;
    6060
    61 bool MPQCCommandFragmentController::addJobsFromQueue(
     61unsigned int MPQCCommandFragmentController::addJobsFromQueue(
    6262    const MPQCData::DoLongrange_t _DoLongrange,
    6363    const MPQCData::DoValenceOnly_t _DoValenceOnly,
  • src/Fragmentation/Automation/MPQCCommandFragmentController.hpp

    r19dfdf r3fa16b  
    5353   * \param _DoValenceOnly whether to sample just the valence or the total elctron and nuclei density
    5454   * \param _command command to pass to jobs for execution
    55    * \return true - jobs obtained, false - queue empty
     55   * \return the number of jobs added to queue
    5656   */
    57   bool addJobsFromQueue(
     57  unsigned int addJobsFromQueue(
    5858      const MPQCData::DoLongrange_t _DoLongrange,
    5959      const MPQCData::DoValenceOnly_t _DoValenceOnly,
  • src/Fragmentation/Automation/ResultContainer_impl.hpp

    r19dfdf r3fa16b  
    5555  for(;resultiter != fragmentresults.end(); ++resultiter, ++dataiter) {
    5656    const JobId_t _id = (*resultiter)->getId();
     57    if ((*resultiter)->exitflag == 0) {
    5758#ifndef NDEBUG
    58     std::pair<typename std::map<JobId_t, T>::iterator, bool> inserter =
     59      std::pair<typename std::map<JobId_t, T>::iterator, bool> inserter =
    5960#endif
    60     IdData.insert( std::make_pair( _id, *dataiter) );
    61     ASSERT( inserter.second,
    62         "ResultContainer::insertResults() - result id "
    63         +toString(inserter.first->first)+" already present.");
     61      IdData.insert( std::make_pair( _id, *dataiter) );
     62      ASSERT( inserter.second,
     63          "ResultContainer::insertResults() - result id "
     64          +toString(inserter.first->first)+" already present.");
     65    }
    6466  }
    6567  ASSERT( dataiter == fragmentData.end(),
  • src/Fragmentation/Automation/SpecificFragmentController_ReceiveResultContainer_impl.hpp

    r19dfdf r3fa16b  
    5252  // wait but receive all results that are already done
    5353  size_t NoReceivedResults = 0;
    54   while (NoReceivedResults != NoExpectedResults) {
     54  while ((NoReceivedResults != NoExpectedResults)
     55      && (callback.getExitflag() == 0)) {
    5556    // wait a bit
    5657    boost::asio::deadline_timer timer(io_service);
     
    6061    callback.checkResults(callback.host, callback.port);
    6162    callback.RunService("Checking on results");
     63    if (callback.getExitflag() != 0)
     64      break;
    6265
    6366    const std::pair<size_t, size_t> JobStatus = callback.getJobStatus();
  • src/Fragmentation/Exporters/unittests/Makefile.am

    r19dfdf r3fa16b  
    1818
    1919TESTS += $(FRAGMENTATIONEXPORTERSTESTS)
     20XFAIL_TESTS += SphericalPointDistributionUnitTest
    2021check_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS)
    2122noinst_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS)
     
    4445
    4546SaturationDistanceMaximizerUnitTest_SOURCES = \
    46         ../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.cpp \
    4747        ../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.hpp \
    4848        ../Fragmentation/Exporters/unittests/stubs/SaturatedBondStub.cpp
     
    5151        $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
    5252        ${FRAGMENTATIONEXPORTERSLIBS}
    53        
     53
    5454
    5555#AUTOMAKE_OPTIONS = parallel-tests
  • src/Fragmentation/Makefile.am

    r19dfdf r3fa16b  
    1010        Fragmentation/Exporters/SaturatedFragment.cpp \
    1111        Fragmentation/Exporters/SaturationDistanceMaximizer.cpp \
     12        Fragmentation/Exporters/SphericalPointDistribution.cpp \
     13        Fragmentation/Exporters/SphericalPointDistribution_getPoints.cpp \
    1214        Fragmentation/Homology/FragmentEdge.cpp \
    1315        Fragmentation/Homology/FragmentNode.cpp \
     
    3840        Fragmentation/Exporters/SaturatedFragment.hpp \
    3941        Fragmentation/Exporters/SaturationDistanceMaximizer.hpp \
     42        Fragmentation/Exporters/SphericalPointDistribution.hpp \
    4043        Fragmentation/Homology/FragmentEdge.hpp \
    4144        Fragmentation/Homology/FragmentNode.hpp \
  • src/Fragmentation/PowerSetGenerator.cpp

    r19dfdf r3fa16b  
    131131    for (TouchedList_t::const_iterator iter = TouchedList.begin();
    132132        iter != TouchedList.end(); ++iter) {
    133       if ((*Binder)->Contains(*iter))   // if we added this very endpiece
     133      if ((*Binder)->ContainsNr(*iter))   // if we added this very endpiece
    134134        SetDimension++;
    135135    }
  • src/Fragmentation/Summation/Containers/MPQCData.cpp

    r19dfdf r3fa16b  
    5252MPQCData::MPQCData() :
    5353  DoLongrange(DontSampleDensity),
    54   DoValenceOnly(DoValenceOnly)
     54  DoValenceOnly(DoSampleValenceOnly)
    5555{}
    5656
  • src/Graph/BondGraph.cpp

    r19dfdf r3fa16b  
    473473}
    474474
     475bool BondGraph::checkBondDegree(const deltaatoms_t &allatoms) const
     476{
     477  deltaatoms_t deltaatoms;
     478  return (gatherAllDeltaAtoms(allatoms, deltaatoms) == 0);
     479}
     480
    475481
    476482int BondGraph::calculateBondDegree(const deltaatoms_t &allatoms) const
  • src/Graph/BondGraph.hpp

    r19dfdf r3fa16b  
    359359  }
    360360
     361  /** Checks whether the bond degree for each atom on the set matches with its valency.
     362   *
     363   * @param Set Range with atoms
     364   * @return true - bond degrees match valency, false - bond degree correction is needed
     365   */
     366  template <class container_type,
     367            class iterator_type,
     368            class const_iterator_type>
     369  bool checkBondDegree(
     370      AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const
     371  {
     372    std::set<atom *> allatoms;
     373    for(iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner)
     374      allatoms.insert(*AtomRunner);
     375    return checkBondDegree(allatoms);
     376  }
     377
    361378  /** correct bond degree by comparing valence and bond degree.
    362379   * correct Bond degree of each bond by checking both bond partners for a mismatch between valence and current sum of bond degrees,
     
    472489  }
    473490
     491  bool checkBondDegree(const std::set<atom *> &allatoms) const;
     492
    474493  /** Calculates the bond degree for each atom on the set.
    475494   *
  • src/Parameters/Makefile.am

    r19dfdf r3fa16b  
    4343        Parameters/ValueAsString.hpp \
    4444        Parameters/ValueInterface.hpp \
     45        Parameters/Specifics/KeyValuePair.hpp \
    4546        Parameters/Specifics/Value_atom.hpp \
    4647        Parameters/Specifics/Value_element.hpp \
  • src/Parameters/Parameter.hpp

    r19dfdf r3fa16b  
    5353  bool isValid(const T &_value) const throw(ParameterValidatorException);
    5454  const T & get() const throw(ParameterValueException);
     55  const T & getUnvalidated() const throw(ParameterValueException);
    5556  void set(const T & _value) throw(ParameterValueException);
    5657  bool isSet() const
  • src/Parameters/Parameter_impl.hpp

    r19dfdf r3fa16b  
    186186}
    187187
     188
     189/** Catch call to value.getUnvalidated() to add exception information.
     190 *
     191 * @return parameter value as string
     192 */
     193template<typename T>
     194inline const T & Parameter<T>::getUnvalidated() const throw(ParameterValueException)
     195{
     196  try {
     197    return value.getUnvalidated();
     198  } catch(ParameterException &e) {
     199    e << ParameterName(ParameterInterface::getName());
     200    throw;
     201  }
     202}
    188203
    189204/** Catch call to value.get() to add exception information.
  • src/Parameters/Validators/Specific/KeyValueValidator.cpp

    r19dfdf r3fa16b  
    3838#include "KeyValueValidator.hpp"
    3939
    40 bool KeyValueValidator::isValid(const std::string & _value) const
     40bool KeyValueValidator::isValid(const KeyValuePair & _value) const
    4141{
    4242  size_t keyvaluestart = 0;
     
    6666}
    6767
    68 bool KeyValueValidator::operator==(const Validator<std::string> &_instance) const
     68bool KeyValueValidator::operator==(const Validator<KeyValuePair> &_instance) const
    6969{
    7070  const KeyValueValidator *inst =
     
    7676}
    7777
    78 Validator< std::string >* KeyValueValidator::clone() const
     78Validator< KeyValuePair >* KeyValueValidator::clone() const
    7979{
    80   Validator< std::string > *inst =
     80  Validator< KeyValuePair > *inst =
    8181      new KeyValueValidator();
    8282  return inst;
  • src/Parameters/Validators/Specific/KeyValueValidator.hpp

    r19dfdf r3fa16b  
    1515#endif
    1616
    17 #include <string>
    18 
     17#include "Parameters/Specifics/KeyValuePair.hpp"
    1918#include "Parameters/Validators/Validator.hpp"
    2019
     
    2221 * concatenation of the following pattern "...=...;"
    2322 */
    24 class KeyValueValidator : public Validator<std::string>
     23class KeyValueValidator : public Validator<KeyValuePair>
    2524{
    26   bool isValid(const std::string & _value) const;
    27   bool operator==(const Validator<std::string> &_instance) const;
    28   Validator< std::string >* clone() const;
     25  bool isValid(const KeyValuePair & _value) const;
     26  bool operator==(const Validator<KeyValuePair> &_instance) const;
     27  Validator< KeyValuePair >* clone() const;
    2928};
    3029
  • src/Parameters/Value.hpp

    r19dfdf r3fa16b  
    7777  // functions for ValueInterface
    7878  bool isValid(const T &_value) const throw(ParameterValidatorException);
     79  const T & getUnvalidated() const throw(ParameterValueException);
    7980  const T & get() const throw(ParameterValueException);
    8081  void set(const T & _value) throw(ParameterException);
  • src/Parameters/ValueInterface.hpp

    r19dfdf r3fa16b  
    3131  virtual bool isValid(const T & _value) const throw(ParameterValidatorException)=0;
    3232  virtual const T & get() const throw(ParameterValueException)=0;
     33  virtual const T & getUnvalidated() const throw(ParameterValueException)=0;
    3334  virtual void set(const T & _value) throw(ParameterException)=0;
    3435  virtual bool isSet() const=0;
  • src/Parameters/Value_impl.hpp

    r19dfdf r3fa16b  
    120120{
    121121  if (!isValid(value)) throw ParameterValueException();
     122  if (!ValueSet) throw ParameterValueException();
     123  return value;
     124}
     125
     126/** Getter of value without any validation
     127 *
     128 * @return value
     129 */
     130template <class T>
     131inline const T & Value<T>::getUnvalidated() const throw(ParameterValueException)
     132{
    122133  if (!ValueSet) throw ParameterValueException();
    123134  return value;
  • src/Python/PythonScripting.cpp

    r19dfdf r3fa16b  
    3939#include "CodePatterns/MemDebug.hpp"
    4040
    41 bool executePythonScript(const std::string &pythonfilename_string)
     41bool executePythonScriptFile(const boost::filesystem::path &pythonfilename)
    4242{
    43   boost::filesystem::path pythonfilename(pythonfilename_string);
    4443  if (exists(pythonfilename)) {
    4544    // parse in and execute the local and global config.py
     
    6160      std::string pythonscript( std::istreambuf_iterator<char>(pythonfile),
    6261          (std::istreambuf_iterator<char>()) );
    63       std::string enveloped_script("print \"BEGIN of "+pythonfilename_string+":\"\n");
     62      std::string enveloped_script("print \"BEGIN of "+pythonfilename.string()+":\"\n");
    6463      enveloped_script += pythonscript;
    65       enveloped_script += std::string("print \"END of "+pythonfilename_string+":\"\n");
     64      enveloped_script += std::string("print \"END of "+pythonfilename.string()+":\"\n");
    6665
    6766      boost::python::handle<> ignored(( PyRun_String( enveloped_script.c_str(),
     
    7877  return false;
    7978}
     79
     80bool executePythonScript(const std::string &python_string, const std::string &python_scripttitle)
     81{
     82  try {
     83    PyImport_AppendInittab( "pyMoleCuilder", &initpyMoleCuilder );
     84
     85    Py_Initialize();
     86
     87    boost::python::object main_module((
     88        boost::python::handle<>(boost::python::borrowed(PyImport_AddModule("__main__")))));
     89
     90    boost::python::object main_namespace = main_module.attr("__dict__");
     91
     92    boost::python::object molecuilder_module( (boost::python::handle<>(PyImport_ImportModule("pyMoleCuilder"))) );
     93    main_namespace["pyMoleCuilder"] = molecuilder_module;
     94
     95    std::string enveloped_script("print \"BEGIN of "+python_scripttitle+":\"\n");
     96    enveloped_script += python_string+std::string("\n");
     97    enveloped_script += std::string("print \"END of "+python_scripttitle+":\"\n");
     98
     99    boost::python::handle<> ignored(( PyRun_String( enveloped_script.c_str(),
     100        Py_file_input,
     101        main_namespace.ptr(),
     102        main_namespace.ptr() ) ));
     103
     104  } catch( boost::python::error_already_set ) {
     105    PyErr_Print();
     106    return false;
     107  }
     108  return true;
     109}
  • src/Python/PythonScripting.hpp

    r19dfdf r3fa16b  
    1515
    1616#include <string>
     17#include <boost/filesystem/path.hpp>
    1718
    18 bool executePythonScript(const std::string &pythonfilename_string);
     19bool executePythonScriptFile(const boost::filesystem::path &pythonfilename);
     20bool executePythonScript(const std::string &python_string, const std::string &python_scripttitle);
    1921
    2022#endif /* PYTHONSCRIPTING_HPP_ */
  • src/Python/PythonScripting_impl.hpp

    r19dfdf r3fa16b  
    66 */
    77
    8 #ifndef PYTHONSCRIPTING_HPP_
    9 #define PYTHONSCRIPTING_HPP_
     8#ifndef PYTHONSCRIPTING_IMPL_HPP_
     9#define PYTHONSCRIPTING_IMPL_HPP_
    1010
    1111
     
    131131
    132132
    133 #endif /* PYTHONSCRIPTING_HPP_ */
     133#endif /* PYTHONSCRIPTING_IMPL_HPP_ */
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    r19dfdf r3fa16b  
    136136}
    137137
    138 void CommandLineDialog::queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &param, const std::string title, const std::string description){
    139   registerQuery(new RandomNumberDistribution_ParametersCommandLineQuery(param, title, description));
     138void CommandLineDialog::queryKeyValuePair(Parameter<KeyValuePair> &param, const std::string title, const std::string description)
     139{
     140  registerQuery(new KeyValuePairCommandLineQuery(param, title,description));
     141}
     142
     143void CommandLineDialog::queryKeyValuePairs(Parameter< std::vector<KeyValuePair> > &param, const std::string title, const std::string description)
     144{
     145  registerQuery(new KeyValuePairsCommandLineQuery(param, title,description));
    140146}
    141147
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    r19dfdf r3fa16b  
    3434
    3535  virtual void queryEmpty(const std::string ="", const std::string = "");
    36   virtual void queryInt(Parameter<int> &, const std::string ="", const std::string = "");
    37   virtual void queryInts(Parameter<std::vector<int> > &, const std::string ="", const std::string = "");
    38   virtual void queryUnsignedInt(Parameter<unsigned int> &, const std::string ="", const std::string = "");
    39   virtual void queryUnsignedInts(Parameter<std::vector<unsigned int> > &, const std::string ="", const std::string = "");
    40   virtual void queryBoolean(Parameter<bool> &, const std::string ="", const std::string = "");
    41   virtual void queryString(Parameter<std::string> &, const std::string ="", const std::string = "");
    42   virtual void queryStrings(Parameter<std::vector<std::string> > &, const std::string ="", const std::string = "");
    43   virtual void queryDouble(Parameter<double> &, const std::string ="", const std::string = "");
    44   virtual void queryDoubles(Parameter<std::vector<double> > &, const std::string ="", const std::string = "");
    45   virtual void queryAtom(Parameter<const atom *> &, const std::string ="", const std::string = "");
    46   virtual void queryAtoms(Parameter<std::vector<const atom *> > &, const std::string ="", const std::string = "");
    47   virtual void queryMolecule(Parameter<const molecule *> &, const std::string ="", const std::string = "");
    48   virtual void queryMolecules(Parameter<std::vector<const molecule *> > &, const std::string ="", const std::string = "");
    49   virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "");
    50   virtual void queryVectors(Parameter<std::vector<Vector> > &, const std::string ="", const std::string = "");
    51   virtual void queryRealSpaceMatrix(Parameter<RealSpaceMatrix> &, const std::string ="", const std::string = "");
    52   virtual void queryElement(Parameter<const element *> &, const std::string ="", const std::string = "");
    53   virtual void queryElements(Parameter<std::vector<const element *> > &, const std::string ="", const std::string = "");
    54   virtual void queryFile(Parameter<boost::filesystem::path> &, const std::string ="", const std::string = "");
    55   virtual void queryFiles(Parameter<std::vector< boost::filesystem::path> > &, const std::string ="", const std::string = "");
    56   virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const std::string ="", const std::string = "");
    57   // specialized stuff for command line queries
    58   // all placed into Query/CommandLineQuery.hpp
    59   // !please adhere to alphabetical ordering!
    60   class AtomCommandLineQuery;
    61   class AtomsCommandLineQuery;
    62   class BooleanCommandLineQuery;
    63   class DoubleCommandLineQuery;
    64   class DoublesCommandLineQuery;
    65   class ElementCommandLineQuery;
    66   class ElementsCommandLineQuery;
     36
     37protected:
     38
    6739  class EmptyCommandLineQuery;
    68   class FileCommandLineQuery;
    69   class FilesCommandLineQuery;
    70   class IntCommandLineQuery;
    71   class IntsCommandLineQuery;
    72   class MoleculeCommandLineQuery;
    73   class MoleculesCommandLineQuery;
    74   class RealSpaceMatrixCommandLineQuery;
    75   class StringCommandLineQuery;
    76   class StringsCommandLineQuery;
    77   class UnsignedIntCommandLineQuery;
    78   class UnsignedIntsCommandLineQuery;
    79   class VectorCommandLineQuery;
    80   class VectorsCommandLineQuery;
    81   class RandomNumberDistribution_ParametersCommandLineQuery;
     40
     41  /** With the following boost::preprocessor code we generate virtual function
     42   * definitions and forward declarations for all desired query types in the
     43   * CommandLineUI specialization of class Dialog.
     44   */
     45#include "UIElements/GlobalListOfParameterQueries.hpp"
     46#include "UIElements/Dialog_impl_pre.hpp"
     47
     48  #include <boost/preprocessor/facilities/empty.hpp>
     49
     50  // iterate over all parameter query types for query declarations
     51  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     52  #define SUFFIX BOOST_PP_EMPTY()
     53  #define BOOST_PP_LOCAL_MACRO(n) dialog_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type)
     54  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     55  #include BOOST_PP_LOCAL_ITERATE()
     56  #undef dialog_declaration
     57  #undef SUFFIX
     58  #endif
     59
     60  // iterate over all parameter query types for forward declarations
     61  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     62  #define BOOST_PP_LOCAL_MACRO(n) forward_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, CommandLineQuery)
     63  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     64  #include BOOST_PP_LOCAL_ITERATE()
     65  #undef forward_declaration
     66  #endif
     67
     68#include "Dialog_impl_undef.hpp"
     69  /* End of preprocessor code piece */
     70
    8271};
    8372
  • src/UIElements/CommandLineUI/CommandLineParser.cpp

    r19dfdf r3fa16b  
    5252#include "CommandLineParser.hpp"
    5353#include "CommandLineParser_validate.hpp"
     54#include "Parameters/Specifics/KeyValuePair.hpp"
    5455#include "World.hpp"
    5556
     
    402403        ;
    403404      break;
    404     case TypeEnumContainer::RandomNumberDistribution_ParametersType:
    405       OptionList->add_options()
    406         (currentOption->getKeyAndShortForm().c_str(),
    407             currentOption->hasDefaultValue() ?
    408                   (_DefaultAsImplicit ?
    409                       po::value < std::string >()->implicit_value(boost::lexical_cast< std::string >(currentOption->getDefaultValue().c_str())) :
    410                       po::value < std::string >()->default_value(boost::lexical_cast< std::string >(currentOption->getDefaultValue().c_str()))) :
    411                   po::value < std::string >(),
    412                   currentOption->getDescription().c_str())
    413         ;
    414       break;
    415405    case TypeEnumContainer::RealSpaceMatrixType:
    416406      OptionList->add_options()
     
    419409//                  po::value < RealSpaceMatrixValue >()->default_value(boost::lexical_cast<BoxValue>(currentOption->getDefaultValue().c_str())) :
    420410                  po::value < RealSpaceMatrixValue >(),
     411                  currentOption->getDescription().c_str())
     412        ;
     413      break;
     414    case TypeEnumContainer::KeyValueType:
     415      OptionList->add_options()
     416        (currentOption->getKeyAndShortForm().c_str(),
     417            currentOption->hasDefaultValue() ?
     418                  (_DefaultAsImplicit ?
     419                      po::value < KeyValuePair >()->implicit_value(boost::lexical_cast< KeyValuePair >(currentOption->getDefaultValue().c_str())) :
     420                      po::value < KeyValuePair >()->default_value(boost::lexical_cast< KeyValuePair >(currentOption->getDefaultValue().c_str()))) :
     421                  po::value < KeyValuePair >(),
     422                  currentOption->getDescription().c_str())
     423        ;
     424      break;
     425    case TypeEnumContainer::ListOfKeyValuesType:
     426      OptionList->add_options()
     427        (currentOption->getKeyAndShortForm().c_str(),
     428//            currentOption->hasDefaultValue() ?
     429//                  po::value < std::vector<KeyValuePair> >()->default_value(boost::lexical_cast< std::vector<KeyValuePair> >(currentOption->getDefaultValue().c_str())) :
     430                  po::value < std::vector<KeyValuePair> >()->multitoken(),
    421431                  currentOption->getDescription().c_str())
    422432        ;
  • src/UIElements/CommandLineUI/CommandLineParser_validate.cpp

    r19dfdf r3fa16b  
    4242#include "Actions/Values.hpp"
    4343#include "CommandLineParser_validate.hpp"
     44#include "Parameters/Specifics/KeyValuePair.hpp"
    4445
    4546/** boost::program_options validator specialization for VectorValue.
     
    157158void validate(boost::any& v, const std::vector<std::string>& values, boost::filesystem::path *, int)
    158159{
    159   boost::filesystem::path filename;
    160 
    161   std::cerr << "boost::filesystem::path validator used." << std::endl;
     160//  std::cerr << "boost::filesystem::path validator used." << std::endl;
     161
     162  // Make sure no previous assignment to 'a' was made.
     163  boost::program_options::validators::check_first_occurrence(v);
     164  // Extract the first string from 'values'. If there is more than
     165  // one string, it's an error, and exception will be thrown.
     166  const std::string& s = boost::program_options::validators::get_single_string(values);
     167
     168  v = boost::any(boost::filesystem::path(s));
     169}
     170
     171/** boost::program_options validator specialization for boost::filesystem::path.
     172 * \param &v  reference for return value
     173 * \param &values string vector of scanned options
     174 * \param *
     175 * \param
     176 *
     177 */
     178void validate(boost::any& v, const std::vector<std::string>& values, KeyValuePair *, int)
     179{
     180//  std::cerr << "KeyValuePair validator used." << std::endl;
     181
     182  // Make sure no previous assignment to 'a' was made.
     183  boost::program_options::validators::check_first_occurrence(v);
     184  // Extract the first string from 'values'. If there is more than
     185  // one string, it's an error, and exception will be thrown.
     186  const std::string& s = boost::program_options::validators::get_single_string(values);
     187
     188  if (s.find("=") == std::string::npos) {
     189#if BOOST_VERSION < 104200
     190    throw boost::program_options::validation_error("Invalid KeyValue given");
     191#else
     192throw boost::program_options::validation_error(
     193    boost::program_options::validation_error::invalid_option_value,
     194    std::string("value"),
     195    std::string("vector<KeyValuePair>")
     196    );
     197#endif
     198  }
     199  v = boost::any(KeyValuePair(s));
     200}
     201
     202/** boost::program_options validator specialization for boost::filesystem::path.
     203 * \param &v  reference for return value
     204 * \param &values string vector of scanned options
     205 * \param *
     206 * \param
     207 *
     208 */
     209void validate(boost::any& v, const std::vector<std::string>& values, std::vector<KeyValuePair> *, int)
     210{
     211//  std::cerr << "vector<KeyValuePair> validator used." << std::endl;
    162212
    163213  // split comma-separated values
    164   if (values.size() != 1) {
    165     std::cerr <<  "Not one file but " << values.size() << " given " << std::endl;
     214  if (values.size() > 1) {
    166215#if BOOST_VERSION < 104200
    167216    throw boost::program_options::validation_error("Unequal to one file given");
     
    171220          boost::program_options::validation_error::at_least_one_value_required,
    172221          std::string("value"),
    173           std::string("boost::filesystem::path")
    174       );
    175     } else {
    176       throw boost::program_options::validation_error(
    177           boost::program_options::validation_error::multiple_values_not_allowed,
    178           std::string("value"),
    179           std::string("boost::filesystem::path")
     222          std::string("vector<KeyValuePair>")
    180223      );
    181224    }
    182225#endif
    183   }
    184   filename = values.at(0);
    185   v = boost::any(boost::filesystem::path(filename));
    186 }
    187 
     226    for (std::vector<std::string>::const_iterator iter = values.begin();
     227        iter != values.end();++iter)
     228      if ((*iter).find("=") == std::string::npos) {
     229#if BOOST_VERSION < 104200
     230    throw boost::program_options::validation_error("Invalid KeyValue given");
     231#else
     232    throw boost::program_options::validation_error(
     233        boost::program_options::validation_error::invalid_option_value,
     234        std::string("value"),
     235        std::string("vector<KeyValuePair>")
     236    );
     237#endif
     238      }
     239  }
     240  std::vector<KeyValuePair> temp;
     241  for (std::vector<std::string>::const_iterator iter = values.begin();
     242      iter != values.end();++iter)
     243    temp.push_back(KeyValuePair(*iter));
     244  v = boost::any(temp);
     245}
  • src/UIElements/CommandLineUI/CommandLineParser_validate.hpp

    r19dfdf r3fa16b  
    2222#include <boost/lexical_cast.hpp>
    2323
     24struct KeyValuePair;
    2425class RealSpaceMatrixValue;
    2526class VectorValue;
    2627
     28void validate(boost::any& v, const std::vector<std::string>& values, KeyValuePair *, int);
     29void validate(boost::any& v, const std::vector<std::string>& values, std::vector<KeyValuePair> *, int);
    2730void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int);
    2831void validate(boost::any& v, const std::vector<std::string>& values, RealSpaceMatrixValue *, int);
  • src/UIElements/CommandLineUI/Query/CommandLineQuery.hpp

    r19dfdf r3fa16b  
    2424};
    2525
    26 class CommandLineDialog::IntCommandLineQuery : public Dialog::TQuery<int> {
    27 public:
    28   IntCommandLineQuery(Parameter<int> &_param, const std::string &_title, const std::string &_description = "");
    29   virtual ~IntCommandLineQuery();
    30   virtual bool handle();
    31 };
     26  /** With the following boost::preprocessor code we generate forward declarations
     27   * of query class for all desired query types in the Qt specialization class of
     28   * Dialog.
     29   */
     30#include "UIElements/GlobalListOfParameterQueries.hpp"
     31#include "UIElements/Dialog_impl_pre.hpp"
    3232
    33 class CommandLineDialog::IntsCommandLineQuery : public Dialog::TQuery<std::vector<int> > {
    34 public:
    35   IntsCommandLineQuery(Parameter<std::vector<int> > &_param, const std::string &_title, const std::string &_description = "");
    36   virtual ~IntsCommandLineQuery();
    37   virtual bool handle();
    38 };
     33  #include <boost/preprocessor/facilities/empty.hpp>
    3934
    40 class CommandLineDialog::UnsignedIntCommandLineQuery : public Dialog::TQuery<unsigned int> {
    41 public:
    42   UnsignedIntCommandLineQuery(Parameter<unsigned int> &_param, const std::string &_title, const std::string &_description = "");
    43   virtual ~UnsignedIntCommandLineQuery();
    44   virtual bool handle();
    45 };
     35  // iterate over all parameter query types for forward declarations
     36  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     37  #define BOOST_PP_LOCAL_MACRO(n) queryclass_definition(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type, CommandLine)
     38  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     39  #include BOOST_PP_LOCAL_ITERATE()
     40  #undef queryclass_definition
     41  #endif
    4642
    47 class CommandLineDialog::UnsignedIntsCommandLineQuery : public Dialog::TQuery<std::vector<unsigned int> > {
    48 public:
    49   UnsignedIntsCommandLineQuery(Parameter<std::vector<unsigned int> > &_param, const std::string &_title, const std::string &_description = "");
    50   virtual ~UnsignedIntsCommandLineQuery();
    51   virtual bool handle();
    52 };
     43#include "Dialog_impl_undef.hpp"
     44  /* End of preprocessor code piece */
    5345
    54 class CommandLineDialog::BooleanCommandLineQuery : public Dialog::TQuery<bool> {
    55 public:
    56   BooleanCommandLineQuery(Parameter<bool> &_param, const std::string &_title, const std::string &_description = "");
    57   virtual ~BooleanCommandLineQuery();
    58   virtual bool handle();
    59 };
    60 
    61 class CommandLineDialog::DoubleCommandLineQuery : public Dialog::TQuery<double> {
    62 public:
    63   DoubleCommandLineQuery(Parameter<double> &_param, const std::string &_title, const std::string &_description = "");
    64   virtual ~DoubleCommandLineQuery();
    65   virtual bool handle();
    66 };
    67 
    68 class CommandLineDialog::DoublesCommandLineQuery : public Dialog::TQuery<std::vector<double> > {
    69 public:
    70   DoublesCommandLineQuery(Parameter<std::vector<double> > &_param, const std::string &_title, const std::string &_description = "");
    71   virtual ~DoublesCommandLineQuery();
    72   virtual bool handle();
    73 };
    74 
    75 class CommandLineDialog::StringCommandLineQuery : public Dialog::TQuery<std::string> {
    76 public:
    77   StringCommandLineQuery(Parameter<std::string> &_param, const std::string &_title, const std::string &_description = "");
    78   virtual ~StringCommandLineQuery();
    79   virtual bool handle();
    80 };
    81 
    82 class CommandLineDialog::StringsCommandLineQuery : public Dialog::TQuery<std::vector<std::string> > {
    83 public:
    84   StringsCommandLineQuery(Parameter<std::vector<std::string> > &_param, const std::string &_title, const std::string &_description = "");
    85   virtual ~StringsCommandLineQuery();
    86   virtual bool handle();
    87 };
    88 
    89 class CommandLineDialog::AtomCommandLineQuery : public Dialog::TQuery<const atom *> {
    90 public:
    91   AtomCommandLineQuery(Parameter<const atom *> &_param, const std::string &_title, const std::string &_description = "");
    92   virtual ~AtomCommandLineQuery();
    93   virtual bool handle();
    94 };
    95 
    96 class CommandLineDialog::AtomsCommandLineQuery : public Dialog::TQuery<std::vector<const atom*> > {
    97 public:
    98   AtomsCommandLineQuery(Parameter<std::vector<const atom *> > &_param, const std::string &_title, const std::string &_description = "");
    99   virtual ~AtomsCommandLineQuery();
    100   virtual bool handle();
    101 };
    102 
    103 class CommandLineDialog::MoleculeCommandLineQuery : public Dialog::TQuery<const molecule *> {
    104 public:
    105   MoleculeCommandLineQuery(Parameter<const molecule *> &_param, const std::string &_title, const std::string &_description = "");
    106   virtual ~MoleculeCommandLineQuery();
    107   virtual bool handle();
    108 };
    109 
    110 class CommandLineDialog::MoleculesCommandLineQuery : public Dialog::TQuery<std::vector<const molecule*> > {
    111 public:
    112   MoleculesCommandLineQuery(Parameter<std::vector<const molecule *> > &_param, const std::string &_title, const std::string &_description = "");
    113   virtual ~MoleculesCommandLineQuery();
    114   virtual bool handle();
    115 };
    116 
    117 class CommandLineDialog::VectorCommandLineQuery : public Dialog::TQuery<Vector> {
    118 public:
    119   VectorCommandLineQuery(Parameter<Vector> &_param, const std::string &_title, const std::string &_description = "");
    120   virtual ~VectorCommandLineQuery();
    121   virtual bool handle();
    122 };
    123 
    124 class CommandLineDialog::VectorsCommandLineQuery : public Dialog::TQuery<std::vector<Vector> > {
    125 public:
    126   VectorsCommandLineQuery(Parameter<std::vector<Vector> > &_param, const std::string &_title, const std::string &_description = "");
    127   virtual ~VectorsCommandLineQuery();
    128   virtual bool handle();
    129 };
    130 
    131 class CommandLineDialog::RealSpaceMatrixCommandLineQuery : public Dialog::TQuery<RealSpaceMatrix> {
    132 public:
    133   RealSpaceMatrixCommandLineQuery(Parameter<RealSpaceMatrix> &_param, const std::string &_title, const std::string &_description = "");
    134   virtual ~RealSpaceMatrixCommandLineQuery();
    135   virtual bool handle();
    136 };
    137 
    138 class CommandLineDialog::ElementCommandLineQuery : public Dialog::TQuery<const element *> {
    139 public:
    140   ElementCommandLineQuery(Parameter<const element *> &_param, const std::string &_title, const std::string &_description = "");
    141   virtual ~ElementCommandLineQuery();
    142   virtual bool handle();
    143 };
    144 
    145 class CommandLineDialog::ElementsCommandLineQuery : public Dialog::TQuery<std::vector<const element *> > {
    146 public:
    147   ElementsCommandLineQuery(Parameter<std::vector<const element *> > &_param, const std::string &_title, const std::string &_description = "");
    148   virtual ~ElementsCommandLineQuery();
    149   virtual bool handle();
    150 };
    151 
    152 class CommandLineDialog::FileCommandLineQuery : public Dialog::TQuery<boost::filesystem::path> {
    153 public:
    154   FileCommandLineQuery(Parameter<boost::filesystem::path> &_param, const std::string &_title, const std::string &_description = "");
    155   virtual ~FileCommandLineQuery();
    156   virtual bool handle();
    157 };
    158 
    159 class CommandLineDialog::FilesCommandLineQuery : public Dialog::TQuery<std::vector<boost::filesystem::path> > {
    160 public:
    161   FilesCommandLineQuery(Parameter<std::vector< boost::filesystem::path> > &param, const std::string &_title, const std::string &_description = "");
    162   virtual ~FilesCommandLineQuery();
    163   virtual bool handle();
    164 };
    165 
    166 class CommandLineDialog::RandomNumberDistribution_ParametersCommandLineQuery : public Dialog::TQuery<RandomNumberDistribution_Parameters> {
    167 public:
    168   RandomNumberDistribution_ParametersCommandLineQuery(Parameter<RandomNumberDistribution_Parameters> &_param, const std::string &_title, const std::string &_description = "");
    169   virtual ~RandomNumberDistribution_ParametersCommandLineQuery();
    170   virtual bool handle();
    171 };
    17246
    17347#endif /* COMMANDLINEQUERY_HPP_ */
  • src/UIElements/CommandLineUI/TypeEnumContainer.cpp

    r19dfdf r3fa16b  
    5151#include "Element/element.hpp"
    5252#include "molecule.hpp"
     53#include "Parameters/Specifics/KeyValuePair.hpp"
    5354#include "RandomNumbers/RandomNumberDistribution_Parameters.hpp"
    5455
     
    8182  TypeEnumMap[&typeid(const element *)] = ElementType;
    8283  TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElementsType;
    83   TypeEnumMap[&typeid(RandomNumberDistribution_Parameters)] = RandomNumberDistribution_ParametersType;
     84  TypeEnumMap[&typeid(KeyValuePair)] = KeyValueType;
     85  TypeEnumMap[&typeid(std::vector<KeyValuePair>)] = ListOfKeyValuesType;
    8486
    8587  // for debugging: list all stored types
  • src/UIElements/CommandLineUI/TypeEnumContainer.hpp

    r19dfdf r3fa16b  
    4646        ElementType,
    4747        ListOfElementsType,
    48         RandomNumberDistribution_ParametersType,
    49         RealSpaceMatrixType
     48        RealSpaceMatrixType,
     49        KeyValueType,
     50        ListOfKeyValuesType
    5051  };
    5152
  • src/UIElements/Dialog.cpp

    r19dfdf r3fa16b  
    135135}*/
    136136
    137 template <> void Dialog::query<bool>(Parameter<bool> &param, const std::string title, const std::string description)
    138 {
    139   queryBoolean(param, title, description);
    140 }
     137/** With the following boost::preprocessor code we generate template
     138 * specializations for each desired query types in the abstract class Dialog.
     139 */
     140#include "UIElements/GlobalListOfParameterQueries.hpp"
     141#include "UIElements/Dialog_impl_pre.hpp"
    141142
    142 template <> void Dialog::query<int>(Parameter<int> &param, const std::string title, const std::string description)
    143 {
    144   queryInt(param, title, description);
    145 }
     143  // print a template body
     144  #define dialog_definition(z,n,TOKENLIST,TYPELIST) \
     145  template <> void Dialog::query< \
     146    BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     147  >(Parameter< \
     148    BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     149  > &param, const std::string title, const std::string description) { \
     150  BOOST_PP_CAT(query, BOOST_PP_SEQ_ELEM(n, TOKENLIST)) \
     151  (param, title, description); }
    146152
    147 template <> void Dialog::query< std::vector<int> >(Parameter<std::vector<int> > &param, const std::string title, const std::string description)
    148 {
    149   queryInts(param, title, description);
    150 }
     153  // print template specialization for every query type
     154  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     155  #define BOOST_PP_LOCAL_MACRO(n) dialog_definition(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type)
     156  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     157  #include BOOST_PP_LOCAL_ITERATE()
     158  #endif
    151159
    152 template <> void Dialog::query<unsigned int>(Parameter<unsigned int> &param, const std::string title, const std::string description)
    153 {
    154   queryUnsignedInt(param, title, description);
    155 }
     160  #undef dialog_definition
    156161
    157 template <> void Dialog::query< std::vector<unsigned int> >(Parameter<std::vector<unsigned int> > &param, const std::string title, const std::string description)
    158 {
    159   queryUnsignedInts(param, title, description);
    160 }
     162#include "Dialog_impl_undef.hpp"
     163/* End of preprocessor code piece */
    161164
    162 template <> void Dialog::query<double>(Parameter<double> &param, const std::string title, const std::string description)
    163 {
    164   queryDouble(param, title, description);
    165 }
    166 
    167 template <> void Dialog::query< std::vector<double> >(Parameter<std::vector<double> > &param, const std::string title, const std::string description)
    168 {
    169   queryDoubles(param, title, description);
    170 }
    171 
    172 template <> void Dialog::query<std::string>(Parameter<std::string> &param, const std::string title, const std::string description)
    173 {
    174   queryString(param, title, description);
    175 }
    176 
    177 template <> void Dialog::query< std::vector<std::string> >(Parameter<std::vector<std::string> > &param, const std::string title, const std::string description)
    178 {
    179   queryStrings(param, title, description);
    180 }
    181 
    182 template <> void Dialog::query<const atom *>(Parameter<const atom *> &param, const std::string title, const std::string description)
    183 {
    184   queryAtom(param, title, description);
    185 }
    186 
    187 template <> void Dialog::query< std::vector<const atom *> >(Parameter<std::vector<const atom *> > &param, const std::string title, const std::string description)
    188 {
    189   queryAtoms(param, title, description);
    190 }
    191 
    192 template <> void Dialog::query<const molecule *>(Parameter<const molecule *> &param, const std::string title, const std::string description)
    193 {
    194   queryMolecule(param, title, description);
    195 }
    196 
    197 template <> void Dialog::query< std::vector<const molecule *> >(Parameter<std::vector<const molecule *> > &param, const std::string title, const std::string description)
    198 {
    199   queryMolecules(param, title, description);
    200 }
    201 
    202 template <> void Dialog::query<Vector>(Parameter<Vector> &param, const std::string title, const std::string description)
    203 {
    204   queryVector(param, title, description);
    205 }
    206 
    207 template <> void Dialog::query< std::vector<Vector> >(Parameter<std::vector<Vector> > &param, const std::string title, const std::string description)
    208 {
    209   queryVectors(param, title, description);
    210 }
    211 
    212 template <> void Dialog::query<RealSpaceMatrix>(Parameter<RealSpaceMatrix> &param, const std::string title, const std::string description)
    213 {
    214   queryRealSpaceMatrix(param, title, description);
    215 }
    216 
    217 template <> void Dialog::query<const element *>(Parameter<const element *> &param, const std::string title, const std::string description)
    218 {
    219   queryElement(param, title, description);
    220 }
    221 
    222 template <> void Dialog::query< std::vector<const element *> >(Parameter<std::vector<const element *> > &param, const std::string title, const std::string description)
    223 {
    224   queryElements(param, title, description);
    225 }
    226 
    227 template <> void Dialog::query< boost::filesystem::path >(Parameter<boost::filesystem::path> &param, const std::string title, const std::string description)
    228 {
    229   queryFile(param, title, description);
    230 }
    231 
    232 template <> void Dialog::query< std::vector<boost::filesystem::path> >(Parameter<std::vector< boost::filesystem::path> > &param, const std::string title, const std::string description)
    233 {
    234   queryFiles(param, title, description);
    235 }
    236 
    237 template <> void Dialog::query< RandomNumberDistribution_Parameters >(Parameter<RandomNumberDistribution_Parameters> &param, const std::string title, const std::string description)
    238 {
    239   queryRandomNumberDistribution_Parameters(param, title, description);
    240 }
     165//template <> void Dialog::query< std::vector<KeyValuePair> >(Parameter< std::vector<KeyValuePair> > &param, const std::string title, const std::string description)
     166//{
     167//  queryKeyValuePairs(param, title, description);
     168//}
    241169
    242170/************************** Query Infrastructure ************************/
  • src/UIElements/Dialog.hpp

    r19dfdf r3fa16b  
    2222#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2323#include "LinearAlgebra/Vector.hpp"
    24 #include "RandomNumbers/RandomNumberDistribution_Parameters.hpp"
    2524#include "Parameters/Parameter.hpp"
     25#include "Parameters/Specifics/KeyValuePair.hpp"
    2626
    2727class atom;
     
    2929class element;
    3030class molecule;
    31 
    3231
    3332/** Dialog is one of the two main classes of the UIFactory base class.
     
    133132 * Due to the three present UI interfaces we have to add a specific Query for each, here
    134133 * is a list:
    135  *   -# add ValueStorage::setCurrentValue() and ValueStorage::queryCurrentValue() for
    136  *      both types
    137  *   -# add Dialog::query...()
    138  *   -# add Dialog::query<>() specialization calling the above function
    139  *   -# add CommandLineDialog::query...(), TextDialog::query...(), and QtDialog::query...(),
    140  *      i.e. for each of the three interface
    141  *   -# add empty definition DummyDialog::query...() to the stub for Action unittests in DummUI.hpp.
    142  *   -# add Dialog::...Query class with tmp value of desired type
     134 *   -# add a token (i.e. a unique name for the query parameter) and its type to the
     135 *      global list in \ref GlobalListOfParameterQueries.hpp. This will via boost
     136 *      preprocessor magic add definitions and some intermediatr template specializations.
     137 *   -# add a specialization for each of the UI interfaces of Dialog::...Query class.
     138 *   -# add class declaration of QtDialog::...Query in \ref QtQuery.hpp
    143139 *   -# add CommandLineDialog::...Query, TextDialog::...Query, QtDialog::...Query
    144  *   -# you probably also need a QtDialog::...QueryPipe() to handle the signal/slot stuff,
    145  *      Qt's moc does not like nested classes. Hence, this has to go extra.
    146  *   -# TypeEnumContainer add new type to query
     140 *   -# TypeEnumContainer add new type to query. Make the Type name match with the token
    147141 *   -# CommandLineParser::AddOptionToParser() add new type to query
    148142 *   -# CommandLineParser_valdiates.[ch]pp: If given above as a new type
    149143 *      program_options::value, define and implement a validate() function here.
     144 *
     145 * Note that the Empty..Query is always specificly present as it has not type and thus
     146 * does not fit into the preprocessor magic scheme (on the plus side it also serves
     147 * as a kind of visualization of what the preprocessor actually does).
    150148 *
    151149 */
     
    159157
    160158  virtual void queryEmpty(const std::string ="", const std::string = "")=0;
    161   virtual void queryBoolean(Parameter<bool> &, const std::string ="", const std::string = "")=0;
    162   virtual void queryInt(Parameter<int> &, const std::string ="", const std::string = "")=0;
    163   virtual void queryInts(Parameter<std::vector<int> > &, const std::string ="", const std::string = "")=0;
    164   virtual void queryUnsignedInt(Parameter<unsigned int> &, const std::string ="", const std::string = "")=0;
    165   virtual void queryUnsignedInts(Parameter<std::vector<unsigned int> > &, const std::string ="", const std::string = "")=0;
    166   virtual void queryDouble(Parameter<double> &, const std::string ="", const std::string = "")=0;
    167   virtual void queryDoubles(Parameter<std::vector<double> > &, const std::string ="", const std::string = "")=0;
    168   virtual void queryString(Parameter<std::string> &, const std::string ="", const std::string = "")=0;
    169   virtual void queryStrings(Parameter<std::vector<std::string> > &, const std::string ="", const std::string = "")=0;
    170   virtual void queryAtom(Parameter<const atom *> &, const std::string = "", const std::string = "")=0;
    171   virtual void queryAtoms(Parameter<std::vector<const atom *> > &, const std::string = "", const std::string = "")=0;
    172   virtual void queryMolecule(Parameter<const molecule *> &, const std::string ="", const std::string = "")=0;
    173   virtual void queryMolecules(Parameter<std::vector<const molecule *> > &, const std::string ="", const std::string = "")=0;
    174   virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "")=0;
    175   virtual void queryVectors(Parameter<std::vector<Vector> > &, const std::string ="", const std::string = "")=0;
    176   virtual void queryRealSpaceMatrix(Parameter<RealSpaceMatrix> &, const std::string ="", const std::string = "")=0;
    177   virtual void queryElement(Parameter<const element *> &, const std::string ="", const std::string = "")=0;
    178   virtual void queryElements(Parameter<std::vector<const element *> > &, const std::string ="", const std::string = "")=0;
    179   virtual void queryFile(Parameter<boost::filesystem::path> &, const std::string ="", const std::string = "")=0;
    180   virtual void queryFiles(Parameter< std::vector<boost::filesystem::path> > &, const std::string ="", const std::string = "")=0;
    181   virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const std::string ="", const std::string = "")=0;
     159
     160  /** With the following boost::preprocessor code we generate virtual function
     161   * definitions for all desired query types in the abstract class Dialog.
     162   */
     163#include "UIElements/GlobalListOfParameterQueries.hpp"
     164#include "UIElements/Dialog_impl_pre.hpp"
     165
     166  // iterate over all parameter query types
     167  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     168  #define SUFFIX =0
     169  #define BOOST_PP_LOCAL_MACRO(n) dialog_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type)
     170  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     171  #include BOOST_PP_LOCAL_ITERATE()
     172  #undef dialog_declaration
     173  #undef SUFFIX
     174  #endif
     175
     176#include "Dialog_impl_undef.hpp"
     177  /* End of preprocessor code piece */
    182178
    183179  virtual bool display();
     
    286282};
    287283
    288 
    289284#endif /* DIALOG_HPP_ */
  • src/UIElements/Makefile.am

    r19dfdf r3fa16b  
    1818  UIElements/CommandLineUI/Query/MoleculeCommandLineQuery.cpp \
    1919  UIElements/CommandLineUI/Query/MoleculesCommandLineQuery.cpp \
     20  UIElements/CommandLineUI/Query/KeyValuePairCommandLineQuery.cpp \
     21  UIElements/CommandLineUI/Query/KeyValuePairsCommandLineQuery.cpp \
    2022  UIElements/CommandLineUI/Query/RealSpaceMatrixCommandLineQuery.cpp \
    2123  UIElements/CommandLineUI/Query/StringCommandLineQuery.cpp \
     
    2527  UIElements/CommandLineUI/Query/VectorCommandLineQuery.cpp \
    2628  UIElements/CommandLineUI/Query/VectorsCommandLineQuery.cpp \
    27   UIElements/CommandLineUI/Query/RandomNumberDistribution_ParametersCommandLineQuery.cpp \
    2829  UIElements/CommandLineUI/CommandLineDialog.cpp \
    2930  UIElements/CommandLineUI/CommandLineParser.cpp \
     
    9091  UIElements/TextUI/Query/MoleculesTextQuery.cpp \
    9192  UIElements/TextUI/Query/MoleculeTextQuery.cpp \
     93  UIElements/TextUI/Query/KeyValuePairTextQuery.cpp \
     94  UIElements/TextUI/Query/KeyValuePairsTextQuery.cpp \
    9295  UIElements/TextUI/Query/RealSpaceMatrixTextQuery.cpp \
    9396  UIElements/TextUI/Query/StringTextQuery.cpp \
     
    97100  UIElements/TextUI/Query/VectorTextQuery.cpp \
    98101  UIElements/TextUI/Query/VectorsTextQuery.cpp \
    99   UIElements/TextUI/Query/RandomNumberDistribution_ParametersTextQuery.cpp \
    100102  UIElements/TextUI/TextDialog.cpp \
    101103  UIElements/TextUI/TextStatusIndicator.cpp \
     
    138140  ${VIEWHEADER} \
    139141  UIElements/Dialog.hpp \
     142  UIElements/Dialog_impl_pre.hpp \
     143  UIElements/Dialog_impl_undef.hpp \
     144  UIElements/GlobalListOfParameterQueries.hpp \
    140145  UIElements/MainWindow.hpp
    141146
     
    156161  UIElements/Qt4/Query/MoleculesQtQuery.cpp \
    157162  UIElements/Qt4/Query/QtQueryList.cpp \
     163  UIElements/Qt4/Query/KeyValuePairQtQuery.cpp \
     164  UIElements/Qt4/Query/KeyValuePairsQtQuery.cpp \
    158165  UIElements/Qt4/Query/RealSpaceMatrixQtQuery.cpp \
    159166  UIElements/Qt4/Query/StringQtQuery.cpp \
     
    163170  UIElements/Qt4/Query/VectorQtQuery.cpp \
    164171  UIElements/Qt4/Query/VectorsQtQuery.cpp \
    165   UIElements/Qt4/Query/RandomNumberDistribution_ParametersQtQuery.cpp \
    166172  UIElements/Qt4/QtMainWindow.cpp \
    167173  UIElements/Qt4/QtDialog.cpp \
  • src/UIElements/Qt4/QtDialog.cpp

    r19dfdf r3fa16b  
    197197}
    198198
    199 void QtDialog::queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &param, const std::string title, const std::string description)
    200 {
    201   registerQuery(new RandomNumberDistribution_ParametersQtQuery(param,title,description,inputLayout,this));
     199void QtDialog::queryKeyValuePair(Parameter<KeyValuePair> &param, const std::string title, const std::string description)
     200{
     201  registerQuery(new KeyValuePairQtQuery(param, title,description,inputLayout,this));
     202}
     203
     204void QtDialog::queryKeyValuePairs(Parameter< std::vector<KeyValuePair> > &param, const std::string title, const std::string description)
     205{
     206  registerQuery(new KeyValuePairsQtQuery(param, title,description,inputLayout,this));
    202207}
    203208
  • src/UIElements/Qt4/QtDialog.hpp

    r19dfdf r3fa16b  
    3535
    3636  virtual void queryEmpty(const std::string ="", const std::string = "");
    37   virtual void queryBoolean(Parameter<bool> &, const std::string ="", const std::string = "");
    38   virtual void queryInt(Parameter<int> &, const std::string ="", const std::string = "");
    39   virtual void queryInts(Parameter<std::vector<int> > &, const std::string ="", const std::string = "");
    40   virtual void queryUnsignedInt(Parameter<unsigned int> &, const std::string ="", const std::string = "");
    41   virtual void queryUnsignedInts(Parameter<std::vector<unsigned int> > &, const std::string ="", const std::string = "");
    42   virtual void queryDouble(Parameter<double> &, const std::string ="", const std::string = "");
    43   virtual void queryDoubles(Parameter<std::vector<double> > &, const std::string ="", const std::string = "");
    44   virtual void queryString(Parameter<std::string> &, const std::string ="", const std::string = "");
    45   virtual void queryStrings(Parameter<std::vector<std::string> > &, const std::string ="", const std::string = "");
    46   virtual void queryAtom(Parameter<const atom *> &, const std::string ="", const std::string = "");
    47   virtual void queryAtoms(Parameter<std::vector<const atom *> > &, const std::string ="", const std::string = "");
    48   virtual void queryMolecule(Parameter<const molecule *> &, const std::string ="", const std::string = "");
    49   virtual void queryMolecules(Parameter<std::vector<const molecule *> > &, const std::string ="", const std::string = "");
    50   virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "");
    51   virtual void queryVectors(Parameter<std::vector<Vector> > &, const std::string ="", const std::string = "");
    52   virtual void queryRealSpaceMatrix(Parameter<RealSpaceMatrix> &, const std::string ="", const std::string = "");
    53   virtual void queryElement(Parameter<const element *> &, const std::string ="", const std::string = "");
    54   virtual void queryElements(Parameter<std::vector<const element *> > &, const std::string ="", const std::string = "");
    55   virtual void queryFile(Parameter<boost::filesystem::path> &, const std::string ="", const std::string = "");
    56   virtual void queryFiles(Parameter<std::vector< boost::filesystem::path> > &, const std::string ="", const std::string = "");
    57   virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const std::string ="", const std::string = "");
     37
     38  /** With the following boost::preprocessor code we generate virtual function
     39   * definitions for all desired query types in the abstract class Dialog.
     40   */
     41#include "UIElements/GlobalListOfParameterQueries.hpp"
     42#include "UIElements/Dialog_impl_pre.hpp"
     43
     44  #include <boost/preprocessor/facilities/empty.hpp>
     45
     46  // iterate over all parameter query types
     47  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     48  #define SUFFIX BOOST_PP_EMPTY()
     49  #define BOOST_PP_LOCAL_MACRO(n) dialog_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type)
     50  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     51  #include BOOST_PP_LOCAL_ITERATE()
     52  #undef dialog_declaration
     53  #undef SUFFIX
     54  #endif
     55
     56#include "Dialog_impl_undef.hpp"
     57  /* End of preprocessor code piece */
    5858
    5959  virtual bool display();
     
    6262
    6363protected:
    64   class AtomQtQuery;
    65   class AtomsQtQuery;
    66   class BooleanQtQuery;
    67   class RealSpaceMatrixQtQuery;
    68   class DoubleQtQuery;
    69   class DoublesQtQuery;
    70   class ElementQtQuery;
    71   class ElementsQtQuery;
     64
    7265  class EmptyQtQuery;
    73   class FileQtQuery;
    74   class FilesQtQuery;
    75   class IntQtQuery;
    76   class IntsQtQuery;
    77   class MoleculeQtQuery;
    78   class MoleculesQtQuery;
    79   class StringQtQuery;
    80   class StringsQtQuery;
    81   class UnsignedIntQtQuery;
    82   class UnsignedIntsQtQuery;
    83   class VectorQtQuery;
    84   class VectorsQtQuery;
    85   class RandomNumberDistribution_ParametersQtQuery;
     66
     67  /** With the following boost::preprocessor code we generate forward declarations
     68   * of query class for all desired query types in the Qt specialization class of
     69   * Dialog.
     70   */
     71#include "UIElements/GlobalListOfParameterQueries.hpp"
     72#include "UIElements/Dialog_impl_pre.hpp"
     73
     74  #include <boost/preprocessor/facilities/empty.hpp>
     75
     76  // iterate over all parameter query types for forward declarations
     77  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     78  #define BOOST_PP_LOCAL_MACRO(n) forward_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, QtQuery)
     79  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     80  #include BOOST_PP_LOCAL_ITERATE()
     81  #undef forward_declaration
     82  #endif
     83
     84#include "Dialog_impl_undef.hpp"
     85  /* End of preprocessor code piece */
    8686
    8787private:
  • src/UIElements/Qt4/QtMainWindow.cpp

    r19dfdf r3fa16b  
    7878#include "Actions/WorldAction/OutputAsAction.hpp"
    7979
     80#include "version.h"
    8081
    8182using namespace MoleCuilder;
     
    8586{
    8687  Q_INIT_RESOURCE(icons);
     88  setWindowTitle(MOLECUILDERVERSION);
    8789  theApp->setWindowIcon(QIcon(QPixmap(":/molecuildergui_logo.png")));
    8890  QCoreApplication::setOrganizationName("ins");
  • src/UIElements/Qt4/QtUIFactory.cpp

    r19dfdf r3fa16b  
    3333#endif
    3434
     35#include <cassert>
    3536#include <iostream>
    36 #include <cassert>
     37#include <fstream>
     38#include <string.h>
     39
     40#include <boost/filesystem/path.hpp>
    3741
    3842#include <Qt/qapplication.h>
     
    4347#include "UIElements/Qt4/QtDialog.hpp"
    4448
     49// boost::python uses placement new which is incompatible with MemDebug.
     50#ifdef HAVE_PYTHON
     51#include "Python/PythonScripting.hpp"
     52#endif
     53
    4554#include "CodePatterns/MemDebug.hpp"
    4655
    47 #include "version.h"
    4856#include "Helpers/defs.hpp"
    4957
    5058using namespace std;
    5159
    52 QtUIFactory::QtUIFactory() :
    53   argc(1)
     60QtUIFactory::QtUIFactory(int _argc, char **_argv) :
     61    argc(1),
     62    argv(new char*[1]),
     63    testlauncher_Interrupted(false),
     64    testlauncher_thread(NULL)
    5465{
    55   // For now we just fake the command line parameters to make QT happy
    56   argv = new char*[1];
    57   argv[0] = new char[256];
    58   strcpy(argv[0],MOLECUILDERVERSION);
    59   app = new QApplication(argc,argv);
     66
     67  // check whether we are in test mode
     68  if ((_argc > 1) && (isTestMode(_argv[1]))) {
     69#ifdef HAVE_BOOST_THREAD_HPP
     70    std::vector<std::string> scripts;
     71    scripts.reserve(_argc-1);
     72    for (int i=2;i<_argc;++i)
     73      scripts.push_back(std::string(_argv[i]));
     74
     75    // check for line-by-line execution
     76    const bool SingleLineStepping = (strncmp(&_argv[1][6], "single", 6) == 0);
     77
     78    // prepare an extra thread
     79    std::cout << "TESTLAUNCHER: Preparing " << std::endl;
     80    testlauncher_thread = new boost::thread(
     81        boost::bind(&QtUIFactory::testrun, this, scripts, SingleLineStepping));
     82#else
     83    std::cerr << "Boost::thread support missing! Cannot launch test scripts.\n";
     84#endif
     85    // use fake commands to not pass test stuff
     86    const int length = strlen(_argv[0]);
     87    argv[0] = new char[length];
     88    strncpy(_argv[0],_argv[0], length);
     89    app = new QApplication(argc,argv);
     90  } else {
     91    app = new QApplication(_argc,_argv);
     92  }
    6093}
    6194
    6295QtUIFactory::~QtUIFactory()
    6396{
    64   //delete app;
    65   delete [] argv[0];
    66   delete [] argv;
     97  if (testlauncher_thread != NULL) {
     98    // notify testlauncher_thread thread that we wish to terminate
     99    testlauncher_thread->interrupt();
     100    // wait till it ends
     101    testlauncher_thread->join();
     102    // and remove
     103    delete testlauncher_thread;
     104  }
     105  // free fake command line argument arrays
     106  delete[] argv[0];
     107  delete[] argv;
    67108}
    68109
     
    75116}
    76117
    77 QtUIFactory::description::description() :
    78     UIFactory::factoryDescription("Qt4")
     118QtUIFactory::description::description(int _argc, char **_argv) :
     119    UIFactory::factoryDescription("Qt4"),
     120    argc(_argc),
     121    argv(_argv)
    79122{}
    80123
     
    83126
    84127UIFactory* QtUIFactory::description::makeFactory(){
    85   return new QtUIFactory();
     128  return new QtUIFactory(argc, argv);
    86129}
     130
     131bool QtUIFactory::isTestMode(const char *_argument)
     132{
     133  return (strncmp(_argument,"--test", 6) == 0);
     134}
     135
     136void QtUIFactory::testrun(const std::vector<std::string> _scripts, const bool _singleLineStepping) const
     137{
     138  std::cout << "TESTLAUNCHER: Waiting for GUI to set up" << std::endl;
     139  testlauncher_sleep(boost::posix_time::seconds(3));
     140
     141  std::vector<std::string>::const_iterator scriptiter = _scripts.begin();
     142  do {
     143    // then launch script
     144    std::cout << "TESTLAUNCHER: Launching script " << *scriptiter
     145        << (_singleLineStepping ? " line by line." : ".") <<std::endl;
     146    if (_singleLineStepping) {
     147      boost::filesystem::path scriptfilename(*scriptiter);
     148      ASSERT( boost::filesystem::exists(scriptfilename),
     149          "QtUIFactory::testrun() - given testmode script file "
     150          +toString(scriptfilename.string())+" does not exist.");
     151      std::ifstream scriptfile(scriptfilename.string().c_str());
     152      std::string scriptfile_line;
     153      const std::string testmode("testmode, line nr.");
     154      unsigned int line_nr = 0;
     155      while(std::getline(scriptfile, scriptfile_line)) {
     156        std::string scriptname = testmode+toString(++line_nr);
     157        executePythonScript(scriptfile_line, scriptname);
     158      }
     159    } else {
     160      executePythonScriptFile(*scriptiter);
     161    }
     162    ++scriptiter;
     163
     164    std::cout << "TESTLAUNCHER: Sleeping after script" << std::endl;
     165    testlauncher_sleep(boost::posix_time::seconds(1.5));
     166
     167  } while ((scriptiter != _scripts.end()) && (!testlauncher_Interrupted));
     168
     169  // send quit signal
     170  std::cout << "TESTLAUNCHER: Quitting" << std::endl;
     171  app->quit();
     172}
     173
     174void QtUIFactory::testlauncher_sleep(const boost::posix_time::time_duration& _period) const
     175{
     176  try {
     177    // first sleep for four seconds
     178#if BOOST_VERSION < 105000
     179    testlauncher_thread->sleep(boost::get_system_time() + _period);
     180#else
     181    boost::this_thread::sleep_for(boost::chrono::seconds(4));
     182#endif
     183  } catch(boost::thread_interrupted &e) {
     184    LOG(2, "INFO: testlauncher thread has received stop signal.");
     185  }
     186}
  • src/UIElements/Qt4/QtUIFactory.hpp

    r19dfdf r3fa16b  
    1717#include "UIElements/UIFactory.hpp"
    1818
     19#include <boost/thread.hpp>
     20#include <string>
     21#include <vector>
     22
    1923class QApplication;
    2024
     
    3034
    3135  struct description : public UIFactory::factoryDescription {
    32     description();
     36    description(int _argc, char **_argv);
    3337    virtual ~description();
    3438
    3539    virtual UIFactory* makeFactory();
    36   };
     40
     41  private:
     42    int argc;
     43    char **argv;
     44 };
    3745  virtual std::string getUIName(){  return "Qt4";  }
    3846
     47  static bool isTestMode(const char *_argument);
     48
    3949protected:
    40   QtUIFactory();
     50  QtUIFactory(int _argc, char **_argv);
    4151
    4252private:
    43   // faked command line arguments
     53
     54  void testrun(const std::vector<std::string> _scripts, const bool _singleLineStepping = false) const;
     55
     56  void testlauncher_sleep(const boost::posix_time::time_duration& _period) const;
     57
     58private:
     59  QApplication *app;
     60
    4461  int argc;
    4562  char **argv;
    46   QApplication *app;
     63
     64  //!> internal flag to tell testlauncher_thread to stop
     65  mutable bool testlauncher_Interrupted;
     66
     67  //!> internal thread to call Actions
     68  boost::thread *testlauncher_thread;
    4769};
    4870
  • src/UIElements/Qt4/Query/QtQuery.hpp

    r19dfdf r3fa16b  
    1717#include <Qt/qwidget.h>
    1818#include "Qt4/QtDialog.hpp"
     19#include "QtQueryList.hpp"
     20
    1921#include "Parameters/Parameter.hpp"
    20 #include "QtQueryList.hpp"
    2122
    2223class QHBoxLayout;
     
    300301};
    301302
     303class QtDialog::KeyValuePairQtQuery : public QWidget, public QtQuery<KeyValuePair> {
     304  Q_OBJECT
     305public:
     306  KeyValuePairQtQuery(Parameter<KeyValuePair> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
     307  virtual ~KeyValuePairQtQuery();
     308
     309public slots:
     310  void onUpdate(const QString&);
     311  void onUpdateCombo(int index);
     312
     313private:
     314  QBoxLayout *parent;
     315  QBoxLayout *thisLayout;
     316  QLabel *titleLabel;
     317  QLineEdit *inputBox;
     318  QComboBox *comboBox;
     319  Dialog *dialog;
     320};
     321
     322class QtDialog::KeyValuePairsQtQuery : public QWidget, public QtQuery<std::vector<KeyValuePair> >, public QtQueryList<KeyValuePair> {
     323  Q_OBJECT
     324public:
     325  KeyValuePairsQtQuery(Parameter<std::vector<KeyValuePair> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
     326  virtual ~KeyValuePairsQtQuery();
     327
     328  virtual void onSubUpdate();
     329
     330public slots:
     331  void onAddElement();
     332  void onRemoveElement();
     333  void onElementSelected();
     334
     335private:
     336  KeyValuePairQtQuery *subQuery;
     337};
     338
    302339class QtDialog::StringQtQuery : public QWidget, public QtQuery<std::string> {
    303340  Q_OBJECT
     
    411448};
    412449
    413 class QtDialog::RandomNumberDistribution_ParametersQtQuery : public QWidget, public QtQuery<RandomNumberDistribution_Parameters> {
    414   Q_OBJECT
    415 public:
    416   RandomNumberDistribution_ParametersQtQuery(Parameter<RandomNumberDistribution_Parameters> &, const std::string &_title, const std::string &_description,QBoxLayout *,Dialog *);
    417   virtual ~RandomNumberDistribution_ParametersQtQuery();
    418 
    419 public slots:
    420   void onUpdate();
    421 
    422 private:
    423   QBoxLayout *parent;
    424   QHBoxLayout *thisLayout;
    425   QLabel *titleLabel;
    426   QTextEdit *inputBox;
    427   QPushButton *okButton;
    428   Dialog *dialog;
    429 };
    430 
    431450#endif /* QTQUERY_HPP_ */
  • src/UIElements/Qt4/Query/QtQueryList.hpp

    r19dfdf r3fa16b  
    142142  virtual void queryFile(Parameter<boost::filesystem::path> &, const std::string = "", const std::string = ""){}
    143143  virtual void queryFiles(Parameter<std::vector< boost::filesystem::path> > &, const std::string = "", const std::string = ""){}
    144   virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const std::string = "", const std::string = ""){}
     144  virtual void queryKeyValuePair(Parameter<KeyValuePair> &, const std::string = "", const std::string = ""){}
     145  virtual void queryKeyValuePairs(Parameter<std::vector<KeyValuePair> > &, const std::string = "", const std::string = ""){}
     146
    145147private:
    146148  QtQueryListUntyped *parent;
  • src/UIElements/TextUI/Query/TextQuery.hpp

    r19dfdf r3fa16b  
    1717#include "TextUI/TextDialog.hpp"
    1818
    19 class TextDialog::AtomTextQuery : public Dialog::TQuery<const atom *> {
    20 public:
    21   AtomTextQuery(Parameter<const atom *> &, const std::string &_title, const std::string &_description = NULL);
    22   virtual ~AtomTextQuery();
    23   virtual bool handle();
    24 };
    25 
    26 class TextDialog::AtomsTextQuery : public Dialog::TQuery<std::vector<const atom *> > {
    27 public:
    28   AtomsTextQuery(Parameter<std::vector<const atom *> > &, const std::string &_title, const std::string &_description = NULL);
    29   virtual ~AtomsTextQuery();
    30   virtual bool handle();
    31 };
    32 
    33 class TextDialog::BooleanTextQuery : public Dialog::TQuery<bool> {
    34 public:
    35   BooleanTextQuery(Parameter<bool> &, const std::string &_title, const std::string &_description = NULL);
    36   virtual ~BooleanTextQuery();
    37   virtual bool handle();
    38 };
    39 
    40 class TextDialog::RealSpaceMatrixTextQuery : public Dialog::TQuery<RealSpaceMatrix> {
    41 public:
    42   RealSpaceMatrixTextQuery(Parameter<RealSpaceMatrix> &, const std::string &_title, const std::string &_description = NULL);
    43   virtual ~RealSpaceMatrixTextQuery();
    44   virtual bool handle();
    45 };
    46 
    47 class TextDialog::DoubleTextQuery : public Dialog::TQuery<double> {
    48 public:
    49   DoubleTextQuery(Parameter<double> &, const std::string &_title, const std::string &_description = NULL);
    50   virtual ~DoubleTextQuery();
    51   virtual bool handle();
    52 };
    53 
    54 class TextDialog::DoublesTextQuery : public Dialog::TQuery<std::vector<double> > {
    55 public:
    56   DoublesTextQuery(Parameter<std::vector<double> > &, const std::string &_title, const std::string &_description = NULL);
    57   virtual ~DoublesTextQuery();
    58   virtual bool handle();
    59 };
    60 
    61 class TextDialog::ElementTextQuery : public Dialog::TQuery<const element *> {
    62 public:
    63   ElementTextQuery(Parameter<const element *> &, const std::string &_title, const std::string &_description = NULL);
    64   virtual ~ElementTextQuery();
    65   virtual bool handle();
    66 };
    67 
    68 class TextDialog::ElementsTextQuery : public Dialog::TQuery<std::vector<const element *> > {
    69 public:
    70   ElementsTextQuery(Parameter<std::vector<const element *> > &, const std::string &_title, const std::string &_description = NULL);
    71   virtual ~ElementsTextQuery();
    72   virtual bool handle();
    73 };
    74 
    7519class TextDialog::EmptyTextQuery : public Dialog::EmptyQuery {
    7620public:
     
    8024};
    8125
    82 class TextDialog::FileTextQuery : public Dialog::TQuery<boost::filesystem::path> {
    83 public:
    84   FileTextQuery(Parameter<boost::filesystem::path> &, const std::string &_title, const std::string &_description = NULL);
    85   virtual ~FileTextQuery();
    86   virtual bool handle();
    87 };
    8826
    89 class TextDialog::FilesTextQuery : public Dialog::TQuery<std::vector<boost::filesystem::path> > {
    90 public:
    91   FilesTextQuery(Parameter<std::vector< boost::filesystem::path> > &param, const std::string &_title, const std::string &_description = NULL);
    92   virtual ~FilesTextQuery();
    93   virtual bool handle();
    94 };
     27  /** With the following boost::preprocessor code we generate forward declarations
     28   * of query class for all desired query types in the Qt specialization class of
     29   * Dialog.
     30   */
     31#include "UIElements/GlobalListOfParameterQueries.hpp"
     32#include "UIElements/Dialog_impl_pre.hpp"
    9533
    96 class TextDialog::IntTextQuery : public Dialog::TQuery<int> {
    97 public:
    98   IntTextQuery(Parameter<int> &, const std::string &_title, const std::string &_description = NULL);
    99   virtual ~IntTextQuery();
    100   virtual bool handle();
    101 };
     34  #include <boost/preprocessor/facilities/empty.hpp>
    10235
    103 class TextDialog::IntsTextQuery : public Dialog::TQuery<std::vector<int> > {
    104 public:
    105   IntsTextQuery(Parameter<std::vector<int> > &, const std::string &_title, const std::string &_description = NULL);
    106   virtual ~IntsTextQuery();
    107   virtual bool handle();
    108 };
     36  // iterate over all parameter query types for forward declarations
     37  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     38  #define BOOST_PP_LOCAL_MACRO(n) queryclass_definition(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type, Text)
     39  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     40  #include BOOST_PP_LOCAL_ITERATE()
     41  #undef queryclass_definition
     42  #endif
    10943
    110 class TextDialog::MoleculeTextQuery : public Dialog::TQuery<const molecule *> {
    111 public:
    112   MoleculeTextQuery(Parameter<const molecule *> &, const std::string &_title, const std::string &_description = NULL);
    113   virtual ~MoleculeTextQuery();
    114   virtual bool handle();
    115 };
     44#include "Dialog_impl_undef.hpp"
     45  /* End of preprocessor code piece */
    11646
    117 class TextDialog::MoleculesTextQuery : public Dialog::TQuery<std::vector<const molecule *> > {
    118 public:
    119   MoleculesTextQuery(Parameter<std::vector<const molecule *> > &, const std::string &_title, const std::string &_description = NULL);
    120   virtual ~MoleculesTextQuery();
    121   virtual bool handle();
    122 };
    123 
    124 class TextDialog::StringTextQuery : public Dialog::TQuery<std::string> {
    125 public:
    126   StringTextQuery(Parameter<std::string> &, const std::string &_title, const std::string &_description = NULL);
    127   virtual ~StringTextQuery();
    128   virtual bool handle();
    129 };
    130 
    131 class TextDialog::StringsTextQuery : public Dialog::TQuery<std::vector<std::string> > {
    132 public:
    133   StringsTextQuery(Parameter<std::vector<std::string> > &, const std::string &_title, const std::string &_description = NULL);
    134   virtual ~StringsTextQuery();
    135   virtual bool handle();
    136 };
    137 
    138 class TextDialog::UnsignedIntTextQuery : public Dialog::TQuery<unsigned int> {
    139 public:
    140   UnsignedIntTextQuery(Parameter<unsigned int> &, const std::string &_title, const std::string &_description = NULL);
    141   virtual ~UnsignedIntTextQuery();
    142   virtual bool handle();
    143 };
    144 
    145 class TextDialog::UnsignedIntsTextQuery : public Dialog::TQuery<std::vector<unsigned int> > {
    146 public:
    147   UnsignedIntsTextQuery(Parameter<std::vector<unsigned int> > &, const std::string &_title, const std::string &_description = NULL);
    148   virtual ~UnsignedIntsTextQuery();
    149   virtual bool handle();
    150 };
    151 
    152 class TextDialog::VectorTextQuery : public Dialog::TQuery<Vector> {
    153 public:
    154   VectorTextQuery(Parameter<Vector> &, const std::string &_title, const std::string &_description = NULL);
    155   virtual ~VectorTextQuery();
    156   virtual bool handle();
    157 };
    158 
    159 class TextDialog::VectorsTextQuery : public Dialog::TQuery<std::vector<Vector> > {
    160 public:
    161   VectorsTextQuery(Parameter<std::vector<Vector> > &, const std::string &_title, const std::string &_description = NULL);
    162   virtual ~VectorsTextQuery();
    163   virtual bool handle();
    164 };
    165 
    166 class TextDialog::RandomNumberDistribution_ParametersTextQuery : public Dialog::TQuery<RandomNumberDistribution_Parameters> {
    167 public:
    168   RandomNumberDistribution_ParametersTextQuery(Parameter<RandomNumberDistribution_Parameters> &, const std::string &_title, const std::string &_description = NULL);
    169   virtual ~RandomNumberDistribution_ParametersTextQuery();
    170   virtual bool handle();
    171 };
    17247
    17348#endif /* TEXTQUERY_HPP_ */
  • src/UIElements/TextUI/TextDialog.cpp

    r19dfdf r3fa16b  
    134134}
    135135
    136 void TextDialog::queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &_param, const std::string title, const std::string description){
    137   registerQuery(new RandomNumberDistribution_ParametersTextQuery(_param, title,description));
     136void TextDialog::queryKeyValuePair(Parameter<KeyValuePair> &param, const std::string title, const std::string description)
     137{
     138  registerQuery(new KeyValuePairTextQuery(param, title,description));
    138139}
    139140
     141void TextDialog::queryKeyValuePairs(Parameter< std::vector<KeyValuePair> > &param, const std::string title, const std::string description)
     142{
     143  registerQuery(new KeyValuePairsTextQuery(param, title,description));
     144}
    140145
    141146/************************** Query Infrastructure ************************/
  • src/UIElements/TextUI/TextDialog.hpp

    r19dfdf r3fa16b  
    2222class element;
    2323class molecule;
     24class KeyValuePair;
    2425class RealSpaceMatrix;
    2526class Vector;
     
    3233
    3334  virtual void queryEmpty(const std::string ="", const std::string = "");
    34   virtual void queryBoolean(Parameter<bool> &, const std::string ="", const std::string = "");
    35   virtual void queryInt(Parameter<int> &, const std::string ="", const std::string = "");
    36   virtual void queryInts(Parameter<std::vector<int> > &, const std::string ="", const std::string = "");
    37   virtual void queryUnsignedInt(Parameter<unsigned int> &, const std::string ="", const std::string = "");
    38   virtual void queryUnsignedInts(Parameter<std::vector<unsigned int> > &, const std::string ="", const std::string = "");
    39   virtual void queryString(Parameter<std::string> &, const std::string ="", const std::string = "");
    40   virtual void queryStrings(Parameter<std::vector<std::string> > &, const std::string ="", const std::string = "");
    41   virtual void queryDouble(Parameter<double> &, const std::string ="", const std::string = "");
    42   virtual void queryDoubles(Parameter<std::vector<double> > &, const std::string ="", const std::string = "");
    43   virtual void queryAtom(Parameter<const atom *> &, const std::string = "",std::string = "");
    44   virtual void queryAtoms(Parameter<std::vector<const atom *> > &, const std::string = "",std::string = "");
    45   virtual void queryMolecule(Parameter<const molecule *> &, const std::string = "",std::string = "");
    46   virtual void queryMolecules(Parameter<std::vector<const molecule *> > &, const std::string = "",std::string = "");
    47   virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "");
    48   virtual void queryVectors(Parameter<std::vector<Vector> > &, const std::string ="", const std::string = "");
    49   virtual void queryRealSpaceMatrix(Parameter<RealSpaceMatrix> &, const std::string ="", const std::string = "");
    50   virtual void queryElement(Parameter<const element *> &, const std::string ="", const std::string = "");
    51   virtual void queryElements(Parameter<std::vector<const element *> > &, const std::string ="", const std::string = "");
    52   virtual void queryFile(Parameter<boost::filesystem::path> &, const std::string ="", const std::string = "");
    53   virtual void queryFiles(Parameter<std::vector<boost::filesystem::path> > &, const std::string ="", const std::string = "");
    54   virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const std::string ="", const std::string = "");
     35
     36  /** With the following boost::preprocessor code we generate virtual function
     37   * definitions for all desired query types in the abstract class Dialog.
     38   */
     39#include "UIElements/GlobalListOfParameterQueries.hpp"
     40#include "UIElements/Dialog_impl_pre.hpp"
     41
     42  #include <boost/preprocessor/facilities/empty.hpp>
     43
     44  // iterate over all parameter query types
     45  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     46  #define SUFFIX BOOST_PP_EMPTY()
     47  #define BOOST_PP_LOCAL_MACRO(n) dialog_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type)
     48  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     49  #include BOOST_PP_LOCAL_ITERATE()
     50  #undef dialog_declaration
     51  #undef SUFFIX
     52  #endif
     53
     54#include "Dialog_impl_undef.hpp"
     55  /* End of preprocessor code piece */
    5556
    5657protected:
    57   // specialized stuff for text queries
    58   // all placed into Query/TextQuery.hpp
    59   // !please adhere to alphabetical ordering!
    60   class AtomTextQuery;
    61   class AtomsTextQuery;
    62   class BooleanTextQuery;
    63   class DoubleTextQuery;
    64   class DoublesTextQuery;
    65   class ElementTextQuery;
    66   class ElementsTextQuery;
     58
    6759  class EmptyTextQuery;
    68   class FileTextQuery;
    69   class FilesTextQuery;
    70   class IntTextQuery;
    71   class IntsTextQuery;
    72   class MoleculeTextQuery;
    73   class MoleculesTextQuery;
    74   class RealSpaceMatrixTextQuery;
    75   class StringTextQuery;
    76   class StringsTextQuery;
    77   class UnsignedIntTextQuery;
    78   class UnsignedIntsTextQuery;
    79   class VectorTextQuery;
    80   class VectorsTextQuery;
    81   class RandomNumberDistribution_ParametersTextQuery;
     60
     61  /** With the following boost::preprocessor code we generate forward declarations
     62   * of query class for all desired query types in the Qt specialization class of
     63   * Dialog.
     64   */
     65#include "UIElements/GlobalListOfParameterQueries.hpp"
     66#include "UIElements/Dialog_impl_pre.hpp"
     67
     68  #include <boost/preprocessor/facilities/empty.hpp>
     69
     70  // iterate over all parameter query types for forward declarations
     71  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     72  #define BOOST_PP_LOCAL_MACRO(n) forward_declaration(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, TextQuery)
     73  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     74  #include BOOST_PP_LOCAL_ITERATE()
     75  #undef forward_declaration
     76  #endif
     77
     78#include "Dialog_impl_undef.hpp"
     79  /* End of preprocessor code piece */
     80
    8281};
    8382
  • src/UIElements/Views/Qt4/QDebugStream.hpp

    r19dfdf r3fa16b  
    3333{
    3434public:
    35   QDebugStream(std::ostream &stream, QTextEdit* text_edit) : m_stream(stream)
     35  QDebugStream(std::ostream &stream, QTextEdit* text_edit) :
     36    m_stream(stream),
     37    printing(false)
    3638  {
    3739    log_window = text_edit;
     
    5456  {
    5557    if (v == '\n') {
     58      while (printing);
     59      printing = true;
    5660      log_window->append(m_string.c_str());
    5761      qDebug() << m_string.c_str();
    5862      m_string.erase(m_string.begin(), m_string.end());
     63      printing = false;
    5964    } else
    6065      m_string += v;
     
    6570  virtual std::streamsize xsputn(const char *p, std::streamsize n)
    6671  {
     72    while (printing);
     73    printing = true;
    6774    m_string.append(p, p + n);
     75    printing = false;
    6876
    6977    size_t pos = 0;
     
    7280      if (pos != std::string::npos) {
    7381        std::string tmp(m_string.begin(), m_string.begin() + pos);
     82        while (printing);
     83        printing = true;
    7484        log_window->append(tmp.c_str());
    7585        qDebug() << tmp.c_str();
    7686        m_string.erase(m_string.begin(), m_string.begin() + pos + 1);
     87        printing = false;
    7788      }
    7889    }
     
    8697  std::string m_string;
    8798
     99  bool printing;
     100
    88101  QTextEdit* log_window;
    89102};
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp

    r19dfdf r3fa16b  
    169169   painter->modelViewMatrix().push();
    170170   painter->modelViewMatrix().translate(m_position);
     171   if (m_rotationAngle != 0.0f)
     172     painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);
    171173   if ((m_scaleX != 1.0f) || (m_scaleY != 1.0f) || (m_scaleZ != 1.0f))
    172174     painter->modelViewMatrix().scale(m_scaleX, m_scaleY, m_scaleZ);
    173    if (m_rotationAngle != 0.0f)
    174      painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);
    175175
    176176   // Apply the material and effect to the painter.
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    r19dfdf r3fa16b  
    329329    }
    330330  }
    331   if (DoResetPosition) {
     331  if (DoResetPosition)
    332332    resetPosition();
     333  if (DoResetWidth)
     334    resetWidth();
     335  if ((DoResetPosition) || (DoResetWidth))
    333336    emit changed();
    334   }
    335   if (DoResetWidth) {
    336     resetWidth();
    337     emit changed();
    338   }
    339337}
    340338
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp

    r19dfdf r3fa16b  
    7171  double minradius = 2.; // TODO: set to maximum bond length value
    7272  LOG(3, "DEBUG: Molecule fits into sphere of radius " << minradius);
    73   if (minradius < 1.)
    74     minradius = 1.;
     73  // check minimum bond radius in molecule
     74  double minlength = std::numeric_limits<double>::max();
     75  for (molecule::const_iterator iter = molref->begin();
     76      iter != molref->end(); ++iter) {
     77    const BondList &ListOfBonds = (*iter)->getListOfBonds();
     78    for (BondList::const_iterator bonditer = ListOfBonds.begin();
     79         bonditer != ListOfBonds.end(); ++bonditer) {
     80      const double bond_distance = (*bonditer)->GetDistance();
     81      minlength = std::min(bond_distance, minlength);
     82    }
     83  }
     84  minradius = std::max( std::max(minradius, minlength), 1.);
    7585
    7686  QGeometryData geo;
     
    457467    painter->modelViewMatrix().push();
    458468    painter->modelViewMatrix().translate(m_position);
     469    if (m_rotationAngle != 0.0f)
     470      painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);
    459471    if ((m_scaleX != 1.0f) || (m_scaleY != 1.0f) || (m_scaleZ != 1.0f))
    460472      painter->modelViewMatrix().scale(m_scaleX, m_scaleY, m_scaleZ);
    461     if (m_rotationAngle != 0.0f)
    462       painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);
    463473
    464474    // Draw a box around the mesh, if selected.
  • src/World.cpp

    r19dfdf r3fa16b  
    4848#include "Descriptors/AtomDescriptor.hpp"
    4949#include "Descriptors/AtomDescriptor_impl.hpp"
     50#include "Descriptors/AtomIdDescriptor.hpp"
    5051#include "Descriptors/AtomSelectionDescriptor.hpp"
    5152#include "Descriptors/MoleculeDescriptor.hpp"
    5253#include "Descriptors/MoleculeDescriptor_impl.hpp"
     54#include "Descriptors/MoleculeIdDescriptor.hpp"
    5355#include "Descriptors/MoleculeSelectionDescriptor.hpp"
    5456#include "Descriptors/SelectiveConstIterator_impl.hpp"
     
    226228    const atom * const Walker = (*bonditer)->leftatom;
    227229    const atom * const OtherWalker = (*bonditer)->rightatom;
    228     const_cast<atom *>(Walker)->addBond(_deststep, const_cast<atom *>(OtherWalker));
     230    bond::ptr const _bond =
     231        const_cast<atom *>(Walker)->addBond(_deststep, const_cast<atom *>(OtherWalker));
     232    _bond->setDegree((*bonditer)->getDegree());
    229233  }
    230234}
     
    559563  OBSERVE;
    560564  NOTIFY(SelectionChanged);
    561   selectedAtoms = selectedAtoms_Stack.top();
     565  const atomIdsVector_t atomids = selectedAtoms_Stack.top();
     566  boost::function<void (const atomId_t)> IdSelector =
     567      boost::bind(static_cast<void (World::*)(const atomId_t)>(&World::selectAtom), this, _1);
     568  selectedAtoms.clear();
     569  std::for_each(atomids.begin(),atomids.end(), IdSelector);
    562570  selectedAtoms_Stack.pop();
    563571}
     
    566574  OBSERVE;
    567575  NOTIFY(SelectionChanged);
    568   selectedAtoms_Stack.push( selectedAtoms );
     576  atomIdsVector_t atomids(countSelectedAtoms(), (atomId_t)-1);
     577  std::copy(
     578      MapKeyIterator<AtomSelectionConstIterator>(beginAtomSelection()),
     579      MapKeyIterator<AtomSelectionConstIterator>(endAtomSelection()),
     580      atomids.begin());
     581  selectedAtoms_Stack.push( atomids );
    569582  selectedAtoms.clear();
    570583}
     
    703716  OBSERVE;
    704717  NOTIFY(SelectionChanged);
    705   selectedMolecules = selectedMolecules_Stack.top();
     718  const moleculeIdsVector_t moleculeids = selectedMolecules_Stack.top();
     719  boost::function<void (const moleculeId_t)> IdSelector =
     720      boost::bind(static_cast<void (World::*)(const moleculeId_t)>(&World::selectMolecule), this, _1);
     721  selectedMolecules.clear();
     722  std::for_each(moleculeids.begin(),moleculeids.end(), IdSelector);
    706723  selectedMolecules_Stack.pop();
    707724}
     
    710727  OBSERVE;
    711728  NOTIFY(SelectionChanged);
    712   selectedMolecules_Stack.push( selectedMolecules );
     729  moleculeIdsVector_t moleculeids(countSelectedMolecules(), (moleculeId_t)-1);
     730  boost::function<moleculeId_t (const molecule*)> IdRetriever =
     731      boost::bind(&molecule::getId, _1);
     732  std::copy(
     733      MapKeyIterator<MoleculeSelectionConstIterator>(beginMoleculeSelection()),
     734      MapKeyIterator<MoleculeSelectionConstIterator>(endMoleculeSelection()),
     735      moleculeids.begin());
     736  selectedMolecules_Stack.push( moleculeids );
    713737  selectedMolecules.clear();
    714738}
  • src/World.hpp

    r19dfdf r3fa16b  
    491491  AtomSet atoms;
    492492  AtomSet selectedAtoms;
    493   std::stack<AtomSet> selectedAtoms_Stack;
     493  typedef std::vector<atomId_t> atomIdsVector_t;
     494  std::stack<atomIdsVector_t> selectedAtoms_Stack;
    494495  /**
    495496   * stores the pool for all available AtomIds below currAtomId
     
    501502  MoleculeSet molecules;
    502503  MoleculeSet selectedMolecules;
    503   std::stack<MoleculeSet> selectedMolecules_Stack;
     504  typedef std::vector<moleculeId_t> moleculeIdsVector_t;
     505  std::stack<moleculeIdsVector_t> selectedMolecules_Stack;
    504506  /**
    505507   * stores the pool for all available AtomIds below currAtomId
  • src/builder_init.cpp

    r19dfdf r3fa16b  
    126126  // if we have python, autoexecute a molecuilder script in current folder
    127127#ifdef HAVE_PYTHON
    128   const std::string pythonfilename_string("./molecuilder.py");
    129   executePythonScript(pythonfilename_string);
     128  const boost::filesystem::path pythonfilename("./molecuilder.py");
     129  executePythonScriptFile(pythonfilename);
    130130#endif
    131131
    132132  // handle remaining arguments by CommandLineParser
    133   if (argc>1) {
     133  // first argument of "--test" initializes special molecuilder gui test mode
     134  if ((argc>1)
     135#ifdef USE_GUI_QT
     136      && !QtUIFactory::isTestMode(argv[1])
     137#endif
     138  ) {
    134139    LOG(0, "Setting UI to CommandLine.");
    135140    CommandLineParser::getInstance().InitializeCommandArguments();
     
    139144  } else {
    140145    // In the interactive mode, we can leave the user the choice in case of error
    141     ASSERT_DO(Assert::Ask);
    142146    #ifdef USE_GUI_QT
     147    if ((argc>1) && (QtUIFactory::isTestMode(argv[1])))
     148      ASSERT_DO(Assert::Abort);
     149    else
     150      ASSERT_DO(Assert::Ask);
    143151      LOG(0, "Setting UI to Qt4.");
    144       UIFactory::registerFactory(new QtUIFactory::description());
     152      UIFactory::registerFactory(new QtUIFactory::description(argc, argv));
    145153      UIFactory::makeUserInterface("Qt4");
    146154    #else
     155      ASSERT_DO(Assert::Ask);
    147156      LOG(0, "Setting UI to Text.");
    148157      cout << MOLECUILDERVERSION << endl;
  • tests/Calculations/testsuite-calculations-1_2-dimethoxyethane.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-1_2-dimethylbenzene.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-2-methylcyclohexanone.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-N_N-dimethylacetamide.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-anthracene.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-benzene.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-cholesterol.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-coronene.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-cycloheptane.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-dimethyl_bromomalonate.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-glucose.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-heptan.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-isoleucine.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-mpqc.at

    r19dfdf r3fa16b  
    3030        ignore,
    3131        ignore)
     32AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     33AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
     34
    3235AT_CLEANUP
  • tests/Calculations/testsuite-calculations-naphthalene.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-neohexane.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-phenanthrene.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-proline.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-putrescine.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Calculations/testsuite-calculations-tartaric_acid.at

    r19dfdf r3fa16b  
    4545         --fragment-resultfile ${FILENAME}_results.dat],
    4646         0, [stdout], [stderr])
    47 AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($2 - energy)/energy) > 1e-5) exit(1)}'], 0)
     47AT_CHECK([tail -n 1 ${FILENAME}_Energy.dat | awk '{print $2}'], 0, [stdout], [stderr])
     48AT_CHECK([cat stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0)
    4849
    4950AT_CLEANUP
    50 
  • tests/Makefile.am

    r19dfdf r3fa16b  
    44        Calculations \
    55        CodeChecks \
     6        GuiChecks \
    67        regression \
    78        Fragmentations \
     
    1011        JobMarket
    1112
    12 .PHONY: extracheck installextracheck
     13.PHONY: extracheck guicheck installextracheck
    1314
     15guicheck:
     16        cd GuiChecks && $(MAKE) guicheck
    1417extracheck:
    1518        cd Calculations && $(MAKE) extracheck
  • tests/regression/Atoms/testsuite-atoms.at

    r19dfdf r3fa16b  
    4444# mirror atoms
    4545m4_include([Atoms/Mirror/testsuite-atoms-mirror.at])
     46
     47# saturate atoms
     48m4_include([Atoms/Saturate/testsuite-atoms-saturate_carbon.at])
     49m4_include([Atoms/Saturate/testsuite-atoms-saturate_nitrogen.at])
  • tests/regression/Bond/Add/testsuite-bond-add.at

    r19dfdf r3fa16b  
    1919
    2020AT_SETUP([Bond - adding bond])
    21 AT_KEYWORDS([bond add-bond])
     21AT_KEYWORDS([bond add-bonds])
    2222file=test.pdb
    2323AT_CHECK([cp -f ${abs_top_srcdir}/tests/regression/Bond/Add/pre/$file $file], 0, [ignore], [ignore])
    2424AT_CHECK([chmod +w $file], 0, [ignore], [ignore])
    25 AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --add-bond], 0, [ignore], [ignore])
    26 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Add/post/test.pdb], 0, [ignore], [ignore])
     25AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --add-bonds], 0, [ignore], [ignore])
     26AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Add/post/$file], 0, [ignore], [ignore])
    2727AT_CLEANUP
    2828
    2929
    3030AT_SETUP([Bond - adding bond with Undo])
    31 AT_KEYWORDS([bond add-bond undo])
     31AT_KEYWORDS([bond add-bonds undo])
    3232file=test.pdb
    3333AT_CHECK([cp -f ${abs_top_srcdir}/tests/regression/Bond/Add/pre/$file $file], 0, [ignore], [ignore])
    3434AT_CHECK([chmod +w $file], 0, [ignore], [ignore])
    35 AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --add-bond --undo], 0, [ignore], [ignore])
    36 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Add/pre/test.pdb], 0, [ignore], [ignore])
     35AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --add-bonds --undo], 0, [ignore], [ignore])
     36AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Add/pre/$file], 0, [ignore], [ignore])
    3737AT_CLEANUP
    3838
    3939
    4040AT_SETUP([Bond - adding bond with Redo])
    41 AT_KEYWORDS([bond add-bond redo])
     41AT_KEYWORDS([bond add-bonds redo])
    4242file=test.pdb
    4343AT_CHECK([cp -f ${abs_top_srcdir}/tests/regression/Bond/Add/pre/$file $file], 0, [ignore], [ignore])
    4444AT_CHECK([chmod +w $file], 0, [ignore], [ignore])
    45 AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --add-bond --undo --redo], 0, [ignore], [ignore])
    46 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Add/post/test.pdb], 0, [ignore], [ignore])
     45AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --add-bonds --undo --redo], 0, [ignore], [ignore])
     46AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Add/post/$file], 0, [ignore], [ignore])
    4747AT_CLEANUP
  • tests/regression/Bond/Remove/testsuite-bond-remove.at

    r19dfdf r3fa16b  
    1919
    2020AT_SETUP([Bond - removing bond])
    21 AT_KEYWORDS([bond remove-bond])
     21AT_KEYWORDS([bond remove-bonds])
    2222file=test.pdb
    2323AT_CHECK([cp -f ${abs_top_srcdir}/tests/regression/Bond/Remove/pre/$file $file], 0, [ignore], [ignore])
    2424AT_CHECK([chmod +w $file], 0, [ignore], [ignore])
    25 AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --remove-bond], 0, [ignore], [ignore])
    26 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Remove/post/test.pdb], 0, [ignore], [ignore])
     25AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --remove-bonds], 0, [ignore], [ignore])
     26AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Remove/post/$file], 0, [ignore], [ignore])
    2727AT_CLEANUP
    2828
    2929
    3030AT_SETUP([Bond - removing bond with Undo])
    31 AT_KEYWORDS([bond remove-bond undo])
     31AT_KEYWORDS([bond remove-bonds undo])
    3232file=test.pdb
    3333AT_CHECK([cp -f ${abs_top_srcdir}/tests/regression/Bond/Remove/pre/$file $file], 0, [ignore], [ignore])
    3434AT_CHECK([chmod +w $file], 0, [ignore], [ignore])
    35 AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --remove-bond --undo], 0, [ignore], [ignore])
    36 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Remove/pre/test.pdb], 0, [ignore], [ignore])
     35AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --remove-bonds --undo], 0, [ignore], [ignore])
     36AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Remove/pre/$file], 0, [ignore], [ignore])
    3737AT_CLEANUP
    3838
    3939
    4040AT_SETUP([Bond - removing bond with Redo])
    41 AT_KEYWORDS([bond remove-bond redo])
     41AT_KEYWORDS([bond remove-bonds redo])
    4242file=test.pdb
    4343AT_CHECK([cp -f ${abs_top_srcdir}/tests/regression/Bond/Remove/pre/$file $file], 0, [ignore], [ignore])
    4444AT_CHECK([chmod +w $file], 0, [ignore], [ignore])
    45 AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --remove-bond --undo --redo], 0, [ignore], [ignore])
    46 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Remove/post/test.pdb], 0, [ignore], [ignore])
     45AT_CHECK([../../molecuilder -i $file -o pdb --select-atom-by-id 0 1 --remove-bonds --undo --redo], 0, [ignore], [ignore])
     46AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Bond/Remove/post/$file], 0, [ignore], [ignore])
    4747AT_CLEANUP
  • tests/regression/Bond/testsuite-bond.at

    r19dfdf r3fa16b  
    2020# add bond
    2121m4_include([Bond/Add/testsuite-bond-add.at])
     22m4_include([Bond/Add/testsuite-bond-add_multiple.at])
    2223
    2324# remove bond
    2425m4_include([Bond/Remove/testsuite-bond-remove.at])
     26m4_include([Bond/Remove/testsuite-bond-remove_multiple.at])
  • tests/regression/Makefile.am

    r19dfdf r3fa16b  
    4040        $(srcdir)/Atoms/RemoveSphere/testsuite-atoms-remove-sphere.at \
    4141        $(srcdir)/Atoms/SaveSelectedAtoms/testsuite-atoms-save-selected-atoms.at \
     42        $(srcdir)/Atoms/Saturate/testsuite-atoms-saturate_carbon.at \
     43        $(srcdir)/Atoms/Saturate/testsuite-atoms-saturate_nitrogen.at \
    4244        $(srcdir)/Atoms/Translation/testsuite-atoms-translation.at \
    4345        $(srcdir)/Atoms/TranslationToOrigin/testsuite-atoms-translation-to-origin.at \
    4446        $(srcdir)/Bond/testsuite-bond.at \
    4547        $(srcdir)/Bond/Add/testsuite-bond-add.at \
     48        $(srcdir)/Bond/Add/testsuite-bond-add_multiple.at \
    4649        $(srcdir)/Bond/Remove/testsuite-bond-remove.at \
     50        $(srcdir)/Bond/Remove/testsuite-bond-remove_multiple.at \
    4751        $(srcdir)/Analysis/testsuite-analysis.at \
    4852        $(srcdir)/Analysis/DipoleAngularCorrelation/testsuite-analysis-dipole-angular-correlation.at \
     
    112116        $(srcdir)/Options/testsuite-options.at \
    113117        $(srcdir)/Options/BondLengthTable/testsuite-options-bond-length-table.at \
     118        $(srcdir)/Options/DryRun/testsuite-options-dryrun.at \
     119        $(srcdir)/Options/DryRun/testsuite-options-dryrun-storesession.at \
     120        $(srcdir)/Options/DryRun/testsuite-options-no-dryrun.at \
    114121        $(srcdir)/Options/ElementsDb/testsuite-options-no-elements-db.at \
    115122        $(srcdir)/Options/ElementsDb/testsuite-options-elements-db.at \
  • tests/regression/Molecules/Remove/post/water_box.pdb

    r19dfdf r3fa16b  
    1 REMARK created by molecuilder on Fri Dec 12 19:01:22 2014, time step 0
     1REMARK created by molecuilder on Tue Feb 10 10:29:29 2015, time step 0
    22ATOM      1 O01 0non 01          1.590   2.000   2.000  0.00  0.00           O 0
    33ATOM      2 H01 0non 01          2.205   2.000   2.774  0.00  0.00           H 0
     
    2424ATOM     23 H01 0non 08          6.205   6.000   6.774  0.00  0.00           H 0
    2525ATOM     24 H02 0non 08          6.205   6.000   5.226  0.00  0.00           H 0
     26CONECT    1    2    3                                                           
     27CONECT    2    1                                                               
     28CONECT    3    1                                                               
    2629CONECT    4    5    6                                                           
    2730CONECT    5    4                                                               
    2831CONECT    6    4                                                               
     32CONECT    7    8    9                                                           
     33CONECT    8    7                                                               
     34CONECT    9    7                                                               
    2935CONECT   10   11   12                                                           
    3036CONECT   11   10                                                               
  • tests/regression/Options/FastParsing/testsuite-options-fast-parsing.at

    r19dfdf r3fa16b  
    3939
    4040AT_CHECK([../../molecuilder -i test.conf -n 1 --undo --redo], 0, [stdout], [stderr])
    41 AT_CHECK([grep -c "I won't parse trajectories" stdout], 0, 2
    42 , [ignore])
     41AT_CHECK([grep -c "I won't parse trajectories" stdout], 0, [ignore])
    4342
    4443AT_CLEANUP
  • tests/regression/Options/testsuite-options.at

    r19dfdf r3fa16b  
    5353m4_include([Options/Session/testsuite-options-store-session-python.at])
    5454m4_include([Options/Session/testsuite-options-load-session-python.at])
     55
     56# test dry run
     57m4_include([Options/DryRun/testsuite-options-dryrun.at])
     58m4_include([Options/DryRun/testsuite-options-no-dryrun.at])
     59m4_include([Options/DryRun/testsuite-options-dryrun-storesession.at])
Note: See TracChangeset for help on using the changeset viewer.