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
RevLine 
[a2ab15]1/*
2 * CommandLineDialog.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
8
[d90762]9#include <cassert>
[a2ab15]10#include <iostream>
11
[d90762]12#include <Descriptors/MoleculeDescriptor.hpp>
13#include <Descriptors/MoleculeIdDescriptor.hpp>
[a2ab15]14#include "UIElements/CommandLineDialog.hpp"
15
16#include "periodentafel.hpp"
17#include "atom.hpp"
[d90762]18#include "CommandLineParser.hpp"
19#include "defs.hpp"
[a2ab15]20#include "molecule.hpp"
21#include "log.hpp"
22#include "verbose.hpp"
[d90762]23#include "World.hpp"
[a2ab15]24
25using namespace std;
26
27
28CommandLineDialog::CommandLineDialog()
29{
30}
31
32CommandLineDialog::~CommandLineDialog()
33{
34}
35
36
[86466e]37void CommandLineDialog::queryEmpty(const char* title, string _description){
38 registerQuery(new EmptyCommandLineQuery(title, _description));
[a2ab15]39}
40
[86466e]41void CommandLineDialog::queryInt(const char* title, int* target, string _description){
42 registerQuery(new IntCommandLineQuery(title,target, _description));
[a2ab15]43}
44
[86466e]45void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
46 registerQuery(new DoubleCommandLineQuery(title,target, _description));
[a2ab15]47}
48
[86466e]49void CommandLineDialog::queryString(const char* title, string* target, string _description){
50 registerQuery(new StringCommandLineQuery(title,target, _description));
[a2ab15]51}
52
[86466e]53void CommandLineDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules, string _description) {
54 registerQuery(new MoleculeCommandLineQuery(title,target,molecules, _description));
[a2ab15]55}
56
[86466e]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));
[a2ab15]63}
64
65/************************** Query Infrastructure ************************/
66
[86466e]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)
[a2ab15]80{}
81
[86466e]82CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
[a2ab15]83
[86466e]84bool CommandLineDialog::IntCommandLineQuery::handle() {
[d90762]85 if (CommandLineParser::getInstance().vm.count(getTitle())) {
86 tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
87 return true;
88 } else
89 return false;
[a2ab15]90}
91
[86466e]92CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
93 Dialog::StringQuery(title,_target, _description)
[a2ab15]94{}
95
[86466e]96CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
[a2ab15]97
[86466e]98bool CommandLineDialog::StringCommandLineQuery::handle() {
[d90762]99 if (CommandLineParser::getInstance().vm.count(getTitle())) {
[86466e]100 tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
[d90762]101 return true;
102 } else
103 return false;
[a2ab15]104}
105
[86466e]106CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
107 Dialog::DoubleQuery(title,_target, _description)
[a2ab15]108{}
109
[86466e]110CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
[a2ab15]111
[86466e]112bool CommandLineDialog::DoubleCommandLineQuery::handle() {
[d90762]113 if (CommandLineParser::getInstance().vm.count(getTitle())) {
114 tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
115 return true;
116 } else
117 return false;
[a2ab15]118}
119
[86466e]120CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, MoleculeListClass *_molecules, string _description) :
121 Dialog::MoleculeQuery(title,_target,_molecules, _description)
[a2ab15]122{}
123
[86466e]124CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
[a2ab15]125
[86466e]126bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
[d90762]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;
[a2ab15]134}
135
[86466e]136CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
137 Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
[a2ab15]138{}
139
[86466e]140CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
[a2ab15]141{}
142
[86466e]143bool CommandLineDialog::VectorCommandLineQuery::handle() {
[d90762]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;
[a2ab15]154}
155
156
[86466e]157CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
158 Dialog::ElementQuery(title,target, _description)
[a2ab15]159{}
160
[86466e]161CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
[a2ab15]162{}
163
[86466e]164bool CommandLineDialog::ElementCommandLineQuery::handle() {
[d90762]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;
[a2ab15]172}
Note: See TracBrowser for help on using the repository browser.