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

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
Last change on this file since ddc85b 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
RevLine 
[03bb99]1/*
2 * LoadXyzAction.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
[bf3817]8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
[112b09]13#include "Helpers/MemDebug.hpp"
14
[a1e929]15using namespace std;
16
[03bb99]17#include "Actions/ParserAction/LoadXyzAction.hpp"
[0430e3]18#include "Actions/ActionRegistry.hpp"
[03bb99]19#include "Parser/XyzParser.hpp"
[215b89]20#include "atom.hpp"
[952f38]21#include "Helpers/Log.hpp"
[215b89]22#include "molecule.hpp"
[952f38]23#include "Helpers/Verbose.hpp"
[215b89]24#include "World.hpp"
[03bb99]25
26#include <iostream>
[a1e929]27#include <set>
[03bb99]28#include <string>
[a1e929]29#include <vector>
[03bb99]30
31#include "UIElements/UIFactory.hpp"
32#include "UIElements/Dialog.hpp"
[861874]33#include "Actions/ValueStorage.hpp"
[03bb99]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
[a1e929]49const char ParserLoadXyzAction::NAME[] = "parse-xyz";
[03bb99]50
51ParserLoadXyzAction::ParserLoadXyzAction() :
52 Action(NAME)
53{}
54
55ParserLoadXyzAction::~ParserLoadXyzAction()
56{}
57
[215b89]58void ParserLoadXyz(std::string &filename) {
59 ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename);
60 ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive);
61};
62
[047878]63Dialog* ParserLoadXyzAction::fillDialog(Dialog *dialog) {
64 ASSERT(dialog,"No Dialog given when filling action dialog");
[0454de]65
66 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
67
68 return dialog;
69}
70
[03bb99]71Action::state_ptr ParserLoadXyzAction::performCall() {
72 string filename;
73
[0454de]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);
[03bb99]85 }
[0454de]86 input.close();
87 return Action::success;
[03bb99]88}
89
[808fd3]90Action::state_ptr ParserLoadXyzAction::performUndo(Action::state_ptr _state) {
[03bb99]91// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
[808fd3]92
93 return Action::failure;
[03bb99]94// string newName = state->mol->getName();
95// state->mol->setName(state->lastName);
96//
97// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
[808fd3]98}
99
100Action::state_ptr ParserLoadXyzAction::performRedo(Action::state_ptr _state){
101 return Action::failure;
102}
[03bb99]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.