- Timestamp:
- Oct 22, 2010, 4:13:36 PM (14 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:
- bd2390, db7cb0
- Parents:
- e4decc
- Location:
- src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MapOfActions.cpp
re4decc r6f5dfe 31 31 #include <boost/optional.hpp> 32 32 #include <boost/program_options.hpp> 33 #include <boost/filesystem.hpp> 33 34 34 35 #include <iostream> … … 367 368 TypeMap["fill-void"] = &typeid(std::string); 368 369 TypeMap["fragment-mol"] = &typeid(std::string); 369 TypeMap["input"] = &typeid( std::string);370 TypeMap["input"] = &typeid(boost::filesystem::path); 370 371 TypeMap["linear-interpolate"] = &typeid(std::string); 371 372 TypeMap["molecular-volume"] = &typeid(molecule); … … 825 826 } 826 827 828 void MapOfActions::queryCurrentValue(const char * name, boost::filesystem::path&_T) 829 { 830 std::string tmp; 831 if (typeid( boost::filesystem::path ) == *TypeMap[name]) { 832 if (CurrentValue.find(name) == CurrentValue.end()) 833 throw MissingValueException(__FILE__, __LINE__); 834 std::istringstream stream(CurrentValue[name]); 835 CurrentValue.erase(name); 836 if (!stream.fail()) { 837 stream >> tmp >> ws; 838 _T = tmp; 839 } 840 } else 841 throw IllegalTypeException(__FILE__,__LINE__); 842 } 843 827 844 828 845 void MapOfActions::setCurrentValue(const char * name, class atom * &_T) … … 927 944 stream << (*iter)->getId() << " "; 928 945 } 946 CurrentValue[name] = stream.str(); 947 } else 948 throw IllegalTypeException(__FILE__,__LINE__); 949 } 950 951 void MapOfActions::setCurrentValue(const char * name, boost::filesystem::path &_T) 952 { 953 if (typeid( boost::filesystem::path ) == *TypeMap[name]) { 954 std::ostringstream stream; 955 stream << _T.string(); 929 956 CurrentValue[name] = stream.str(); 930 957 } else -
src/Actions/MapOfActions.hpp
re4decc r6f5dfe 9 9 #define MAPOFACTIONS_HPP_ 10 10 11 #include <boost/filesystem.hpp> 12 #include <boost/lexical_cast.hpp> 11 13 #include <boost/program_options.hpp> 12 #include <boost/lexical_cast.hpp>13 14 14 15 #include <map> … … 31 32 32 33 namespace po = boost::program_options; 34 namespace fs = boost::filesystem; 33 35 34 36 using boost::lexical_cast; … … 173 175 void queryCurrentValue(const char * name, std::vector<const element *>&_T); 174 176 void queryCurrentValue(const char * name, std::vector<molecule *>&_T); 177 void queryCurrentValue(const char * name, fs::path&_T); 175 178 template<typename T> void queryCurrentValue(const char * name, T &_T) 176 179 { … … 208 211 void setCurrentValue(const char * name, std::vector<const element *>&_T); 209 212 void setCurrentValue(const char * name, std::vector<molecule *>&_T); 213 void setCurrentValue(const char * name, fs::path&_T); 210 214 template<class T> void setCurrentValue(const char * name, T &_T) 211 215 { -
src/Actions/WorldAction/InputAction.cpp
re4decc r6f5dfe 30 30 #include <string> 31 31 32 #include <boost/filesystem/fstream.hpp> 33 32 34 using namespace std; 33 35 … … 39 41 /** =========== define the function ====================== */ 40 42 Action::state_ptr WorldInputAction::performCall() { 41 MoleculeListClass *molecules = World::getInstance().getMolecules();42 molecule *mol = NULL;43 std::ifstream test;43 // MoleculeListClass *molecules = World::getInstance().getMolecules(); 44 // molecule *mol = NULL; 45 boost::filesystem::ifstream test; 44 46 45 47 // obtain information 46 48 getParametersfromValueStorage(); 47 49 48 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl); 49 if (params.filename.find('.') != string::npos) { 50 std::string FilenamePrefix = params.filename.substr(0,params.filename.find_last_of('.')); 51 std::string FilenameSuffix = params.filename.substr(params.filename.find_last_of('.')+1, params.filename.length()); 52 DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl); 53 test.open(params.filename.c_str()); 54 if (test == NULL) { 55 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << params.filename << " not found." << endl); 50 DoLog(0) && (Log() << Verbose(0) << "Config file given " << params.filename << "." << endl); 51 if (!boost::filesystem::exists(params.filename)) { 52 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << params.filename << " not found." << endl); 53 return Action::failure; 54 } else { 55 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 56 if (params.filename.has_filename()) { 57 // get suffix 58 std::string FilenameSuffix = params.filename.extension(); 59 std::string FilenamePrefix = params.filename.stem(); 60 DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl); 61 FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix); 62 63 // parse the file 64 test.open(params.filename); 65 FormatParserStorage::getInstance().get(test, FilenameSuffix); 66 test.close(); 67 // 68 // // set mol to first active molecule 69 // if (molecules->ListOfMolecules.size() != 0) { 70 // for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 71 // if ((*ListRunner)->ActiveFlag) { 72 // mol = *ListRunner; 73 // break; 74 // } 75 // } 76 // if (mol == NULL) { 77 // mol = World::getInstance().createMolecule(); 78 // mol->ActiveFlag = true; 79 // molecules->insert(mol); 80 // } 81 // mol->SetNameFromFilename(params.filename.substr(0,params.filename.find('.')).c_str()); 82 return Action::success; 56 83 } else { 57 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 58 FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix); 59 test.close(); 84 DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl); 85 return Action::failure; 60 86 } 61 FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);62 // set mol to first active molecule63 if (molecules->ListOfMolecules.size() != 0) {64 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)65 if ((*ListRunner)->ActiveFlag) {66 mol = *ListRunner;67 break;68 }69 }70 if (mol == NULL) {71 mol = World::getInstance().createMolecule();72 mol->ActiveFlag = true;73 molecules->insert(mol);74 }75 mol->SetNameFromFilename(params.filename.substr(0,params.filename.find('.')).c_str());76 } else {77 DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);78 87 } 79 return Action::success;80 88 } 81 89 -
src/Actions/WorldAction/InputAction.def
re4decc r6f5dfe 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 9 #include <boost/filesystem.hpp> 10 10 11 11 // i.e. there is an integer with variable name Z that can be found in 12 12 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 13 13 // "undefine" if no parameters are required 14 #define paramtypes ( std::string)14 #define paramtypes (boost::filesystem::path) 15 15 #define paramtokens (WorldInputAction::NAME) 16 16 #define paramreferences (filename) -
src/UIElements/CommandLineUI/CommandLineDialog.cpp
re4decc r6f5dfe 125 125 void CommandLineDialog::queryElements(const char* title, string _description){ 126 126 registerQuery(new ElementsCommandLineQuery(title, _description)); 127 } 128 129 void CommandLineDialog::queryFile(const char* title, string _description){ 130 registerQuery(new FileCommandLineQuery(title, _description)); 127 131 } 128 132 … … 457 461 } 458 462 } 463 464 CommandLineDialog::FileCommandLineQuery::FileCommandLineQuery(string title, string _description) : 465 Dialog::FileQuery(title, _description) 466 {} 467 468 CommandLineDialog::FileCommandLineQuery::~FileCommandLineQuery() {} 469 470 bool CommandLineDialog::FileCommandLineQuery::handle() { 471 if (CommandLineParser::getInstance().vm.count(getTitle())) { 472 tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>(); 473 return true; 474 } else { 475 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl); 476 return false; 477 } 478 } 479 -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
re4decc r6f5dfe 44 44 virtual void queryElement(const char*, std::string = ""); 45 45 virtual void queryElements(const char*, std::string = ""); 46 virtual void queryFile(const char*, std::string = ""); 46 47 47 48 protected: … … 165 166 virtual bool handle(); 166 167 }; 168 169 class FileCommandLineQuery : public Dialog::FileQuery { 170 public: 171 FileCommandLineQuery(std::string title, std::string _description = ""); 172 virtual ~FileCommandLineQuery(); 173 virtual bool handle(); 174 }; 167 175 }; 168 176 -
src/UIElements/Dialog.cpp
re4decc r6f5dfe 180 180 } 181 181 182 template <> void Dialog::query< boost::filesystem::path >(const char *token, std::string description) 183 { 184 queryFile(token, description); 185 } 186 182 187 /****************** Query types Infrastructure **************************/ 183 188 … … 407 412 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 408 413 } 414 415 // File Queries 416 Dialog::FileQuery::FileQuery(std::string title, std::string _description) : 417 Query(title, _description) 418 {} 419 420 Dialog::FileQuery::~FileQuery(){} 421 422 void Dialog::FileQuery::setResult(){ 423 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 424 } -
src/UIElements/Dialog.hpp
re4decc r6f5dfe 12 12 #include<list> 13 13 #include<vector> 14 15 #include <boost/filesystem.hpp> 14 16 15 17 #include "Box.hpp" … … 57 59 virtual void queryElement(const char*, std::string = "")=0; 58 60 virtual void queryElements(const char*, std::string = "")=0; 61 virtual void queryFile(const char*, std::string = "")=0; 59 62 60 63 virtual bool display(); … … 271 274 }; 272 275 276 class FileQuery : public Query { 277 public: 278 FileQuery(std::string title, std::string _description = ""); 279 virtual ~FileQuery(); 280 virtual bool handle()=0; 281 virtual void setResult(); 282 protected: 283 boost::filesystem::path tmp; 284 }; 285 273 286 void registerQuery(Query* query); 274 287 -
src/UIElements/QT4/QTDialog.cpp
re4decc r6f5dfe 179 179 // TODO 180 180 ASSERT(false, "Not implemented yet"); 181 } 182 183 void QTDialog::queryFile(const char* title, std::string){ 184 registerQuery(new FileQTQuery(title,inputLayout,this)); 181 185 } 182 186 … … 622 626 } 623 627 628 QTDialog::FileQTQuery::FileQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) : 629 Dialog::FileQuery(_title), 630 parent(_parent) 631 { 632 633 filenameLineEdit = new QLineEdit(_dialog); 634 filenameLineEdit->setText(QString()); 635 filenameLineEdit->setReadOnly(true); 636 637 filedialogButton = new QPushButton("&Choose", _dialog); 638 639 pipe = new FileQTQueryPipe(tmp,_dialog,filenameLineEdit,filedialogButton); 640 641 thisLayout = new QHBoxLayout(); 642 parent->addLayout(thisLayout); 643 thisLayout->addWidget(filenameLineEdit); 644 thisLayout->addWidget(filedialogButton); 645 646 QObject::connect(filedialogButton,SIGNAL(clicked()),pipe,SLOT(showFileDialog())); 647 } 648 649 QTDialog::FileQTQuery::~FileQTQuery() 650 { 651 delete pipe; 652 } 653 654 bool QTDialog::FileQTQuery::handle(){ 655 return true; 656 } 657 624 658 /*************************** Plumbing *******************************/ 625 659 … … 862 896 } 863 897 864 898 FileQTQueryPipe::FileQTQueryPipe(const boost::filesystem::path &_content, QTDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton) : 899 content(_content), 900 dialog(_dialog), 901 filenameLineEdit(_filenameLineEdit), 902 filedialogButton(_filedialogButton) 903 {} 904 905 FileQTQueryPipe::~FileQTQueryPipe() 906 {} 907 908 void FileQTQueryPipe::update() { 909 QStringList ListOfFilenames = theFileDialog->selectedFiles(); 910 std::cout << "Selected File is " << ListOfFilenames.at(0).toStdString() << std::endl; 911 content = ListOfFilenames.at(0).toStdString(); 912 dialog->update(); 913 } 914 915 void FileQTQueryPipe::showFileDialog() { 916 filedialogButton->setFlat(true); 917 if (theFileDialog == NULL) { 918 theFileDialog = new QFileDialog(NULL, tr("Open input file"), QString(), tr("ParallelCarParrinello (*.conf);;MassivelyParallelQuantumChemistry (*.mpqc);;ParticleDataBase (*.pdb);;XYZ (*.xyz)")); 919 theFileDialog->setAcceptMode(QFileDialog::AcceptOpen); 920 theFileDialog->setFileMode(QFileDialog::ExistingFile); 921 theFileDialog->setViewMode(QFileDialog::List); 922 } 923 theFileDialog->show(); 924 925 filenameLineEdit->setText(QString()); 926 filedialogButton->setFlat(false); 927 } 928 929 930 -
src/UIElements/QT4/QTDialog.hpp
re4decc r6f5dfe 11 11 #include "UIElements/Dialog.hpp" 12 12 #include <QtGui/QDialog> 13 #include <QtGui/QFileDialog> 14 15 #include <boost/filesystem.hpp> 13 16 14 17 class QBoxLayout; … … 37 40 class VectorQTQueryPipe; 38 41 class VectorsQTQueryPipe; 42 class FileQTQueryPipe; 39 43 40 44 class QTDialog : public QDialog, public Dialog … … 62 66 virtual void queryElement(const char*,std::string = ""); 63 67 virtual void queryElements(const char*,std::string = ""); 68 virtual void queryFile(const char*,std::string = ""); 64 69 65 70 virtual bool display(); … … 271 276 272 277 ElementsQTQueryPipe *pipe; 278 }; 279 280 class FileQTQuery : public Dialog::FileQuery { 281 public: 282 FileQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog); 283 virtual ~FileQTQuery(); 284 virtual bool handle(); 285 private: 286 QBoxLayout *parent; 287 QBoxLayout *thisLayout; 288 QLineEdit *filenameLineEdit; 289 QPushButton *filedialogButton; 290 291 FileQTQueryPipe *pipe; 273 292 }; 274 293 … … 477 496 QComboBox *theBox; 478 497 }; 498 499 class FileQTQueryPipe : public QWidget { 500 Q_OBJECT 501 public: 502 FileQTQueryPipe(const boost::filesystem::path &_content, QTDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton); 503 virtual ~FileQTQueryPipe(); 504 505 public slots: 506 void update(); 507 void showFileDialog(); 508 509 private: 510 boost::filesystem::path content; 511 QTDialog *dialog; 512 QLineEdit *filenameLineEdit; 513 QPushButton *filedialogButton; 514 QFileDialog *theFileDialog; 515 }; 516 479 517 #endif /* QTDIALOG_HPP_ */ -
src/UIElements/TextUI/TextDialog.cpp
re4decc r6f5dfe 42 42 43 43 #include <boost/lexical_cast.hpp> 44 #include <boost/filesystem.hpp> 44 45 45 46 using namespace std; … … 123 124 void TextDialog::queryElements(const char* title, std::string description){ 124 125 registerQuery(new ElementsTextQuery(title,description)); 126 } 127 128 void TextDialog::queryFile(const char* title, std::string description){ 129 registerQuery(new FileTextQuery(title,description)); 125 130 } 126 131 … … 684 689 return (Z!=-1); 685 690 } 691 692 TextDialog::FileTextQuery::FileTextQuery(string title, std::string _description) : 693 Dialog::FileQuery(title,_description) 694 {} 695 696 TextDialog::FileTextQuery::~FileTextQuery() {} 697 698 bool TextDialog::FileTextQuery::handle() { 699 Log() << Verbose(0) << getTitle(); 700 std::string tempstring; 701 getline(cin,tempstring); 702 tmp = tempstring; 703 return true; 704 } 705 -
src/UIElements/TextUI/TextDialog.hpp
re4decc r6f5dfe 41 41 virtual void queryElement(const char*, std::string = ""); 42 42 virtual void queryElements(const char*, std::string = ""); 43 virtual void queryFile(const char*, std::string = ""); 43 44 44 45 protected: … … 162 163 virtual bool handle(); 163 164 }; 165 166 class FileTextQuery : public Dialog::FileQuery { 167 public: 168 FileTextQuery(std::string title, std::string _description = NULL); 169 virtual ~FileTextQuery(); 170 virtual bool handle(); 171 }; 164 172 }; 165 173 -
src/unittests/DummyUI.hpp
re4decc r6f5dfe 35 35 virtual void queryElement(const char*, std::string = ""){} 36 36 virtual void queryElements(const char*, std::string = ""){} 37 virtual void queryFile(const char*, std::string = ""){} 37 38 }; 38 39
Note:
See TracChangeset
for help on using the changeset viewer.