Changes in / [101d2d:78ea3c]


Ignore:
Files:
54 added
47 edited

Legend:

Unmodified
Added
Removed
  • doc/userguide/userguide.xml

    r101d2d r78ea3c  
    1 <?xml version='1.0' encoding='UTF-8'?>
     1<?xml version='1.0' encoding='UTF-8'?>
    22<!-- This document was created with Syntext Serna Free. --><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
    33<!ENTITY molecuilder_logo SYSTEM "pictures/molecuilder_logo.png" NDATA PNG>
     
    100100            spheres, cubes, or cylinders.</para>
    101101          </listitem>
    102           <listitem>World refers to the whole of the molecular system, i.e. all atoms with coordinates and element type (over all time steps), all bonds between pairs of atoms, the size of the simulation domain. This state is also referred to as the state.</listitem>
    103           <listitem>Time step is the current discrete position in time. Molecular dynamics simulations are executed in discrete (but very small) time steps. Each atom has a distinct position per time step. The discrete positions over the discrete time steps samples its trajectory during a simulation.</listitem>
     102          <listitem>World refers to the whole of the molecular system, i.e. all
     103          atoms with coordinates and element type (over all time steps), all
     104          bonds between pairs of atoms, the size of the simulation domain.
     105          This is also referred to as the state.</listitem>
     106          <listitem>Time step is the current discrete position in time. Molecular
     107          dynamics simulations are executed in discrete (but very small) time
     108          steps.  Each atom has a distinct position per time step. The discrete
     109          positions over the discrete time steps samples its trajectory during a
     110          simulation.</listitem>
    104111        </itemizedlist>
    105112      </section>
     
    110117        respect to their functionality, while newer features or actions are
    111118        probably missing. This should be a clear sign to you that these are
    112         probably not safe to use yet. If you nonetheless require them, you         should acquire some familiarity with the code itself. This suggests
    113         changing to the developer documentation which is maintained along with
    114         the source code with <productname>doxygen</productname>.</para>
     119        probably not safe to use yet. If you nonetheless require them, you
     120        should acquire some familiarity with the code itself. This suggests
     121        changing to the developer documentation which is maintained along
     122        with the source code with <productname>doxygen</productname>.
     123        </para>
    115124      </section>
    116125    </section>
     
    313322      </formalpara>
    314323      <note>
    315         <para>Note further that when placing a slew of commands in a script file it is generally recommended to use the above formatting: One command or option per line and each</para>
    316         <para>option receives an extra tab for indentation.</para>
     324        <para>Note further that when placing a slew of commands in a script file
     325         it is generally recommended to use the above formatting: One command
     326         or option per line and each receives an extra tab for indentation.</para>
    317327      </note>
    318328      <section xml:id="preliminaries">
     
    728738        </section>
    729739      </section>
     740      <section xml:id="geometry">
     741        <title xml:id="geometry.title">Geometry Objects</title>
     742        <para>Although we use the term geometry objects in the title, we
     743        actually mean vectors, i.e. a position or direction in the
     744        three-dimensional space. But maybe we have need for the more
     745        general term in the future.</para>
     746        <para>Vectors are required as input to many of the Actions further
     747        below: translating atoms, rotating atoms around a specific axis,
     748        aligning a molecule with a vector, ...</para>
     749        <para>Therefore, vectors can be stored and referenced using a given
     750        name. This allows for a very powerful and handy manipulation of the
     751       molecular system afterwards. And to give a concrete example, let's have
     752       a look at translating a set of selected atoms, see subsection on
     753       <link linkend='atoms.translate-atom'>Translating atoms</link>. </para>
     754       <programlisting>
     755... --translate-atoms &quot;unitVectorX&quot;
     756       </programlisting>
     757       <para>This would use the automatically created reference
     758       &quot;unitVectorX&quot;, i.e. the vector with components (1,0,0) as
     759       the translation vector for the given set of atoms. In other words, all
     760       selected atoms get shifted by 1 unit (e.g. Angstr&ouml;m) in +X
     761       direction.</para>
     762       <para>We have the following automatically created geometry objects
     763       whose names are self-explanatory:</para>
     764       <itemizedlist>
     765        <listitem>zeroVector</listitem>
     766        <listitem>unitVectorX</listitem>
     767        <listitem>unitVectorY</listitem>
     768        <listitem>unitVectorZ</listitem>
     769       </itemizedlist>
     770       <para>However, more vectors can be simply constructed from atomic
     771       positions, such as the position of an atom directly, the distance between
     772       two atoms (in case they are bonded, then this would be the bond vector)
     773       or from three atoms, defining a plane and giving its normal vector.
     774       </para>
     775       <remark>We have refrained from giving automated names to vectors and even
     776       keeping them up-to-date automatically, i.e. the distance between two atoms
     777       O1 and O2 could be named &quot;distance_O1_O2&quot; or similar. However, we want
     778       the user to have full control and maybe come up with more suitable names
     779       such as &quot;rotation_axis&quot; in this case.</remark>
     780       <warning>Note that names have to be unique and the Action will fail if
     781       the name is already used.</warning>
     782        <section xml:id="geometry.distance-to.vector">
     783          <title xml:id="geometry.distance-to-vector.title">Atomic distance to stored vector</title>
     784          <para>The distance between two selected atoms is stored as a vector as follows,</para>
     785          <programlisting>
     786  ... --distance-to-vector &quot;distance_vec&quot; \
     787          </programlisting>
     788          <para>where the distance vector can be referenced by &quot;distance_vec&quot;
     789          from then on in other Actions requiring a vector as input.</para>
     790        </section>
     791        <section xml:id="geometry.input-to.vector">
     792          <title xml:id="geometry.input-to-vector.title">Coordinates to stored vector</title>
     793          <para>We may also create a geometry vector simply by supplying the
     794          three coordinates of a vector.</para>
     795          <programlisting>
     796  ... --input-to-vector &quot;vector&quot; \
     797      --position &quot;1,2,3&quot;
     798          </programlisting>
     799          <para>where the vector with components (1,2,3) can be referenced
     800          by &quot;vector&quot; .</para>
     801        </section>
     802        <section xml:id="geometry.plane-to.vector">
     803          <title xml:id="geometry.plane-to-vector.title">Normal of plane to stored vector</title>
     804          <para>Three positions in space (if they are not linear dependent)
     805          define a plane in three-dimensional space.</para>
     806          <para>Therefore, when exactly three atoms are selected, this Action
     807          will construct the resulting plane and store its normal vector as a
     808          geometry object for later reference.</para>
     809          <programlisting>
     810  ... --plane-to-vector &quot;planenormal&quot; \
     811          </programlisting>
     812          <para>where the plane's normal vector can be referenced by
     813          &quot;planenormal&quot;.</para>
     814        </section>
     815        <section xml:id="geometry.position-to.vector">
     816          <title xml:id="geometry.position-to-vector.title">Atomic position to stored vector</title>
     817          <para>Storing the position of a singly selected atom as a vector is simply done as follows,</para>
     818          <programlisting>
     819  ... --position-to-vector &quot;vector_O1&quot; \
     820          </programlisting>
     821          <para>where the vector can be referenced by &quot;vector_O1&quot;
     822          from then on.</para>
     823        </section>
     824        <section xml:id="geometry.remove-geometry">
     825          <title xml:id="geometry.remove-geometry.title">Remove A stored vector</title>
     826          <para>Finally, a stored vector can also be removed.</para>
     827          <programlisting>
     828  ... --remove-geometry &quot;vector_O1&quot; \
     829          </programlisting>
     830          <para>this removes  the stored &quot;vector_O1&quot;.</para>
     831        </section>
     832      </section>
    730833      <section xml:id="randomization">
    731834        <title xml:id="randomization.title">Randomization</title>
     
    772875          <para>where the element is given via its chemical symbol and the
    773876          vector gives the position within the domain</para>
     877         <para>Note that instead of giving an explicit vector you may also use
     878        a vector stored as a geometry object, see section
     879        <link linkend='geometry'>Geometry</link>.</para>
    774880        </section>
    775881        <section xml:id="atoms.remove-atom">
     
    787893  ... --saturate-atoms
    788894   </programlisting>
    789           <para>A number of hydrogen atoms is added around each selected atom corresponding to the valence of the chemical element. The hydrogen atoms are placed in the same
    790           distance to this atom and approximately with same distance to their
    791    nearest neighbors. Already present bonds (i.e. the position of neighboring atoms) is taken into account.</para>
     895          <para>A number of hydrogen atoms is added around each selected atom
     896          corresponding to the valence of the chemical element. The hydrogen
     897          atoms are placed in the same distance to this atom and approximately
     898          with same distance to their nearest neighbors. Already present bonds
     899          (i.e. the position of neighboring atoms) is taken into account.</para>
    792900        </section>
    793901        <section xml:id="atoms.translate-atom">
     
    802910          mind the boundary conditions, i.e. it might shift atoms outside of the
    803911          domain.</para>
     912         <para>Again, note that instead of giving an explicit vector you may
     913         also use a vector stored as a geometry object, see section
     914        <link linkend='geometry'>Geometry</link>.</para>
    804915        </section>
    805916        <section xml:id="atoms.mirror-atoms">
     
    813924                    --periodic 0
    814925   </programlisting>
     926         <para>And of course instead of giving an explicit vector you may also
     927         use a vector stored as a geometry object, see section
     928        <link linkend='geometry'>Geometry</link>.</para>
    815929        </section>
    816930        <section xml:id="atoms.translate-to-origin">
     
    10231137          and adds new bonds in between these copied atoms such that their
    10241138          bond subgraphs are identical.</para>
     1139         <para>Here, instead of giving an explicit vector you may also use
     1140        a vector stored as a geometry object, see section
     1141        <link linkend='geometry'>Geometry</link>.</para>
    10251142        </section>
    10261143        <section xml:id="molecule.change-molname">
     
    10531170   specific offset..</para>
    10541171          <programlisting>... -translate-molecules</programlisting>
    1055           <para>As before, this is actually just an operation on all of the molecule&apos;s atoms, namely translating them.</para>
     1172          <para>As before, this is actually just an operation on all of the
     1173          molecule&apos;s atoms, namely translating them.</para>
     1174         <para>Same as with <link linkend='atoms.translate-atom'>translate-atoms</link>
     1175         instead of giving an explicit vector you may also use a vector stored
     1176         as a geometry object, see section
     1177        <link linkend='geometry'>Geometry</link>.</para>
    10561178        </section>
    10571179        <section xml:id="molecule.rotate-around-bond">
     
    10851207   </programlisting>
    10861208          <para>This rotates the molecule around an axis from the origin to
    1087           the position (0,0,1), i.e. around the z axis, by 90 degrees.</para>
     1209          the position (0,0,1), i.e. around the z axis, by 90 degrees, where
     1210          for the position you may also use a stored vector, see section
     1211        <link linkend='geometry'>Geometry</link>.</para>
    10881212        </section>
    10891213        <section xml:id="molecule.rotate-to-principal-axis-system">
     
    10981222          </programlisting>
    10991223          <para>This rotates the molecule in such a manner that the ellipsoids
    1100           largest axis is aligned with the z axis. <remark>Note that &quot;0,0,-1&quot; would align anti-parallel.</remark></para>
     1224          largest axis is aligned with the z axis. <remark>Note that
     1225          &quot;0,0,-1&quot; would align anti-parallel.</remark></para>
     1226         <para>Again instead of giving the coordinates explicitly you may also
     1227         use a vector stored as a geometry object, see section
     1228        <link linkend='geometry'>Geometry</link>.</para>
    11011229        </section>
    11021230        <section xml:id="molecule.verlet-integration">
     
    13431471      --Alignment-Axis &quot;0,0,1&quot;
    13441472   </programlisting>
     1473         <para>Note that instead of giving an explicit axis you may also use
     1474        a vector stored as a geometry object, see section
     1475        <link linkend='geometry'>Geometry</link>.</para>
    13451476        </section>
    13461477        <section xml:id="filling.suspend-in-molecule">
     
    14501581          <para>This would calculate the correlation of all hydrogen and
    14511582          oxygen atoms with respect to the origin.</para>
     1583         <para>Naturally, instead of giving explicit coordinates you may also
     1584         use a vector stored as a geometry object for position, see section
     1585        <link linkend='geometry'>Geometry</link>.</para>
    14521586        </section>
    14531587        <section xml:id="analysis.surface-correlation">
     
    23852519          <para>Underneath the time line there is another place for
    23862520          tabs.</para>
     2521          <itemizedlist>
     2522            <listitem>Molecules</listitem>
     2523            <listitem>All Elements</listitem>
     2524            <listitem>All Fragments</listitem>
     2525            <listitem>All Homologies</listitem>
     2526            <listitem>All Geometries</listitem>
     2527            <listitem>Logs</listitem>
     2528            <listitem>Errors</listitem>
     2529          </itemizedlist>
    23872530          <para>The first is on molecules, listing all present molecules of
    23882531          the molecular system in a tree view. If you click on a specific
     
    23942537          system. Clicking on a present element will select all atoms of this
    23952538          specific element. A subsequent click unselects again.</para>
    2396           <para>Subsequently follow tabs on enumerating the fragments and their
     2539          <para>Subsequently follow two tabs on enumerating the fragments and their
    23972540          fragment energies if calculated and the homologies along with
    23982541          graphical depiction (via QWT), again if present.</para>
     2542          <para>After that, we have a tab listing all geometry objects. These
     2543          are vectors you may store via one of the Actions. If you hover over
     2544          a vector, its length is shown. If you have selected one vector and
     2545          hover over another one, then the angle between the two is shown.
     2546          </para>
     2547          <para>Finally, there are two tabs showing log messages of actions
     2548          in the first tab and general information on what is currently done. Errors and
     2549          warnings are listed in the second tab.</para>
    23992550        </section>
    24002551      </section>
  • src/Actions/Action_impl_pre.hpp

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    7575  shape("shape options"),
    7676  fragmentation("Fragmentation options"),
     77  geometry("Geometry options"),
    7778  graph("Graph options"),
    7879  molecule("Molecule options"),
     
    9394  CmdParserLookup["shape"] = &shape;
    9495  CmdParserLookup["fragmentation"] = &fragmentation;
     96  CmdParserLookup["geometry"] = &geometry;
    9597  CmdParserLookup["graph"] = &graph;
    9698  CmdParserLookup["options"] = &options;
  • src/UIElements/CommandLineUI/CommandLineParser.hpp

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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

    r101d2d r78ea3c  
    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();
  • tests/GuiChecks/Makefile.am

    r101d2d r78ea3c  
    1212        $(srcdir)/./Fragmentation/FragmentationAutomation/testsuite-fragmentation-fragmentation-automation.at \
    1313        $(srcdir)/./Fragmentation/AnalyseFragmentationResults/testsuite-fragmentation-analyse-fragment-results.at \
     14        $(srcdir)/./Geometry/Remove/testsuite-geometry-remove.at \
     15        $(srcdir)/./Geometry/PositionToVector/testsuite-geometry-position-to-vector.at \
     16        $(srcdir)/./Geometry/DistanceToVector/testsuite-geometry-distance-to-vector.at \
     17        $(srcdir)/./Geometry/testsuite-geometry.at \
     18        $(srcdir)/./Geometry/testsuite-geometry-common.at \
     19        $(srcdir)/./Geometry/InputToVector/testsuite-geometry-input-to-vector.at \
     20        $(srcdir)/./Geometry/PlaneToVector/testsuite-geometry-plane-to-vector.at \
    1421        $(srcdir)/./Atoms/ChangeElement/testsuite-atoms-change-element.at \
    1522        $(srcdir)/./Atoms/Add/testsuite-atoms-add.at \
  • tests/GuiChecks/testsuite.at

    r101d2d r78ea3c  
    3636m4_include(Options/testsuite-options.at)
    3737
     38m4_include(WorldTime/testsuite-worldtime.at)
     39
    3840m4_include(Parser/testsuite-parser.at)
    3941
     
    4143
    4244m4_include(Bond/testsuite-bond.at)
     45
     46m4_include(Geometry/testsuite-geometry.at)
    4347
    4448m4_include(Selection/testsuite-selection.at)
  • tests/Python/AllActions/options.dat

    r101d2d r78ea3c  
    4545convex-envelope "50."
    4646convex-file     "convexfile"
     47coordinates     "1,0,0"
    4748copy-molecule   "0"
    4849count   "12"
     
    5960distance-to-molecule    "1.5"
    6061distance-to-molecule    "2.1"
     62distance-to-vector      "named_vector"
    6163domain-position "0.  0. 0."
    6264domain-position "0 0 0"
     
    9395id-mapping      "1"
    9496input   "test.data"
     97input-to-vector "named_vector"
    9598inter-order     "2"
    9699interpolation-degree    "5"
     
    142145periodic        "0"
    143146plane-offset    "5."
     147plane-to-vector "named_vector"
    144148position        "0 0 0"
    145149position        "0 0 1"
     
    151155position        "7.283585982 3.275186040 3.535886037"
    152156position        "9.78 2.64 2.64"
     157position-to-vector      "named_vector"
    153158potential-charges       "1 1"
    154159potential-type  "morse"
     
    158163random-number-distribution-parameters   "max=20;"
    159164random-number-engine-parameters "seed=2;"
     165remove-geometry "named_vector"
    160166repeat-box      "1 1 1"
    161167reset   1
     168reverse "0"
    162169rotate-around-bond      "90."
    163170rotate-around-origin    "180."
  • tests/regression/Makefile.am

    r101d2d r78ea3c  
    119119        $(srcdir)/Fragmentation/ParseSaveFragmentResults/testsuite-fragmentation-parse-save-fragment-results.at \
    120120        $(srcdir)/Fragmentation/StoreSaturatedFragment/testsuite-fragmentation-store-saturated-fragment.at \
     121        $(srcdir)/Geometry/testsuite-geometry.at \
     122        $(srcdir)/Geometry/testsuite-geometry-common.at \
     123        $(srcdir)/Geometry/DistanceToVector/testsuite-geometry-distance-to-vector.at \
     124        $(srcdir)/Geometry/InputToVector/testsuite-geometry-input-to-vector.at \
     125        $(srcdir)/Geometry/PlaneToVector/testsuite-geometry-plane-to-vector.at \
     126        $(srcdir)/Geometry/PositionToVector/testsuite-geometry-position-to-vector.at \
     127        $(srcdir)/Geometry/Remove/testsuite-geometry-remove.at \
    121128        $(srcdir)/Graph/testsuite-graph.at \
    122129        $(srcdir)/Graph/CreateAdjacency/testsuite-graph-create-adjacency.at \
  • tests/regression/Options/DryRun/post/session.py

    r101d2d r78ea3c  
    55pyMoleCuilder.AtomAdd("1", "0,0,0")
    66pyMoleCuilder.SelectionAllAtoms()
    7 pyMoleCuilder.AtomTranslate("0,0,0", "0")
     7pyMoleCuilder.AtomTranslate("5,5,5", "0")
    88pyMoleCuilder.CommandNoDryRun()
    99# =========================== Stored Session END ===========================
  • tests/regression/Options/DryRun/testsuite-options-dryrun-storesession.at

    r101d2d r78ea3c  
    2020AT_SETUP([Standard Options - dry run and store session])
    2121AT_KEYWORDS([options dry-run no-dry-run store-session])
     22AT_SKIP_IF([../../molecuilder --help store-session; if test $? -eq 5; then /bin/true; else /bin/false; fi])
    2223
    2324# sample session
    2425file="session.py"
    25 AT_CHECK([../../molecuilder --dry-run --input hydrogen.xyz --add-atom 1 --domain-position "0,0,0" --select-all-atoms --translate-atoms "5,5,5" --no-dry-run --store-session $file --session-type python], 0, [ignore], [ignore])
     26AT_CHECK([../../molecuilder --dry-run --input hydrogen.xyz --add-atom 1 --domain-position "0,0,0" --select-all-atoms --translate-atoms --position "5,5,5" --no-dry-run --store-session $file --session-type python], 0, [ignore], [ignore])
    2627AT_CHECK([test -f $file], 0, [ignore], [ignore])
    2728AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Options/DryRun/post/$file], 0, [ignore], [ignore])
  • tests/regression/Options/Session/post/complextest.py

    r101d2d r78ea3c  
    99pyMoleCuilder.GraphSubgraphDissection()
    1010pyMoleCuilder.SelectionMoleculeOfAtom()
    11 pyMoleCuilder.FillRegularGrid("3 3 3", "0.5,0.5,0.5", "1", "0", "0", "0", "0")
     11pyMoleCuilder.FillRegularGrid("3 3 3", ".5,.5,.5", "1", "0", "0", "0", "0")
    1212pyMoleCuilder.CommandVersion()
    1313# =========================== Stored Session END ===========================
  • tests/regression/Options/Session/pre/complextest.py

    r101d2d r78ea3c  
    99pyMoleCuilder.GraphSubgraphDissection()
    1010pyMoleCuilder.SelectionMoleculeOfAtom()
    11 pyMoleCuilder.FillRegularGrid("3 3 3", "0.5,0.5,0.5", "1", "0", "0", "0", "0")
     11pyMoleCuilder.FillRegularGrid("3 3 3", ".5,.5,.5", "1", "0", "0", "0", "0")
    1212pyMoleCuilder.CommandVersion()
    1313# =========================== Stored Session END ===========================
  • tests/regression/testsuite.at

    r101d2d r78ea3c  
    4444m4_include(Bond/testsuite-bond.at)
    4545
     46m4_include(Geometry/testsuite-geometry.at)
     47
    4648m4_include(Selection/testsuite-selection.at)
    4749
Note: See TracChangeset for help on using the changeset viewer.