source: src/UIElements/CommandLineUI/CommandLineDialog.cpp@ b9c847

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

New SetOutputFormatsAction introduced.

Fixes:

new SetOutputFormatsAction:

  • new action SetOutputFormatsAction which instantiates various specializations of FormatParser in FormatParserStorage.
  • main(): mpqc, pcp and xyz and no more added by default to FormatParserStorage, this now has to be done by specifying them (e.g. on the command line as -o pcp mpqc xyz)
  • TESTFIXES: case 10,11,13,16,17,22 all failed due to the missing -o specification which has been added (this has been intended in this way from the very beginning of the ParseCommandLineOptions() refactoring)
  • action "convex-envelope" now more has ShortForm "-o" due to obvious reasons.
  • Property mode set to 100644
File size: 10.3 KB
Line 
1/*
2 * CommandLineDialog.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include <iostream>
11#include <vector>
12
13#include <Descriptors/AtomDescriptor.hpp>
14#include <Descriptors/AtomIdDescriptor.hpp>
15#include <Descriptors/MoleculeDescriptor.hpp>
16#include <Descriptors/MoleculeIdDescriptor.hpp>
17#include "CommandLineUI/CommandLineDialog.hpp"
18
19#include "Actions/Values.hpp"
20
21#include "element.hpp"
22#include "periodentafel.hpp"
23#include "CommandLineParser.hpp"
24#include "defs.hpp"
25#include "log.hpp"
26#include "periodentafel.hpp"
27#include "verbose.hpp"
28#include "World.hpp"
29
30#include "atom.hpp"
31#include "element.hpp"
32#include "molecule.hpp"
33#include "vector.hpp"
34
35using namespace std;
36
37
38CommandLineDialog::CommandLineDialog()
39{
40}
41
42CommandLineDialog::~CommandLineDialog()
43{
44}
45
46
47void CommandLineDialog::queryEmpty(const char* title, string _description){
48 registerQuery(new EmptyCommandLineQuery(title, _description));
49}
50
51void CommandLineDialog::queryInt(const char* title, int* target, string _description){
52 registerQuery(new IntCommandLineQuery(title,target, _description));
53}
54
55void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
56 registerQuery(new BooleanCommandLineQuery(title,target, _description));
57}
58
59void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
60 registerQuery(new DoubleCommandLineQuery(title,target, _description));
61}
62
63void CommandLineDialog::queryString(const char* title, string* target, string _description){
64 registerQuery(new StringCommandLineQuery(title,target, _description));
65}
66
67void CommandLineDialog::queryStrings(const char* title, vector<string> * target, string _description){
68 registerQuery(new StringsCommandLineQuery(title,target, _description));
69}
70
71void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
72 registerQuery(new AtomCommandLineQuery(title,target, _description));
73}
74
75void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
76 registerQuery(new MoleculeCommandLineQuery(title,target, _description));
77}
78
79void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
80 registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
81}
82
83void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {
84 registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
85}
86
87void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){
88 registerQuery(new ElementCommandLineQuery(title,target, _description));
89}
90
91/************************** Query Infrastructure ************************/
92
93CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
94 Dialog::EmptyQuery(title, _description)
95{}
96
97CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
98
99bool CommandLineDialog::EmptyCommandLineQuery::handle() {
100 cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
101 return true;
102}
103
104CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
105 Dialog::IntQuery(title,_target, _description)
106{}
107
108CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
109
110bool CommandLineDialog::IntCommandLineQuery::handle() {
111 if (CommandLineParser::getInstance().vm.count(getTitle())) {
112 tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
113 return true;
114 } else {
115 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl);
116 return false;
117 }
118}
119
120CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
121 Dialog::BooleanQuery(title,_target, _description)
122{}
123
124CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
125
126bool CommandLineDialog::BooleanCommandLineQuery::handle() {
127 if (CommandLineParser::getInstance().vm.count(getTitle())) {
128 tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
129 return true;
130 } else {
131 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl);
132 return false;
133 }
134}
135
136CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
137 Dialog::StringQuery(title,_target, _description)
138{}
139
140CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
141
142bool CommandLineDialog::StringCommandLineQuery::handle() {
143 if (CommandLineParser::getInstance().vm.count(getTitle())) {
144 tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
145 return true;
146 } else {
147 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
148 return false;
149 }
150}
151
152CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title,vector<string> *_target, string _description) :
153 Dialog::StringsQuery(title,_target, _description)
154{}
155
156CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
157
158bool CommandLineDialog::StringsCommandLineQuery::handle() {
159 if (CommandLineParser::getInstance().vm.count(getTitle())) {
160 tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >();
161 return true;
162 } else {
163 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
164 return false;
165 }
166}
167
168CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
169 Dialog::DoubleQuery(title,_target, _description)
170{}
171
172CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
173
174bool CommandLineDialog::DoubleCommandLineQuery::handle() {
175 if (CommandLineParser::getInstance().vm.count(getTitle())) {
176 tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
177 return true;
178 } else {
179 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl);
180 return false;
181 }
182}
183
184CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
185 Dialog::AtomQuery(title,_target, _description)
186{}
187
188CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
189
190bool CommandLineDialog::AtomCommandLineQuery::handle() {
191 int IdxOfAtom = -1;
192 if (CommandLineParser::getInstance().vm.count(getTitle())) {
193 IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
194 tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
195 return true;
196 } else {
197 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl);
198 return false;
199 }
200}
201
202CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
203 Dialog::MoleculeQuery(title,_target, _description)
204{}
205
206CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
207
208bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
209 int IdxOfMol = -1;
210 if (CommandLineParser::getInstance().vm.count(getTitle())) {
211 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
212 cout << "IdxOfMol " << IdxOfMol << endl;
213 if (IdxOfMol >= 0)
214 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
215 else
216 tmp = NULL;
217 return true;
218 } else {
219 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
220 return false;
221 }
222}
223
224CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
225 Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
226{}
227
228CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
229{}
230
231bool CommandLineDialog::VectorCommandLineQuery::handle() {
232 VectorValue temp;
233 if (CommandLineParser::getInstance().vm.count(getTitle())) {
234 temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
235 tmp->at(0) = temp.x;
236 tmp->at(1) = temp.y;
237 tmp->at(2) = temp.z;
238 return true;
239 } else {
240 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl);
241 return false;
242 }
243}
244
245
246CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
247 Dialog::BoxQuery(title,_cellSize, _description)
248{}
249
250CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
251{}
252
253bool CommandLineDialog::BoxCommandLineQuery::handle() {
254 BoxValue temp;
255 if (CommandLineParser::getInstance().vm.count(getTitle())) {
256 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
257 tmp[0] = temp.xx;
258 tmp[1] = temp.xy;
259 tmp[2] = temp.xz;
260 tmp[3] = temp.yy;
261 tmp[4] = temp.yz;
262 tmp[5] = temp.zz;
263 return true;
264 } else {
265 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl);
266 return false;
267 }
268}
269
270CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
271 Dialog::ElementQuery(title,target, _description)
272{}
273
274CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
275{}
276
277bool CommandLineDialog::ElementCommandLineQuery::handle() {
278 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
279 periodentafel *periode = World::getInstance().getPeriode();
280 element *elemental = NULL;
281 if (CommandLineParser::getInstance().vm.count(getTitle())) {
282 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
283 for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
284 elemental = periode->FindElement(*ZRunner);
285 ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery");
286 elements.push_back(elemental);
287 }
288 return true;
289 } else {
290 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
291 return false;
292 }
293}
Note: See TracBrowser for help on using the repository browser.