Changeset 6f5dfe for src/UIElements


Ignore:
Timestamp:
Oct 22, 2010, 4:13:36 PM (14 years ago)
Author:
Frederik Heber <heber@…>
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
Message:

Added boost::filesystem usage for input files.

  • parameters for Action input now have type boost::filesystem.
  • rewritten Actions to use boost::filesystems
  • in the progress of writing FileQtQuery to present a file dialog.
Location:
src/UIElements
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    re4decc r6f5dfe  
    125125void CommandLineDialog::queryElements(const char* title, string _description){
    126126  registerQuery(new ElementsCommandLineQuery(title, _description));
     127}
     128
     129void CommandLineDialog::queryFile(const char* title, string _description){
     130  registerQuery(new FileCommandLineQuery(title, _description));
    127131}
    128132
     
    457461  }
    458462}
     463
     464CommandLineDialog::FileCommandLineQuery::FileCommandLineQuery(string title, string _description) :
     465    Dialog::FileQuery(title, _description)
     466{}
     467
     468CommandLineDialog::FileCommandLineQuery::~FileCommandLineQuery() {}
     469
     470bool 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  
    4444  virtual void queryElement(const char*, std::string = "");
    4545  virtual void queryElements(const char*, std::string = "");
     46  virtual void queryFile(const char*, std::string = "");
    4647
    4748protected:
     
    165166    virtual bool handle();
    166167  };
     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  };
    167175};
    168176
  • src/UIElements/Dialog.cpp

    re4decc r6f5dfe  
    180180}
    181181
     182template <> void Dialog::query< boost::filesystem::path >(const char *token, std::string description)
     183{
     184  queryFile(token, description);
     185}
     186
    182187/****************** Query types Infrastructure **************************/
    183188
     
    407412  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    408413}
     414
     415// File Queries
     416Dialog::FileQuery::FileQuery(std::string title, std::string _description) :
     417  Query(title, _description)
     418  {}
     419
     420Dialog::FileQuery::~FileQuery(){}
     421
     422void Dialog::FileQuery::setResult(){
     423  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     424}
  • src/UIElements/Dialog.hpp

    re4decc r6f5dfe  
    1212#include<list>
    1313#include<vector>
     14
     15#include <boost/filesystem.hpp>
    1416
    1517#include "Box.hpp"
     
    5759  virtual void queryElement(const char*, std::string = "")=0;
    5860  virtual void queryElements(const char*, std::string = "")=0;
     61  virtual void queryFile(const char*, std::string = "")=0;
    5962
    6063  virtual bool display();
     
    271274  };
    272275
     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
    273286void registerQuery(Query* query);
    274287
  • src/UIElements/QT4/QTDialog.cpp

    re4decc r6f5dfe  
    179179  // TODO
    180180  ASSERT(false, "Not implemented yet");
     181}
     182
     183void QTDialog::queryFile(const char* title, std::string){
     184  registerQuery(new FileQTQuery(title,inputLayout,this));
    181185}
    182186
     
    622626}
    623627
     628QTDialog::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
     649QTDialog::FileQTQuery::~FileQTQuery()
     650{
     651  delete pipe;
     652}
     653
     654bool QTDialog::FileQTQuery::handle(){
     655  return true;
     656}
     657
    624658/*************************** Plumbing *******************************/
    625659
     
    862896}
    863897
    864 
     898FileQTQueryPipe::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
     905FileQTQueryPipe::~FileQTQueryPipe()
     906{}
     907
     908void 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
     915void 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  
    1111#include "UIElements/Dialog.hpp"
    1212#include <QtGui/QDialog>
     13#include <QtGui/QFileDialog>
     14
     15#include <boost/filesystem.hpp>
    1316
    1417class QBoxLayout;
     
    3740class VectorQTQueryPipe;
    3841class VectorsQTQueryPipe;
     42class FileQTQueryPipe;
    3943
    4044class QTDialog : public QDialog, public Dialog
     
    6266  virtual void queryElement(const char*,std::string = "");
    6367  virtual void queryElements(const char*,std::string = "");
     68  virtual void queryFile(const char*,std::string = "");
    6469
    6570  virtual bool display();
     
    271276
    272277      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;
    273292    };
    274293
     
    477496  QComboBox *theBox;
    478497};
     498
     499class FileQTQueryPipe : public QWidget {
     500  Q_OBJECT
     501public:
     502  FileQTQueryPipe(const boost::filesystem::path &_content, QTDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton);
     503  virtual ~FileQTQueryPipe();
     504
     505public slots:
     506  void update();
     507  void showFileDialog();
     508
     509private:
     510  boost::filesystem::path content;
     511  QTDialog *dialog;
     512  QLineEdit *filenameLineEdit;
     513  QPushButton *filedialogButton;
     514  QFileDialog *theFileDialog;
     515};
     516
    479517#endif /* QTDIALOG_HPP_ */
  • src/UIElements/TextUI/TextDialog.cpp

    re4decc r6f5dfe  
    4242
    4343#include <boost/lexical_cast.hpp>
     44#include <boost/filesystem.hpp>
    4445
    4546using namespace std;
     
    123124void TextDialog::queryElements(const char* title, std::string description){
    124125  registerQuery(new ElementsTextQuery(title,description));
     126}
     127
     128void TextDialog::queryFile(const char* title, std::string description){
     129  registerQuery(new FileTextQuery(title,description));
    125130}
    126131
     
    684689  return (Z!=-1);
    685690}
     691
     692TextDialog::FileTextQuery::FileTextQuery(string title, std::string _description) :
     693    Dialog::FileQuery(title,_description)
     694{}
     695
     696TextDialog::FileTextQuery::~FileTextQuery() {}
     697
     698bool 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  
    4141  virtual void queryElement(const char*, std::string = "");
    4242  virtual void queryElements(const char*, std::string = "");
     43  virtual void queryFile(const char*, std::string = "");
    4344
    4445protected:
     
    162163    virtual bool handle();
    163164  };
     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  };
    164172};
    165173
Note: See TracChangeset for help on using the changeset viewer.