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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.