Changeset f47e00b for src/Actions
- Timestamp:
- Apr 29, 2014, 12:42:43 PM (11 years ago)
- 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:
- 9bac15
- Parents:
- 237f93
- git-author:
- Frederik Heber <heber@…> (01/11/14 20:57:55)
- git-committer:
- Frederik Heber <heber@…> (04/29/14 12:42:43)
- Location:
- src/Actions
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/MolecularDynamicsAction.hpp
r237f93 rf47e00b 21 21 22 22 #endif /* MOLECULARDYNAMICSACTION_HPP_ */ 23 24 //// some derived names: if CATEGORY is not given, we don't prefix with it25 //#ifdef CATEGORY26 //#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))27 //#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)28 //#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))29 //#else30 //#define ACTION BOOST_PP_CAT(ACTIONNAME, Action)31 //#define COMMAND ACTIONNAME32 //#define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters)33 //#endif34 //// check if no lists given35 //#ifndef paramtypes36 //#define MAXPARAMTYPES 037 //#else38 //#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)39 //#endif40 //#ifndef paramdefaults41 //#define MAXPARAMDEFAULTS 042 //#else43 //#define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults)44 //#endif45 //46 //namespace MoleCuilder {47 //48 //// print a list of type ref followed, i.e. "int i, double position"49 //#define type_list(z,n,TYPELIST, VARLIST) \50 // BOOST_PP_COMMA_IF(n)\51 // BOOST_PP_SEQ_ELEM(n, TYPELIST) \52 // BOOST_PP_SEQ_ELEM(n, VARLIST)53 //54 //void COMMAND(55 //#if defined paramtypes && defined paramreferences56 //#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)57 //#define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1)58 //#include BOOST_PP_LOCAL_ITERATE()59 //#endif60 // );61 //62 //class FragmentationMolecularDynamicsAction;63 //64 //template <>65 //class ActionTraits<ACTION> : public ActionTrait {66 //public:67 // ActionTraits() :68 //#ifndef SHORTFORM69 // ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string()))70 //#else71 // ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string(), SHORTFORM))72 //#endif /* SHORTFORM */73 // {74 // // initialize remainder of action info75 //#ifdef MENUNAME76 // MenuTitle = MENUNAME;77 //#endif78 //#ifdef MENUPOSITION79 // MenuPosition = MENUPOSITION;80 //#endif81 //82 // // we got no options to initialize83 // }84 //85 // virtual ~ActionTraits() {86 // //std::cout << "ActionTraits<" << BOOST_PP_STRINGIZE(ACTION) << ">::~ActionTraits() on instance " << this << " with name " << getName() << " called." << std::endl;87 // }88 //};89 //90 //class FragmentationMolecularDynamicsAction : public MakroAction91 //{92 //public:93 // FragmentationMolecularDynamicsAction();94 // virtual ~FragmentationMolecularDynamicsAction();95 //96 // // must be called after all primitive actions are present97 // void prepare(ActionRegistry &AR);98 // // must be called before alle primitive actions are removed99 // void unprepare(ActionRegistry &AR);100 //101 // virtual ActionState::ptr performCall();102 // virtual ActionState::ptr performUndo(ActionState::ptr);103 // virtual ActionState::ptr performRedo(ActionState::ptr);104 //105 //private:106 // //!> flag to check whether actions have been prepared107 // static bool isPrepared;108 // //!> sequence of actions for this macro action109 // static ActionSequence actions;110 //};111 //112 //}113 //114 //#undef ACTION115 //#undef COMMAND116 //#undef COMMANDFULL117 //#undef PARAMS118 //119 //#undef ACTIONNAME120 //#undef CATEGORY121 //#undef MENUNAME122 //#undef MENUPOSITION123 //#undef TOKEN124 //125 //#undef DESCRIPTION126 //#undef SHORTFORM127 //128 //#endif /* MOLECULARDYNAMICSACTION_HPP_ */ -
src/Actions/GraphAction/SubgraphDissectionAction.cpp
r237f93 rf47e00b 47 47 #include "Descriptors/AtomDescriptor.hpp" 48 48 49 using namespace MoleCuilder; 50 51 // and construct the stuff 49 52 #include "SubgraphDissectionAction.def" 50 51 // some derived names: if CATEGORY is not given, we don't prefix with it 52 #ifdef CATEGORY 53 #define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action)) 54 #define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME) 55 #define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters)) 56 #else 57 #define ACTION BOOST_PP_CAT(ACTIONNAME, Action) 58 #define COMMAND ACTIONNAME 59 #define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters) 60 #endif 61 // check if no lists given 62 #ifndef paramtypes 63 #define MAXPARAMTYPES 0 64 #else 65 #define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes) 66 #endif 67 #ifndef paramdefaults 68 #define MAXPARAMDEFAULTS 0 69 #else 70 #define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults) 71 #endif 72 73 namespace MoleCuilder { 53 #include "MakroAction_impl_pre.hpp" 54 /** =========== define the function ====================== */ 74 55 75 56 // static instances … … 77 58 bool GraphSubgraphDissectionAction::isPrepared = false; 78 59 79 GraphSubgraphDissectionAction::GraphSubgraphDissectionAction() :80 MakroAction(ActionTraits< GraphSubgraphDissectionAction >(), actions)81 {}82 83 GraphSubgraphDissectionAction::~GraphSubgraphDissectionAction()84 {}85 86 60 void GraphSubgraphDissectionAction::prepare(ActionRegistry &AR) 87 61 { 62 actions.addAction(AR.getActionByName(std::string("select-all-atoms"))); 88 63 actions.addAction(AR.getActionByName(std::string("destroy-adjacency"))); 89 64 actions.addAction(AR.getActionByName(std::string("create-adjacency"))); … … 111 86 // we need to "emulate" that all atoms have been selected without destroying 112 87 // current selection 113 Chronos::getInstance().startTiming(TOKEN);114 88 const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms(); 115 World::getInstance().selectAllAtoms(AllAtoms());116 89 ActionState::ptr state(MakroAction::performCall()); 117 90 reselectAtoms(selected_atoms); 118 Chronos::getInstance().endTiming(TOKEN);119 91 120 92 return state; … … 125 97 // current selection 126 98 const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms(); 127 World::getInstance().selectAllAtoms(AllAtoms());128 99 ActionState::ptr state(MakroAction::performUndo(_state)); 129 100 reselectAtoms(selected_atoms); … … 136 107 // current selection 137 108 const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms(); 138 World::getInstance().selectAllAtoms(AllAtoms());139 109 ActionState::ptr state(MakroAction::performRedo(_state)); 140 110 reselectAtoms(selected_atoms); … … 143 113 } 144 114 145 // =========== command for calling action directly =========== 146 void COMMAND( 147 #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) 148 #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences) 149 #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1) 150 #include BOOST_PP_LOCAL_ITERATE() 151 #endif 152 ) 153 { 154 ACTION *ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params); 155 //ACTION::PARAMS params; 156 #if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) 157 #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, paramreferences, ToCall->params.) 158 #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1) 159 #include BOOST_PP_LOCAL_ITERATE() 160 #endif 161 ActionQueue::getInstance().queueAction( ToCall, Action::NonInteractive); 162 }; 115 bool GraphSubgraphDissectionAction::canUndo(){ 116 return true; 117 } 163 118 164 void BOOST_PP_CAT( COMMAND, _stringargs)( 165 #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) 166 #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_TRANSFORM( type2string, , paramtypes), paramreferences) 167 #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1) 168 #include BOOST_PP_LOCAL_ITERATE() 169 #endif 170 ) { 171 ACTION *ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params); 172 //ACTION::PARAMS params; 173 #if defined paramtypes && defined paramtypes && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) 174 #define BOOST_PP_LOCAL_MACRO(n) valuetype_print(~, n, paramreferences, paramtypes, ToCall->params. ) 175 #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1) 176 #include BOOST_PP_LOCAL_ITERATE() 177 #endif 178 ActionQueue::getInstance().queueAction( ToCall, Action::NonInteractive); 179 }; 180 119 bool GraphSubgraphDissectionAction::shouldUndo(){ 120 return true; 181 121 } -
src/Actions/GraphAction/SubgraphDissectionAction.def
r237f93 rf47e00b 21 21 #undef paramvalids 22 22 23 # define statetypes (MolAtomList)24 # define statereferences (moleculelist)23 #undef statetypes 24 #undef statereferences 25 25 26 26 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/GraphAction/SubgraphDissectionAction.hpp
r237f93 rf47e00b 14 14 #endif 15 15 16 #include "Actions/ActionSequence.hpp" 17 #include "Actions/ActionTraits.hpp" 16 18 17 #include "Actions/MakroAction.hpp" 19 18 20 19 #include "SubgraphDissectionAction.def" 21 22 // some derived names: if CATEGORY is not given, we don't prefix with it 23 #ifdef CATEGORY 24 #define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action)) 25 #define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME) 26 #define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters)) 27 #else 28 #define ACTION BOOST_PP_CAT(ACTIONNAME, Action) 29 #define COMMAND ACTIONNAME 30 #define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters) 31 #endif 32 // check if no lists given 33 #ifndef paramtypes 34 #define MAXPARAMTYPES 0 35 #else 36 #define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes) 37 #endif 38 #ifndef paramdefaults 39 #define MAXPARAMDEFAULTS 0 40 #else 41 #define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults) 42 #endif 43 44 namespace MoleCuilder { 45 46 // print a list of type ref followed, i.e. "int i, double position" 47 #define type_list(z,n,TYPELIST, VARLIST) \ 48 BOOST_PP_COMMA_IF(n)\ 49 BOOST_PP_SEQ_ELEM(n, TYPELIST) \ 50 BOOST_PP_SEQ_ELEM(n, VARLIST) 51 52 void COMMAND( 53 #if defined paramtypes && defined paramreferences 54 #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences) 55 #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1) 56 #include BOOST_PP_LOCAL_ITERATE() 57 #endif 58 ); 59 60 class GraphSubgraphDissectionAction; 61 62 template <> 63 class ActionTraits<ACTION> : public ActionTrait { 64 public: 65 ActionTraits() : 66 #ifndef SHORTFORM 67 ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string())) 68 #else 69 ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string(), SHORTFORM)) 70 #endif /* SHORTFORM */ 71 { 72 // initialize remainder of action info 73 #ifdef MENUNAME 74 MenuTitle = MENUNAME; 75 #endif 76 #ifdef MENUPOSITION 77 MenuPosition = MENUPOSITION; 78 #endif 79 80 // we got no options to initialize 81 } 82 83 virtual ~ActionTraits() { 84 //std::cout << "ActionTraits<" << BOOST_PP_STRINGIZE(ACTION) << ">::~ActionTraits() on instance " << this << " with name " << getName() << " called." << std::endl; 85 } 86 }; 87 88 class GraphSubgraphDissectionAction : public MakroAction 89 { 90 public: 91 GraphSubgraphDissectionAction(); 92 virtual ~GraphSubgraphDissectionAction(); 93 94 // must be called after all primitive actions are present 95 void prepare(ActionRegistry &AR); 96 // must be called before alle primitive actions are removed 97 void unprepare(ActionRegistry &AR); 98 99 virtual ActionState::ptr performCall(); 100 virtual ActionState::ptr performUndo(ActionState::ptr); 101 virtual ActionState::ptr performRedo(ActionState::ptr); 102 103 private: 104 //!> flag to check whether actions have been prepared 105 static bool isPrepared; 106 //!> sequence of actions for this macro action 107 static ActionSequence actions; 108 }; 109 110 } 111 112 #undef ACTION 113 #undef COMMAND 114 #undef COMMANDFULL 115 #undef PARAMS 116 117 #undef ACTIONNAME 118 #undef CATEGORY 119 #undef MENUNAME 120 #undef MENUPOSITION 121 #undef TOKEN 122 123 #undef DESCRIPTION 124 #undef SHORTFORM 20 #include "MakroAction_impl_header.hpp" 125 21 126 22 #endif /* SUBGRAPHDISSECTIONACTION_HPP_ */ -
src/Actions/MakroAction_impl_pre.hpp
r237f93 rf47e00b 233 233 public: 234 234 STATE( 235 #if defined statetypes && defined statereferences // if we have parameters, we have to add "_" before each reference and add the params as the last one235 #if defined statetypes && defined statereferences // if we have states, we have to add "_" before each reference and add the params as the last one 236 236 #define OP(s,data,elem) BOOST_PP_CAT(data, elem) // OP to add "_" 237 237 #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_PUSH_BACK(statetypes, const ACTION::PARAMS &), BOOST_PP_SEQ_TRANSFORM(OP, _, BOOST_PP_SEQ_PUSH_BACK(statereferences, params))) … … 242 242 #include BOOST_PP_LOCAL_ITERATE() 243 243 ) : 244 #if defined statetypes && defined statereferences // do we have parameters at all?244 #if defined statetypes && defined statereferences // do we have states at all? 245 245 BOOST_PP_REPEAT(MAXSTATETYPES, initialiser_print, statereferences) 246 246 #endif
Note:
See TracChangeset
for help on using the changeset viewer.