Changeset 6af6470 for src/UIElements


Ignore:
Timestamp:
Jun 19, 2017, 8:24:16 AM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChemicalSpaceEvaluator, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
Children:
d8c6c7
Parents:
d6d2129
git-author:
Frederik Heber <heber@…> (03/30/17 14:37:42)
git-committer:
Frederik Heber <frederik.heber@…> (06/19/17 08:24:16)
Message:

Removed Vector and Vectors from boost preprocessor magic.

  • this is preparatory for allowing to change the class Dialog::Query<Vector> by specialization and have the Vector stored as string and not directly as Vector.
Location:
src/UIElements
Files:
9 edited

Legend:

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

    rd6d2129 r6af6470  
    4848  #include <boost/preprocessor/facilities/empty.hpp>
    4949
     50  virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "");
     51  virtual void queryVectors(Parameter< std::vector<Vector> > &, const std::string ="", const std::string = "");
     52
    5053  // iterate over all parameter query types for query declarations
    5154  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     
    5760  #undef SUFFIX
    5861  #endif
     62
     63  class VectorCommandLineQuery;
     64  class VectorsCommandLineQuery;
    5965
    6066  // iterate over all parameter query types for forward declarations
  • src/UIElements/CommandLineUI/Query/CommandLineQuery.hpp

    rd6d2129 r6af6470  
    2424};
    2525
     26class CommandLineDialog::VectorCommandLineQuery : public Dialog::TQuery<Vector> {
     27public:
     28  VectorCommandLineQuery(Parameter<Vector> &_param, const std::string &_title, const std::string &_description = "");
     29  virtual ~VectorCommandLineQuery();
     30  virtual bool handle();
     31};
     32
     33class CommandLineDialog::VectorsCommandLineQuery : public Dialog::TQuery< std::vector<Vector> > {
     34public:
     35  VectorsCommandLineQuery(Parameter< std::vector<Vector> > &_param, const std::string &_title, const std::string &_description = "");
     36  virtual ~VectorsCommandLineQuery();
     37  virtual bool handle();
     38};
     39
    2640  /** With the following boost::preprocessor code we generate forward declarations
    2741   * of query class for all desired query types in the Qt specialization class of
  • src/UIElements/Dialog.cpp

    rd6d2129 r6af6470  
    134134  queryEmpty(param, title, description);
    135135}*/
     136template <>
     137void Dialog::query<Vector>(Parameter<Vector> &param, const std::string title, const std::string description)
     138{
     139  queryVector(param, title, description);
     140}
     141template <>
     142void Dialog::query< std::vector<Vector> >(Parameter< std::vector<Vector> > &param, const std::string title, const std::string description)
     143{
     144  queryVectors(param, title, description);
     145}
    136146
    137147/** With the following boost::preprocessor code we generate template
  • src/UIElements/Dialog.hpp

    rd6d2129 r6af6470  
    158158  virtual void queryEmpty(const std::string ="", const std::string = "")=0;
    159159
     160  virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "")=0;
     161  virtual void queryVectors(Parameter< std::vector<Vector> > &, const std::string ="", const std::string = "")=0;
     162
    160163  /** With the following boost::preprocessor code we generate virtual function
    161164   * definitions for all desired query types in the abstract class Dialog.
     
    250253  };
    251254
    252 
    253255  template<class T>
    254256  class TQuery : public Query {
     
    282284};
    283285
     286// we have specialization of Vector to allow internal storing as string
     287template <>
     288void Dialog::query<Vector>(Parameter<Vector> &, const std::string, const std::string);
     289template <>
     290void Dialog::query< std::vector<Vector> >(Parameter< std::vector<Vector> > &, const std::string, const std::string);
     291
     292/** Template specialization for Query<Vector> to allow internal storing of a
     293 * string instead of a Vector.
     294 *
     295 * Because we need to evaluate the string as a possible GeometryRegistry key
     296 * and we may do this only when the Action (whose options we are querying)
     297 * is executed, not before.
     298 */
     299template <>
     300class Dialog::TQuery<Vector> : public Query {
     301public:
     302  TQuery(Parameter<Vector> &_param, const std::string title, const std::string _description = "") :
     303    Query(title, _description), param(_param) {}
     304  virtual ~TQuery(){}
     305  virtual bool handle()=0;
     306  virtual bool isValid(){ return param.isValid(temp);  }
     307  virtual void setResult(){ param.set(temp);  }
     308protected:
     309  Vector temp;
     310  Parameter<Vector> &param;
     311};
     312
     313template <>
     314class Dialog::TQuery< std::vector<Vector> > : public Query {
     315public:
     316  TQuery(Parameter< std::vector<Vector> > &_param, const std::string title, const std::string _description = "") :
     317    Query(title, _description), param(_param) {}
     318  virtual ~TQuery(){}
     319  virtual bool handle()=0;
     320  virtual bool isValid(){ return param.isValid(temp);  }
     321  virtual void setResult(){ param.set(temp);  }
     322protected:
     323  std::vector<Vector> temp;
     324  Parameter< std::vector<Vector> > &param;
     325};
     326
     327
    284328#endif /* DIALOG_HPP_ */
  • src/UIElements/GlobalListOfParameterQueries.hpp

    rd6d2129 r6af6470  
    2828        (Molecule) \
    2929        (Molecules) \
    30         (Vector) \
    31         (Vectors) \
    3230        (RealSpaceMatrix) \
    3331        (Element) \
     
    5250        (const molecule *) \
    5351        (std::vector<const molecule *> ) \
    54         (Vector) \
    55         (std::vector<Vector> ) \
    5652        (RealSpaceMatrix) \
    5753        (const element *) \
  • src/UIElements/Qt4/QtDialog.hpp

    rd6d2129 r6af6470  
    3636  virtual void queryEmpty(const std::string ="", const std::string = "");
    3737
     38  virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "");
     39  virtual void queryVectors(Parameter< std::vector<Vector> > &, const std::string ="", const std::string = "");
     40
    3841  /** With the following boost::preprocessor code we generate virtual function
    3942   * definitions for all desired query types in the abstract class Dialog.
     
    6467
    6568  class EmptyQtQuery;
     69
     70  class VectorQtQuery;
     71  class VectorsQtQuery;
    6672
    6773  /** With the following boost::preprocessor code we generate forward declarations
  • src/UIElements/Qt4/Query/QtQueryList.hpp

    rd6d2129 r6af6470  
    100100  std::vector<T> &tempRef;
    101101  Parameter<T> *subParam;
     102};
     103
     104template<>
     105class QtQueryList<Vector> : public QtQueryListUntyped {
     106public:
     107  QtQueryList(Parameter<std::vector<Vector> > &parentParam, QBoxLayout *parent, Dialog *_dialog, std::vector<Vector> &_temp) : QtQueryListUntyped(parent, _dialog), tempRef(_temp)
     108  {
     109    // do we have an STLVectorValidator?
     110    Validator<std::vector<Vector> > *val = &parentParam.getValidator();
     111    STLVectorValidator<std::vector<Vector> > *vector_val = NULL;
     112
     113    // might be hidden inside an And_Validator
     114    And_Validator<std::vector<Vector> > * and_val = dynamic_cast<And_Validator<std::vector<Vector> > *>(val);
     115    if (and_val){
     116      if (dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getA()))
     117        vector_val = dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getA());
     118      else if (dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getB()))
     119        vector_val = dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getB());
     120    }else{
     121      vector_val = dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(val);
     122    }
     123
     124    if (vector_val){
     125      // if so, try to use its ElementwiseValidator
     126      subParam = new Parameter<Vector>("sub-param", *(vector_val->getElementwiseValidator()));
     127    }else{
     128      subParam = new Parameter<Vector>("sub-param");
     129    }
     130  }
     131  virtual ~QtQueryList()
     132  {
     133    delete(subParam);
     134  }
     135
     136  void addElement() {
     137    // add item to both
     138    addElementToListWidget(subParam->getAsString());
     139    tempRef.push_back(subParam->get());
     140    onUpdate();
     141  }
     142  void removeElements()
     143  {
     144    std::vector<int> rows = getSelectedRows();
     145    removeSelectedRows(rows);
     146    for (int i = rows.size() - 1; i >= 0; i --){
     147      ASSERT((size_t)(rows[i]) < tempRef.size(), "QtQueryList<Vector>::removeElements() trying to remove invalid element.");
     148      tempRef.erase(tempRef.begin() + rows[i]);
     149    }
     150    onUpdate();
     151  }
     152protected:
     153  std::vector<Vector> &tempRef;
     154  Parameter<Vector> *subParam;
    102155};
    103156
  • src/UIElements/TextUI/Query/TextQuery.hpp

    rd6d2129 r6af6470  
    2424};
    2525
     26class TextDialog::VectorTextQuery : public Dialog::TQuery<Vector> {
     27public:
     28  VectorTextQuery(Parameter<Vector> &_param, const std::string &_title, const std::string &_description = "");
     29  virtual ~VectorTextQuery();
     30  virtual bool handle();
     31};
     32
     33class TextDialog::VectorsTextQuery : public Dialog::TQuery< std::vector<Vector> > {
     34public:
     35  VectorsTextQuery(Parameter< std::vector<Vector> > &_param, const std::string &_title, const std::string &_description = "");
     36  virtual ~VectorsTextQuery();
     37  virtual bool handle();
     38};
    2639
    2740  /** With the following boost::preprocessor code we generate forward declarations
  • src/UIElements/TextUI/TextDialog.hpp

    rd6d2129 r6af6470  
    3434  virtual void queryEmpty(const std::string ="", const std::string = "");
    3535
     36  virtual void queryVector(Parameter<Vector> &, const std::string ="", const std::string = "");
     37  virtual void queryVectors(Parameter< std::vector<Vector> > &, const std::string ="", const std::string = "");
     38
    3639  /** With the following boost::preprocessor code we generate virtual function
    3740   * definitions for all desired query types in the abstract class Dialog.
     
    5962  class EmptyTextQuery;
    6063
     64  class VectorTextQuery;
     65  class VectorsTextQuery;
     66
    6167  /** With the following boost::preprocessor code we generate forward declarations
    6268   * of query class for all desired query types in the Qt specialization class of
Note: See TracChangeset for help on using the changeset viewer.