Changeset 7cd6e7 for src/UIElements/CommandLineUI
- Timestamp:
- Jul 25, 2010, 3:07:42 PM (15 years ago)
- Branches:
- 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
- Children:
- e2f3114
- Parents:
- 0ff6b5
- Location:
- src/UIElements/CommandLineUI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineDialog.cpp
r0ff6b5 r7cd6e7 54 54 } 55 55 56 void CommandLineDialog::queryInts(const char* title, string _description){ 57 registerQuery(new IntsCommandLineQuery(title, _description)); 58 } 59 56 60 void CommandLineDialog::queryBoolean(const char* title, string _description){ 57 61 registerQuery(new BooleanCommandLineQuery(title, _description)); … … 62 66 } 63 67 68 void CommandLineDialog::queryDoubles(const char* title, string _description){ 69 registerQuery(new DoublesCommandLineQuery(title, _description)); 70 } 71 64 72 void CommandLineDialog::queryString(const char* title, string _description){ 65 73 registerQuery(new StringCommandLineQuery(title, _description)); … … 74 82 } 75 83 84 void CommandLineDialog::queryAtoms(const char* title, string _description) { 85 registerQuery(new AtomsCommandLineQuery(title, _description)); 86 } 87 76 88 void CommandLineDialog::queryMolecule(const char* title, string _description) { 77 89 registerQuery(new MoleculeCommandLineQuery(title, _description)); 78 90 } 79 91 92 void CommandLineDialog::queryMolecules(const char* title, string _description) { 93 registerQuery(new MoleculesCommandLineQuery(title, _description)); 94 } 95 80 96 void CommandLineDialog::queryVector(const char* title, bool check, string _description) { 81 97 registerQuery(new VectorCommandLineQuery(title,check, _description)); 82 98 } 83 99 100 void CommandLineDialog::queryVectors(const char* title, bool check, string _description) { 101 registerQuery(new VectorsCommandLineQuery(title,check, _description)); 102 } 103 84 104 void CommandLineDialog::queryBox(const char* title, string _description) { 85 105 registerQuery(new BoxCommandLineQuery(title,_description)); … … 88 108 void CommandLineDialog::queryElement(const char* title, string _description){ 89 109 registerQuery(new ElementCommandLineQuery(title, _description)); 110 } 111 112 void CommandLineDialog::queryElements(const char* title, string _description){ 113 registerQuery(new ElementsCommandLineQuery(title, _description)); 90 114 } 91 115 … … 119 143 } 120 144 145 CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) : 146 Dialog::IntsQuery(title, _description) 147 {} 148 149 CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {} 150 151 bool CommandLineDialog::IntsCommandLineQuery::handle() { 152 if (CommandLineParser::getInstance().vm.count(getTitle())) { 153 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 154 return true; 155 } else { 156 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl); 157 return false; 158 } 159 } 160 121 161 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) : 122 162 Dialog::BooleanQuery(title, _description) … … 162 202 return true; 163 203 } else { 164 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);204 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl); 165 205 return false; 166 206 } … … 183 223 } 184 224 225 CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) : 226 Dialog::DoublesQuery(title, _description) 227 {} 228 229 CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {} 230 231 bool CommandLineDialog::DoublesCommandLineQuery::handle() { 232 if (CommandLineParser::getInstance().vm.count(getTitle())) { 233 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >(); 234 return true; 235 } else { 236 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl); 237 return false; 238 } 239 } 240 185 241 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) : 186 242 Dialog::AtomQuery(title, _description) … … 201 257 } 202 258 259 CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) : 260 Dialog::AtomsQuery(title, _description) 261 {} 262 263 CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {} 264 265 bool CommandLineDialog::AtomsCommandLineQuery::handle() { 266 std::vector<int> IdxOfAtom; 267 if (CommandLineParser::getInstance().vm.count(getTitle())) { 268 IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 269 for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) { 270 temp = World::getInstance().getAtom(AtomById(*iter)); 271 if (temp) 272 tmp.push_back(temp); 273 } 274 return true; 275 } else { 276 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl); 277 return false; 278 } 279 } 280 203 281 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) : 204 282 Dialog::MoleculeQuery(title, _description) … … 211 289 if (CommandLineParser::getInstance().vm.count(getTitle())) { 212 290 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 213 cout << "IdxOfMol " << IdxOfMol << endl; 214 if (IdxOfMol >= 0) 215 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 216 else 217 tmp = NULL; 291 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 218 292 return true; 219 293 } else { 220 294 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl); 295 return false; 296 } 297 } 298 299 CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) : 300 Dialog::MoleculesQuery(title, _description) 301 {} 302 303 CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {} 304 305 bool CommandLineDialog::MoleculesCommandLineQuery::handle() { 306 std::vector<int> IdxOfMol; 307 if (CommandLineParser::getInstance().vm.count(getTitle())) { 308 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 309 for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) { 310 temp = World::getInstance().getMolecule(MoleculeById(*iter)); 311 if (temp) 312 tmp.push_back(temp); 313 } 314 return true; 315 } else { 316 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl); 221 317 return false; 222 318 } … … 234 330 if (CommandLineParser::getInstance().vm.count(getTitle())) { 235 331 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; 332 tmp[0] = temp.x; 333 tmp[1] = temp.y; 334 tmp[2] = temp.z; 335 if ((check) && (World::getInstance().getDomain().isInside(tmp))) { 336 tmp.Zero(); 337 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl); 338 } 239 339 return true; 240 340 } else { … … 244 344 } 245 345 346 CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) : 347 Dialog::VectorsQuery(title,_check, _description) 348 {} 349 350 CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery() 351 {} 352 353 bool CommandLineDialog::VectorsCommandLineQuery::handle() { 354 std::vector<VectorValue> temporary; 355 if (CommandLineParser::getInstance().vm.count(getTitle())) { 356 temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >(); 357 for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) { 358 temp[0] = (*iter).x; 359 temp[1] = (*iter).y; 360 temp[2] = (*iter).z; 361 if ((!check) || (World::getInstance().getDomain().isInside(temp))) 362 tmp.push_back(temp); 363 else 364 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl); 365 } 366 return true; 367 } else { 368 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl); 369 return false; 370 } 371 } 246 372 247 373 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) : … … 279 405 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 280 406 periodentafel *periode = World::getInstance().getPeriode(); 281 element *elemental = NULL; 407 if (CommandLineParser::getInstance().vm.count(getTitle())) { 408 int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >(); 409 tmp = periode->FindElement(Z); 410 ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery"); 411 return true; 412 } else { 413 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl); 414 return false; 415 } 416 } 417 418 CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) : 419 Dialog::ElementsQuery(title, _description) 420 {} 421 422 CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery() 423 {} 424 425 bool CommandLineDialog::ElementsCommandLineQuery::handle() { 426 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 427 periodentafel *periode = World::getInstance().getPeriode(); 282 428 if (CommandLineParser::getInstance().vm.count(getTitle())) { 283 429 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >(); 284 430 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 tmp.push_back( elemental);431 temp = periode->FindElement(*ZRunner); 432 ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery"); 433 tmp.push_back(temp); 288 434 } 289 435 return true; 290 436 } else { 291 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);292 return false; 293 } 294 } 437 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl); 438 return false; 439 } 440 } -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
r0ff6b5 r7cd6e7 29 29 virtual void queryEmpty(const char *, std::string = ""); 30 30 virtual void queryInt(const char *, std::string = ""); 31 virtual void queryInts(const char *, std::string = ""); 31 32 virtual void queryBoolean(const char *, std::string = ""); 32 33 virtual void queryString(const char*, std::string = ""); 33 34 virtual void queryStrings(const char*, std::string = ""); 34 35 virtual void queryDouble(const char*, std::string = ""); 36 virtual void queryDoubles(const char*, std::string = ""); 35 37 virtual void queryAtom(const char*, std::string = ""); 38 virtual void queryAtoms(const char*, std::string = ""); 36 39 virtual void queryMolecule(const char*, std::string = ""); 40 virtual void queryMolecules(const char*, std::string = ""); 37 41 virtual void queryVector(const char*, bool, std::string = ""); 42 virtual void queryVectors(const char*, bool, std::string = ""); 38 43 virtual void queryBox(const char*, std::string = ""); 39 44 virtual void queryElement(const char*, std::string = ""); 45 virtual void queryElements(const char*, std::string = ""); 40 46 41 47 protected: … … 55 61 }; 56 62 63 class IntsCommandLineQuery : public Dialog::IntsQuery { 64 public: 65 IntsCommandLineQuery(std::string title, std::string _description = ""); 66 virtual ~IntsCommandLineQuery(); 67 virtual bool handle(); 68 }; 69 57 70 class BooleanCommandLineQuery : public Dialog::BooleanQuery { 58 71 public: … … 66 79 DoubleCommandLineQuery(std::string title, std::string _description = ""); 67 80 virtual ~DoubleCommandLineQuery(); 81 virtual bool handle(); 82 }; 83 84 class DoublesCommandLineQuery : public Dialog::DoublesQuery { 85 public: 86 DoublesCommandLineQuery(std::string title, std::string _description = ""); 87 virtual ~DoublesCommandLineQuery(); 68 88 virtual bool handle(); 69 89 }; … … 90 110 }; 91 111 112 class AtomsCommandLineQuery : public Dialog::AtomsQuery { 113 public: 114 AtomsCommandLineQuery(std::string title, std::string _description = ""); 115 virtual ~AtomsCommandLineQuery(); 116 virtual bool handle(); 117 }; 118 92 119 class MoleculeCommandLineQuery : public Dialog::MoleculeQuery { 93 120 public: … … 97 124 }; 98 125 126 class MoleculesCommandLineQuery : public Dialog::MoleculesQuery { 127 public: 128 MoleculesCommandLineQuery(std::string title, std::string _description = ""); 129 virtual ~MoleculesCommandLineQuery(); 130 virtual bool handle(); 131 }; 132 99 133 class VectorCommandLineQuery : public Dialog::VectorQuery { 100 134 public: 101 135 VectorCommandLineQuery(std::string title,bool _check, std::string _description = ""); 102 136 virtual ~VectorCommandLineQuery(); 137 virtual bool handle(); 138 }; 139 140 class VectorsCommandLineQuery : public Dialog::VectorsQuery { 141 public: 142 VectorsCommandLineQuery(std::string title,bool _check, std::string _description = ""); 143 virtual ~VectorsCommandLineQuery(); 103 144 virtual bool handle(); 104 145 }; … … 117 158 virtual bool handle(); 118 159 }; 160 161 class ElementsCommandLineQuery : public Dialog::ElementsQuery { 162 public: 163 ElementsCommandLineQuery(std::string title, std::string _description = ""); 164 virtual ~ElementsCommandLineQuery(); 165 virtual bool handle(); 166 }; 119 167 }; 120 168
Note:
See TracChangeset
for help on using the changeset viewer.