source: src/UIElements/CommandLineDialog.cpp@ d90762

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

Rewrote all CommandLineDialog's Query... to use the prorgam_options::vm.

  • we scan for the given title of the Query in program_options::vm and return the value.
  • in case of molecule we use MoleculeIdDescriptor.
  • in case of vector, new vector is created and components initialized from vector<double>
  • in case of element we use Periodetafel::FindElement()

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 4.4 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/MoleculeDescriptor.hpp>
13#include <Descriptors/MoleculeIdDescriptor.hpp>
14#include "UIElements/CommandLineDialog.hpp"
15
16#include "periodentafel.hpp"
17#include "atom.hpp"
18#include "CommandLineParser.hpp"
19#include "defs.hpp"
20#include "molecule.hpp"
21#include "log.hpp"
22#include "verbose.hpp"
23#include "World.hpp"
24
25using namespace std;
26
27
28CommandLineDialog::CommandLineDialog()
29{
30}
31
32CommandLineDialog::~CommandLineDialog()
33{
34}
35
36
37void CommandLineDialog::queryInt(const char* title, int* target){
38 registerQuery(new IntTextQuery(title,target));
39}
40
41void CommandLineDialog::queryDouble(const char* title, double* target){
42 registerQuery(new DoubleTextQuery(title,target));
43}
44
45void CommandLineDialog::queryString(const char* title, string* target){
46 registerQuery(new StringTextQuery(title,target));
47}
48
49void CommandLineDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules) {
50 registerQuery(new MoleculeTextQuery(title,target,molecules));
51}
52
53void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) {
54 registerQuery(new VectorTextQuery(title,target,cellSize,check));
55}
56
57void CommandLineDialog::queryElement(const char* title, const element **target){
58 registerQuery(new ElementTextQuery(title,target));
59}
60
61/************************** Query Infrastructure ************************/
62
63CommandLineDialog::IntTextQuery::IntTextQuery(string title,int *_target) :
64 Dialog::IntQuery(title,_target)
65{}
66
67CommandLineDialog::IntTextQuery::~IntTextQuery() {}
68
69bool CommandLineDialog::IntTextQuery::handle() {
70 if (CommandLineParser::getInstance().vm.count(getTitle())) {
71 tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
72 return true;
73 } else
74 return false;
75}
76
77CommandLineDialog::StringTextQuery::StringTextQuery(string title,string *_target) :
78 Dialog::StringQuery(title,_target)
79{}
80
81CommandLineDialog::StringTextQuery::~StringTextQuery() {}
82
83bool CommandLineDialog::StringTextQuery::handle() {
84 if (CommandLineParser::getInstance().vm.count(getTitle())) {
85 tmp = CommandLineParser::getInstance().vm[getTitle()].as<std::string>();
86 return true;
87 } else
88 return false;
89}
90
91CommandLineDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target) :
92 Dialog::DoubleQuery(title,_target)
93{}
94
95CommandLineDialog::DoubleTextQuery::~DoubleTextQuery() {}
96
97bool CommandLineDialog::DoubleTextQuery::handle() {
98 if (CommandLineParser::getInstance().vm.count(getTitle())) {
99 tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
100 return true;
101 } else
102 return false;
103}
104
105CommandLineDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
106 Dialog::MoleculeQuery(title,_target,_molecules)
107{}
108
109CommandLineDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
110
111bool CommandLineDialog::MoleculeTextQuery::handle() {
112 int IdxOfMol = -1;
113 if (CommandLineParser::getInstance().vm.count(getTitle())) {
114 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
115 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
116 return true;
117 } else
118 return false;
119}
120
121CommandLineDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check) :
122 Dialog::VectorQuery(title,_target,_cellSize,_check)
123{}
124
125CommandLineDialog::VectorTextQuery::~VectorTextQuery()
126{}
127
128bool CommandLineDialog::VectorTextQuery::handle() {
129 vector<double> temp;
130 if (CommandLineParser::getInstance().vm.count(getTitle())) {
131 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
132 assert((temp.size() == 3) && "Vector from command line does not have three components.");
133 tmp = new Vector;
134 for (int i=0;i<NDIM;i++)
135 tmp->at(i) = temp[i];
136 return true;
137 } else
138 return false;
139}
140
141
142CommandLineDialog::ElementTextQuery::ElementTextQuery(std::string title, const element **target) :
143 Dialog::ElementQuery(title,target)
144{}
145
146CommandLineDialog::ElementTextQuery::~ElementTextQuery()
147{}
148
149bool CommandLineDialog::ElementTextQuery::handle() {
150 int Z = -1;
151 if (CommandLineParser::getInstance().vm.count(getTitle())) {
152 Z = CommandLineParser::getInstance().vm[getTitle()].as<int>();
153 tmp = World::getInstance().getPeriode()->FindElement(Z);
154 return true;
155 } else
156 return false;
157}
Note: See TracBrowser for help on using the repository browser.