- Timestamp:
- Oct 10, 2011, 4:58:17 PM (13 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:
- f08ae7
- Parents:
- aa8cc2
- git-author:
- Frederik Heber <heber@…> (09/05/11 17:25:14)
- git-committer:
- Frederik Heber <heber@…> (10/10/11 16:58:17)
- Location:
- src/Actions/MoleculeAction
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/LoadAction.cpp
raa8cc2 r78d5b2 22 22 #include "CodePatterns/Log.hpp" 23 23 #include "CodePatterns/Verbose.hpp" 24 #include "Descriptors/MoleculeIdDescriptor.hpp" 24 25 #include "Parser/FormatParserStorage.hpp" 26 #include "Parser/FormatParser_Parameters.hpp" 25 27 #include "molecule.hpp" 26 28 #include "World.hpp" … … 45 47 if (!boost::filesystem::exists(params.filename)) { 46 48 DoLog(1) && (Log() << Verbose(1) << "Specified input file " << params.filename << " not found." << endl); 47 // DONT FAIL: it's just empty and we use the name. //return Action::failure;49 return Action::failure; 48 50 } else { 49 51 DoLog(1) && (Log() << Verbose(1) << "Specified input file found, parsing ... "); … … 66 68 } 67 69 70 // get undo state for parser 71 enum ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix); 72 FormatParser_Parameters *ParserParams = FormatParserStorage::getInstance().get(type).parameters; 73 if (ParserParams != NULL) 74 ParserParams = ParserParams->clone(); 75 else 76 ParserParams = NULL; 77 68 78 // parse the file 69 79 boost::filesystem::ifstream input; … … 76 86 (*iter)->SetNameFromFilename(FilenamePrefix.c_str()); 77 87 DoLog(0) && (Log() << Verbose(0) << "Chemical formula is " << (*iter)->getFormula() << std::endl); 88 89 return Action::state_ptr( 90 new MoleculeLoadState((*iter)->getId(),FilenamePrefix,FilenameSuffix,boost::shared_ptr<FormatParser_Parameters>(ParserParams),params) 91 ); 78 92 } 79 return Action::success;80 93 } 81 94 82 95 Action::state_ptr MoleculeLoadAction::performUndo(Action::state_ptr _state) { 83 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());96 MoleculeLoadState *state = assert_cast<MoleculeLoadState*>(_state.get()); 84 97 85 return Action::failure; 86 // string newName = state->mol->getName(); 87 // state->mol->setName(state->lastName); 88 // 89 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 98 // remove loaded molecule and its atoms 99 molecule *mol = World::getInstance().getMolecule(MoleculeById(state->molId)); 100 for(molecule::iterator iter = mol->begin(); !mol->empty(); iter = mol->begin()) 101 World::getInstance().destroyAtom(*iter); 102 //World::getInstance().destroyMolecule(mol); 103 104 // undo changes to FormatParser 105 enum ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(state->FilenameSuffix); 106 FormatParser_Parameters *ParserParams = FormatParserStorage::getInstance().get(type).parameters; 107 if (ParserParams != NULL) 108 ParserParams->makeClone(*state->ParserParameters); 109 110 return Action::state_ptr(_state); 90 111 } 91 112 92 113 Action::state_ptr MoleculeLoadAction::performRedo(Action::state_ptr _state){ 93 return Action::failure; 114 MoleculeLoadState *state = assert_cast<MoleculeLoadState*>(_state.get()); 115 116 // get undo state for parser 117 enum ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(state->FilenameSuffix); 118 FormatParser_Parameters *ParserParams = FormatParserStorage::getInstance().get(type).parameters; 119 if (ParserParams != NULL) 120 ParserParams = ParserParams->clone(); 121 else 122 ParserParams = NULL; 123 124 // parse the file 125 boost::filesystem::ifstream input; 126 input.open(state->params.filename); 127 FormatParserStorage::getInstance().load(input, state->FilenameSuffix); 128 input.close(); 129 130 // set file name of last molecule 131 MoleculeList::const_reverse_iterator iter = World::getInstance().getMolecules()->ListOfMolecules.rbegin(); 132 (*iter)->SetNameFromFilename(state->FilenamePrefix.c_str()); 133 (*iter)->setId(state->molId); 134 DoLog(0) && (Log() << Verbose(0) << "Chemical formula is " << (*iter)->getFormula() << std::endl); 135 136 return Action::state_ptr( 137 new MoleculeLoadState((*iter)->getId(),state->FilenamePrefix,state->FilenameSuffix,boost::shared_ptr<FormatParser_Parameters>(ParserParams),params) 138 ); 94 139 } 95 140 -
src/Actions/MoleculeAction/LoadAction.def
raa8cc2 r78d5b2 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 #include "Parser/FormatParser_Parameters.hpp" 9 10 11 #include <boost/shared_ptr.hpp> 10 12 11 13 // i.e. there is an integer with variable name Z that can be found in … … 18 20 #define paramreferences (filename) 19 21 20 # undef statetypes21 # undef statereferences22 #define statetypes (moleculeId_t)(std::string)(std::string)(boost::shared_ptr<FormatParser_Parameters>) 23 #define statereferences (molId)(FilenamePrefix)(FilenameSuffix)(ParserParameters) 22 24 23 25 // some defines for all the names, you may use ACTION, STATE and PARAMS
Note:
See TracChangeset
for help on using the changeset viewer.