Changeset 7f1b51 for src/Actions


Ignore:
Timestamp:
Sep 15, 2014, 3:05:28 PM (11 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
7e1a88
Parents:
b73545 (diff), 8859b5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'GUI_Fixes' into stable

Location:
src/Actions
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.cpp

    rb73545 r7f1b51  
    127127
    128128Dialog * Action::createDialog(){
    129   Dialog *dialog = UIFactory::getInstance().makeDialog();
     129  Dialog *dialog = UIFactory::getInstance().makeDialog(Traits.getName());
    130130  return fillDialog(dialog);
    131131}
  • src/Actions/ActionQueue.cpp

    rb73545 r7f1b51  
    5555using namespace MoleCuilder;
    5656
     57const Action* ActionQueue::_lastchangedaction = NULL;
     58
    5759ActionQueue::ActionQueue() :
     60    Observable("ActionQueue"),
    5861    AR(new ActionRegistry()),
    5962    history(new ActionHistory),
     
    6669    run_thread_isIdle(true)
    6770#endif
    68 {}
     71{
     72  // channels of observable
     73  Channels *OurChannel = new Channels;
     74  NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) );
     75  // add instance for each notification type
     76  for (size_t type = 0; type < NotificationType_MAX; ++type)
     77    OurChannel->addChannel(type);
     78}
    6979
    7080ActionQueue::~ActionQueue()
     
    8898void ActionQueue::queueAction(const Action * const _action, enum Action::QueryOptions state)
    8999{
     100  OBSERVE;
     101  NOTIFY(ActionQueued);
    90102  Action *newaction = _action->clone(state);
    91103  newaction->prepare(state);
     
    118130  mtx_queue.unlock();
    119131#endif
     132  _lastchangedaction = newaction;
    120133}
    121134
  • src/Actions/ActionQueue.hpp

    rb73545 r7f1b51  
    1616#include "CodePatterns/Singleton.hpp"
    1717
     18#include "CodePatterns/Observer/Channels.hpp"
     19#include "CodePatterns/Observer/Observable.hpp"
    1820
    1921#ifdef HAVE_ACTION_THREAD
     
    3840class ActionRegistry;
    3941class ActionTrait;
     42
     43namespace Queuedetail {
     44  template <class T> const T* lastChanged()
     45  {
     46    ASSERT(0, "Queuedetail::lastChanged() - only specializations may be used.");
     47    return NULL;
     48  }
     49}
    4050
    4151/** This class combines the whole handling of Actions into a single class.
     
    4454 * automatically queued and placed into a History after execution.
    4555 */
    46 class ActionQueue : public Singleton<ActionQueue>
     56class ActionQueue : public Singleton<ActionQueue>, public Observable
    4757{
    4858  friend class Singleton<ActionQueue>;
     
    5161  typedef std::vector< Action * > ActionQueue_t;
    5262
     63  //!> channels for this observable
     64  enum NotificationType {
     65    ActionQueued,  // new action was queued
     66    NotificationType_MAX  // denotes the maximum of available notification types
     67  };
     68
     69  //>! access to last changed element (atom or molecule)
     70  template <class T> const T* lastChanged() const
     71  { return Queuedetail::lastChanged<T>(); }
     72
    5373  /** Queues the Action with \a name to be called.
    5474   *
     
    222242  ~ActionQueue();
    223243
     244private:
     245  friend const Action *Queuedetail::lastChanged<Action>();
     246  static const Action *_lastchangedaction;
     247
    224248  //!> ActionRegistry to spawn new actions
    225249  ActionRegistry *AR;
     
    260284  ActionStatusList StatusList;
    261285};
     286namespace Queuedetail {
     287  template <>       inline  const Action* lastChanged<Action>() { return ActionQueue::_lastchangedaction; }
     288}
    262289
    263290};
  • src/Actions/Action_impl_pre.hpp

    rb73545 r7f1b51  
    111111)
    112112#endif
     113#ifdef paramdescriptions
     114BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramdescriptions)),\
     115  ERROR: There are not the same number of "paramtokens" and "paramdescriptions" in: __FILE__ \
     116)
     117#endif
    113118
    114119#ifdef statetypes
     
    143148  ,\
    144149  BOOST_PP_SEQ_ELEM(n, paramtokens)\
    145   , Traits.getDescription()\
     150  ,\
     151  BOOST_PP_SEQ_ELEM(n, paramdescriptions)\
    146152  );
    147153
  • src/Actions/CommandAction/BondLengthTableAction.def

    rb73545 r7f1b51  
    1010#include "Graph/BondGraph.hpp"
    1111
     12#include "Parameters/Validators/Ops_Validator.hpp"
    1213#include "Parameters/Validators/Specific/FilePresentValidator.hpp"
     14#include "Parameters/Validators/Specific/FileSuffixValidator.hpp"
    1315
    1416// i.e. there is an integer with variable name Z that can be found in
     
    2123#define paramreferences (BondGraphFileName)
    2224#define paramvalids \
    23 (FilePresentValidator())
     25(FilePresentValidator() && (FileSuffixValidator("dat") || FileSuffixValidator("db")))
    2426
    2527#define statetypes (std::string)
  • src/Actions/CommandAction/ElementDbAction.def

    rb73545 r7f1b51  
    99#include <sstream>
    1010
     11#include "Parameters/Validators/Ops_Validator.hpp"
    1112#include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    1213
  • src/Actions/CommandAction/LoadSessionAction.def

    rb73545 r7f1b51  
    99#include <boost/filesystem/path.hpp>
    1010
     11#include "Parameters/Validators/Ops_Validator.hpp"
    1112#include "Parameters/Validators/Specific/FilePresentValidator.hpp"
     13#include "Parameters/Validators/Specific/FileSuffixValidator.hpp"
    1214
    1315// i.e. there is an integer with variable name Z that can be found in
     
    2022#define paramreferences (filename)
    2123#define paramvalids \
    22 (FilePresentValidator())
     24(FilePresentValidator() && FileSuffixValidator("py"))
    2325
    2426#undef statetypes
  • src/Actions/CommandAction/StoreSessionAction.def

    rb73545 r7f1b51  
    1111
    1212#include "Parameters/Validators/DummyValidator.hpp"
     13#include "Parameters/Validators/Ops_Validator.hpp"
     14#include "Parameters/Validators/Specific/FileSuffixValidator.hpp"
    1315#include "Parameters/Validators/Specific/SessionTypeValidator.hpp"
    1416
     
    2224#define paramreferences (filename)(sessiontype)
    2325#define paramvalids \
    24 (DummyValidator< boost::filesystem::path >()) \
     26(FileSuffixValidator("py") || FileSuffixValidator("sh") || FileSuffixValidator("bat")) \
    2527(SessionTypeValidator())
    2628
  • src/Actions/FragmentationAction/ClearFragmentationResultsAction.def

    rb73545 r7f1b51  
    77
    88// all includes and forward declarations necessary for non-integral types below
    9 #include <boost/filesystem/path.hpp>
    10 #include <vector>
    11 
    12 #include "Parameters/Validators/RangeValidator.hpp"
    13 #include "Parameters/Validators/Ops_Validator.hpp"
    14 #include "Parameters/Validators/STLVectorValidator.hpp"
    15 #include "Parameters/Validators/Specific/ParserFileValidator.hpp"
    16 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    179
    1810// i.e. there is an integer with variable name Z that can be found in
  • src/Actions/FragmentationAction/MolecularDynamicsAction.cpp

    rb73545 r7f1b51  
    6565  actions.addAction(AR.getActionByName(std::string("output")));
    6666  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")));
    6770  actions.addAction(AR.getActionByName(std::string("fragment-molecule")));
    6871  actions.addAction(AR.getActionByName(std::string("fragment-automation")));
     
    9194        "FragmentationMolecularDynamicsAction::performCall() - output not found in ActionSequence.");
    9295  }
     96  // don't recreate bond graph if not desired
     97  if (params.DontCreateGraphEachStep.get()) {
     98#ifndef NDEBUG
     99    bool status = true;
     100    status &=
     101#endif
     102        removeAction(std::string("destroy-adjacency"));
     103
     104#ifndef NDEBUG
     105    status &=
     106#endif
     107        removeAction(std::string("create-adjacency"));
     108
     109#ifndef NDEBUG
     110    status &=
     111#endif
     112        removeAction(std::string("update-molecules"));
     113    ASSERT( status,
     114        "FragmentationStructuralOptimizationAction::performCall() - at least one graph action not found in ActionSequence.");
     115  }
    93116  // and call
    94117  ActionState::ptr state(MakroAction::performCall());
  • src/Actions/FragmentationAction/MolecularDynamicsAction.def

    rb73545 r7f1b51  
    1212// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1313// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    14 #define paramtypes (unsigned int)(bool)
    15 #define paramtokens ("steps")("output-every-step")
    16 #define paramdescriptions ("numer of MD steps to perform")("whether World should be written after every step, useful if integration might hang")
    17 #define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))
    18 #define paramreferences (steps)(DoOutput)
     14#define paramtypes (unsigned int)(bool)(bool)
     15#define paramtokens ("steps")("output-every-step")("keep-bondgraph")
     16#define paramdescriptions ("numer of MD steps to perform")("whether World should be written after every step, useful if integration might hang")("whether the bond graph should be kept the same during each step and not updated")
     17#define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))(PARAM_DEFAULT("0"))
     18#define paramreferences (steps)(DoOutput)(DontCreateGraphEachStep)
    1919#define paramvalids \
    2020(NotZeroValidator< unsigned int >()) \
     21(DummyValidator<bool>()) \
    2122(DummyValidator<bool>())
    2223
  • src/Actions/FragmentationAction/StructuralOptimizationAction.cpp

    rb73545 r7f1b51  
    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")));
    6467  actions.addAction(AR.getActionByName(std::string("fragment-molecule")));
    6568  actions.addAction(AR.getActionByName(std::string("fragment-automation")));
     
    9194        "FragmentationStructuralOptimizationAction::performCall() - output not found in ActionSequence.");
    9295  }
     96  // don't recreate bond graph if not desired
     97  if (params.DontCreateGraphEachStep.get()) {
     98#ifndef NDEBUG
     99    bool status = true;
     100    status &=
     101#endif
     102        removeAction(std::string("destroy-adjacency"));
     103
     104#ifndef NDEBUG
     105    status &=
     106#endif
     107        removeAction(std::string("create-adjacency"));
     108
     109#ifndef NDEBUG
     110    status &=
     111#endif
     112        removeAction(std::string("update-molecules"));
     113    ASSERT( status,
     114        "FragmentationStructuralOptimizationAction::performCall() - at least one graph action not found in ActionSequence.");
     115  }
    93116  // and call
    94117  ActionState::ptr state(MakroAction::performCall());
  • src/Actions/FragmentationAction/StructuralOptimizationAction.def

    rb73545 r7f1b51  
    1212// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1313// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    14 #define paramtypes (unsigned int)(bool)
    15 #define paramtokens ("steps")("output-every-step")
    16 #define paramdescriptions ("numer of MD steps to perform")("whether we should update the timestep in each descent step sp as to visualize the minimisation")
    17 #define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))
    18 #define paramreferences (steps)(DoOutput)
     14#define paramtypes (unsigned int)(bool)(bool)
     15#define paramtokens ("steps")("output-every-step")("keep-bondgraph")
     16#define paramdescriptions ("numer of MD steps to perform")("whether we should update the timestep in each descent step sp as to visualize the minimisation")("whether the bond graph should be kept the same during each step and not updated")
     17#define paramdefaults (NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))(PARAM_DEFAULT("0"))
     18#define paramreferences (steps)(DoOutput)(DontCreateGraphEachStep)
    1919#define paramvalids \
    2020(NotZeroValidator< unsigned int >()) \
     21(DummyValidator<bool>()) \
    2122(DummyValidator<bool>())
    2223
  • src/Actions/GraphAction/CorrectBondDegreeAction.cpp

    rb73545 r7f1b51  
    106106  BG->CorrectBondDegree(Set);
    107107
    108   // give info
    109   size_t BondCount = 0;
    110   std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    111   for (std::vector<molecule *>::const_iterator iter = molecules.begin();
    112       iter != molecules.end(); ++iter)
    113     BondCount += (*iter)->getBondCount();
    114   LOG(0, "STATUS: Recognized " << BondCount << " bonds.");
    115 
    116108  return ActionState::ptr(UndoState);
    117109}
  • src/Actions/MoleculeAction/ForceAnnealingAction.def

    rb73545 r7f1b51  
    77
    88// all includes and forward declarations necessary for non-integral types below
     9#include <boost/filesystem/path.hpp>
     10
    911#include "Parameters/Validators/DummyValidator.hpp"
    1012#include "Parameters/Validators/GenericValidators.hpp"
    1113#include "Parameters/Validators/Ops_Validator.hpp"
    12 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    1314
    1415// i.e. there is an integer with variable name Z that can be found in
  • src/Actions/MoleculeAction/VerletIntegrationAction.def

    rb73545 r7f1b51  
    88// all includes and forward declarations necessary for non-integral types below
    99#include "LinearAlgebra/Vector.hpp"
     10#include <boost/filesystem/path.hpp>
    1011#include <vector>
    1112typedef std::vector<Vector> Vectors_t;
     
    1415#include "Parameters/Validators/GenericValidators.hpp"
    1516#include "Parameters/Validators/Ops_Validator.hpp"
    16 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    1717
    1818// i.e. there is an integer with variable name Z that can be found in
  • src/Actions/PotentialAction/FitPotentialAction.def

    rb73545 r7f1b51  
    1818#include "Parameters/Validators/Specific/ElementValidator.hpp"
    1919#include "Parameters/Validators/Specific/EmptyStringValidator.hpp"
     20#include "Parameters/Validators/Specific/FileSuffixValidator.hpp"
    2021#include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    2122#include "Parameters/Validators/Specific/PotentialTypeValidator.hpp"
     
    2627#define paramtypes (boost::filesystem::path)(std::string)(boost::filesystem::path)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double)
    2728#define paramtokens ("training-file")("potential-type")("potential-file")("potential-charges")("fragment-charges")("take-best-of")("set-threshold")
    28 #define paramdescriptions ("optional file to write training data to")("potential type to fit")("potential file specifying multiple potentials to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")
     29#define paramdescriptions ("optional file to write training data to")("potential type to fit")("optional potential file specifying multiple potentials to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")
    2930#define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))
    3031#define paramreferences (training_file)(potentialtype)(potential_file)(charges)(fragment)(best_of_howmany)(threshold)
     
    3233(DummyValidator<boost::filesystem::path>()) \
    3334(EmptyStringValidator() || PotentialTypeValidator()) \
    34 (DummyValidator<boost::filesystem::path>()) \
     35(!FilePresentValidator() || FileSuffixValidator("potentials")) \
    3536(STLVectorValidator< std::vector<const element *> >(0,99, ElementValidator())) \
    3637(STLVectorValidator< std::vector<const element *> >(1,99, ElementValidator())) \
  • src/Actions/unittests/stubs/DummyUI.hpp

    rb73545 r7f1b51  
    2121{
    2222public:
    23   DummyDialog(){}
     23  DummyDialog(const std::string &_title) :
     24    Dialog(_title)
     25  {}
    2426  virtual ~DummyDialog(){}
    2527
     
    5355  virtual ~DummyUIFactory(){}
    5456
    55   virtual Dialog* makeDialog(){return new DummyDialog;}
     57  virtual Dialog* makeDialog(const std::string &_title){return new DummyDialog(_title);}
    5658  virtual MainWindow* makeMainWindow(){return 0;}
    5759
Note: See TracChangeset for help on using the changeset viewer.