source: src/Actions/MoleculeAction/FillWithMoleculeAction.cpp@ 112b09

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 Candidate_v1.7.0 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 112b09 was 112b09, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added #include "Helpers/MemDebug.hpp" to all .cpp files

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 * FillWithMoleculeAction.cpp
3 *
4 * Created on: May 10, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
11
12#include <iostream>
13#include <string>
14
15using namespace std;
16
17#include "UIElements/UIFactory.hpp"
18#include "UIElements/Dialog.hpp"
19#include "Actions/MapOfActions.hpp"
20
21#include "atom.hpp"
22#include "bondgraph.hpp"
23#include "boundary.hpp"
24#include "config.hpp"
25#include "defs.hpp"
26#include "molecule.hpp"
27#include "periodentafel.hpp"
28#include "vector.hpp"
29#include "verbose.hpp"
30#include "World.hpp"
31
32/****** MoleculeFillWithMoleculeAction *****/
33
34// memento to remember the state when undoing
35
36//class MoleculeFillWithMoleculeState : public ActionState {
37//public:
38// MoleculeFillWithMoleculeState(molecule* _mol,std::string _lastName) :
39// mol(_mol),
40// lastName(_lastName)
41// {}
42// molecule* mol;
43// std::string lastName;
44//};
45
46const char MoleculeFillWithMoleculeAction::NAME[] = "fill-molecule";
47
48MoleculeFillWithMoleculeAction::MoleculeFillWithMoleculeAction() :
49 Action(NAME)
50{}
51
52MoleculeFillWithMoleculeAction::~MoleculeFillWithMoleculeAction()
53{}
54
55Action::state_ptr MoleculeFillWithMoleculeAction::performCall() {
56 string filename;
57 Dialog *dialog = UIFactory::getInstance().makeDialog();
58 Vector distances;
59 Vector lengths;
60 double MaxDistance = -1.;
61 bool DoRotate = false;
62
63 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
64 dialog->queryVector("distances", &distances, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("distances"));
65 dialog->queryVector("lengths", &lengths, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("lengths"));
66 dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate"));
67 dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance"));
68
69 if(dialog->display()) {
70 // construct water molecule
71 molecule *filler = World::getInstance().createMolecule();
72// if (!filler->AddXYZFile(filename)) {
73// DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
74// }
75// filler->SetNameFromFilename(filename);
76 molecule *Filling = NULL;
77 atom *first = NULL, *second = NULL, *third = NULL;
78 first = World::getInstance().createAtom();
79 first->type = World::getInstance().getPeriode()->FindElement(1);
80 first->x = Vector(0.441, -0.143, 0.);
81 filler->AddAtom(first);
82 second = World::getInstance().createAtom();
83 second->type = World::getInstance().getPeriode()->FindElement(1);
84 second->x = Vector(-0.464, 1.137, 0.0);
85 filler->AddAtom(second);
86 third = World::getInstance().createAtom();
87 third->type = World::getInstance().getPeriode()->FindElement(8);
88 third->x = Vector(-0.464, 0.177, 0.);
89 filler->AddAtom(third);
90 filler->AddBond(first, third, 1);
91 filler->AddBond(second, third, 1);
92 World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
93 filler->SetNameFromFilename("water");
94 // call routine
95 double distance[NDIM];
96 for (int i=0;i<NDIM;i++)
97 distance[i] = distances[i];
98 Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
99 if (Filling != NULL) {
100 Filling->ActiveFlag = false;
101 World::getInstance().getMolecules()->insert(Filling);
102 }
103 World::getInstance().destroyMolecule(filler);
104
105 delete dialog;
106 return Action::success;
107 }
108 delete dialog;
109 return Action::failure;
110}
111
112Action::state_ptr MoleculeFillWithMoleculeAction::performUndo(Action::state_ptr _state) {
113// MoleculeFillWithMoleculeState *state = assert_cast<MoleculeFillWithMoleculeState*>(_state.get());
114
115// string newName = state->mol->getName();
116// state->mol->setName(state->lastName);
117
118 return Action::failure;
119}
120
121Action::state_ptr MoleculeFillWithMoleculeAction::performRedo(Action::state_ptr _state){
122 // Undo and redo have to do the same for this action
123 return performUndo(_state);
124}
125
126bool MoleculeFillWithMoleculeAction::canUndo() {
127 return false;
128}
129
130bool MoleculeFillWithMoleculeAction::shouldUndo() {
131 return false;
132}
133
134const string MoleculeFillWithMoleculeAction::getName() {
135 return NAME;
136}
Note: See TracBrowser for help on using the repository browser.