source: src/UIElements/CommandLineUI/CommandLineDialog.cpp@ 0286bc

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 0286bc was 0286bc, checked in by Frederik Heber <heber@…>, 15 years ago

BUGFIX: ListOfDoubles changed to Box and Vector.

  • Property mode set to 100644
File size: 8.2 KB
Line 
1/*
2 * CommandLineDialog.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
8
9#include <cassert>
10#include <iostream>
11
12#include <Descriptors/AtomDescriptor.hpp>
13#include <Descriptors/AtomIdDescriptor.hpp>
14#include <Descriptors/MoleculeDescriptor.hpp>
15#include <Descriptors/MoleculeIdDescriptor.hpp>
16#include "CommandLineUI/CommandLineDialog.hpp"
17
18#include "Actions/Values.hpp"
19
20#include "element.hpp"
21#include "periodentafel.hpp"
22#include "CommandLineParser.hpp"
23#include "defs.hpp"
24#include "log.hpp"
25#include "periodentafel.hpp"
26#include "verbose.hpp"
27#include "World.hpp"
28
29#include "atom.hpp"
30#include "element.hpp"
31#include "molecule.hpp"
32#include "vector.hpp"
33
34using namespace std;
35
36
37CommandLineDialog::CommandLineDialog()
38{
39}
40
41CommandLineDialog::~CommandLineDialog()
42{
43}
44
45
46void CommandLineDialog::queryEmpty(const char* title, string _description){
47 registerQuery(new EmptyCommandLineQuery(title, _description));
48}
49
50void CommandLineDialog::queryInt(const char* title, int* target, string _description){
51 registerQuery(new IntCommandLineQuery(title,target, _description));
52}
53
54void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
55 registerQuery(new BooleanCommandLineQuery(title,target, _description));
56}
57
58void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
59 registerQuery(new DoubleCommandLineQuery(title,target, _description));
60}
61
62void CommandLineDialog::queryString(const char* title, string* target, string _description){
63 registerQuery(new StringCommandLineQuery(title,target, _description));
64}
65
66void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
67 registerQuery(new AtomCommandLineQuery(title,target, _description));
68}
69
70void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
71 registerQuery(new MoleculeCommandLineQuery(title,target, _description));
72}
73
74void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
75 registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
76}
77
78void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {
79 registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
80}
81
82void CommandLineDialog::queryElement(const char* title, const element **target, string _description){
83 registerQuery(new ElementCommandLineQuery(title,target, _description));
84}
85
86/************************** Query Infrastructure ************************/
87
88CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
89 Dialog::EmptyQuery(title, _description)
90{}
91
92CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
93
94bool CommandLineDialog::EmptyCommandLineQuery::handle() {
95 cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
96 return true;
97}
98
99CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
100 Dialog::IntQuery(title,_target, _description)
101{}
102
103CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
104
105bool CommandLineDialog::IntCommandLineQuery::handle() {
106 if (CommandLineParser::getInstance().vm.count(getTitle())) {
107 tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
108 return true;
109 } else
110 return false;
111}
112
113CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
114 Dialog::BooleanQuery(title,_target, _description)
115{}
116
117CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
118
119bool CommandLineDialog::BooleanCommandLineQuery::handle() {
120 if (CommandLineParser::getInstance().vm.count(getTitle())) {
121 tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
122 return true;
123 } else
124 return false;
125}
126
127CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
128 Dialog::StringQuery(title,_target, _description)
129{}
130
131CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
132
133bool CommandLineDialog::StringCommandLineQuery::handle() {
134 if (CommandLineParser::getInstance().vm.count(getTitle())) {
135 tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
136 return true;
137 } else
138 return false;
139}
140
141CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
142 Dialog::DoubleQuery(title,_target, _description)
143{}
144
145CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
146
147bool CommandLineDialog::DoubleCommandLineQuery::handle() {
148 if (CommandLineParser::getInstance().vm.count(getTitle())) {
149 tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
150 return true;
151 } else
152 return false;
153}
154
155CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
156 Dialog::AtomQuery(title,_target, _description)
157{}
158
159CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
160
161bool CommandLineDialog::AtomCommandLineQuery::handle() {
162 int IdxOfAtom = -1;
163 if (CommandLineParser::getInstance().vm.count(getTitle())) {
164 IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
165 tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
166 return true;
167 } else
168 return false;
169}
170
171CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
172 Dialog::MoleculeQuery(title,_target, _description)
173{}
174
175CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
176
177bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
178 int IdxOfMol = -1;
179 if (CommandLineParser::getInstance().vm.count(getTitle())) {
180 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
181 cout << "IdxOfMol " << IdxOfMol << endl;
182 if (IdxOfMol >= 0)
183 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
184 else
185 tmp = NULL;
186 return true;
187 } else
188 return false;
189}
190
191CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
192 Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
193{}
194
195CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
196{}
197
198bool CommandLineDialog::VectorCommandLineQuery::handle() {
199 VectorValue temp;
200 if (CommandLineParser::getInstance().vm.count(getTitle())) {
201 temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
202 tmp->at(0) = temp.x;
203 tmp->at(1) = temp.y;
204 tmp->at(2) = temp.z;
205 return true;
206 } else
207 return false;
208}
209
210
211CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
212 Dialog::BoxQuery(title,_cellSize, _description)
213{}
214
215CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
216{}
217
218bool CommandLineDialog::BoxCommandLineQuery::handle() {
219 BoxValue temp;
220 if (CommandLineParser::getInstance().vm.count(getTitle())) {
221 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
222 tmp[0] = temp.xx;
223 tmp[1] = temp.xy;
224 tmp[2] = temp.xz;
225 tmp[3] = temp.yy;
226 tmp[4] = temp.yz;
227 tmp[5] = temp.zz;
228 return true;
229 } else
230 return false;
231}
232
233CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
234 Dialog::ElementQuery(title,target, _description)
235{}
236
237CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
238{}
239
240bool CommandLineDialog::ElementCommandLineQuery::handle() {
241 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
242 int Z;
243 if (CommandLineParser::getInstance().vm.count(getTitle())) {
244 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
245 vector<int>::iterator ElementRunner = AllElements.begin();
246 Z = *ElementRunner;
247 // TODO: So far, this does not really erase the element in the parsed list.
248 AllElements.erase(ElementRunner);
249 tmp = World::getInstance().getPeriode()->FindElement(Z);
250 return true;
251 } else
252 return false;
253}
Note: See TracBrowser for help on using the repository browser.