Changes in src/Actions/MapOfActions.cpp [446bc1:83f176]
- 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 1 8 /* 2 9 * MapOfActions.cpp … … 5 12 * Author: heber 6 13 */ 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 7 19 8 20 #include "Helpers/MemDebug.hpp" … … 67 79 #include "Actions/ParserAction/SaveXyzAction.hpp" 68 80 #include "Actions/SelectionAction/AllAtomsAction.hpp" 81 #include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp" 82 #include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp" 69 83 #include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp" 70 84 #include "Actions/SelectionAction/AllMoleculesAction.hpp" 85 #include "Actions/SelectionAction/AtomByElementAction.hpp" 71 86 #include "Actions/SelectionAction/AtomByIdAction.hpp" 72 87 #include "Actions/SelectionAction/ClearAllAtomsAction.hpp" 73 88 #include "Actions/SelectionAction/ClearAllMoleculesAction.hpp" 89 #include "Actions/SelectionAction/MoleculeByFormulaAction.hpp" 74 90 #include "Actions/SelectionAction/MoleculeByIdAction.hpp" 75 91 #include "Actions/SelectionAction/MoleculeOfAtomAction.hpp" 76 92 #include "Actions/SelectionAction/NotAllAtomsAction.hpp" 93 #include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp" 94 #include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp" 77 95 #include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp" 78 96 #include "Actions/SelectionAction/NotAllMoleculesAction.hpp" 97 #include "Actions/SelectionAction/NotAtomByElementAction.hpp" 79 98 #include "Actions/SelectionAction/NotAtomByIdAction.hpp" 99 #include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp" 80 100 #include "Actions/SelectionAction/NotMoleculeByIdAction.hpp" 81 101 #include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp" … … 89 109 #include "Actions/WorldAction/InputAction.hpp" 90 110 #include "Actions/WorldAction/OutputAction.hpp" 91 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"92 111 #include "Actions/WorldAction/RepeatBoxAction.hpp" 93 112 #include "Actions/WorldAction/ScaleBoxAction.hpp" … … 212 231 DescriptionMap["redo"] = "redo last action"; 213 232 DescriptionMap["remove-atom"] = "remove a specified atom"; 214 DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";215 233 DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis"; 216 234 DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin"; … … 224 242 DescriptionMap["select-all-atoms"] = "select all atoms"; 225 243 DescriptionMap["select-all-molecules"] = "select all molecules"; 244 DescriptionMap["select-atom-by-element"] = "select an atom by element"; 226 245 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"; 227 248 DescriptionMap["select-molecule-by-id"] = "select a molecule by index"; 249 DescriptionMap["select-molecule-by-formula"] = "select a molecule by chemical formula"; 228 250 DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs"; 229 251 DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule"; … … 237 259 DescriptionMap["unselect-all-atoms"] = "unselect all atoms"; 238 260 DescriptionMap["unselect-all-molecules"] = "unselect all molecules"; 261 DescriptionMap["unselect-atom-by-element"] = "unselect an atom by element"; 239 262 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"; 240 266 DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index"; 241 267 DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs"; … … 245 271 DescriptionMap["version"] = "show version"; 246 272 // 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"; 247 276 DescriptionMap["bin-output-file"] = "name of the bin output file"; 248 277 DescriptionMap["bin-end"] = "start of the last bin"; … … 293 322 ShortFormMap["parse-xyz"] = "p"; 294 323 ShortFormMap["remove-atom"] = "r"; 295 ShortFormMap["remove-sphere"] = "R";296 324 ShortFormMap["repeat-box"] = "d"; 297 325 ShortFormMap["rotate-to-pas"] = "m"; … … 310 338 311 339 // value types for the actions 312 TypeMap["add-atom"] = &typeid( element);340 TypeMap["add-atom"] = &typeid(const element); 313 341 TypeMap["bond-file"] = &typeid(std::string); 314 342 TypeMap["bond-table"] = &typeid(std::string); … … 316 344 TypeMap["center-in-box"] = &typeid(BoxValue); 317 345 TypeMap["change-box"] = &typeid(BoxValue); 318 TypeMap["change-element"] = &typeid( element);346 TypeMap["change-element"] = &typeid(const element); 319 347 TypeMap["change-molname"] = &typeid(std::string); 320 348 TypeMap["clear-atom-selection"] = &typeid(void); … … 338 366 TypeMap["redo"] = &typeid(void); 339 367 TypeMap["remove-atom"] = &typeid(void); 340 TypeMap["remove-sphere"] = &typeid(double);341 368 TypeMap["repeat-box"] = &typeid(VectorValue); 342 369 TypeMap["rotate-origin"] = &typeid(double); … … 349 376 TypeMap["select-all-atoms"] = &typeid(void); 350 377 TypeMap["select-all-molecules"] = &typeid(void); 378 TypeMap["select-atom-by-element"] = &typeid(const element); 351 379 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); 352 383 TypeMap["select-molecule-by-id"] = &typeid(molecule); 353 384 TypeMap["select-molecule-of-atom"] = &typeid(atom); … … 362 393 TypeMap["unselect-all-atoms"] = &typeid(void); 363 394 TypeMap["unselect-all-molecules"] = &typeid(void); 395 TypeMap["unselect-atom-by-element"] = &typeid(const element); 364 396 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); 365 400 TypeMap["unselect-molecule-by-id"] = &typeid(molecule); 366 401 TypeMap["unselect-molecule-of-atom"] = &typeid(atom); … … 370 405 371 406 // value types for the values 407 TypeMap["angle-x"] = &typeid(double); 408 TypeMap["angle-y"] = &typeid(double); 409 TypeMap["angle-z"] = &typeid(double); 372 410 TypeMap["bin-output-file"] = &typeid(std::string); 373 411 TypeMap["bin-end"] = &typeid(double); … … 378 416 TypeMap["distances"] = &typeid(VectorValue); 379 417 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 *>); 382 420 TypeMap["end-step"] = &typeid(int); 383 421 TypeMap["id-mapping"] = &typeid(bool); … … 408 446 TypeEnumMap[&typeid(atom)] = Atom; 409 447 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; 412 450 413 451 // default values for any action that needs one (always string!) … … 468 506 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") ); 469 507 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") ); 508 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-element") ); 470 509 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") ); 471 512 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") ); 472 514 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") ); 473 515 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") ); 474 516 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") ); 475 517 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") ); 518 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-element") ); 476 519 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") ); 477 523 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") ); 478 524 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") ); … … 489 535 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") ); 490 536 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") ); 491 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );492 537 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") ); 493 538 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") ); … … 528 573 generic.insert("redo"); 529 574 generic.insert("remove-atom"); 530 generic.insert("remove-sphere");531 575 generic.insert("repeat-box"); 532 576 generic.insert("rotate-origin"); … … 539 583 generic.insert("select-all-atoms"); 540 584 generic.insert("select-all-molecules"); 585 generic.insert("select-atom-by-element"); 541 586 generic.insert("select-atom-by-id"); 587 generic.insert("select-atoms-inside-cuboid"); 588 generic.insert("select-atoms-inside-sphere"); 542 589 generic.insert("select-molecule-by-id"); 590 generic.insert("select-molecule-by-formula"); 543 591 generic.insert("select-molecule-of-atom"); 544 592 generic.insert("select-molecules-atoms"); … … 552 600 generic.insert("unselect-all-atoms"); 553 601 generic.insert("unselect-all-molecules"); 602 generic.insert("unselect-atom-by-element"); 554 603 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"); 555 607 generic.insert("unselect-molecule-by-id"); 556 608 generic.insert("unselect-molecule-of-atom"); … … 564 616 565 617 // hidden arguments 618 hidden.insert("angle-x"); 619 hidden.insert("angle-y"); 620 hidden.insert("angle-z"); 566 621 hidden.insert("bin-end"); 567 622 hidden.insert("bin-output-file"); … … 595 650 } 596 651 652 bool MapOfActions::isCurrentValuePresent(const char *name) const 653 { 654 return (CurrentValue.find(name) != CurrentValue.end()); 655 } 656 597 657 void MapOfActions::queryCurrentValue(const char * name, class atom * &_T) 598 658 { … … 608 668 } 609 669 610 void MapOfActions::queryCurrentValue(const char * name, c lasselement * &_T) {670 void MapOfActions::queryCurrentValue(const char * name, const element * &_T) { 611 671 int Z = -1; 612 if (typeid( element ) == *TypeMap[name]) {672 if (typeid(const element ) == *TypeMap[name]) { 613 673 if (CurrentValue.find(name) == CurrentValue.end()) 614 674 throw MissingValueException(__FILE__, __LINE__); … … 692 752 } 693 753 694 void MapOfActions::queryCurrentValue(const char * name, std::vector< element *>&_T)754 void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T) 695 755 { 696 756 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]) { 699 759 if (CurrentValue.find(name) == CurrentValue.end()) 700 760 throw MissingValueException(__FILE__, __LINE__); … … 744 804 } 745 805 746 void MapOfActions::setCurrentValue(const char * name, c lasselement * &_T)747 { 748 if (typeid( element ) == *TypeMap[name]) {806 void MapOfActions::setCurrentValue(const char * name, const element * &_T) 807 { 808 if (typeid(const element ) == *TypeMap[name]) { 749 809 std::ostringstream stream; 750 stream << _T-> Z;810 stream << _T->getAtomicNumber(); 751 811 CurrentValue[name] = stream.str(); 752 812 } else … … 804 864 } 805 865 806 void MapOfActions::setCurrentValue(const char * name, std::vector< element *>&_T)807 { 808 if (typeid( std::vector< element *> ) == *TypeMap[name]) {866 void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T) 867 { 868 if (typeid( std::vector<const element *> ) == *TypeMap[name]) { 809 869 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() << " "; 812 872 } 813 873 CurrentValue[name] = stream.str(); … … 873 933 new SelectionClearAllMoleculesAction(); 874 934 new SelectionAllAtomsAction(); 935 new SelectionAllAtomsInsideCuboidAction(); 936 new SelectionAllAtomsInsideSphereAction(); 875 937 new SelectionAllAtomsOfMoleculeAction(); 876 938 new SelectionAllMoleculesAction(); 939 new SelectionAtomByElementAction(); 877 940 new SelectionAtomByIdAction(); 878 941 new SelectionMoleculeByIdAction(); 942 new SelectionMoleculeByFormulaAction(); 879 943 new SelectionMoleculeOfAtomAction(); 880 944 new SelectionNotAllAtomsAction(); 945 new SelectionNotAllAtomsInsideCuboidAction(); 946 new SelectionNotAllAtomsInsideSphereAction(); 881 947 new SelectionNotAllAtomsOfMoleculeAction(); 882 948 new SelectionNotAllMoleculesAction(); 949 new SelectionNotAtomByElementAction(); 883 950 new SelectionNotAtomByIdAction(); 951 new SelectionNotMoleculeByFormulaAction(); 884 952 new SelectionNotMoleculeByIdAction(); 885 953 new SelectionNotMoleculeOfAtomAction(); … … 895 963 new WorldInputAction(); 896 964 new WorldOutputAction(); 897 new WorldRemoveSphereOfAtomsAction();898 965 new WorldRepeatBoxAction(); 899 966 new WorldScaleBoxAction();
Note:
See TracChangeset
for help on using the changeset viewer.