source: src/Actions/ParserAction/LoadXyzAction.cpp@ a19d73e

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 v1.0.0
Last change on this file since a19d73e was bb4408, checked in by Frederik Heber <heber@…>, 15 years ago

BUGFIX: Removed adding of parsed atoms in LoadXyzAction.

  • a molecule is created and added already in XyzParser::load().
  • this caused the id of a newly parsed in xyz file to be 2 instead of 1 and the creation of an empty molecule.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * LoadXyzAction.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15using namespace std;
16
17#include "Actions/ParserAction/LoadXyzAction.hpp"
18#include "Actions/ActionRegistry.hpp"
19#include "Parser/XyzParser.hpp"
20#include "atom.hpp"
21#include "Helpers/Log.hpp"
22#include "molecule.hpp"
23#include "Helpers/Verbose.hpp"
24#include "World.hpp"
25
26#include <iostream>
27#include <set>
28#include <string>
29#include <vector>
30
31#include "UIElements/UIFactory.hpp"
32#include "UIElements/Dialog.hpp"
33#include "Actions/ValueStorage.hpp"
34
35/****** ParserLoadXyzAction *****/
36
37//// memento to remember the state when undoing
38//
39//class ParserLoadXyzState : public ActionState {
40//public:
41// ParserLoadXyzState(molecule* _mol,std::string _lastName) :
42// mol(_mol),
43// lastName(_lastName)
44// {}
45// molecule* mol;
46// std::string lastName;
47//};
48
49const char ParserLoadXyzAction::NAME[] = "parse-xyz";
50
51ParserLoadXyzAction::ParserLoadXyzAction() :
52 Action(NAME)
53{}
54
55ParserLoadXyzAction::~ParserLoadXyzAction()
56{}
57
58void ParserLoadXyz(std::string &filename) {
59 ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename);
60 ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive);
61};
62
63Dialog* ParserLoadXyzAction::fillDialog(Dialog *dialog) {
64 ASSERT(dialog,"No Dialog given when filling action dialog");
65
66 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
67
68 return dialog;
69}
70
71Action::state_ptr ParserLoadXyzAction::performCall() {
72 string filename;
73
74 ValueStorage::getInstance().queryCurrentValue(NAME, filename);
75
76 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
77 // parse xyz file
78 ifstream input;
79 input.open(filename.c_str());
80 if (!input.fail()) {
81 XyzParser parser; // briefly instantiate a parser which is removed at end of focus
82 parser.load(&input);
83 } else {
84 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
85 }
86 input.close();
87 return Action::success;
88}
89
90Action::state_ptr ParserLoadXyzAction::performUndo(Action::state_ptr _state) {
91// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
92
93 return Action::failure;
94// string newName = state->mol->getName();
95// state->mol->setName(state->lastName);
96//
97// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
98}
99
100Action::state_ptr ParserLoadXyzAction::performRedo(Action::state_ptr _state){
101 return Action::failure;
102}
103
104bool ParserLoadXyzAction::canUndo() {
105 return false;
106}
107
108bool ParserLoadXyzAction::shouldUndo() {
109 return false;
110}
111
112const string ParserLoadXyzAction::getName() {
113 return NAME;
114}
Note: See TracBrowser for help on using the repository browser.