Changeset 73faf4 for src


Ignore:
Timestamp:
May 8, 2017, 2:00:47 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_goodresults, ForceAnnealing_tocheck
Children:
c8165c
Parents:
ce254c (diff), cb6357 (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
Files:
30 added
35 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action_impl_pre.hpp

    rce254c r73faf4  
    173173    output << \
    174174    BOOST_PP_IF(n, ", ", "") \
    175     << "\"" << toPythonString(params. \
     175    << "\"" << params. \
    176176        BOOST_PP_SEQ_ELEM(n, paramreferences) \
    177         .getUnvalidated()) \
     177        .getAsStringUnvalidated() \
    178178    << "\"";
    179179
  • src/Actions/CommandAction/HelpAction.cpp

    rce254c r73faf4  
    7373  std::cout << "\t - List/vector of strings: gives as \"first\" \"second\" \"third\"." << std::endl;
    7474  std::cout << "\t - Vector: give as \"x,y,z\", i.e. its 3 components." << std::endl;
     75  std::cout << "\t -         or give as \"<name>\", where <name> is a stored geometry name." << std::endl;
    7576  std::cout << "\t - Domain: give as \"xx,yx,yy,zx,zy,zz\", i.e. symmetric 3x3 matrix." << std::endl;
    7677  std::cout << "\t - Path/filename: give as \"<path/filename>\"." << std::endl;
  • src/Actions/GlobalListOfActions.hpp

    rce254c r73faf4  
    6969  (FragmentationStoreSaturatedFragment) \
    7070  (FragmentationStructuralOptimization) \
     71  (GeometryDistanceToVector) \
     72  (GeometryInputToVector) \
     73  (GeometryPlaneToVector) \
     74  (GeometryPositionToVector) \
     75  (GeometryRemove) \
    7176  (GraphUpdateMolecules) \
    7277  (GraphCorrectBondDegree) \
  • src/Actions/Makefile.am

    rce254c r73faf4  
    6464  ${FILLACTIONSOURCE} \
    6565  ${FRAGMENTATIONACTIONSOURCE} \
     66  ${GEOMETRYACTIONSOURCE} \
    6667  ${GRAPHACTIONSOURCE} \
    6768  ${MOLECULEACTIONSOURCE} \
     
    8485  ${FILLACTIONHEADER} \
    8586  ${FRAGMENTATIONACTIONHEADER} \
     87  ${GEOMETRYACTIONHEADER} \
    8688  ${GRAPHACTIONHEADER} \
    8789  ${MOLECULEACTIONHEADER} \
     
    104106  ${FILLACTIONDEFS} \
    105107  ${FRAGMENTATIONACTIONDEFS} \
     108  ${GEOMETRYACTIONDEFS} \
    106109  ${GRAPHACTIONDEFS} \
    107110  ${MOLECULEACTIONDEFS} \
     
    285288  Actions/FragmentationAction/StoreSaturatedFragmentAction.def \
    286289  Actions/FragmentationAction/StructuralOptimizationAction.def
     290
     291GEOMETRYACTIONSOURCE = \
     292        Actions/GeometryAction/GeometryDistanceToVectorAction.cpp \
     293        Actions/GeometryAction/GeometryInputToVectorAction.cpp \
     294        Actions/GeometryAction/GeometryPlaneToVectorAction.cpp \
     295        Actions/GeometryAction/GeometryPositionToVectorAction.cpp \
     296        Actions/GeometryAction/GeometryRemoveAction.cpp
     297GEOMETRYACTIONHEADER = \
     298        Actions/GeometryAction/GeometryDistanceToVectorAction.hpp \
     299        Actions/GeometryAction/GeometryInputToVectorAction.hpp \
     300        Actions/GeometryAction/GeometryPlaneToVectorAction.hpp \
     301        Actions/GeometryAction/GeometryPositionToVectorAction.hpp \
     302        Actions/GeometryAction/GeometryRemoveAction.hpp
     303GEOMETRYACTIONDEFS = \
     304        Actions/GeometryAction/GeometryDistanceToVectorAction.def \
     305        Actions/GeometryAction/GeometryInputToVectorAction.def \
     306        Actions/GeometryAction/GeometryPlaneToVectorAction.def \
     307        Actions/GeometryAction/GeometryPositionToVectorAction.def \
     308        Actions/GeometryAction/GeometryRemoveAction.def
    287309
    288310GRAPHACTIONSOURCE = \
  • src/Actions/MakroAction_impl_pre.hpp

    rce254c r73faf4  
    165165    output << \
    166166    BOOST_PP_IF(n, ", ", "") \
    167     << "\"" << toPythonString(params. \
     167    << "\"" << params. \
    168168        BOOST_PP_SEQ_ELEM(n, paramreferences) \
    169         .get()) \
     169        .getAsStringUnvalidated() \
    170170    << "\"";
    171171
  • src/Actions/Values.cpp

    rce254c r73faf4  
    3737#include "CodePatterns/Assert.hpp"
    3838
     39#include <boost/lexical_cast.hpp>
     40#include <boost/tokenizer.hpp>
     41
    3942#include "Box.hpp"
    4043#include "LinearAlgebra/BoxVector.hpp"
     
    4447#include "Values.hpp"
    4548
     49static const Vector parseAsVector(const std::string &_string)
     50{
     51  Vector temp;
     52  // dissect by ","
     53  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
     54  boost::char_separator<char> value_separator(",)(");
     55
     56  bool status = true;
     57  tokenizer tokens(_string, value_separator);
     58  if (!_string.empty()) {
     59    tokenizer::iterator tok_iter = tokens.begin();
     60    for (size_t i=0;i<NDIM;++i) {
     61      if (tok_iter == tokens.end()) {
     62        status = false;
     63        break;
     64      }
     65      temp[i] = boost::lexical_cast<double>(*(tok_iter++));
     66    }
     67  }
     68  if (!status)
     69    temp.Zero();
     70
     71  return temp;
     72}
     73
    4674Vector VectorValue::toVector() const
    4775{
    48   Vector returnVector(vector);
     76  Vector returnVector = parseAsVector(vectorstring);
    4977
    5078  return returnVector;
     
    5482{
    5583  BoxVector returnVector;
    56   static_cast<Vector>(returnVector) = Vector(vector); // under its hood it's still a Vector
     84  static_cast<Vector>(returnVector) = parseAsVector(vectorstring); // under its hood it's still a Vector
    5785
    5886  ASSERT(_box.isValid(returnVector),
  • src/Actions/Values.hpp

    rce254c r73faf4  
    2727 * are registered as VectorValue and lateron inside the CommandLineQuery placed
    2828 * into the real vector.
     29 *
     30 * We use this abstraction also for Geometry Objects, i.e. string names
     31 * referencing vectors in the GeomtryRegistry.
    2932 */
    3033struct VectorValue
    3134{
    32   double vector[NDIM];
     35  std::string vectorstring;
    3336
    3437  Vector toVector() const;
  • src/Makefile.am

    rce254c r73faf4  
    1111# libMolecuilder.la requires the libraries listed below
    1212
     13include Geometry/Makefile.am
    1314include Helpers/Makefile.am
    1415include Shapes/Makefile.am
  • src/Parameters/Makefile.am

    rce254c r73faf4  
    44
    55PARAMETERSOURCE = \
     6        Parameters/Specifics/Parameter_vector.cpp \
    67        Parameters/Specifics/Value_atom.cpp \
    78        Parameters/Specifics/Value_element.cpp \
     
    910        Parameters/Specifics/Value_molecule.cpp \
    1011        Parameters/Specifics/Value_string.cpp \
     12        Parameters/Specifics/Value_vector.cpp \
    1113        Parameters/Validators/Specific/ActionNameValidator.cpp \
    1214        Parameters/Validators/Specific/AtomDataValidator.cpp \
     
    1719        Parameters/Validators/Specific/FileSuffixValidator.cpp \
    1820        Parameters/Validators/Specific/FormulaValidator.cpp \
     21        Parameters/Validators/Specific/GeometryNameValidator.cpp \
    1922        Parameters/Validators/Specific/KeyValueValidator.cpp \
    2023        Parameters/Validators/Specific/MoleculeIdValidator.cpp \
    2124        Parameters/Validators/Specific/ParserFileValidator.cpp \
    2225        Parameters/Validators/Specific/ParserTypeValidator.cpp \
     26        Parameters/Validators/Specific/PresentGeometryNameValidator.cpp \
    2327        Parameters/Validators/Specific/RandomNumberValidators.cpp \
    2428        Parameters/Validators/Specific/RealSpaceMatrixInvertibleValidator.cpp \
     
    4549        Parameters/ValueInterface.hpp \
    4650        Parameters/Specifics/KeyValuePair.hpp \
     51        Parameters/Specifics/Parameter_vector.hpp \
    4752        Parameters/Specifics/Value_atom.hpp \
    4853        Parameters/Specifics/Value_element.hpp \
     
    5055        Parameters/Specifics/Value_molecule.hpp \
    5156        Parameters/Specifics/Value_string.hpp \
     57        Parameters/Specifics/Value_vector.hpp \
    5258        Parameters/Validators/DiscreteValidator.hpp \
    5359        Parameters/Validators/DiscreteValidator_impl.hpp \
     
    7480        Parameters/Validators/Specific/FileSuffixValidator.hpp \
    7581        Parameters/Validators/Specific/FormulaValidator.hpp \
     82        Parameters/Validators/Specific/GeometryNameValidator.hpp \
    7683        Parameters/Validators/Specific/KeyValueValidator.hpp \
    7784        Parameters/Validators/Specific/MoleculeIdValidator.hpp \
    7885        Parameters/Validators/Specific/ParserFileValidator.hpp \
    7986        Parameters/Validators/Specific/ParserTypeValidator.hpp \
     87        Parameters/Validators/Specific/PresentGeometryNameValidator.hpp \
    8088        Parameters/Validators/Specific/RandomNumberValidators.hpp \
    8189        Parameters/Validators/Specific/RealSpaceMatrixInvertibleValidator.hpp \
  • src/Parameters/Parameter.hpp

    rce254c r73faf4  
    2525class ParameterValueException;
    2626
    27 /** This class encapsulates a clonable, continuous value.
     27/** This class encapsulates a cloneable, continuous value.
    2828 *
    2929 */
     
    4848  bool isValidAsString(const std::string &_value) const throw(ParameterValidatorException);
    4949  const std::string getAsString() const throw(ParameterValueException);
     50  const std::string getAsStringUnvalidated() const throw(ParameterValueException);
    5051  void setAsString(const std::string &_value) throw(ParameterValueException);
    5152
     
    7879};
    7980
     81#include "Parameters/Specifics/Parameter_vector.hpp"
     82
    8083#include "Parameter_impl.hpp"
    8184
  • src/Parameters/Parameter_impl.hpp

    rce254c r73faf4  
    2323  value(instance.value.getValidator())
    2424{
    25   value.set(instance.value.value);
     25  value.set(instance.value.getUnvalidated());
    2626}
    2727
     
    171171}
    172172
     173/** Catch call to value.getAsStringUnvalidated() to add exception information.
     174 *
     175 * @return parameter value as string
     176 */
     177template<typename T>
     178inline const std::string Parameter<T>::getAsStringUnvalidated() const throw(ParameterValueException)
     179{
     180  try {
     181    return value.getAsStringUnvalidated();
     182  } catch(ParameterException &e) {
     183    e << ParameterName(ParameterInterface::getName());
     184    throw;
     185  }
     186}
     187
    173188/** Catch call to value.isValid() to add exception information.
    174189 *
     
    258273  try {
    259274    status = status &&
    260         (value == _instance.value);
     275        (getUnvalidated() == _instance.getUnvalidated());
    261276    status = status && (ParameterInterface::getName() == _instance.ParameterInterface::getName());
    262277  } catch(ParameterException &e) {
     
    276291  Parameter<T> *instance = new Parameter<T>(ParameterInterface::getName(), value.getValidator());
    277292  // do not use get, we do not check for validity here
    278   if (value.ValueSet)
    279     instance->set(value.value);
     293  if (value.isSet())
     294    instance->set(value.getUnvalidated());
    280295  return instance;
    281296}
  • src/Parameters/Value.hpp

    rce254c r73faf4  
    6767  friend class ValueTest;
    6868  friend class ContinuousValueTest;
    69   friend class Parameter<T>;
     69//  friend class Parameter<T>;
    7070public:
    7171  Value();
     
    8585  bool isValidAsString(const std::string &_value) const throw(ParameterValidatorException);
    8686  const std::string getAsString() const throw(ParameterValueException);
     87  const std::string getAsStringUnvalidated() const throw(ParameterValueException);
    8788  void setAsString(const std::string &_value) throw(ParameterException);
    8889
     
    123124#include "Specifics/Value_molecule.hpp"
    124125#include "Specifics/Value_string.hpp"
     126#include "Specifics/Value_vector.hpp"
    125127
    126128#include "Value_impl.hpp"
  • src/Parameters/Value_impl.hpp

    rce254c r73faf4  
    2222#include "CodePatterns/Log.hpp"
    2323
     24#include "Actions/toPythonString.hpp"
    2425#include "Validators/DummyValidator.hpp"
    2526#include "Validators/DiscreteValidator.hpp"
     
    184185{
    185186  return toString(get());
     187}
     188
     189/** Getter of unvalidated value, returning string.
     190 *
     191 * @return string value
     192 */
     193template <class T>
     194inline const std::string Value<T>::getAsStringUnvalidated() const throw(ParameterValueException)
     195{
     196  return toPythonString(getUnvalidated());
    186197}
    187198
  • src/Parameters/unittests/Makefile.am

    rce254c r73faf4  
    3131        libUnitTest.la \
    3232        ../libMolecuilder.la \
     33        ../libMolecuilderParameters.la \
     34        ../libMolecuilderGeometry.la \
    3335        $(top_builddir)/ThirdParty/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
    3436        ${CodePatterns_LIBS} \
     
    4749        ../Parameters/ValueInterface.hpp
    4850ContinuousValueTest_LDADD = \
     51        ../libMolecuilderParameters.la \
     52        ../libMolecuilderGeometry.la \
    4953        $(PARAMETERSLIBS)
    5054 
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    rce254c r73faf4  
    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_validate.cpp

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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

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

    rce254c r73faf4  
    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

    rce254c r73faf4  
    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
  • src/cleanUp.cpp

    rce254c r73faf4  
    5454#include "Fragmentation/Summation/Containers/FragmentationResultContainer.hpp"
    5555
     56#include "Geometry/GeometryRegistry.hpp"
     57
    5658#include "MoleculeObserver.hpp"
    5759
     
    9597  // make sure that ActionQueue is already purged!
    9698  FragmentationResultContainer::purgeInstance();
     99  GeometryRegistry::purgeInstance();
    97100  Chronos::purgeInstance();
    98101  PotentialFactory::purgeInstance();
Note: See TracChangeset for help on using the changeset viewer.