Changeset 04488a for src/Actions


Ignore:
Timestamp:
Jun 25, 2010, 9:57:15 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
b6dbff
Parents:
ce4487 (diff), 0d1ad0 (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 'StructureRefactoring' into QT4Refactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/builder.cpp

Location:
src/Actions
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionRegistry.cpp

    rce4487 r04488a  
    1919using namespace std;
    2020
     21/** Constructor for class ActionRegistry.
     22 */
    2123ActionRegistry::ActionRegistry()
    2224{
    2325}
    2426
     27/** Destructor for class ActionRegistry.
     28 */
    2529ActionRegistry::~ActionRegistry()
    2630{
     
    3236}
    3337
     38/** Returns pointer to an action named by \a name.
     39 * \param name name of action
     40 * \return pointer to Action
     41 */
    3442Action* ActionRegistry::getActionByName(const std::string name){
    3543  map<const string,Action*>::iterator iter;
     
    3947}
    4048
     49/** States whether action is present or not.
     50 * \note This iss needed as ActionRegistry::getActionByName() ASSERT()s that action is in map.
     51 * \param name name of action
     52 * \return true - Action present, false - Action absent
     53 */
    4154bool ActionRegistry::isActionByNamePresent(const std::string name){
    4255  map<const string,Action*>::iterator iter;
     
    4558}
    4659
     60/** Registers an Action with the ActionRegistry.
     61 * \param *action pointer to Action.
     62 */
    4763void ActionRegistry::registerAction(Action* action){
    4864  pair<map<const string,Action*>::iterator,bool> ret;
     65  //cout << "Trying to register action with name " << action->getName() << "." << endl;
    4966  ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));
    5067  ASSERT(ret.second,"Two actions with the same name added to registry");
    5168}
    5269
     70/** Unregisters an Action.
     71 * \param *action pointer to Action.
     72 */
    5373void ActionRegistry::unregisterAction(Action* action){
     74  //cout << "Unregistering action with name " << action->getName() << "." << endl;
    5475  actionMap.erase(action->getName());
    5576}
    5677
     78/** Returns an iterator pointing to the start of the map of Action's.
     79 * \return begin iterator
     80 */
    5781std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter()
    5882{
     
    6084}
    6185
     86/** Returns an iterator pointing to the end of the map of Action's.
     87 * \return end iterator
     88 */
    6289std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter()
    6390{
     
    6592}
    6693
     94/** Returns a const iterator pointing to the start of the map of Action's.
     95 * \return constant begin iterator
     96 */
     97std::map<const std::string,Action*>::const_iterator ActionRegistry::getBeginIter() const
     98{
     99  return actionMap.begin();
     100}
     101
     102/** Returns a const iterator pointing to the end of the map of Action's.
     103 * \return constant end iterator
     104 */
     105std::map<const std::string,Action*>::const_iterator ActionRegistry::getEndIter() const
     106{
     107  return actionMap.end();
     108}
     109
     110/** Prints the contents of the ActionRegistry \a &m to \a &ost.
     111 * \param &ost output stream
     112 * \param &m reference to ActionRegistry
     113 * \return reference to the above out stream for concatenation
     114 */
     115ostream& operator<<(ostream& ost, const ActionRegistry& m)
     116{
     117  ost << "ActionRegistry contains:" << endl;
     118  for (std::map<const std::string,Action*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {
     119    ost << "\t" << iter->first << " with pointer " << iter->second << endl;
     120  }
     121  return ost;
     122};
     123
     124
     125
    67126CONSTRUCT_SINGLETON(ActionRegistry)
  • src/Actions/ActionRegistry.hpp

    rce4487 r04488a  
    99#define ACTIONREGISTRY_HPP_
    1010
     11#include <iostream>
    1112#include <string>
    1213#include <map>
     
    2627
    2728  std::map<const std::string,Action*>::iterator getBeginIter();
     29  std::map<const std::string,Action*>::const_iterator getBeginIter() const;
    2830  std::map<const std::string,Action*>::iterator getEndIter();
     31  std::map<const std::string,Action*>::const_iterator getEndIter() const;
    2932
    3033private:
     
    3639};
    3740
     41std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m);
     42
    3843#endif /* ACTIONREGISTRY_HPP_ */
  • src/Actions/CmdAction/BondLengthTableAction.cpp

    rce4487 r04488a  
    99
    1010#include "Actions/CmdAction/BondLengthTableAction.hpp"
     11#include "bondgraph.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    rce4487 r04488a  
    1010#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
    1111#include "atom.hpp"
     12#include "bondgraph.hpp"
    1213#include "config.hpp"
    1314#include "log.hpp"
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    rce4487 r04488a  
    1010#include "Actions/FragmentationAction/FragmentationAction.hpp"
    1111#include "atom.hpp"
     12#include "bondgraph.hpp"
    1213#include "config.hpp"
    1314#include "log.hpp"
     
    4142  double distance = -1.;
    4243  int order = 0;
     44  std::string path;
    4345  config *configuration = World::getInstance().getConfig();
    4446  int ExitFlag = 0;
    4547
    4648  cout << "pre-dialog"<< endl;
    47   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
     49  dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME));
     50  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    4851  dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance"));
    4952  dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order"));
     
    5861    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    5962    if (mol->hasBondStructure()) {
    60       ExitFlag = mol->FragmentMolecule(order, configuration);
     63      ExitFlag = mol->FragmentMolecule(order, path);
    6164    }
    6265    World::getInstance().setExitFlag(ExitFlag);
  • src/Actions/Makefile.am

    rce4487 r04488a  
    120120  WorldAction/CenterOnEdgeAction.cpp \
    121121  WorldAction/ChangeBoxAction.cpp \
     122  WorldAction/InputAction.cpp \
     123  WorldAction/OutputAction.cpp \
    122124  WorldAction/RemoveSphereOfAtomsAction.cpp \
    123125  WorldAction/RepeatBoxAction.cpp \
     
    131133  WorldAction/CenterOnEdgeAction.hpp \
    132134  WorldAction/ChangeBoxAction.hpp \
     135  WorldAction/InputAction.hpp \
     136  WorldAction/OutputAction.hpp \
    133137  WorldAction/RemoveSphereOfAtomsAction.hpp \
    134138  WorldAction/RepeatBoxAction.hpp \
  • src/Actions/MapOfActions.cpp

    rce4487 r04488a  
    8383  DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
    8484  DescriptionMap["help"] = "Give this help screen";
     85  DescriptionMap["input"] = "specify input files";
    8586  DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
    8687  DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
    8788  DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
     89  DescriptionMap["output"] = "specify output formats";
    8890  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
    8991  DescriptionMap["parse-xyz"] = "parse xyz file into World";
     
    185187  TypeMap["fastparsing"] = Boolean;
    186188  TypeMap["fill-molecule"] = String;
    187   TypeMap["fragment-mol"] = Molecule;
     189  TypeMap["fragment-mol"] = String;
    188190  TypeMap["input"] = String;
    189191  TypeMap["linear-interpolate"] = String;
    190192  TypeMap["molecular-volume"] = Molecule;
    191193  TypeMap["nonconvex-envelope"] = Molecule;
     194  TypeMap["output"] = String;
    192195  TypeMap["parse-xyz"] = String;
    193196  TypeMap["pair-correlation"] = String;
     
    262265  generic.insert("fragment-mol");
    263266  generic.insert("help");
    264         generic.insert("linear-interpolate");
     267  generic.insert("input");
     268  generic.insert("linear-interpolate");
    265269//  generic.insert("molecular-volume");
    266270  generic.insert("nonconvex-envelope");
     271  generic.insert("output");
    267272        generic.insert("pair-correlation");
    268 //      generic.insert("parse-xyz");
     273        generic.insert("parse-xyz");
    269274//  generic.insert("principal-axis-system");
    270275  generic.insert("remove-atom");
  • src/Actions/MoleculeAction/FillWithMoleculeAction.cpp

    rce4487 r04488a  
    102102      World::getInstance().getMolecules()->insert(Filling);
    103103    }
     104    for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
     105      atom *Walker = *iter;
     106      filler->erase(iter);
     107      World::getInstance().destroyAtom(Walker);
     108    }
    104109    World::getInstance().destroyMolecule(filler);
    105110
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp

    rce4487 r04488a  
    6969    if (IdMapping)
    7070      DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    71     char outputname[MAXSTRINGSIZE];
    72     strcpy(outputname, filename.c_str());
    73     // TODO: LinearInterpolationBetweenConfiguration should use stream, not the filename directly! (better for unit test)
    74     if (!mol->LinearInterpolationBetweenConfiguration(start, end, outputname, *(World::getInstance().getConfig()), IdMapping))
    75       DoLog(2) && (Log() << Verbose(2) << "Could not store " << outputname << " files." << endl);
     71    if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping))
     72      DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl);
    7673    else
    7774      DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
  • src/Actions/MoleculeAction/SaveAdjacencyAction.cpp

    rce4487 r04488a  
    6565    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    6666    // TODO: sollte stream nicht filename benutzen, besser fuer unit test
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreAdjacencyToFile(NULL, outputname);
     67    mol->StoreAdjacencyToFile(filename);
    7068    delete dialog;
    7169    return Action::success;
  • src/Actions/MoleculeAction/SaveBondsAction.cpp

    rce4487 r04488a  
    6464    DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl);
    6565    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    66     // TODO: sollte stream, nicht filenamen direkt nutzen, beser fuer unit tests
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreBondsToFile(NULL, outputname);
     66    // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests
     67    mol->StoreBondsToFile(filename);
    7068    delete dialog;
    7169    return Action::success;
  • src/Actions/ParserAction/LoadXyzAction.cpp

    rce4487 r04488a  
    88#include "Helpers/MemDebug.hpp"
    99
     10using namespace std;
     11
    1012#include "Actions/ParserAction/LoadXyzAction.hpp"
    1113#include "Parser/XyzParser.hpp"
    1214
    1315#include <iostream>
     16#include <set>
    1417#include <string>
     18#include <vector>
    1519
    16 using namespace std;
    1720
    1821#include "UIElements/UIFactory.hpp"
     
    2124
    2225#include "atom.hpp"
     26#include "log.hpp"
    2327#include "molecule.hpp"
     28#include "verbose.hpp"
     29#include "World.hpp"
    2430
    2531/****** ParserLoadXyzAction *****/
     
    3743//};
    3844
    39 const char ParserLoadXyzAction::NAME[] = "LoadXyz";
     45const char ParserLoadXyzAction::NAME[] = "parse-xyz";
    4046
    4147ParserLoadXyzAction::ParserLoadXyzAction() :
     
    4854Action::state_ptr ParserLoadXyzAction::performCall() {
    4955  string filename;
    50   XyzParser parser;
    5156  Dialog *dialog = UIFactory::getInstance().makeDialog();
    5257
    53   dialog->queryString("filename",&filename, "Filename of the xyz file");
     58  dialog->queryString(NAME,&filename, NAME);
    5459
    5560  if(dialog->display()) {
     61    DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    5662    // parse xyz file
    5763    ifstream input;
    5864    input.open(filename.c_str());
    59     if (!input.fail())
     65    if (!input.fail()) {
     66      // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
     67      set <atom*> UniqueList;
     68      {
     69        vector<atom *> ListBefore = World::getInstance().getAllAtoms();
     70        for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
     71          UniqueList.insert(*runner);
     72      }
     73      XyzParser parser; // briefly instantiate a parser which is removed at end of focus
    6074      parser.load(&input);
     75      {
     76        vector<atom *> ListAfter = World::getInstance().getAllAtoms();
     77        pair< set<atom *>::iterator, bool > Inserter;
     78        if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
     79          MoleculeListClass *molecules = World::getInstance().getMolecules();
     80          molecule *mol= NULL;
     81          if (molecules->ListOfMolecules.empty()) {
     82            mol = World::getInstance().createMolecule();
     83            molecules->insert(mol);
     84          } else {
     85            mol = *(molecules->ListOfMolecules.begin());
     86          }
     87          for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
     88            Inserter = UniqueList.insert(*runner);
     89            if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
     90              cout << "Adding new atom " << **runner << " to new mol." << endl;
     91              mol->AddAtom(*runner);
     92            }
     93          }
     94          mol->doCountAtoms();
     95        } else {
     96          cout << "No atoms parsed?" << endl;
     97        }
     98      }
     99    } else {
     100      DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
     101    }
    61102    input.close();
    62103  }
Note: See TracChangeset for help on using the changeset viewer.