Ignore:
Timestamp:
Jul 25, 2010, 3:07:42 PM (15 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:
e2f3114
Parents:
0ff6b5
Message:

Add all possible versions of queries where the user is asked for multiples of the same.

  • Note that these are correctly implemented in TextUI and CommandLineUI, but not yet in QT4.
Location:
src/UIElements/CommandLineUI
Files:
2 edited

Legend:

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

    r0ff6b5 r7cd6e7  
    5454}
    5555
     56void CommandLineDialog::queryInts(const char* title, string _description){
     57  registerQuery(new IntsCommandLineQuery(title, _description));
     58}
     59
    5660void CommandLineDialog::queryBoolean(const char* title, string _description){
    5761  registerQuery(new BooleanCommandLineQuery(title, _description));
     
    6266}
    6367
     68void CommandLineDialog::queryDoubles(const char* title, string _description){
     69  registerQuery(new DoublesCommandLineQuery(title, _description));
     70}
     71
    6472void CommandLineDialog::queryString(const char* title, string _description){
    6573  registerQuery(new StringCommandLineQuery(title, _description));
     
    7482}
    7583
     84void CommandLineDialog::queryAtoms(const char* title, string _description) {
     85  registerQuery(new AtomsCommandLineQuery(title, _description));
     86}
     87
    7688void CommandLineDialog::queryMolecule(const char* title, string _description) {
    7789  registerQuery(new MoleculeCommandLineQuery(title, _description));
    7890}
    7991
     92void CommandLineDialog::queryMolecules(const char* title, string _description) {
     93  registerQuery(new MoleculesCommandLineQuery(title, _description));
     94}
     95
    8096void CommandLineDialog::queryVector(const char* title, bool check, string _description) {
    8197  registerQuery(new VectorCommandLineQuery(title,check, _description));
    8298}
    8399
     100void CommandLineDialog::queryVectors(const char* title, bool check, string _description) {
     101  registerQuery(new VectorsCommandLineQuery(title,check, _description));
     102}
     103
    84104void CommandLineDialog::queryBox(const char* title, string _description) {
    85105  registerQuery(new BoxCommandLineQuery(title,_description));
     
    88108void CommandLineDialog::queryElement(const char* title, string _description){
    89109  registerQuery(new ElementCommandLineQuery(title, _description));
     110}
     111
     112void CommandLineDialog::queryElements(const char* title, string _description){
     113  registerQuery(new ElementsCommandLineQuery(title, _description));
    90114}
    91115
     
    119143}
    120144
     145CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
     146    Dialog::IntsQuery(title, _description)
     147{}
     148
     149CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
     150
     151bool 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
    121161CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
    122162    Dialog::BooleanQuery(title, _description)
     
    162202    return true;
    163203  } 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);
    165205    return false;
    166206  }
     
    183223}
    184224
     225CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
     226    Dialog::DoublesQuery(title, _description)
     227{}
     228
     229CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
     230
     231bool 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
    185241CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
    186242    Dialog::AtomQuery(title, _description)
     
    201257}
    202258
     259CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
     260    Dialog::AtomsQuery(title, _description)
     261{}
     262
     263CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
     264
     265bool 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
    203281CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
    204282    Dialog::MoleculeQuery(title, _description)
     
    211289  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    212290    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));
    218292    return true;
    219293  } else {
    220294    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
     295    return false;
     296  }
     297}
     298
     299CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
     300    Dialog::MoleculesQuery(title, _description)
     301{}
     302
     303CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
     304
     305bool 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);
    221317    return false;
    222318  }
     
    234330  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    235331    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    }
    239339    return true;
    240340  } else {
     
    244344}
    245345
     346CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
     347    Dialog::VectorsQuery(title,_check, _description)
     348{}
     349
     350CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
     351{}
     352
     353bool 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}
    246372
    247373CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
     
    279405  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    280406  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
     418CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
     419    Dialog::ElementsQuery(title, _description)
     420{}
     421
     422CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
     423{}
     424
     425bool 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();
    282428  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    283429    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
    284430    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);
    288434    }
    289435    return true;
    290436  } 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  
    2929  virtual void queryEmpty(const char *, std::string = "");
    3030  virtual void queryInt(const char *, std::string = "");
     31  virtual void queryInts(const char *, std::string = "");
    3132  virtual void queryBoolean(const char *, std::string = "");
    3233  virtual void queryString(const char*, std::string = "");
    3334  virtual void queryStrings(const char*, std::string = "");
    3435  virtual void queryDouble(const char*, std::string = "");
     36  virtual void queryDoubles(const char*, std::string = "");
    3537  virtual void queryAtom(const char*, std::string = "");
     38  virtual void queryAtoms(const char*, std::string = "");
    3639  virtual void queryMolecule(const char*, std::string = "");
     40  virtual void queryMolecules(const char*, std::string = "");
    3741  virtual void queryVector(const char*, bool, std::string = "");
     42  virtual void queryVectors(const char*, bool, std::string = "");
    3843  virtual void queryBox(const char*, std::string = "");
    3944  virtual void queryElement(const char*, std::string = "");
     45  virtual void queryElements(const char*, std::string = "");
    4046
    4147protected:
     
    5561  };
    5662
     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
    5770  class BooleanCommandLineQuery : public Dialog::BooleanQuery {
    5871  public:
     
    6679    DoubleCommandLineQuery(std::string title, std::string _description = "");
    6780    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();
    6888    virtual bool handle();
    6989  };
     
    90110  };
    91111
     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
    92119  class MoleculeCommandLineQuery : public Dialog::MoleculeQuery {
    93120  public:
     
    97124  };
    98125
     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
    99133  class VectorCommandLineQuery : public Dialog::VectorQuery {
    100134  public:
    101135    VectorCommandLineQuery(std::string title,bool _check, std::string _description = "");
    102136    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();
    103144    virtual bool handle();
    104145  };
     
    117158    virtual bool handle();
    118159  };
     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  };
    119167};
    120168
Note: See TracChangeset for help on using the changeset viewer.