Changeset e6317b for src/UIElements
- Timestamp:
- Jun 16, 2010, 12:24:21 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:
- 492279
- Parents:
- f8e486 (diff), 980dd6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/UIElements
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineDialog.cpp
rf8e486 re6317b 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 #include <cassert>11 10 #include <iostream> 11 #include <vector> 12 12 13 13 #include <Descriptors/AtomDescriptor.hpp> … … 16 16 #include <Descriptors/MoleculeIdDescriptor.hpp> 17 17 #include "CommandLineUI/CommandLineDialog.hpp" 18 19 #include "Actions/Values.hpp" 18 20 19 21 #include "element.hpp" … … 79 81 } 80 82 81 void CommandLineDialog::queryElement(const char* title, const element **target, string _description){83 void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){ 82 84 registerQuery(new ElementCommandLineQuery(title,target, _description)); 83 85 } … … 106 108 tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 107 109 return true; 108 } else 109 return false; 110 } else { 111 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl); 112 return false; 113 } 110 114 } 111 115 … … 117 121 118 122 bool CommandLineDialog::BooleanCommandLineQuery::handle() { 119 bool badInput = false; 120 char input = ' '; 121 do{ 122 badInput = false; 123 Log() << Verbose(0) << getTitle(); 124 cin >> input; 125 if ((input == 'y' ) || (input == 'Y')) { 126 tmp = true; 127 } else if ((input == 'n' ) || (input == 'N')) { 128 tmp = false; 129 } else { 130 badInput=true; 131 cin.clear(); 132 cin.ignore(std::numeric_limits<streamsize>::max(),'\n'); 133 Log() << Verbose(0) << "Input was not of [yYnN]!" << endl; 134 } 135 } while(badInput); 136 // clear the input buffer of anything still in the line 137 cin.ignore(std::numeric_limits<streamsize>::max(),'\n'); 138 return true; 123 if (CommandLineParser::getInstance().vm.count(getTitle())) { 124 tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>(); 125 return true; 126 } else { 127 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl); 128 return false; 129 } 139 130 } 140 131 … … 149 140 tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>(); 150 141 return true; 151 } else 152 return false; 142 } else { 143 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl); 144 return false; 145 } 153 146 } 154 147 … … 163 156 tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>(); 164 157 return true; 165 } else 166 return false; 158 } else { 159 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl); 160 return false; 161 } 167 162 } 168 163 … … 179 174 tmp = World::getInstance().getAtom(AtomById(IdxOfAtom)); 180 175 return true; 181 } else 182 return false; 176 } else { 177 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl); 178 return false; 179 } 183 180 } 184 181 … … 199 196 tmp = NULL; 200 197 return true; 201 } else 202 return false; 198 } else { 199 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl); 200 return false; 201 } 203 202 } 204 203 … … 211 210 212 211 bool CommandLineDialog::VectorCommandLineQuery::handle() { 213 vector<double> temp; 214 if (CommandLineParser::getInstance().vm.count(getTitle())) { 215 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >(); 216 assert((temp.size() == 3) && "Vector from command line does not have three components."); 217 for (int i=0;i<NDIM;i++) 218 tmp->at(i) = temp[i]; 219 return true; 220 } else 221 return false; 212 VectorValue temp; 213 if (CommandLineParser::getInstance().vm.count(getTitle())) { 214 temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >(); 215 tmp->at(0) = temp.x; 216 tmp->at(1) = temp.y; 217 tmp->at(2) = temp.z; 218 return true; 219 } else { 220 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl); 221 return false; 222 } 222 223 } 223 224 … … 231 232 232 233 bool CommandLineDialog::BoxCommandLineQuery::handle() { 233 vector<double> temp; 234 if (CommandLineParser::getInstance().vm.count(getTitle())) { 235 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >(); 236 assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components."); 237 for (int i=0;i<6;i++) { 238 tmp[i] = temp[i]; 239 } 240 return true; 241 } else 242 return false; 243 } 244 245 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) : 234 BoxValue temp; 235 if (CommandLineParser::getInstance().vm.count(getTitle())) { 236 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >(); 237 tmp[0] = temp.xx; 238 tmp[1] = temp.xy; 239 tmp[2] = temp.xz; 240 tmp[3] = temp.yy; 241 tmp[4] = temp.yz; 242 tmp[5] = temp.zz; 243 return true; 244 } else { 245 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl); 246 return false; 247 } 248 } 249 250 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) : 246 251 Dialog::ElementQuery(title,target, _description) 247 252 {} … … 252 257 bool CommandLineDialog::ElementCommandLineQuery::handle() { 253 258 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 254 int Z; 259 periodentafel *periode = World::getInstance().getPeriode(); 260 element *elemental = NULL; 255 261 if (CommandLineParser::getInstance().vm.count(getTitle())) { 256 262 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >(); 257 vector<int>::iterator ElementRunner = AllElements.begin(); 258 Z = *ElementRunner; 259 // TODO: So far, this does not really erase the element in the parsed list. 260 AllElements.erase(ElementRunner); 261 tmp = World::getInstance().getPeriode()->FindElement(Z); 262 return true; 263 } else 264 return false; 265 } 263 for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) { 264 elemental = periode->FindElement(*ZRunner); 265 ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery"); 266 elements.push_back(elemental); 267 } 268 return true; 269 } else { 270 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl); 271 return false; 272 } 273 } -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
rf8e486 re6317b 36 36 virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = ""); 37 37 virtual void queryBox(const char*,double ** const, std::string = ""); 38 virtual void queryElement(const char*, const element **, std::string = "");38 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 39 39 40 40 protected: … … 105 105 class ElementCommandLineQuery : public Dialog::ElementQuery { 106 106 public: 107 ElementCommandLineQuery(std::string title, const element **_target, std::string _description = "");107 ElementCommandLineQuery(std::string title, std::vector<element *> *_target, std::string _description = ""); 108 108 virtual ~ElementCommandLineQuery(); 109 109 virtual bool handle(); -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
rf8e486 re6317b 14 14 15 15 #include "Actions/ActionRegistry.hpp" 16 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 16 17 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 17 #include "Actions/AnalysisAction/PairCorrelationToPointAction.hpp" 18 #include "Actions/AnalysisAction/PairCorrelationToSurfaceAction.hpp" 18 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 19 19 #include "Actions/AtomAction/AddAction.hpp" 20 20 #include "Actions/AtomAction/ChangeElementAction.hpp" … … 28 28 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 29 29 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 30 #include "Actions/FragmentationAction/FragmentationAction.hpp" 30 31 #include "Actions/MoleculeAction/BondFileAction.hpp" 31 32 #include "Actions/MoleculeAction/ChangeNameAction.hpp" … … 35 36 #include "Actions/MoleculeAction/SaveBondsAction.hpp" 36 37 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp" 38 #include "Actions/MoleculeAction/TranslateAction.hpp" 37 39 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp" 38 40 #include "Actions/ParserAction/LoadXyzAction.hpp" … … 75 77 CommandLineWindow::~CommandLineWindow() 76 78 { 77 // // go through all possible actions78 // for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRegistry::getInstance().getBeginIter() != ActionRegistry::getInstance().getEndIter(); ActionRunner = ActionRegistry::getInstance().getBeginIter()) {79 // ActionRegistry::getInstance().unregisterAction(ActionRunner->second);80 // delete(ActionRunner->second);81 // }82 83 79 delete statusIndicator; 84 80 } … … 86 82 void CommandLineWindow::display() { 87 83 // go through all possible actions 88 for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRunner != ActionRegistry::getInstance().getEndIter(); ActionRunner++) { 89 // check whether action is present in command line 90 if (CommandLineParser::getInstance().vm.count(ActionRunner->first)) { 91 ActionRunner->second->call(); 92 } 84 for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) { 85 cout << "Checking presence of " << *CommandRunner << endl; 86 if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner)) 87 ActionRegistry::getInstance().getActionByName(*CommandRunner)->call(); 93 88 } 94 89 } … … 96 91 void CommandLineWindow::populateAnalysisActions() 97 92 { 93 new AnalysisMolecularVolumeAction(); 98 94 new AnalysisPairCorrelationAction(); 99 new AnalysisPairCorrelationToPointAction(); 100 new AnalysisPairCorrelationToSurfaceAction(); 95 new AnalysisPrincipalAxisSystemAction(); 101 96 } 102 97 … … 121 116 { 122 117 new FragmentationDepthFirstSearchAction(); 118 new FragmentationFragmentationAction(); 119 new FragmentationSubgraphDissectionAction(); 123 120 } 124 121 … … 132 129 new MoleculeSaveBondsAction(); 133 130 new MoleculeSaveTemperatureAction(); 131 new MoleculeTranslateAction(); 134 132 new MoleculeVerletIntegrationAction(); 135 133 } -
src/UIElements/Dialog.cpp
rf8e486 re6317b 41 41 retval &= (*iter)->handle(); 42 42 // if any query fails (is canceled), we can end the handling process 43 if(!retval) 43 if(!retval) { 44 DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl); 44 45 break; 46 } 45 47 } 46 48 if (retval){ … … 201 203 202 204 // Element Queries 203 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target, std::string _description) :205 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) : 204 206 Query(title, _description), 205 tmp(0),206 207 target(_target) 207 208 {} … … 210 211 211 212 void Dialog::ElementQuery::setResult(){ 212 *target= tmp;213 } 213 *target=elements; 214 } -
src/UIElements/Dialog.hpp
rf8e486 re6317b 11 11 #include<string> 12 12 #include<list> 13 #include<vector> 13 14 14 15 class atom; … … 32 33 virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0; 33 34 virtual void queryBox(const char*,double ** const, std::string = "")=0; 34 virtual void queryElement(const char*, const element **, std::string = "")=0;35 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0; 35 36 36 37 virtual bool display(); … … 49 50 //base class for all queries 50 51 class Query { 52 friend class Dialog; 51 53 public: 52 54 Query(std::string _title, std::string _description = ""); … … 172 174 class ElementQuery : public Query { 173 175 public: 174 ElementQuery(std::string title, const element**_target, std::string _description = "");176 ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = ""); 175 177 virtual ~ElementQuery(); 176 178 virtual bool handle()=0; 177 179 virtual void setResult(); 178 180 protected: 179 const element *tmp;181 std::vector<element *> elements; 180 182 private: 181 const element **target;183 std::vector<element *> * const target; 182 184 }; 183 185 -
src/UIElements/TextUI/TextDialog.cpp
rf8e486 re6317b 74 74 } 75 75 76 void TextDialog::queryElement(const char* title, const element **target, string description){76 void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){ 77 77 registerQuery(new ElementTextQuery(title,target,description)); 78 78 } … … 283 283 } 284 284 285 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, const element **target, std::string _description) :286 Dialog::ElementQuery(title, target,_description)285 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) : 286 Dialog::ElementQuery(title,_target,_description) 287 287 {} 288 288 … … 293 293 bool badInput=false; 294 294 bool aborted = false; 295 element * tmp = NULL; 295 296 do{ 296 297 badInput = false; … … 309 310 Log() << Verbose(0) << "No element with this atomic number!" << endl; 310 311 badInput = true; 312 } else { 313 elements.push_back(tmp); 311 314 } 312 315 } … … 331 334 Log() << Verbose(0) << "No element with this shorthand!" << endl; 332 335 badInput = true; 336 } else { 337 elements.push_back(tmp); 333 338 } 334 339 } -
src/UIElements/TextUI/TextDialog.hpp
rf8e486 re6317b 33 33 virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = ""); 34 34 virtual void queryBox(const char*,double ** const, std::string = ""); 35 virtual void queryElement(const char*, const element **, std::string = "");35 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 36 36 37 37 protected: … … 102 102 class ElementTextQuery : public Dialog::ElementQuery { 103 103 public: 104 ElementTextQuery(std::string title, const element **_target, std::string _description = NULL);104 ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description = NULL); 105 105 virtual ~ElementTextQuery(); 106 106 virtual bool handle();
Note:
See TracChangeset
for help on using the changeset viewer.