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, 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).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ====================== */
Note: See TracChangeset for help on using the changeset viewer.