Changeset 9ee38b for src/Actions


Ignore:
Timestamp:
Aug 28, 2010, 12:52:58 AM (15 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, Candidate_v1.7.0, 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:
b4fa106
Parents:
0b2ce9
git-author:
Frederik Heber <heber@…> (08/25/10 17:20:37)
git-committer:
Frederik Heber <heber@…> (08/28/10 00:52:58)
Message:

Extended macro framework.

Extensions:

  • all central definitions reside in .def files
    • This if file is necessary because we need the definitions at two places: hpp and cpp
    • And as we always use the same define names, we have to undefine them at the end of both (otherwise we get compiler warnings and are prone to dumb mistakes of forgotten defines seeming present)
  • the .hpp is just a very tiny header, that should be possible to batch- construct inside Makefile as well
  • .cpp includes some Action_...hpp files and implements the function

For later (i.e. when ActionRegistry becomes prototype copier)

  • instead of waiting for clone(), for now we simply call the prototype.
  • in the action command we must not yet prefix paramreferences with "params."

Changes:

  • Dialog::query<> is a template which is specialized for every present query...() function. We need it to automatize fillDialog()
  • all AnalysisAction's are now converted, i.e. framework is functional with parameters and queries (MolecularVolume had none).
Location:
src/Actions
Files:
5 added
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action_impl_header.hpp

    r0b2ce9 r9ee38b  
    1818#include <boost/preprocessor/seq/seq.hpp>
    1919#include <boost/preprocessor/seq/size.hpp>
     20#include <boost/preprocessor/seq/transform.hpp>
    2021
    2122// some derived names
     
    2425#define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State))
    2526#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
    26 
     27#define PARAMSDOT BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
    2728
    2829// check if no lists given
     
    7980#define value_print(z,n,command) \
    8081  ValueStorage::getInstance(). command (\
     82  BOOST_PP_SEQ_ELEM(n, tokens)\
     83  , \
     84  params.\
    8185  BOOST_PP_SEQ_ELEM(n, references)\
    82   , \
    83   BOOST_PP_SEQ_ELEM(n, tokens)\
    8486  );
    8587
     
    106108  virtual const std::string getName();
    107109
    108   struct PARAMS;
     110  struct PARAMS : ActionParameters {
     111  #if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
     112  #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, ;)
     113  #define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
     114  #include BOOST_PP_LOCAL_ITERATE()
     115  #undef BOOST_PP_LOCAL_MACRO
     116  #undef BOOST_PP_LOCAL_LIMITS
     117  #endif
     118  } params;
    109119
    110120protected:
     
    119129};
    120130
     131#undef types
     132#undef tokens
     133#undef references
     134#undef MAXNOTOKENS
     135
     136#undef ACTION
     137#undef ACTIONNAME
     138#undef CATEGORY
     139#undef COMMAND
     140#undef COMMANDFULL
     141#undef PARAMS
     142#undef STATE
     143#undef TOKEN
  • src/Actions/Action_impl_pre.hpp

    r0b2ce9 r9ee38b  
    2323 */
    2424
     25
     26#include <boost/preprocessor/cat.hpp>
     27#include <boost/preprocessor/comparison/equal.hpp>
     28#include <boost/preprocessor/comparison/not_equal.hpp>
     29#include <boost/preprocessor/control/if.hpp>
     30#include <boost/preprocessor/debug/assert.hpp>
     31#include <boost/preprocessor/iteration/local.hpp>
     32#include <boost/preprocessor/punctuation/comma_if.hpp>
     33#include <boost/preprocessor/repetition/repeat.hpp>
     34#include <boost/preprocessor/seq/elem.hpp>
     35#include <boost/preprocessor/seq/push_back.hpp>
     36#include <boost/preprocessor/seq/seq.hpp>
     37#include <boost/preprocessor/seq/size.hpp>
     38#include <boost/preprocessor/seq/transform.hpp>
     39
     40// some derived names
     41#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
     42#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
     43#define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State))
     44#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
     45#define PARAMSDOT BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
     46
     47// check if no lists given
     48#ifndef types
     49#define MAXNOTOKENS 0
     50#else
     51#define MAXNOTOKENS BOOST_PP_SEQ_SIZE(types)
     52#endif
     53
     54// check user has given name and category
     55#ifndef CATEGORY
     56ERROR: No "CATEGORY" defined in: __FILE__
     57#endif
     58
     59#ifndef ACTIONNAME
     60ERROR: No "ACTIONNAME" defined in: __FILE__
     61#endif
     62
     63// calculate numbers and check whether all have same size
     64#ifdef tokens
     65BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(tokens)),\
     66  ERROR: There are not the same number of "tokens" and "types" in: __FILE__ \
     67)
     68#endif
     69#ifdef references
     70BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(references)),\
     71  ERROR: There are not the same number of "tokens" and "references" in: __FILE__ \
     72)
     73#endif
     74
     75// print a list of type ref followed by a separator, i.e. "int i;"
     76#define type_print(z,n,separator) \
     77  BOOST_PP_SEQ_ELEM(n, types) \
     78  BOOST_PP_SEQ_ELEM(n, references)\
     79  separator
     80
     81// print a list of type ref followed, i.e. "int i, double position"
     82#define type_list(z,n,unused) \
     83  BOOST_PP_COMMA_IF(n)\
     84  BOOST_PP_SEQ_ELEM(n, types) \
     85  BOOST_PP_SEQ_ELEM(n, references)
     86
     87// prints dialog->query calls for types with tokens
     88#define dialog_print(z,n,unused) \
     89  dialog->query<\
     90  BOOST_PP_SEQ_ELEM(n, types)\
     91  >(\
     92  BOOST_PP_SEQ_ELEM(n, tokens)\
     93  , ValueStorage::getInstance().getDescription(\
     94  BOOST_PP_SEQ_ELEM(n, tokens)\
     95  ));
     96
     97// prints set/queryCurrentValue (command) for paramreferences and paramtokens
     98#define value_print(z,n,command, prefix) \
     99  ValueStorage::getInstance(). command (\
     100  BOOST_PP_SEQ_ELEM(n, tokens)\
     101  , \
     102  prefix\
     103  BOOST_PP_SEQ_ELEM(n, references)\
     104  );
     105
     106#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
     107#define COMMANDFULL \
     108void COMMAND( \
     109BOOST_PP_REPEAT(MAXNOTOKENS, type_list, ~) \
     110)
     111# else
     112#define COMMANDFULL void COMMAND()
     113#endif
     114
    25115#include "Actions/ActionRegistry.hpp"
    26116#include "UIElements/Dialog.hpp"
    27117#include "Actions/ValueStorage.hpp"
     118
    28119
    29120const char ACTION::NAME[] = TOKEN;
     
    52143};
    53144
    54 struct PARAMS : ActionParameters {
     145COMMANDFULL
     146{
     147  ACTION::PARAMS params;
     148  Action *ToCall = ActionRegistry::getInstance().getActionByName( ACTION::NAME ); //->clone(params);
    55149#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
    56 #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, ;)
     150#define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, setCurrentValue, )
    57151#define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
    58152#include BOOST_PP_LOCAL_ITERATE()
     
    60154#undef BOOST_PP_LOCAL_LIMITS
    61155#endif
     156  ToCall->call(Action::NonInteractive);
    62157};
    63158
    64 COMMANDFULL
    65 {
     159void ACTION::getParametersfromValueStorage() {
    66160#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
    67 #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, setCurrentValue)
    68 #define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
    69 #include BOOST_PP_LOCAL_ITERATE()
    70 #undef BOOST_PP_LOCAL_MACRO
    71 #undef BOOST_PP_LOCAL_LIMITS
    72 #endif
    73         ActionRegistry::getInstance().getActionByName( ACTION::NAME )->call(Action::NonInteractive);
    74 };
    75 
    76 void AnalysisMolecularVolumeAction::getParametersfromValueStorage() {
    77 #if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
    78 #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, queryCurrentValue)
     161#define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, queryCurrentValue, params.)
    79162#define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
    80163#include BOOST_PP_LOCAL_ITERATE()
     
    89172#undef MAXNOTOKENS
    90173
     174#undef ACTION
     175#undef ACTIONNAME
     176#undef CATEGORY
     177#undef COMMAND
     178#undef COMMANDFULL
     179#undef PARAMS
     180#undef STATE
     181#undef TOKEN
  • src/Actions/AnalysisAction/MolecularVolumeAction.cpp

    r0b2ce9 r9ee38b  
    3737
    3838// and construct the stuff
     39#include "MolecularVolumeAction.def"
    3940#include "Action_impl_pre.hpp"
    4041
    4142/** =========== define the function ====================== */
    42 Action::state_ptr ACTION::performCall() {
     43Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
    4344  // obtain information
    4445  getParametersfromValueStorage();
     
    6667}
    6768
    68 Action::state_ptr ACTION::performUndo(Action::state_ptr _state) {
     69Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
    6970  return Action::success;
    7071}
    7172
    72 Action::state_ptr ACTION::performRedo(Action::state_ptr _state){
     73Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
    7374  return Action::success;
    7475}
    7576
    76 bool ACTION::canUndo() {
     77bool AnalysisMolecularVolumeAction::canUndo() {
    7778  return true;
    7879}
    7980
    80 bool ACTION::shouldUndo() {
     81bool AnalysisMolecularVolumeAction::shouldUndo() {
    8182  return true;
    8283}
    8384
    84 const string ACTION::getName() {
     85const string AnalysisMolecularVolumeAction::getName() {
    8586  return NAME;
    8687}
    8788/** =========== end of function ====================== */
    88 
    89 // and clean the stuff
    90 #include "Action_impl_post.hpp"
  • src/Actions/AnalysisAction/MolecularVolumeAction.hpp

    r0b2ce9 r9ee38b  
    1616#include "Actions/Action.hpp"
    1717
    18 // i.e. there is an integer with variable name Z that can be found in
    19 // ValueStorage by the token "Z" -> first column: int, Z, "Z"
    20 // "undefine" if no parameters are required
    21 //#define types (int)
    22 //#define references (molID)
    23 //#define tokens (NAME)
    24 // some defines for all the names, you may use ACTION, STATE and PARAMS
    25 #define CATEGORY Analysis
    26 #define ACTIONNAME MolecularVolume
    27 #define TOKEN "molecular-volume"
    28 
    29 #include "Action_impl_header.hpp"
     18#include "MolecularVolumeAction.def"
     19#include "Actions/Action_impl_header.hpp"
    3020
    3121#endif /* MOLECULARVOLUMEACTION_HPP_ */
  • src/Actions/AnalysisAction/PairCorrelationAction.cpp

    r0b2ce9 r9ee38b  
    2020#include "Helpers/MemDebug.hpp"
    2121
    22 #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
    23 #include "Actions/ActionRegistry.hpp"
    2422#include "analysis_correlation.hpp"
    2523#include "boundary.hpp"
     
    3836using namespace std;
    3937
    40 #include "UIElements/UIFactory.hpp"
    41 #include "UIElements/Dialog.hpp"
    42 #include "Actions/ValueStorage.hpp"
     38#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
    4339
    44 const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
     40// and construct the stuff
     41#include "PairCorrelationAction.def"
     42#include "Action_impl_pre.hpp"
    4543
    46 AnalysisPairCorrelationAction::AnalysisPairCorrelationAction() :
    47   Action(NAME)
    48 {}
    49 
    50 AnalysisPairCorrelationAction::~AnalysisPairCorrelationAction()
    51 {}
    52 
    53 void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
    54   ValueStorage::getInstance().setCurrentValue("elements", elements);
    55   ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
    56   ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
    57   ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
    58   ValueStorage::getInstance().setCurrentValue("output-file", outputname);
    59   ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
    60   ValueStorage::getInstance().setCurrentValue("periodic", periodic);
    61   ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive);
    62 };
    63 
    64 
    65 void AnalysisPairCorrelationAction::getParametersfromValueStorage()
    66 {};
    67 
    68 Dialog* AnalysisPairCorrelationAction::fillDialog(Dialog* dialog) {
    69   ASSERT(dialog,"No Dialog given when filling action dialog");
    70 
    71   dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
    72   dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
    73   dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
    74   dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
    75   dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
    76   dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
    77   dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
    78 
    79   return dialog;
    80 }
    81 
     44/** =========== define the function ====================== */
    8245Action::state_ptr AnalysisPairCorrelationAction::performCall() {
    8346  int ranges[3] = {1, 1, 1};
    84   double BinEnd = 0.;
    85   double BinStart = 0.;
    86   double BinWidth = 0.;
    87   string outputname;
    88   string binoutputname;
    89   bool periodic;
    9047  ofstream output;
    9148  ofstream binoutput;
    92   std::vector<const element *> elements;
    9349  string type;
    94   Vector Point;
    9550  BinPairMap *binmap = NULL;
    9651
    9752  // obtain information
    98   ValueStorage::getInstance().queryCurrentValue("elements", elements);
    99   ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
    100   ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
    101   ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
    102   ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
    103   ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
    104   ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
     53  getParametersfromValueStorage();
    10554
    10655  // execute action
    107   output.open(outputname.c_str());
    108   binoutput.open(binoutputname.c_str());
     56  output.open(params.outputname.c_str());
     57  binoutput.open(params.binoutputname.c_str());
    10958  PairCorrelationMap *correlationmap = NULL;
    11059  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
    111   if (periodic)
    112     correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
     60  if (params.periodic)
     61    correlationmap = PeriodicPairCorrelation(molecules, params.elements, ranges);
    11362  else
    114     correlationmap = PairCorrelation(molecules, elements);
     63    correlationmap = PairCorrelation(molecules, params.elements);
    11564  OutputPairCorrelation(&output, correlationmap);
    116   binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
     65  binmap = BinData( correlationmap, params.BinWidth, params.BinStart, params.BinEnd );
    11766  OutputCorrelation ( &binoutput, binmap );
    11867  delete(binmap);
     
    14291  return NAME;
    14392}
     93/** =========== end of function ====================== */
  • src/Actions/AnalysisAction/PairCorrelationAction.hpp

    r0b2ce9 r9ee38b  
    1515
    1616#include "Actions/Action.hpp"
    17 #include <string>
    18 #include <vector>
    1917
    20 class element;
    21 
    22 void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    23 
    24 class AnalysisPairCorrelationAction : public Action {
    25   friend void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    26 public:
    27   AnalysisPairCorrelationAction();
    28   virtual ~AnalysisPairCorrelationAction();
    29 
    30   bool canUndo();
    31   bool shouldUndo();
    32 
    33   virtual const std::string getName();
    34 protected:
    35   virtual Dialog * fillDialog(Dialog*);
    36 private:
    37    virtual void getParametersfromValueStorage();
    38   virtual Action::state_ptr performCall();
    39   virtual Action::state_ptr performUndo(Action::state_ptr);
    40   virtual Action::state_ptr performRedo(Action::state_ptr);
    41 
    42   static const char NAME[];
    43 };
     18#include "PairCorrelationAction.def"
     19#include "Action_impl_header.hpp"
    4420
    4521#endif /* PAIRCORRELATIONACTION_HPP_ */
  • src/Actions/AnalysisAction/PointCorrelationAction.cpp

    r0b2ce9 r9ee38b  
    2020#include "Helpers/MemDebug.hpp"
    2121
    22 #include "Actions/AnalysisAction/PointCorrelationAction.hpp"
    23 #include "Actions/ActionRegistry.hpp"
    2422#include "analysis_correlation.hpp"
    2523#include "boundary.hpp"
     
    3937using namespace std;
    4038
    41 #include "UIElements/UIFactory.hpp"
    42 #include "UIElements/Dialog.hpp"
    43 #include "Actions/ValueStorage.hpp"
     39#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
    4440
    45 const char AnalysisPointCorrelationAction::NAME[] = "point-correlation";
    4641
    47 AnalysisPointCorrelationAction::AnalysisPointCorrelationAction() :
    48   Action(NAME)
    49 {}
     42// and construct the stuff
     43#include "PointCorrelationAction.def"
     44#include "Action_impl_pre.hpp"
    5045
    51 AnalysisPointCorrelationAction::~AnalysisPointCorrelationAction()
    52 {}
    53 
    54 void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
    55   ValueStorage::getInstance().setCurrentValue("elements", elements);
    56   ValueStorage::getInstance().setCurrentValue("position", position);
    57   ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
    58   ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
    59   ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
    60   ValueStorage::getInstance().setCurrentValue("output-file", outputname);
    61   ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
    62   ValueStorage::getInstance().setCurrentValue("periodic", periodic);
    63   ActionRegistry::getInstance().getActionByName(AnalysisPointCorrelationAction::NAME)->call(Action::NonInteractive);
    64 };
    65 
    66 void AnalysisPointCorrelationAction::getParametersfromValueStorage()
    67 {};
    68 
    69 Dialog* AnalysisPointCorrelationAction::fillDialog(Dialog *dialog) {
    70   ASSERT(dialog,"No Dialog given when filling action dialog");
    71 
    72   dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
    73   dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
    74   dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
    75   dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
    76   dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
    77   dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
    78   dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
    79   dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
    80 
    81   return dialog;
    82 }
    83 
     46/** =========== define the function ====================== */
    8447Action::state_ptr AnalysisPointCorrelationAction::performCall() {
    8548  int ranges[3] = {1, 1, 1};
    86   double BinEnd = 0.;
    87   double BinStart = 0.;
    88   double BinWidth = 0.;
    89   string outputname;
    90   string binoutputname;
    91   bool periodic;
    9249  ofstream output;
    9350  ofstream binoutput;
    94   std::vector<const element *> elements;
    9551  string type;
    96   Vector Point;
    9752  BinPairMap *binmap = NULL;
    9853
    9954  // obtain information
    100   ValueStorage::getInstance().queryCurrentValue("position", Point);
    101   ValueStorage::getInstance().queryCurrentValue("elements", elements);
    102   ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
    103   ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
    104   ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
    105   ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
    106   ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
    107   ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
     55  getParametersfromValueStorage();
    10856
    10957  // execute action
    110   output.open(outputname.c_str());
    111   binoutput.open(binoutputname.c_str());
    112   cout << "Point to correlate to is  " << Point << endl;
     58  output.open(params.outputname.c_str());
     59  binoutput.open(params.binoutputname.c_str());
     60  cout << "Point to correlate to is  " << params.Point << endl;
    11361  CorrelationToPointMap *correlationmap = NULL;
    114   for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
     62  for(std::vector<const element *>::iterator iter = params.elements.begin(); iter != params.elements.end(); ++iter)
    11563    cout << "element is " << (*iter)->getSymbol() << endl;
    11664  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
    117   if (periodic)
    118     correlationmap  = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
     65  if (params.periodic)
     66    correlationmap  = PeriodicCorrelationToPoint(molecules, params.elements, &params.Point, ranges);
    11967  else
    120     correlationmap = CorrelationToPoint(molecules, elements, &Point);
     68    correlationmap = CorrelationToPoint(molecules, params.elements, &params.Point);
    12169  OutputCorrelationToPoint(&output, correlationmap);
    122   binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
     70  binmap = BinData( correlationmap, params.BinWidth, params.BinStart, params.BinEnd );
    12371  OutputCorrelation ( &binoutput, binmap );
    12472  delete(binmap);
     
    14896  return NAME;
    14997}
     98/** =========== end of function ====================== */
  • src/Actions/AnalysisAction/PointCorrelationAction.hpp

    r0b2ce9 r9ee38b  
    1515
    1616#include "Actions/Action.hpp"
    17 #include "LinearAlgebra/Vector.hpp"
    18 #include <vector>
    19 #include <string>
    2017
    21 class element;
    22 
    23 void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    24 
    25 class AnalysisPointCorrelationAction : public Action {
    26   friend void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    27 
    28 public:
    29   AnalysisPointCorrelationAction();
    30   virtual ~AnalysisPointCorrelationAction();
    31 
    32   bool canUndo();
    33   bool shouldUndo();
    34 
    35   virtual const std::string getName();
    36 protected:
    37   virtual Dialog * fillDialog(Dialog*);
    38 private:
    39   virtual void getParametersfromValueStorage();
    40   virtual Action::state_ptr performCall();
    41   virtual Action::state_ptr performUndo(Action::state_ptr);
    42   virtual Action::state_ptr performRedo(Action::state_ptr);
    43 
    44   static const char NAME[];
    45 };
     18#include "PointCorrelationAction.def"
     19#include "Action_impl_header.hpp"
    4620
    4721#endif /* POINTCORRELATIONACTION_HPP_ */
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp

    r0b2ce9 r9ee38b  
    2020#include "Helpers/MemDebug.hpp"
    2121
    22 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
    23 #include "Actions/ActionRegistry.hpp"
    2422#include "Helpers/Log.hpp"
    2523#include "Helpers/Verbose.hpp"
     
    3432using namespace std;
    3533
    36 #include "UIElements/UIFactory.hpp"
    37 #include "UIElements/Dialog.hpp"
    38 #include "Actions/ValueStorage.hpp"
     34#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
    3935
    40 const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system";
     36// and construct the stuff
     37#include "PrincipalAxisSystemAction.def"
     38#include "Action_impl_pre.hpp"
    4139
    42 AnalysisPrincipalAxisSystemAction::AnalysisPrincipalAxisSystemAction() :
    43   Action(NAME)
    44 {}
    45 
    46 AnalysisPrincipalAxisSystemAction::~AnalysisPrincipalAxisSystemAction()
    47 {}
    48 
    49 void AnalysisPrincipalAxisSystem() {
    50   ActionRegistry::getInstance().getActionByName(AnalysisPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
    51 };
    52 
    53 void AnalysisPrincipalAxisSystemAction::getParametersfromValueStorage()
    54 {};
    55 
    56 Dialog* AnalysisPrincipalAxisSystemAction::fillDialog(Dialog *dialog) {
    57   ASSERT(dialog,"No Dialog given when filling action dialog");
    58 
    59   dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
    60 
    61   return dialog;
    62 }
    63 
     40/** =========== define the function ====================== */
    6441Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
    65   molecule *mol = NULL;
    6642  Matrix InertiaTensor;
    6743
    68   ValueStorage::getInstance().queryCurrentValue(NAME, mol);
    6944  DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    7045  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     
    11590  return NAME;
    11691}
     92/** =========== end of function ====================== */
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp

    r0b2ce9 r9ee38b  
    1111#include "Actions/Action.hpp"
    1212
    13 void AnalysisPrincipalAxisSystem();
    14 
    15 class AnalysisPrincipalAxisSystemAction : public Action {
    16   friend void AnalysisPrincipalAxisSystem();
    17 
    18 public:
    19   AnalysisPrincipalAxisSystemAction();
    20   virtual ~AnalysisPrincipalAxisSystemAction();
    21 
    22   bool canUndo();
    23   bool shouldUndo();
    24 
    25   virtual const std::string getName();
    26 protected:
    27   virtual Dialog * fillDialog(Dialog *);
    28 private:
    29   virtual void getParametersfromValueStorage();
    30   virtual Action::state_ptr performCall();
    31   virtual Action::state_ptr performUndo(Action::state_ptr);
    32   virtual Action::state_ptr performRedo(Action::state_ptr);
    33 
    34   static const char NAME[];
    35 };
     13#include "PrincipalAxisSystemAction.def"
     14#include "Action_impl_header.hpp"
    3615
    3716#endif /* PRINCIPALAXISSYSTEMACTION_HPP_ */
  • src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp

    r0b2ce9 r9ee38b  
    2020#include "Helpers/MemDebug.hpp"
    2121
    22 #include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
    23 #include "Actions/ActionRegistry.hpp"
    2422#include "analysis_correlation.hpp"
    2523#include "boundary.hpp"
     
    3937using namespace std;
    4038
    41 #include "UIElements/UIFactory.hpp"
    42 #include "UIElements/Dialog.hpp"
    43 #include "Actions/ValueStorage.hpp"
     39#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
    4440
    45 const char AnalysisSurfaceCorrelationAction::NAME[] = "surface-correlation";
     41// and construct the stuff
     42#include "SurfaceCorrelationAction.def"
     43#include "Action_impl_pre.hpp"
    4644
    47 AnalysisSurfaceCorrelationAction::AnalysisSurfaceCorrelationAction() :
    48   Action(NAME)
    49 {}
    50 
    51 AnalysisSurfaceCorrelationAction::~AnalysisSurfaceCorrelationAction()
    52 {}
    53 
    54 void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic) {
    55   ValueStorage::getInstance().setCurrentValue("elements", elements);
    56   ValueStorage::getInstance().setCurrentValue("molecule-by-id", mol);
    57   ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
    58   ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
    59   ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
    60   ValueStorage::getInstance().setCurrentValue("output-file", outputname);
    61   ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
    62   ValueStorage::getInstance().setCurrentValue("periodic", periodic);
    63   ActionRegistry::getInstance().getActionByName(AnalysisSurfaceCorrelationAction::NAME)->call(Action::NonInteractive);
    64 };
    65 
    66 
    67 void AnalysisSurfaceCorrelationAction::getParametersfromValueStorage()
    68 {};
    69 
    70 Dialog* AnalysisSurfaceCorrelationAction::fillDialog(Dialog *dialog) {
    71   ASSERT(dialog,"No Dialog given when filling action dialog");
    72 
    73   dialog->queryMolecule("molecule-by-id", ValueStorage::getInstance().getDescription("molecule-by-id"));
    74   dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
    75   dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
    76   dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
    77   dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
    78   dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
    79   dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
    80   dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
    81 
    82   return dialog;
    83 }
    84 
     45/** =========== define the function ====================== */
    8546Action::state_ptr AnalysisSurfaceCorrelationAction::performCall() {
    8647  int ranges[3] = {1, 1, 1};
    87   double BinEnd = 0.;
    88   double BinStart = 0.;
    89   double BinWidth = 0.;
    90   molecule *Boundary = NULL;
    91   string outputname;
    92   string binoutputname;
    93   bool periodic;
    9448  ofstream output;
    9549  ofstream binoutput;
    96   std::vector<const element *> elements;
    9750  string type;
    98   Vector Point;
    9951  BinPairMap *binmap = NULL;
    10052
    10153  // obtain information
    102   ValueStorage::getInstance().queryCurrentValue("molecule-by-id", Boundary);
    103   ValueStorage::getInstance().queryCurrentValue("elements", elements);
    104   ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
    105   ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
    106   ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
    107   ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
    108   ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
    109   ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
     54  getParametersfromValueStorage();
    11055
    11156  // execute action
    112   output.open(outputname.c_str());
    113   binoutput.open(binoutputname.c_str());
    114   ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
     57  output.open(params.outputname.c_str());
     58  binoutput.open(params.binoutputname.c_str());
     59  ASSERT(params.Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
    11560  const double radius = 4.;
    11661  double LCWidth = 20.;
    117   if (BinEnd > 0) {
    118     if (BinEnd > 2.*radius)
    119       LCWidth = BinEnd;
     62  if (params.BinEnd > 0) {
     63    if (params.BinEnd > 2.*radius)
     64      LCWidth = params.BinEnd;
    12065    else
    12166      LCWidth = 2.*radius;
     
    12873  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
    12974  std::cout << "There are " << molecules.size() << " selected molecules." << std::endl;
    130   LCList = new LinkedCell(Boundary, LCWidth);
    131   FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
     75  LCList = new LinkedCell(params.Boundary, LCWidth);
     76  FindNonConvexBorder(params.Boundary, TesselStruct, LCList, radius, NULL);
    13277  CorrelationToSurfaceMap *surfacemap = NULL;
    133   if (periodic)
    134     surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
     78  if (params.periodic)
     79    surfacemap = PeriodicCorrelationToSurface( molecules, params.elements, TesselStruct, LCList, ranges);
    13580  else
    136     surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
     81    surfacemap = CorrelationToSurface( molecules, params.elements, TesselStruct, LCList);
    13782  delete LCList;
    13883  OutputCorrelationToSurface(&output, surfacemap);
     
    14489      DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
    14590  }
    146   binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
     91  binmap = BinData( surfacemap, params.BinWidth, params.BinStart, params.BinEnd );
    14792  OutputCorrelation ( &binoutput, binmap );
    14893  delete TesselStruct;  // surfacemap contains refs to triangles! delete here, not earlier!
     
    173118  return NAME;
    174119}
     120/** =========== end of function ====================== */
  • src/Actions/AnalysisAction/SurfaceCorrelationAction.hpp

    r0b2ce9 r9ee38b  
    1010
    1111#include "Actions/Action.hpp"
    12 #include <string>
    13 #include <vector>
    1412
    15 class element;
    16 class molecule;
    17 
    18 void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    19 
    20 class AnalysisSurfaceCorrelationAction : public Action {
    21   friend void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    22 public:
    23   AnalysisSurfaceCorrelationAction();
    24   virtual ~AnalysisSurfaceCorrelationAction();
    25 
    26   bool canUndo();
    27   bool shouldUndo();
    28 
    29   virtual const std::string getName();
    30 protected:
    31   virtual Dialog * fillDialog(Dialog*);
    32 private:
    33   virtual void getParametersfromValueStorage();
    34   virtual Action::state_ptr performCall();
    35   virtual Action::state_ptr performUndo(Action::state_ptr);
    36   virtual Action::state_ptr performRedo(Action::state_ptr);
    37 
    38   static const char NAME[];
    39 };
     13#include "SurfaceCorrelationAction.def"
     14#include "Action_impl_header.hpp"
    4015
    4116#endif /* SURFACECORRELATIONACTION_HPP_ */
  • src/Actions/Makefile.am

    r0b2ce9 r9ee38b  
    200200lib_LTLIBRARIES = libMolecuilderActions-@MOLECUILDER_API_VERSION@.la
    201201libMolecuilderActions_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
    202 libMolecuilderActions_libs = ../Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la
     202libMolecuilderActions_libs = \
     203        ../Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \
     204        ../UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la
    203205nobase_libMolecuilderActions_include_HEADERS = ${ACTIONSHEADER}
    204206
Note: See TracChangeset for help on using the changeset viewer.