Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Actions/MapOfActions.cpp

    r446bc1 r83f176  
     1/*
     2 * Project: MoleCuilder
     3 * Description: creates and alters molecular systems
     4 * Copyright (C)  2010 University of Bonn. All rights reserved.
     5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
     6 */
     7
    18/*
    29 * MapOfActions.cpp
     
    512 *      Author: heber
    613 */
     14
     15// include config.h
     16#ifdef HAVE_CONFIG_H
     17#include <config.h>
     18#endif
    719
    820#include "Helpers/MemDebug.hpp"
     
    6779#include "Actions/ParserAction/SaveXyzAction.hpp"
    6880#include "Actions/SelectionAction/AllAtomsAction.hpp"
     81#include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp"
     82#include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp"
    6983#include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
    7084#include "Actions/SelectionAction/AllMoleculesAction.hpp"
     85#include "Actions/SelectionAction/AtomByElementAction.hpp"
    7186#include "Actions/SelectionAction/AtomByIdAction.hpp"
    7287#include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
    7388#include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
     89#include "Actions/SelectionAction/MoleculeByFormulaAction.hpp"
    7490#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
    7591#include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
    7692#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
     93#include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp"
     94#include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp"
    7795#include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
    7896#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
     97#include "Actions/SelectionAction/NotAtomByElementAction.hpp"
    7998#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
     99#include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp"
    80100#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
    81101#include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
     
    89109#include "Actions/WorldAction/InputAction.hpp"
    90110#include "Actions/WorldAction/OutputAction.hpp"
    91 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
    92111#include "Actions/WorldAction/RepeatBoxAction.hpp"
    93112#include "Actions/WorldAction/ScaleBoxAction.hpp"
     
    212231  DescriptionMap["redo"] = "redo last action";
    213232  DescriptionMap["remove-atom"] = "remove a specified atom";
    214   DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";
    215233  DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
    216234  DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin";
     
    224242  DescriptionMap["select-all-atoms"] = "select all atoms";
    225243  DescriptionMap["select-all-molecules"] = "select all molecules";
     244  DescriptionMap["select-atom-by-element"] = "select an atom by element";
    226245  DescriptionMap["select-atom-by-id"] = "select an atom by index";
     246  DescriptionMap["select-atoms-inside-cuboid"] = "select all atoms inside a cuboid";
     247  DescriptionMap["select-atoms-inside-sphere"] = "select all atoms inside a sphere";
    227248  DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
     249  DescriptionMap["select-molecule-by-formula"] = "select a molecule by chemical formula";
    228250  DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs";
    229251  DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule";
     
    237259  DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
    238260  DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
     261  DescriptionMap["unselect-atom-by-element"] = "unselect an atom by element";
    239262  DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
     263  DescriptionMap["unselect-atoms-inside-cuboid"] = "unselect all atoms inside a cuboid";
     264  DescriptionMap["unselect-atoms-inside-sphere"] = "unselect all atoms inside a sphere";
     265  DescriptionMap["unselect-molecule-by-formula"] = "unselect a molecule by chemical formula";
    240266  DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
    241267  DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs";
     
    245271  DescriptionMap["version"] = "show version";
    246272  // keys for values
     273  DescriptionMap["angle-x"] = "angle of a rotation around x axis";
     274  DescriptionMap["angle-y"] = "angle of a rotation around y axis";
     275  DescriptionMap["angle-z"] = "angle of a rotation around z axis";
    247276  DescriptionMap["bin-output-file"] = "name of the bin output file";
    248277  DescriptionMap["bin-end"] = "start of the last bin";
     
    293322  ShortFormMap["parse-xyz"] = "p";
    294323  ShortFormMap["remove-atom"] = "r";
    295   ShortFormMap["remove-sphere"] = "R";
    296324  ShortFormMap["repeat-box"] = "d";
    297325  ShortFormMap["rotate-to-pas"] = "m";
     
    310338
    311339  // value types for the actions
    312   TypeMap["add-atom"] = &typeid(element);
     340  TypeMap["add-atom"] = &typeid(const element);
    313341  TypeMap["bond-file"] = &typeid(std::string);
    314342  TypeMap["bond-table"] = &typeid(std::string);
     
    316344  TypeMap["center-in-box"] = &typeid(BoxValue);
    317345  TypeMap["change-box"] = &typeid(BoxValue);
    318   TypeMap["change-element"] = &typeid(element);
     346  TypeMap["change-element"] = &typeid(const element);
    319347  TypeMap["change-molname"] = &typeid(std::string);
    320348  TypeMap["clear-atom-selection"] = &typeid(void);
     
    338366  TypeMap["redo"] = &typeid(void);
    339367  TypeMap["remove-atom"] = &typeid(void);
    340   TypeMap["remove-sphere"] = &typeid(double);
    341368  TypeMap["repeat-box"] = &typeid(VectorValue);
    342369  TypeMap["rotate-origin"] = &typeid(double);
     
    349376  TypeMap["select-all-atoms"] = &typeid(void);
    350377  TypeMap["select-all-molecules"] = &typeid(void);
     378  TypeMap["select-atom-by-element"] = &typeid(const element);
    351379  TypeMap["select-atom-by-id"] = &typeid(atom);
     380  TypeMap["select-atoms-inside-cuboid"] = &typeid(VectorValue);
     381  TypeMap["select-atoms-inside-sphere"] = &typeid(double);
     382  TypeMap["select-molecule-by-formula"] = &typeid(std::string);
    352383  TypeMap["select-molecule-by-id"] = &typeid(molecule);
    353384  TypeMap["select-molecule-of-atom"] = &typeid(atom);
     
    362393  TypeMap["unselect-all-atoms"] = &typeid(void);
    363394  TypeMap["unselect-all-molecules"] = &typeid(void);
     395  TypeMap["unselect-atom-by-element"] = &typeid(const element);
    364396  TypeMap["unselect-atom-by-id"] = &typeid(atom);
     397  TypeMap["unselect-atoms-inside-cuboid"] = &typeid(VectorValue);
     398  TypeMap["unselect-atoms-inside-sphere"] = &typeid(double);
     399  TypeMap["unselect-molecule-by-formula"] = &typeid(std::string);
    365400  TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
    366401  TypeMap["unselect-molecule-of-atom"] = &typeid(atom);
     
    370405
    371406  // value types for the values
     407  TypeMap["angle-x"] = &typeid(double);
     408  TypeMap["angle-y"] = &typeid(double);
     409  TypeMap["angle-z"] = &typeid(double);
    372410  TypeMap["bin-output-file"] = &typeid(std::string);
    373411  TypeMap["bin-end"] = &typeid(double);
     
    378416  TypeMap["distances"] = &typeid(VectorValue);
    379417  TypeMap["DoRotate"] = &typeid(bool);
    380   TypeMap["element"] = &typeid(element);
    381   TypeMap["elements"] = &typeid(std::vector<element *>);
     418  TypeMap["element"] = &typeid(const element);
     419  TypeMap["elements"] = &typeid(std::vector<const element *>);
    382420  TypeMap["end-step"] = &typeid(int);
    383421  TypeMap["id-mapping"] = &typeid(bool);
     
    408446  TypeEnumMap[&typeid(atom)] = Atom;
    409447  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
    410   TypeEnumMap[&typeid(element)] = Element;
    411   TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
     448  TypeEnumMap[&typeid(const element)] = Element;
     449  TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
    412450
    413451  // default values for any action that needs one (always string!)
     
    468506  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") );
    469507  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") );
     508  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-element") );
    470509  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
     510  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-cuboid") );
     511  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-sphere") );
    471512  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
     513  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-formula") );
    472514  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") );
    473515  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") );
    474516  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") );
    475517  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") );
     518  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-element") );
    476519  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
     520  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-cuboid") );
     521  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-sphere") );
     522  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-formula") );
    477523  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
    478524  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") );
     
    489535  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
    490536  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
    491   MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
    492537  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
    493538  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
     
    528573  generic.insert("redo");
    529574  generic.insert("remove-atom");
    530   generic.insert("remove-sphere");
    531575  generic.insert("repeat-box");
    532576  generic.insert("rotate-origin");
     
    539583  generic.insert("select-all-atoms");
    540584  generic.insert("select-all-molecules");
     585  generic.insert("select-atom-by-element");
    541586  generic.insert("select-atom-by-id");
     587  generic.insert("select-atoms-inside-cuboid");
     588  generic.insert("select-atoms-inside-sphere");
    542589  generic.insert("select-molecule-by-id");
     590  generic.insert("select-molecule-by-formula");
    543591  generic.insert("select-molecule-of-atom");
    544592  generic.insert("select-molecules-atoms");
     
    552600  generic.insert("unselect-all-atoms");
    553601  generic.insert("unselect-all-molecules");
     602  generic.insert("unselect-atom-by-element");
    554603  generic.insert("unselect-atom-by-id");
     604  generic.insert("unselect-atoms-inside-cuboid");
     605  generic.insert("unselect-atoms-inside-sphere");
     606  generic.insert("unselect-molecule-by-formula");
    555607  generic.insert("unselect-molecule-by-id");
    556608  generic.insert("unselect-molecule-of-atom");
     
    564616
    565617    // hidden arguments
     618  hidden.insert("angle-x");
     619  hidden.insert("angle-y");
     620  hidden.insert("angle-z");
    566621  hidden.insert("bin-end");
    567622  hidden.insert("bin-output-file");
     
    595650}
    596651
     652bool MapOfActions::isCurrentValuePresent(const char *name) const
     653{
     654  return (CurrentValue.find(name) != CurrentValue.end());
     655}
     656
    597657void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
    598658{
     
    608668}
    609669
    610 void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
     670void MapOfActions::queryCurrentValue(const char * name, const element * &_T)  {
    611671  int Z = -1;
    612   if (typeid( element ) == *TypeMap[name]) {
     672  if (typeid(const element ) == *TypeMap[name]) {
    613673    if (CurrentValue.find(name) == CurrentValue.end())
    614674      throw MissingValueException(__FILE__, __LINE__);
     
    692752}
    693753
    694 void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
     754void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
    695755{
    696756  int Z = -1;
    697   element *elemental = NULL;
    698   if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     757  const element *elemental = NULL;
     758  if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
    699759    if (CurrentValue.find(name) == CurrentValue.end())
    700760      throw MissingValueException(__FILE__, __LINE__);
     
    744804}
    745805
    746 void MapOfActions::setCurrentValue(const char * name, class element * &_T)
    747 {
    748   if (typeid( element ) == *TypeMap[name]) {
     806void MapOfActions::setCurrentValue(const char * name, const element * &_T)
     807{
     808  if (typeid(const element ) == *TypeMap[name]) {
    749809    std::ostringstream stream;
    750     stream << _T->Z;
     810    stream << _T->getAtomicNumber();
    751811    CurrentValue[name] = stream.str();
    752812  } else
     
    804864}
    805865
    806 void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
    807 {
    808   if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     866void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
     867{
     868  if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
    809869    std::ostringstream stream;
    810     for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
    811       stream << (*iter)->Z << " ";
     870    for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     871      stream << (*iter)->getAtomicNumber() << " ";
    812872    }
    813873    CurrentValue[name] = stream.str();
     
    873933  new SelectionClearAllMoleculesAction();
    874934  new SelectionAllAtomsAction();
     935  new SelectionAllAtomsInsideCuboidAction();
     936  new SelectionAllAtomsInsideSphereAction();
    875937  new SelectionAllAtomsOfMoleculeAction();
    876938  new SelectionAllMoleculesAction();
     939  new SelectionAtomByElementAction();
    877940  new SelectionAtomByIdAction();
    878941  new SelectionMoleculeByIdAction();
     942  new SelectionMoleculeByFormulaAction();
    879943  new SelectionMoleculeOfAtomAction();
    880944  new SelectionNotAllAtomsAction();
     945  new SelectionNotAllAtomsInsideCuboidAction();
     946  new SelectionNotAllAtomsInsideSphereAction();
    881947  new SelectionNotAllAtomsOfMoleculeAction();
    882948  new SelectionNotAllMoleculesAction();
     949  new SelectionNotAtomByElementAction();
    883950  new SelectionNotAtomByIdAction();
     951  new SelectionNotMoleculeByFormulaAction();
    884952  new SelectionNotMoleculeByIdAction();
    885953  new SelectionNotMoleculeOfAtomAction();
     
    895963  new WorldInputAction();
    896964  new WorldOutputAction();
    897   new WorldRemoveSphereOfAtomsAction();
    898965  new WorldRepeatBoxAction();
    899966  new WorldScaleBoxAction();
Note: See TracChangeset for help on using the changeset viewer.