Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MapOfActions.cpp

    r83f176 r446bc1  
    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 
    81/*
    92 * MapOfActions.cpp
     
    125 *      Author: heber
    136 */
    14 
    15 // include config.h
    16 #ifdef HAVE_CONFIG_H
    17 #include <config.h>
    18 #endif
    197
    208#include "Helpers/MemDebug.hpp"
     
    7967#include "Actions/ParserAction/SaveXyzAction.hpp"
    8068#include "Actions/SelectionAction/AllAtomsAction.hpp"
    81 #include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp"
    82 #include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp"
    8369#include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
    8470#include "Actions/SelectionAction/AllMoleculesAction.hpp"
    85 #include "Actions/SelectionAction/AtomByElementAction.hpp"
    8671#include "Actions/SelectionAction/AtomByIdAction.hpp"
    8772#include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
    8873#include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
    89 #include "Actions/SelectionAction/MoleculeByFormulaAction.hpp"
    9074#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
    9175#include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
    9276#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
    93 #include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp"
    94 #include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp"
    9577#include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
    9678#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
    97 #include "Actions/SelectionAction/NotAtomByElementAction.hpp"
    9879#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
    99 #include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp"
    10080#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
    10181#include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
     
    10989#include "Actions/WorldAction/InputAction.hpp"
    11090#include "Actions/WorldAction/OutputAction.hpp"
     91#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
    11192#include "Actions/WorldAction/RepeatBoxAction.hpp"
    11293#include "Actions/WorldAction/ScaleBoxAction.hpp"
     
    231212  DescriptionMap["redo"] = "redo last action";
    232213  DescriptionMap["remove-atom"] = "remove a specified atom";
     214  DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";
    233215  DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
    234216  DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin";
     
    242224  DescriptionMap["select-all-atoms"] = "select all atoms";
    243225  DescriptionMap["select-all-molecules"] = "select all molecules";
    244   DescriptionMap["select-atom-by-element"] = "select an atom by element";
    245226  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";
    248227  DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
    249   DescriptionMap["select-molecule-by-formula"] = "select a molecule by chemical formula";
    250228  DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs";
    251229  DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule";
     
    259237  DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
    260238  DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
    261   DescriptionMap["unselect-atom-by-element"] = "unselect an atom by element";
    262239  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";
    266240  DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
    267241  DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs";
     
    271245  DescriptionMap["version"] = "show version";
    272246  // 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";
    276247  DescriptionMap["bin-output-file"] = "name of the bin output file";
    277248  DescriptionMap["bin-end"] = "start of the last bin";
     
    322293  ShortFormMap["parse-xyz"] = "p";
    323294  ShortFormMap["remove-atom"] = "r";
     295  ShortFormMap["remove-sphere"] = "R";
    324296  ShortFormMap["repeat-box"] = "d";
    325297  ShortFormMap["rotate-to-pas"] = "m";
     
    338310
    339311  // value types for the actions
    340   TypeMap["add-atom"] = &typeid(const element);
     312  TypeMap["add-atom"] = &typeid(element);
    341313  TypeMap["bond-file"] = &typeid(std::string);
    342314  TypeMap["bond-table"] = &typeid(std::string);
     
    344316  TypeMap["center-in-box"] = &typeid(BoxValue);
    345317  TypeMap["change-box"] = &typeid(BoxValue);
    346   TypeMap["change-element"] = &typeid(const element);
     318  TypeMap["change-element"] = &typeid(element);
    347319  TypeMap["change-molname"] = &typeid(std::string);
    348320  TypeMap["clear-atom-selection"] = &typeid(void);
     
    366338  TypeMap["redo"] = &typeid(void);
    367339  TypeMap["remove-atom"] = &typeid(void);
     340  TypeMap["remove-sphere"] = &typeid(double);
    368341  TypeMap["repeat-box"] = &typeid(VectorValue);
    369342  TypeMap["rotate-origin"] = &typeid(double);
     
    376349  TypeMap["select-all-atoms"] = &typeid(void);
    377350  TypeMap["select-all-molecules"] = &typeid(void);
    378   TypeMap["select-atom-by-element"] = &typeid(const element);
    379351  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);
    383352  TypeMap["select-molecule-by-id"] = &typeid(molecule);
    384353  TypeMap["select-molecule-of-atom"] = &typeid(atom);
     
    393362  TypeMap["unselect-all-atoms"] = &typeid(void);
    394363  TypeMap["unselect-all-molecules"] = &typeid(void);
    395   TypeMap["unselect-atom-by-element"] = &typeid(const element);
    396364  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);
    400365  TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
    401366  TypeMap["unselect-molecule-of-atom"] = &typeid(atom);
     
    405370
    406371  // value types for the values
    407   TypeMap["angle-x"] = &typeid(double);
    408   TypeMap["angle-y"] = &typeid(double);
    409   TypeMap["angle-z"] = &typeid(double);
    410372  TypeMap["bin-output-file"] = &typeid(std::string);
    411373  TypeMap["bin-end"] = &typeid(double);
     
    416378  TypeMap["distances"] = &typeid(VectorValue);
    417379  TypeMap["DoRotate"] = &typeid(bool);
    418   TypeMap["element"] = &typeid(const element);
    419   TypeMap["elements"] = &typeid(std::vector<const element *>);
     380  TypeMap["element"] = &typeid(element);
     381  TypeMap["elements"] = &typeid(std::vector<element *>);
    420382  TypeMap["end-step"] = &typeid(int);
    421383  TypeMap["id-mapping"] = &typeid(bool);
     
    446408  TypeEnumMap[&typeid(atom)] = Atom;
    447409  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
    448   TypeEnumMap[&typeid(const element)] = Element;
    449   TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
     410  TypeEnumMap[&typeid(element)] = Element;
     411  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
    450412
    451413  // default values for any action that needs one (always string!)
     
    506468  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") );
    507469  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") );
    508   MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-element") );
    509470  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") );
    512471  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") );
    514472  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") );
    515473  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") );
    516474  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") );
    517475  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") );
    518   MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-element") );
    519476  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") );
    523477  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
    524478  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") );
     
    535489  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
    536490  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
     491  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
    537492  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
    538493  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
     
    573528  generic.insert("redo");
    574529  generic.insert("remove-atom");
     530  generic.insert("remove-sphere");
    575531  generic.insert("repeat-box");
    576532  generic.insert("rotate-origin");
     
    583539  generic.insert("select-all-atoms");
    584540  generic.insert("select-all-molecules");
    585   generic.insert("select-atom-by-element");
    586541  generic.insert("select-atom-by-id");
    587   generic.insert("select-atoms-inside-cuboid");
    588   generic.insert("select-atoms-inside-sphere");
    589542  generic.insert("select-molecule-by-id");
    590   generic.insert("select-molecule-by-formula");
    591543  generic.insert("select-molecule-of-atom");
    592544  generic.insert("select-molecules-atoms");
     
    600552  generic.insert("unselect-all-atoms");
    601553  generic.insert("unselect-all-molecules");
    602   generic.insert("unselect-atom-by-element");
    603554  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");
    607555  generic.insert("unselect-molecule-by-id");
    608556  generic.insert("unselect-molecule-of-atom");
     
    616564
    617565    // hidden arguments
    618   hidden.insert("angle-x");
    619   hidden.insert("angle-y");
    620   hidden.insert("angle-z");
    621566  hidden.insert("bin-end");
    622567  hidden.insert("bin-output-file");
     
    650595}
    651596
    652 bool MapOfActions::isCurrentValuePresent(const char *name) const
    653 {
    654   return (CurrentValue.find(name) != CurrentValue.end());
    655 }
    656 
    657597void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
    658598{
     
    668608}
    669609
    670 void MapOfActions::queryCurrentValue(const char * name, const element * &_T)  {
     610void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
    671611  int Z = -1;
    672   if (typeid(const element ) == *TypeMap[name]) {
     612  if (typeid( element ) == *TypeMap[name]) {
    673613    if (CurrentValue.find(name) == CurrentValue.end())
    674614      throw MissingValueException(__FILE__, __LINE__);
     
    752692}
    753693
    754 void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
     694void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
    755695{
    756696  int Z = -1;
    757   const element *elemental = NULL;
    758   if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     697  element *elemental = NULL;
     698  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
    759699    if (CurrentValue.find(name) == CurrentValue.end())
    760700      throw MissingValueException(__FILE__, __LINE__);
     
    804744}
    805745
    806 void MapOfActions::setCurrentValue(const char * name, const element * &_T)
    807 {
    808   if (typeid(const element ) == *TypeMap[name]) {
     746void MapOfActions::setCurrentValue(const char * name, class element * &_T)
     747{
     748  if (typeid( element ) == *TypeMap[name]) {
    809749    std::ostringstream stream;
    810     stream << _T->getAtomicNumber();
     750    stream << _T->Z;
    811751    CurrentValue[name] = stream.str();
    812752  } else
     
    864804}
    865805
    866 void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
    867 {
    868   if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     806void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
     807{
     808  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
    869809    std::ostringstream stream;
    870     for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
    871       stream << (*iter)->getAtomicNumber() << " ";
     810    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     811      stream << (*iter)->Z << " ";
    872812    }
    873813    CurrentValue[name] = stream.str();
     
    933873  new SelectionClearAllMoleculesAction();
    934874  new SelectionAllAtomsAction();
    935   new SelectionAllAtomsInsideCuboidAction();
    936   new SelectionAllAtomsInsideSphereAction();
    937875  new SelectionAllAtomsOfMoleculeAction();
    938876  new SelectionAllMoleculesAction();
    939   new SelectionAtomByElementAction();
    940877  new SelectionAtomByIdAction();
    941878  new SelectionMoleculeByIdAction();
    942   new SelectionMoleculeByFormulaAction();
    943879  new SelectionMoleculeOfAtomAction();
    944880  new SelectionNotAllAtomsAction();
    945   new SelectionNotAllAtomsInsideCuboidAction();
    946   new SelectionNotAllAtomsInsideSphereAction();
    947881  new SelectionNotAllAtomsOfMoleculeAction();
    948882  new SelectionNotAllMoleculesAction();
    949   new SelectionNotAtomByElementAction();
    950883  new SelectionNotAtomByIdAction();
    951   new SelectionNotMoleculeByFormulaAction();
    952884  new SelectionNotMoleculeByIdAction();
    953885  new SelectionNotMoleculeOfAtomAction();
     
    963895  new WorldInputAction();
    964896  new WorldOutputAction();
     897  new WorldRemoveSphereOfAtomsAction();
    965898  new WorldRepeatBoxAction();
    966899  new WorldScaleBoxAction();
Note: See TracChangeset for help on using the changeset viewer.