Changeset 0454de for src/Actions
- Timestamp:
- Jul 22, 2010, 8:50:59 PM (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:
- ce8755
- Parents:
- bcd16a
- Location:
- src/Actions/ParserAction
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ParserAction/LoadXyzAction.cpp
rbcd16a r0454de 21 21 #include "UIElements/UIFactory.hpp" 22 22 #include "UIElements/Dialog.hpp" 23 #include " Actions/MapOfActions.hpp"23 #include "UIElements/ValueStorage.hpp" 24 24 25 25 #include "atom.hpp" … … 52 52 {} 53 53 54 Dialog* ParserLoadXyzAction::createDialog() { 55 Dialog *dialog = UIFactory::getInstance().makeDialog(); 56 57 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 58 59 return dialog; 60 } 61 54 62 Action::state_ptr ParserLoadXyzAction::performCall() { 55 63 string filename; 56 Dialog *dialog = UIFactory::getInstance().makeDialog();57 64 58 dialog->queryString(NAME,&filename, NAME);65 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 59 66 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); 67 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 68 // parse xyz file 69 ifstream input; 70 input.open(filename.c_str()); 71 if (!input.fail()) { 72 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 73 set <atom*> UniqueList; 74 { 75 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 76 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 77 UniqueList.insert(*runner); 78 } 79 XyzParser parser; // briefly instantiate a parser which is removed at end of focus 80 parser.load(&input); 81 { 82 vector<atom *> ListAfter = World::getInstance().getAllAtoms(); 83 pair< set<atom *>::iterator, bool > Inserter; 84 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed 85 MoleculeListClass *molecules = World::getInstance().getMolecules(); 86 molecule *mol = World::getInstance().createMolecule(); 87 molecules->insert(mol); 88 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) { 89 Inserter = UniqueList.insert(*runner); 90 if (Inserter.second) { // if not present, then new (just parsed) atom, add ... 91 cout << "Adding new atom " << **runner << " to new mol." << endl; 92 mol->AddAtom(*runner); 93 } 94 } 95 mol->doCountAtoms(); 96 } else { 97 cout << "No atoms parsed?" << endl; 72 98 } 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 99 } 97 input.close(); 100 } else { 101 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl); 98 102 } 99 delete dialog;100 return Action:: failure;103 input.close(); 104 return Action::success; 101 105 } 102 106 -
src/Actions/ParserAction/LoadXyzAction.hpp
rbcd16a r0454de 22 22 virtual const std::string getName(); 23 23 private: 24 virtual Dialog * createDialog(); 24 25 virtual Action::state_ptr performCall(); 25 26 virtual Action::state_ptr performUndo(Action::state_ptr);
Note:
See TracChangeset
for help on using the changeset viewer.