source: src/UIElements/CommandLineDialog.cpp@ 86466e

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

new query class EmptyQuery for showing text messages.

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

  • Property mode set to 100644
File size: 5.6 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::queryEmpty(const char* title, string _description){
38 registerQuery(new EmptyCommandLineQuery(title, _description));
39}
40
41void CommandLineDialog::queryInt(const char* title, int* target, string _description){
42 registerQuery(new IntCommandLineQuery(title,target, _description));
43}
44
45void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
46 registerQuery(new DoubleCommandLineQuery(title,target, _description));
47}
48
49void CommandLineDialog::queryString(const char* title, string* target, string _description){
50 registerQuery(new StringCommandLineQuery(title,target, _description));
51}
52
53void CommandLineDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules, string _description) {
54 registerQuery(new MoleculeCommandLineQuery(title,target,molecules, _description));
55}
56
57void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
58 registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
59}
60
61void CommandLineDialog::queryElement(const char* title, const element **target, string _description){
62 registerQuery(new ElementCommandLineQuery(title,target, _description));
63}
64
65/************************** Query Infrastructure ************************/
66
67CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
68 Dialog::EmptyQuery(title, _description)
69{}
70
71CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
72
73bool CommandLineDialog::EmptyCommandLineQuery::handle() {
74 cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
75 return true;
76}
77
78CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
79 Dialog::IntQuery(title,_target, _description)
80{}
81
82CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
83
84bool CommandLineDialog::IntCommandLineQuery::handle() {
85 if (CommandLineParser::getInstance().vm.count(getTitle())) {
86 tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
87 return true;
88 } else
89 return false;
90}
91
92CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
93 Dialog::StringQuery(title,_target, _description)
94{}
95
96CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
97
98bool CommandLineDialog::StringCommandLineQuery::handle() {
99 if (CommandLineParser::getInstance().vm.count(getTitle())) {
100 tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
101 return true;
102 } else
103 return false;
104}
105
106CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
107 Dialog::DoubleQuery(title,_target, _description)
108{}
109
110CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
111
112bool CommandLineDialog::DoubleCommandLineQuery::handle() {
113 if (CommandLineParser::getInstance().vm.count(getTitle())) {
114 tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
115 return true;
116 } else
117 return false;
118}
119
120CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, MoleculeListClass *_molecules, string _description) :
121 Dialog::MoleculeQuery(title,_target,_molecules, _description)
122{}
123
124CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
125
126bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
127 int IdxOfMol = -1;
128 if (CommandLineParser::getInstance().vm.count(getTitle())) {
129 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
130 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
131 return true;
132 } else
133 return false;
134}
135
136CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
137 Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
138{}
139
140CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
141{}
142
143bool CommandLineDialog::VectorCommandLineQuery::handle() {
144 vector<double> temp;
145 if (CommandLineParser::getInstance().vm.count(getTitle())) {
146 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
147 assert((temp.size() == 3) && "Vector from command line does not have three components.");
148 tmp = new Vector;
149 for (int i=0;i<NDIM;i++)
150 tmp->at(i) = temp[i];
151 return true;
152 } else
153 return false;
154}
155
156
157CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
158 Dialog::ElementQuery(title,target, _description)
159{}
160
161CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
162{}
163
164bool CommandLineDialog::ElementCommandLineQuery::handle() {
165 int Z = -1;
166 if (CommandLineParser::getInstance().vm.count(getTitle())) {
167 Z = CommandLineParser::getInstance().vm[getTitle()].as<int>();
168 tmp = World::getInstance().getPeriode()->FindElement(Z);
169 return true;
170 } else
171 return false;
172}
Note: See TracBrowser for help on using the repository browser.