Changeset 04488a for src/Actions
- Timestamp:
- Jun 25, 2010, 9:57:15 AM (15 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:
- 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. - Location:
- src/Actions
- Files:
-
- 4 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.cpp
rce4487 r04488a 19 19 using namespace std; 20 20 21 /** Constructor for class ActionRegistry. 22 */ 21 23 ActionRegistry::ActionRegistry() 22 24 { 23 25 } 24 26 27 /** Destructor for class ActionRegistry. 28 */ 25 29 ActionRegistry::~ActionRegistry() 26 30 { … … 32 36 } 33 37 38 /** Returns pointer to an action named by \a name. 39 * \param name name of action 40 * \return pointer to Action 41 */ 34 42 Action* ActionRegistry::getActionByName(const std::string name){ 35 43 map<const string,Action*>::iterator iter; … … 39 47 } 40 48 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 */ 41 54 bool ActionRegistry::isActionByNamePresent(const std::string name){ 42 55 map<const string,Action*>::iterator iter; … … 45 58 } 46 59 60 /** Registers an Action with the ActionRegistry. 61 * \param *action pointer to Action. 62 */ 47 63 void ActionRegistry::registerAction(Action* action){ 48 64 pair<map<const string,Action*>::iterator,bool> ret; 65 //cout << "Trying to register action with name " << action->getName() << "." << endl; 49 66 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action)); 50 67 ASSERT(ret.second,"Two actions with the same name added to registry"); 51 68 } 52 69 70 /** Unregisters an Action. 71 * \param *action pointer to Action. 72 */ 53 73 void ActionRegistry::unregisterAction(Action* action){ 74 //cout << "Unregistering action with name " << action->getName() << "." << endl; 54 75 actionMap.erase(action->getName()); 55 76 } 56 77 78 /** Returns an iterator pointing to the start of the map of Action's. 79 * \return begin iterator 80 */ 57 81 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter() 58 82 { … … 60 84 } 61 85 86 /** Returns an iterator pointing to the end of the map of Action's. 87 * \return end iterator 88 */ 62 89 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter() 63 90 { … … 65 92 } 66 93 94 /** Returns a const iterator pointing to the start of the map of Action's. 95 * \return constant begin iterator 96 */ 97 std::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 */ 105 std::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 */ 115 ostream& 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 67 126 CONSTRUCT_SINGLETON(ActionRegistry) -
src/Actions/ActionRegistry.hpp
rce4487 r04488a 9 9 #define ACTIONREGISTRY_HPP_ 10 10 11 #include <iostream> 11 12 #include <string> 12 13 #include <map> … … 26 27 27 28 std::map<const std::string,Action*>::iterator getBeginIter(); 29 std::map<const std::string,Action*>::const_iterator getBeginIter() const; 28 30 std::map<const std::string,Action*>::iterator getEndIter(); 31 std::map<const std::string,Action*>::const_iterator getEndIter() const; 29 32 30 33 private: … … 36 39 }; 37 40 41 std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m); 42 38 43 #endif /* ACTIONREGISTRY_HPP_ */ -
src/Actions/CmdAction/BondLengthTableAction.cpp
rce4487 r04488a 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "bondgraph.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
rce4487 r04488a 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" 13 14 #include "log.hpp" -
src/Actions/FragmentationAction/FragmentationAction.cpp
rce4487 r04488a 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" 13 14 #include "log.hpp" … … 41 42 double distance = -1.; 42 43 int order = 0; 44 std::string path; 43 45 config *configuration = World::getInstance().getConfig(); 44 46 int ExitFlag = 0; 45 47 46 48 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")); 48 51 dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance")); 49 52 dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order")); … … 58 61 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 59 62 if (mol->hasBondStructure()) { 60 ExitFlag = mol->FragmentMolecule(order, configuration);63 ExitFlag = mol->FragmentMolecule(order, path); 61 64 } 62 65 World::getInstance().setExitFlag(ExitFlag); -
src/Actions/Makefile.am
rce4487 r04488a 120 120 WorldAction/CenterOnEdgeAction.cpp \ 121 121 WorldAction/ChangeBoxAction.cpp \ 122 WorldAction/InputAction.cpp \ 123 WorldAction/OutputAction.cpp \ 122 124 WorldAction/RemoveSphereOfAtomsAction.cpp \ 123 125 WorldAction/RepeatBoxAction.cpp \ … … 131 133 WorldAction/CenterOnEdgeAction.hpp \ 132 134 WorldAction/ChangeBoxAction.hpp \ 135 WorldAction/InputAction.hpp \ 136 WorldAction/OutputAction.hpp \ 133 137 WorldAction/RemoveSphereOfAtomsAction.hpp \ 134 138 WorldAction/RepeatBoxAction.hpp \ -
src/Actions/MapOfActions.cpp
rce4487 r04488a 83 83 DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order"; 84 84 DescriptionMap["help"] = "Give this help screen"; 85 DescriptionMap["input"] = "specify input files"; 85 86 DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule"; 86 87 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule"; 87 88 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule"; 89 DescriptionMap["output"] = "specify output formats"; 88 90 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface"; 89 91 DescriptionMap["parse-xyz"] = "parse xyz file into World"; … … 185 187 TypeMap["fastparsing"] = Boolean; 186 188 TypeMap["fill-molecule"] = String; 187 TypeMap["fragment-mol"] = Molecule;189 TypeMap["fragment-mol"] = String; 188 190 TypeMap["input"] = String; 189 191 TypeMap["linear-interpolate"] = String; 190 192 TypeMap["molecular-volume"] = Molecule; 191 193 TypeMap["nonconvex-envelope"] = Molecule; 194 TypeMap["output"] = String; 192 195 TypeMap["parse-xyz"] = String; 193 196 TypeMap["pair-correlation"] = String; … … 262 265 generic.insert("fragment-mol"); 263 266 generic.insert("help"); 264 generic.insert("linear-interpolate"); 267 generic.insert("input"); 268 generic.insert("linear-interpolate"); 265 269 // generic.insert("molecular-volume"); 266 270 generic.insert("nonconvex-envelope"); 271 generic.insert("output"); 267 272 generic.insert("pair-correlation"); 268 //generic.insert("parse-xyz");273 generic.insert("parse-xyz"); 269 274 // generic.insert("principal-axis-system"); 270 275 generic.insert("remove-atom"); -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
rce4487 r04488a 102 102 World::getInstance().getMolecules()->insert(Filling); 103 103 } 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 } 104 109 World::getInstance().destroyMolecule(filler); 105 110 -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
rce4487 r04488a 69 69 if (IdMapping) 70 70 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); 76 73 else 77 74 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl); -
src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
rce4487 r04488a 65 65 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 66 // 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); 70 68 delete dialog; 71 69 return Action::success; -
src/Actions/MoleculeAction/SaveBondsAction.cpp
rce4487 r04488a 64 64 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl); 65 65 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); 70 68 delete dialog; 71 69 return Action::success; -
src/Actions/ParserAction/LoadXyzAction.cpp
rce4487 r04488a 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 using namespace std; 11 10 12 #include "Actions/ParserAction/LoadXyzAction.hpp" 11 13 #include "Parser/XyzParser.hpp" 12 14 13 15 #include <iostream> 16 #include <set> 14 17 #include <string> 18 #include <vector> 15 19 16 using namespace std;17 20 18 21 #include "UIElements/UIFactory.hpp" … … 21 24 22 25 #include "atom.hpp" 26 #include "log.hpp" 23 27 #include "molecule.hpp" 28 #include "verbose.hpp" 29 #include "World.hpp" 24 30 25 31 /****** ParserLoadXyzAction *****/ … … 37 43 //}; 38 44 39 const char ParserLoadXyzAction::NAME[] = " LoadXyz";45 const char ParserLoadXyzAction::NAME[] = "parse-xyz"; 40 46 41 47 ParserLoadXyzAction::ParserLoadXyzAction() : … … 48 54 Action::state_ptr ParserLoadXyzAction::performCall() { 49 55 string filename; 50 XyzParser parser;51 56 Dialog *dialog = UIFactory::getInstance().makeDialog(); 52 57 53 dialog->queryString( "filename",&filename, "Filename of the xyz file");58 dialog->queryString(NAME,&filename, NAME); 54 59 55 60 if(dialog->display()) { 61 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 56 62 // parse xyz file 57 63 ifstream input; 58 64 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 60 74 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 } 61 102 input.close(); 62 103 }
Note:
See TracChangeset
for help on using the changeset viewer.