Changeset be848d for src/UIElements


Ignore:
Timestamp:
Jun 21, 2017, 10:02:14 PM (9 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, Candidate_v1.7.0, Candidate_v1.7.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, 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, stable
Children:
78ea3c
Parents:
9a9f847 (diff), 6116df (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'GeometryObjects' into Candidate_v1.6.1

Location:
src/UIElements
Files:
2 added
22 edited

Legend:

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

    r9a9f847 rbe848d  
    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/CommandLineParser.cpp

    r9a9f847 rbe848d  
    7272  shape("shape options"),
    7373  fragmentation("Fragmentation options"),
     74  geometry("Geometry options"),
    7475  graph("Graph options"),
    7576  molecule("Molecule options"),
     
    9091  CmdParserLookup["shape"] = &shape;
    9192  CmdParserLookup["fragmentation"] = &fragmentation;
     93  CmdParserLookup["geometry"] = &geometry;
    9294  CmdParserLookup["graph"] = &graph;
    9395  CmdParserLookup["options"] = &options;
  • src/UIElements/CommandLineUI/CommandLineParser.hpp

    r9a9f847 rbe848d  
    6262  po::options_description shape;
    6363  po::options_description fragmentation;
     64  po::options_description geometry;
    6465  po::options_description graph;
    6566  po::options_description molecule;
  • src/UIElements/CommandLineUI/CommandLineParser_validate.cpp

    r9a9f847 rbe848d  
    6666        std::string("value"),
    6767        std::string("VectorValue")
     68    );
     69#endif
     70  }
     71  VV.vectorstring = values.at(0);
     72  v = boost::any(VectorValue(VV));
     73}
     74
     75void validate(boost::any& v, const std::vector<std::string>& values, RealSpaceMatrixValue *, int)
     76{
     77  RealSpaceMatrixValue RSMV;
     78  std::vector<std::string> components;
     79
     80  // split comma-separated values
     81  if (values.size() != 1) {
     82    std::cerr <<  "Not one vector but " << values.size() << " given " << std::endl;
     83#if BOOST_VERSION < 104200
     84    throw boost::program_options::validation_error("Unequal to one vector given");
     85#else
     86    throw boost::program_options::validation_error(
     87        boost::program_options::validation_error::invalid_option_value,
     88        std::string("value"),
     89        std::string("BoxValue")
    6890    );
    6991#endif
     
    83105  components.push_back(std::string(Biter,argument.end()));
    84106
    85   if (components.size() != 3) {
    86     std::cerr <<  "Specified vector does not have three components but " << components.size() << std::endl;
    87 #if BOOST_VERSION < 104200
    88     throw boost::program_options::validation_error("Specified vector does not have three components");
    89 #else
    90     throw boost::program_options::validation_error(
    91         boost::program_options::validation_error::invalid_option_value,
    92         std::string("value"),
    93         std::string("VectorValue")
    94     );
    95 #endif
    96   }
    97   for (size_t i=0;i<NDIM;++i)
    98     VV.vector[i] = boost::lexical_cast<double>(components.at(i));
    99   v = boost::any(VectorValue(VV));
    100 }
    101 
    102 void validate(boost::any& v, const std::vector<std::string>& values, RealSpaceMatrixValue *, int)
    103 {
    104   RealSpaceMatrixValue RSMV;
    105   std::vector<std::string> components;
    106 
    107   // split comma-separated values
    108   if (values.size() != 1) {
    109     std::cerr <<  "Not one vector but " << values.size() << " given " << std::endl;
    110 #if BOOST_VERSION < 104200
    111     throw boost::program_options::validation_error("Unequal to one vector given");
    112 #else
    113     throw boost::program_options::validation_error(
    114         boost::program_options::validation_error::invalid_option_value,
    115         std::string("value"),
    116         std::string("BoxValue")
    117     );
    118 #endif
    119   }
    120   std::string argument(values.at(0));
    121   std::string::iterator Aiter = argument.begin();
    122   std::string::iterator Biter = argument.begin();
    123   for (; Aiter != argument.end(); ++Aiter) {
    124     if (*Aiter == ',') {
    125       components.push_back(std::string(Biter,Aiter));
    126       do {
    127         Aiter++;
    128       } while (*Aiter == ' ' || *Aiter == '\t');
    129       Biter = Aiter;
    130     }
    131   }
    132   components.push_back(std::string(Biter,argument.end()));
    133 
    134107  if (components.size() != 6) {
    135108    std::cerr <<  "Specified vector does not have three components but " << components.size() << std::endl;
  • src/UIElements/CommandLineUI/Query/CommandLineQuery.hpp

    r9a9f847 rbe848d  
    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/CommandLineUI/Query/VectorCommandLineQuery.cpp

    r9a9f847 rbe848d  
    5353
    5454bool CommandLineDialog::VectorCommandLineQuery::handle() {
    55   VectorValue _temp;
     55  VectorValue temporary;
    5656  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    57     try {
    58       _temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
    59     } catch(boost::bad_any_cast &e) {
    60       for (size_t i=0;i<NDIM;++i)
    61         _temp.vector[i] = 0.;
    62       return false;
    63     }
    64     temp = _temp.toVector();
     57    temporary = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
     58    temp = temporary.vectorstring;
    6559    return true;
    6660  }
  • src/UIElements/CommandLineUI/Query/VectorsCommandLineQuery.cpp

    r9a9f847 rbe848d  
    4646
    4747CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(Parameter<std::vector<Vector> > &_param, const std::string &_title, const std::string &_description) :
    48     Dialog::TQuery<std::vector<Vector> >(_param, _title, _description)
     48    Dialog::TQuery< std::vector<Vector> >(_param, _title, _description)
    4949{}
    5050
     
    5353
    5454bool CommandLineDialog::VectorsCommandLineQuery::handle() {
    55   std::vector<VectorValue> temporary;
     55  std::vector<std::string> temporary;
     56  std::stringstream output;
    5657  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    57     try {
    58       temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >();
    59     } catch(boost::bad_any_cast &e) {
    60       temporary.clear();
    61       return false;
    62     }
    63     for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
    64       Vector temp_element = (*iter).toVector();
    65       temp.push_back(temp_element);
    66     }
     58    temp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<std::string> >();
    6759    return true;
    6860  }
  • src/UIElements/Dialog.cpp

    r9a9f847 rbe848d  
    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}
     146
     147static const std::string concatenateStrings(const std::vector<std::string> &_strings)
     148{
     149  std::stringstream output;
     150  for (std::vector<std::string>::const_iterator iter = _strings.begin();
     151      iter != _strings.end(); ++iter)
     152    output << *iter << " ";
     153  return output.str();
     154}
     155
     156bool Dialog::TQuery< std::vector<Vector> >::isValid()
     157{
     158  return param.isValidAsString(concatenateStrings(temp));
     159}
     160void Dialog::TQuery< std::vector<Vector> >::setResult()
     161{
     162  param.setAsString(concatenateStrings(temp));
     163}
    136164
    137165/** With the following boost::preprocessor code we generate template
  • src/UIElements/Dialog.hpp

    r9a9f847 rbe848d  
    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.isValidAsString(temp);  }
     307  virtual void setResult(){ param.setAsString(temp);  }
     308protected:
     309  std::string 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();
     321  virtual void setResult();
     322protected:
     323  std::vector<std::string> temp;
     324  Parameter< std::vector<Vector> > &param;
     325};
     326
     327
    284328#endif /* DIALOG_HPP_ */
  • src/UIElements/GlobalListOfParameterQueries.hpp

    r9a9f847 rbe848d  
    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/Makefile.am

    r9a9f847 rbe848d  
    190190  UIElements/Menu/Qt4/QtMenuPipe.cpp \
    191191  UIElements/Views/Qt4/QtFragmentList.cpp \
     192  UIElements/Views/Qt4/QtGeometryList.cpp \
    192193  UIElements/Views/Qt4/QtHomologyList.cpp \
    193194  UIElements/Views/Qt4/QtInfoBox.cpp \
     
    225226  UIElements/Views/Qt4/MoleculeList/QtObservedMoleculeObserver.hpp \
    226227  UIElements/Views/Qt4/QtFragmentList.hpp \
     228  UIElements/Views/Qt4/QtGeometryList.hpp \
    227229  UIElements/Views/Qt4/QtHomologyList.hpp \
    228230  UIElements/Views/Qt4/QtInfoBox.hpp \
     
    308310        libMolecuilderParser.la \
    309311        libMolecuilderParameters.la \
     312        libMolecuilderGeometry.la \
    310313        libMolecuilderShapes.la \
    311314        libMolecuilderLinkedCell.la \
  • src/UIElements/Menu/MenuDescription.cpp

    r9a9f847 rbe848d  
    6161  // put each menu into its place, "" means top level
    6262  MenuPositionMap->insert(std::make_pair("analysis",TopPosition("tools",1)));
    63   MenuPositionMap->insert(std::make_pair("atom",TopPosition("edit",1)));
    64   MenuPositionMap->insert(std::make_pair("bond",TopPosition("edit",2)));
     63  MenuPositionMap->insert(std::make_pair("atom",TopPosition("edit",2)));
     64  MenuPositionMap->insert(std::make_pair("bond",TopPosition("edit",3)));
    6565  MenuPositionMap->insert(std::make_pair("command",TopPosition("",3)));
    6666  MenuPositionMap->insert(std::make_pair("edit",TopPosition("",2)));
    6767  MenuPositionMap->insert(std::make_pair("fill",TopPosition("tools",5)));
    6868  MenuPositionMap->insert(std::make_pair("fragmentation",TopPosition("tools",3)));
     69  MenuPositionMap->insert(std::make_pair("geometry",TopPosition("edit",5)));
    6970  MenuPositionMap->insert(std::make_pair("graph",TopPosition("tools",4)));
    70   MenuPositionMap->insert(std::make_pair("molecule",TopPosition("edit",3)));
     71  MenuPositionMap->insert(std::make_pair("molecule",TopPosition("edit",4)));
    7172  MenuPositionMap->insert(std::make_pair("potential",TopPosition("tools",7)));
    72   MenuPositionMap->insert(std::make_pair("parser",TopPosition("edit",4)));
    73   MenuPositionMap->insert(std::make_pair("selection",TopPosition("edit",5)));
     73  MenuPositionMap->insert(std::make_pair("parser",TopPosition("edit",6)));
     74  MenuPositionMap->insert(std::make_pair("selection",TopPosition("edit",1)));
    7475  MenuPositionMap->insert(std::make_pair("tesselation",TopPosition("tools",2)));
    7576  MenuPositionMap->insert(std::make_pair("shape",TopPosition("tools",6)));
     
    8586  MenuDescriptionsMap->insert(std::make_pair("fill","Fill"));
    8687  MenuDescriptionsMap->insert(std::make_pair("fragmentation","Fragmentation"));
     88  MenuDescriptionsMap->insert(std::make_pair("geometry","Geometry"));
    8789  MenuDescriptionsMap->insert(std::make_pair("graph","Graph"));
    8890  MenuDescriptionsMap->insert(std::make_pair("molecule","Parse files into system"));
     
    103105  MenuNameMap->insert(std::make_pair("fill","Fill"));
    104106  MenuNameMap->insert(std::make_pair("fragmentation","Fragmentation"));
     107  MenuNameMap->insert(std::make_pair("geometry","Geometry"));
    105108  MenuNameMap->insert(std::make_pair("graph","Graph"));
    106109  MenuNameMap->insert(std::make_pair("molecule","Molecules"));
  • src/UIElements/Qt4/QtDialog.hpp

    r9a9f847 rbe848d  
    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/QtMainWindow.cpp

    r9a9f847 rbe848d  
    5959#include "Views/Qt4/QtHomologyList.hpp"
    6060#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
     61#include "Views/Qt4/QtGeometryList.hpp"
    6162#include "Views/Qt4/QtLogBox.hpp"
    6263#include "Views/Qt4/QtShapeController.hpp"
     
    112113  homologyList = new QtHomologyList(worldTab);
    113114  fragmentList = new QtFragmentList(worldTab);
     115  geometryList = new QtGeometryList(worldTab);
    114116  logBox = new QtLogBox(std::cout, worldTab);
    115117  errorlogBox = new QtLogBox(std::cerr, worldTab);
     
    147149  worldTab->addTab(fragmentList, "All Fragments");
    148150  worldTab->addTab(homologyList, "All Homologies");
     151  worldTab->addTab(geometryList, "All Geometries");
    149152  worldTab->addTab(logBox, "Log");
    150153  worldTab->addTab(errorlogBox, "Errors");
  • src/UIElements/Qt4/QtMainWindow.hpp

    r9a9f847 rbe848d  
    2727class QtElementList;
    2828class QtFragmentList;
     29class QtGeometryList;
    2930class QtHomologyList;
    3031class QtLogBox;
     
    6061  QtMoleculeList *moleculeList;
    6162  QtElementList *elementList;
     63  QtGeometryList *geometryList;
    6264  QtHomologyList *homologyList;
    6365  QtFragmentList *fragmentList;
  • src/UIElements/Qt4/Query/QtQuery.hpp

    r9a9f847 rbe848d  
    414414
    415415public slots:
     416  void pageChanged(int);
     417  void onUpdateName(int);
    416418  void onUpdateX(double);
    417419  void onUpdateY(double);
     
    424426  QBoxLayout *subLayout;
    425427  QBoxLayout *coordLayout;
    426   QLabel *coordLabel;
    427428  QDoubleSpinBox *coordInputX;
    428429  QDoubleSpinBox *coordInputY;
    429430  QDoubleSpinBox *coordInputZ;
    430431  Dialog *dialog;
    431 };
    432 
    433 class QtDialog::VectorsQtQuery : public QWidget, public QtQuery<std::vector<Vector> >, public QtQueryList<Vector> {
     432  QBoxLayout *nameLayout;
     433  QComboBox *nameComboBox;
     434};
     435
     436class QtDialog::VectorsQtQuery :
     437    public QWidget,
     438    public QtQuery<std::vector<Vector> >,
     439    public QtQueryList<Vector> {
    434440  Q_OBJECT
    435441public:
  • src/UIElements/Qt4/Query/QtQueryList.hpp

    r9a9f847 rbe848d  
    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<std::string> &_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->getAsString());
     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<std::string> &tempRef;
     154  Parameter<Vector> *subParam;
    102155};
    103156
  • src/UIElements/Qt4/Query/VectorQtQuery.cpp

    r9a9f847 rbe848d  
    3737#include <Qt/qcombobox.h>
    3838#include <Qt/qlabel.h>
     39#include <Qt/qstackedwidget.h>
    3940
    4041//#include "CodePatterns/MemDebug.hpp"
     
    4243#include "UIElements/Qt4/Query/QtQuery.hpp"
    4344
     45#include "CodePatterns/toString.hpp"
     46
     47#include "Geometry/GeometryRegistry.hpp"
     48#include "Parameters/Specifics/Value_vector.hpp"
    4449
    4550QtDialog::VectorQtQuery::VectorQtQuery(Parameter<Vector> &_param, const std::string &_title, const std::string &_description, QBoxLayout *_parent,Dialog *_dialog) :
     
    4853    dialog(_dialog)
    4954{
    50   temp = Vector(0, 0, 0);
    51   if (param.isSet())
    52     temp = param.get();
     55  Vector temporary(0, 0, 0);
     56  temp = "0, 0, 0";
     57  if (param.isSet()) {
     58    temporary = param.get();
     59    temp = param.getAsString();
     60  }
    5361  mainLayout= new QHBoxLayout();
    5462  titleLabel = new QLabel(QString(getTitle().c_str()));
    5563  titleLabel->setToolTip(QString(getDescription().c_str()));
    5664  mainLayout->addWidget(titleLabel);
    57   subLayout = new QVBoxLayout();
     65  subLayout = new QHBoxLayout();
    5866  mainLayout->addLayout(subLayout);
    5967//  QComboBox* inputBox = new QComboBox();
     68
     69  QWidget *firstPageWidget = new QWidget;
     70  QWidget *secondPageWidget = new QWidget;
     71
     72  QStackedWidget *stackedWidget = new QStackedWidget;
     73  stackedWidget->addWidget(firstPageWidget);
     74  stackedWidget->addWidget(secondPageWidget);
     75
     76  QComboBox *pageComboBox = new QComboBox;
     77  pageComboBox->addItem(tr("x,y,z"));
     78  pageComboBox->addItem(tr("vector name"));
     79  connect(pageComboBox, SIGNAL(activated(int)),
     80      stackedWidget, SLOT(setCurrentIndex(int)));
     81  connect(pageComboBox, SIGNAL(activated(int)),
     82      this, SLOT(pageChanged(int)));
     83  subLayout->addWidget(pageComboBox);
     84  subLayout->addWidget(stackedWidget);
     85
     86   // first widget with coordinates
    6087  coordLayout = new QHBoxLayout();
    61   subLayout->addLayout(coordLayout);
    62   coordLabel = new QLabel(QString("x,y,z"));
    63   coordLayout->addWidget(coordLabel);
    6488  coordInputX = new QDoubleSpinBox();
    6589  coordInputX->setRange(-std::numeric_limits<double>::max(),std::numeric_limits<double>::max());
    66   coordInputX->setValue(temp[0]);
     90  coordInputX->setValue(temporary[0]);
    6791//  coordInputX->setRange(0,M.at(i,i));
    6892  coordInputX->setDecimals(3);
     
    7094  coordInputY = new QDoubleSpinBox();
    7195  coordInputY->setRange(-std::numeric_limits<double>::max(),std::numeric_limits<double>::max());
    72   coordInputY->setValue(temp[1]);
     96  coordInputY->setValue(temporary[1]);
    7397//  coordInputY->setRange(0,M.at(i,i));
    7498  coordInputY->setDecimals(3);
     
    76100  coordInputZ = new QDoubleSpinBox();
    77101  coordInputZ->setRange(-std::numeric_limits<double>::max(),std::numeric_limits<double>::max());
    78   coordInputZ->setValue(temp[2]);
     102  coordInputZ->setValue(temporary[2]);
    79103//  coordInputZ->setRange(0,M.at(i,i));
    80104  coordInputZ->setDecimals(3);
     
    83107  connect(coordInputY,SIGNAL(valueChanged(double)),this,SLOT(onUpdateY(double)));
    84108  connect(coordInputZ,SIGNAL(valueChanged(double)),this,SLOT(onUpdateZ(double)));
     109  firstPageWidget->setLayout(coordLayout);
     110
     111  // second widget with string field
     112  nameLayout = new QHBoxLayout();
     113  nameComboBox = new QComboBox;
     114  GeometryRegistry &reg = GeometryRegistry::getInstance();
     115//  nameComboBox->setEditable(true);
     116  GeometryRegistry::const_iterator iter;
     117  for (iter = reg.getBeginIter(); iter != reg.getEndIter(); iter ++){
     118    GeometryObject *v = iter->second;
     119    nameComboBox->addItem(tr(v->getName().c_str()));
     120    nameComboBox->setItemData(nameComboBox->count()-1, tr(toString<Vector>(v->getVector()).c_str()), Qt::ToolTipRole);
     121  }
     122  connect(nameComboBox, SIGNAL(activated(int)),
     123      this, SLOT(onUpdateName(int)));
     124  nameLayout->addWidget(nameComboBox);
     125  secondPageWidget->setLayout(nameLayout);
     126
    85127  parent->addLayout(mainLayout);
    86128}
     
    89131{}
    90132
     133static void updateVectorString(std::string &_temp, const double newDouble, int component)
     134{
     135  //!> Internal converter from string to internal type
     136  Vector vec = Value<Vector>::parseAsVector(_temp);
     137  vec[component] = newDouble;
     138  _temp = Value<Vector>::setFromVector(vec);
     139}
     140
     141void QtDialog::VectorQtQuery::pageChanged(int pagenr) {
     142  if (pagenr == 1) {
     143    // change from x,y,z input
     144    onUpdateName(nameComboBox->currentIndex());
     145    dialog->update();
     146  } else if (pagenr == 0) {
     147    // change from name input
     148    if (GeometryRegistry::getInstance().isPresentByName(temp)) {
     149      const GeometryObject * const v = GeometryRegistry::getInstance().getByName(temp);
     150      coordInputX->setValue(v->getVector()[0]);
     151      coordInputY->setValue(v->getVector()[1]);
     152      coordInputZ->setValue(v->getVector()[2]);
     153    } else {
     154      coordInputX->setValue(0.);
     155      coordInputY->setValue(0.);
     156      coordInputZ->setValue(0.);
     157    }
     158    dialog->update();
     159  } else {
     160    ASSERT(0, "VectorQtQuery::pageChanged() - unknown page for pageComboBox.");
     161  }
     162}
     163
     164void QtDialog::VectorQtQuery::onUpdateName(int index) {
     165  const QString itemtext = nameComboBox->itemText(index);
     166  temp = itemtext.toStdString();
     167  dialog->update();
     168}
     169
    91170void QtDialog::VectorQtQuery::onUpdateX(double newDouble) {
    92   temp[0] = newDouble;
     171  updateVectorString(temp, newDouble, 0);
    93172  dialog->update();
    94173}
    95174
    96175void QtDialog::VectorQtQuery::onUpdateY(double newDouble) {
    97   temp[1] = newDouble;
     176  updateVectorString(temp, newDouble, 1);
    98177  dialog->update();
    99178}
    100179
    101180void QtDialog::VectorQtQuery::onUpdateZ(double newDouble) {
    102   temp[2] = newDouble;
     181  updateVectorString(temp, newDouble, 2);
    103182  dialog->update();
    104183}
  • src/UIElements/TextUI/Query/TextQuery.hpp

    r9a9f847 rbe848d  
    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/Query/VectorTextQuery.cpp

    r9a9f847 rbe848d  
    8383
    8484  // check vector
    85   return World::getInstance().getDomain().isValid(temp);
     85  return true;
    8686}
    8787
  • src/UIElements/TextUI/Query/VectorsTextQuery.cpp

    r9a9f847 rbe848d  
    4141#include "CodePatterns/Log.hpp"
    4242#include "CodePatterns/Verbose.hpp"
     43#include "Geometry/GeometryRegistry.hpp"
    4344#include "LinearAlgebra/Vector.hpp"
    4445#include "LinearAlgebra/RealSpaceMatrix.hpp"
     
    5455
    5556bool TextDialog::VectorsTextQuery::handle() {
     57  std::stringstream output;
    5658  std::cout << getDescription() << std::endl;
    5759  char coords[3] = {'x', 'y', 'z'};
    5860  const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    59   for (int i=0;i<3;i++)
    60     std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     61  std::cout << "Enter three comma-separated coordinates, vector name, ? for list or empty for end." << std::endl;
     62  while (true) {
     63    for (int i=0;i<3;i++)
     64      std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
    6165
    62   std::string line;
    63   getline(std::cin,line);
     66    std::string line;
     67    getline(std::cin,line);
    6468
    65   // dissect by ","
    66   double coord = 0.;
    67   std::string::iterator olditerspace = line.begin();
    68   std::string::iterator olditercomma = line.begin();
    69   int counter = 0;
    70   Vector temp_element;
    71   for(std::string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
    72     if (*vectoriter == ',')
    73       counter++;
    74     if ((*vectoriter == ' ') && (counter == 2)) {
    75       counter = 0;
    76       for(std::string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) {
    77         if (*componentiter == ',') {
    78           std::istringstream stream(std::string(componentiter, olditercomma));
    79           stream >> coord;
    80           temp_element[counter++] = coord;
    81           olditercomma = componentiter;
    82         }
     69    if (line == "?") {
     70      GeometryRegistry &reg = GeometryRegistry::getInstance();
     71
     72      GeometryRegistry::const_iterator iter;
     73      for (iter = reg.getBeginIter(); iter != reg.getEndIter(); iter ++){
     74        GeometryObject *v = iter->second;
     75        std::cout << "\t" << *v << std::endl;
    8376      }
    84       if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also
    85         std::istringstream stream(std::string(olditercomma, vectoriter));
    86         stream >> coord;
    87         temp_element[counter++] = coord;
    88       }
    89       if (World::getInstance().getDomain().isValid(temp_element))
    90         temp.push_back(temp_element);
    91       olditerspace = vectoriter;
     77    } else if (line.empty()) {
     78      break;
     79    } else {
     80      // simply append with white-space delimiter
     81      temp.push_back(line);
    9282    }
    9383  }
  • src/UIElements/TextUI/TextDialog.hpp

    r9a9f847 rbe848d  
    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.