Changeset 677e13 for src/Actions/ParserAction
- Timestamp:
- Jul 28, 2010, 9:21:14 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:
- 400170, a7b777c
- Parents:
- 7067bd6 (diff), 0430e3 (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/ParserAction
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ParserAction/LoadXyzAction.cpp
r7067bd6 r677e13 11 11 12 12 #include "Actions/ParserAction/LoadXyzAction.hpp" 13 #include "Actions/ActionRegistry.hpp" 13 14 #include "Parser/XyzParser.hpp" 15 #include "atom.hpp" 16 #include "log.hpp" 17 #include "molecule.hpp" 18 #include "verbose.hpp" 19 #include "World.hpp" 14 20 15 21 #include <iostream> … … 18 24 #include <vector> 19 25 20 21 26 #include "UIElements/UIFactory.hpp" 22 27 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 25 #include "atom.hpp" 26 #include "log.hpp" 27 #include "molecule.hpp" 28 #include "verbose.hpp" 29 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 30 29 31 30 /****** ParserLoadXyzAction *****/ … … 52 51 {} 53 52 53 void ParserLoadXyz(std::string &filename) { 54 ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename); 55 ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* ParserLoadXyzAction::createDialog() { 59 Dialog *dialog = UIFactory::getInstance().makeDialog(); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 54 66 Action::state_ptr ParserLoadXyzAction::performCall() { 55 67 string filename; 56 Dialog *dialog = UIFactory::getInstance().makeDialog();57 68 58 dialog->queryString(NAME,&filename, NAME);69 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 59 70 60 if(dialog->display()) { 61 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 62 // parse xyz file 63 ifstream input; 64 input.open(filename.c_str()); 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); 71 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 72 // parse xyz file 73 ifstream input; 74 input.open(filename.c_str()); 75 if (!input.fail()) { 76 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 77 set <atom*> UniqueList; 78 { 79 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 80 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 81 UniqueList.insert(*runner); 82 } 83 XyzParser parser; // briefly instantiate a parser which is removed at end of focus 84 parser.load(&input); 85 { 86 vector<atom *> ListAfter = World::getInstance().getAllAtoms(); 87 pair< set<atom *>::iterator, bool > Inserter; 88 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed 89 MoleculeListClass *molecules = World::getInstance().getMolecules(); 90 molecule *mol = World::getInstance().createMolecule(); 91 molecules->insert(mol); 92 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) { 93 Inserter = UniqueList.insert(*runner); 94 if (Inserter.second) { // if not present, then new (just parsed) atom, add ... 95 cout << "Adding new atom " << **runner << " to new mol." << endl; 96 mol->AddAtom(*runner); 97 } 98 } 99 mol->doCountAtoms(); 100 } else { 101 cout << "No atoms parsed?" << endl; 72 102 } 73 XyzParser parser; // briefly instantiate a parser which is removed at end of focus74 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 parsed79 MoleculeListClass *molecules = World::getInstance().getMolecules();80 molecule *mol = World::getInstance().createMolecule();81 molecules->insert(mol);82 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {83 Inserter = UniqueList.insert(*runner);84 if (Inserter.second) { // if not present, then new (just parsed) atom, add ...85 cout << "Adding new atom " << **runner << " to new mol." << endl;86 mol->AddAtom(*runner);87 }88 }89 mol->doCountAtoms();90 } else {91 cout << "No atoms parsed?" << endl;92 }93 }94 } else {95 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);96 103 } 97 input.close(); 104 } else { 105 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl); 98 106 } 99 delete dialog;100 return Action:: failure;107 input.close(); 108 return Action::success; 101 109 } 102 110 -
src/Actions/ParserAction/LoadXyzAction.hpp
r7067bd6 r677e13 12 12 #include "Actions/Process.hpp" 13 13 14 void ParserLoadXyz(std::string &filename); 15 14 16 class ParserLoadXyzAction : public Action { 17 friend void ParserLoadXyz(std::string &filename); 18 15 19 public: 16 20 ParserLoadXyzAction(); … … 22 26 virtual const std::string getName(); 23 27 private: 28 virtual Dialog * createDialog(); 24 29 virtual Action::state_ptr performCall(); 25 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/ParserAction/SaveXyzAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/ParserAction/SaveXyzAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "Parser/XyzParser.hpp" 13 #include "atom.hpp" 14 #include "molecule.hpp" 12 15 13 16 #include <iostream> … … 18 21 #include "UIElements/UIFactory.hpp" 19 22 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"23 #include "UIElements/ValueStorage.hpp" 21 24 22 #include "atom.hpp"23 #include "molecule.hpp"24 25 25 26 /****** ParserSaveXyzAction *****/ … … 46 47 {} 47 48 49 void ParserSaveXyz(std::string &filename) { 50 ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename); 51 ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive); 52 }; 53 54 Dialog* ParserSaveXyzAction::createDialog() { 55 Dialog *dialog = UIFactory::getInstance().makeDialog(); 56 57 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 58 59 return dialog; 60 } 61 48 62 Action::state_ptr ParserSaveXyzAction::performCall() { 49 63 string filename; 50 64 XyzParser parser; 51 Dialog *dialog = UIFactory::getInstance().makeDialog();52 65 53 dialog->queryString("filename",&filename, "Filename of the xyz file");66 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 54 67 55 if(dialog->display()) { 56 // store xyz file 57 ofstream output; 58 output.open(filename.c_str()); 59 if (!output.fail()) 60 parser.save(&output); 61 output.close(); 62 } 63 delete dialog; 68 // store xyz file 69 ofstream output; 70 output.open(filename.c_str()); 71 if (!output.fail()) 72 parser.save(&output); 73 output.close(); 64 74 return Action::failure; 65 75 } -
src/Actions/ParserAction/SaveXyzAction.hpp
r7067bd6 r677e13 12 12 #include "Actions/Process.hpp" 13 13 14 void ParserSaveXyz(std::string &filename); 15 14 16 class ParserSaveXyzAction : public Action { 17 friend void ParserSaveXyz(std::string &filename); 18 15 19 public: 16 20 ParserSaveXyzAction(); … … 22 26 virtual const std::string getName(); 23 27 private: 28 virtual Dialog * createDialog(); 24 29 virtual Action::state_ptr performCall(); 25 30 virtual Action::state_ptr performUndo(Action::state_ptr);
Note:
See TracChangeset
for help on using the changeset viewer.