Changeset cabb46 for src/Actions/MoleculeAction/SaveAction.cpp
- Timestamp:
- Dec 5, 2010, 12:20:07 AM (14 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:
- 001f8a, ca03c7
- Parents:
- 4fbca9c
- git-author:
- Frederik Heber <heber@…> (12/04/10 21:23:07)
- git-committer:
- Frederik Heber <heber@…> (12/05/10 00:20:07)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/SaveAction.cpp
r4fbca9c rcabb46 7 7 8 8 /* 9 * Save XyzAction.cpp9 * SaveAction.cpp 10 10 * 11 11 * Created on: May 8, 2010 … … 22 22 #include "Helpers/Log.hpp" 23 23 #include "Helpers/Verbose.hpp" 24 #include "Parser/ XyzParser.hpp"24 #include "Parser/FormatParserStorage.hpp" 25 25 26 26 #include <iostream> 27 27 #include <string> 28 28 29 #include <boost/filesystem/fstream.hpp> 30 29 31 using namespace std; 30 32 31 #include " Actions/ParserAction/SaveXyzAction.hpp"33 #include "SaveAction.hpp" 32 34 33 35 // and construct the stuff 34 #include "Save XyzAction.def"36 #include "SaveAction.def" 35 37 #include "Action_impl_pre.hpp" 36 38 /** =========== define the function ====================== */ 37 Action::state_ptr ParserSaveXyzAction::performCall() { 38 XyzParser parser; 39 39 Action::state_ptr MoleculeSaveAction::performCall() { 40 40 // obtain information 41 41 getParametersfromValueStorage(); 42 42 43 DoLog(1) && (Log() << Verbose(1) << "Storing xyz file " << params.filename << "." << endl); 44 // store xyz file 45 ofstream output; 46 output.open(params.filename.string().c_str()); 43 DoLog(1) && (Log() << Verbose(1) << "Storing world to file " << params.filename << "." << endl); 44 45 // extract suffix 46 std::string FilenameSuffix; 47 std::string FilenamePrefix; 48 if (params.filename.has_filename()) { 49 // get suffix 50 FilenameSuffix = params.filename.extension().substr(1); // remove the prefixed "." 51 FilenamePrefix = params.filename.stem(); 52 } else { 53 DoeLog(1) && (eLog() << Verbose(1) << "Output file does not have a suffix, cannot recognize format." << endl); 54 return Action::failure; 55 } 56 57 // store file 58 // parse the file 59 boost::filesystem::ofstream output; 60 output.open(params.filename); 47 61 if (!output.fail()) { 48 parser.save(&output);62 FormatParserStorage::getInstance().put(output, FilenameSuffix); 49 63 } else { 50 64 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << params.filename << "." << endl); 51 65 } 52 66 output.close(); 67 53 68 return Action::failure; 54 69 } 55 70 56 Action::state_ptr ParserSaveXyzAction::performUndo(Action::state_ptr _state) {71 Action::state_ptr MoleculeSaveAction::performUndo(Action::state_ptr _state) { 57 72 // ParserSaveXyzState *state = assert_cast<ParserSaveXyzState*>(_state.get()); 58 73 … … 64 79 } 65 80 66 Action::state_ptr ParserSaveXyzAction::performRedo(Action::state_ptr _state){81 Action::state_ptr MoleculeSaveAction::performRedo(Action::state_ptr _state){ 67 82 return Action::failure; 68 83 // // Undo and redo have to do the same for this action … … 70 85 } 71 86 72 bool ParserSaveXyzAction::canUndo() {87 bool MoleculeSaveAction::canUndo() { 73 88 return false; 74 89 } 75 90 76 bool ParserSaveXyzAction::shouldUndo() {91 bool MoleculeSaveAction::shouldUndo() { 77 92 return false; 78 93 }
Note:
See TracChangeset
for help on using the changeset viewer.