source: src/UIElements/CommandLineUI/CommandLineDialog.cpp@ 48dcbd

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 48dcbd was 4e10f5, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Merge branch 'stable' into StructureRefactoring

Conflicts:

src/Actions/WorldAction/CenterOnEdgeAction.cpp
src/Actions/WorldAction/ChangeBoxAction.cpp
src/Actions/WorldAction/RepeatBoxAction.cpp
src/Actions/WorldAction/ScaleBoxAction.cpp
src/World.cpp
src/boundary.cpp

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