Changes in src/World.cpp [654394:e4afb4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/World.cpp
r654394 re4afb4 34 34 #include "Descriptors/MoleculeDescriptor_impl.hpp" 35 35 #include "Descriptors/SelectiveIterator_impl.hpp" 36 #include "Actions/ActionTraits.hpp" 36 37 #include "Actions/ManipulateAtomsProcess.hpp" 37 38 #include "Helpers/Assert.hpp" … … 245 246 246 247 ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name,AtomDescriptor descr){ 247 return new ManipulateAtomsProcess(op, descr,name,true); 248 ActionTraits manipulateTrait(name); 249 return new ManipulateAtomsProcess(op, descr,manipulateTrait,false); 248 250 } 249 251 … … 535 537 } 536 538 537 void World::selectAtom(atom *atom){ 538 ASSERT(atom,"Invalid pointer in selection of atom"); 539 selectedAtoms[atom->getId()]=atom; 540 } 541 542 void World::selectAtom(atomId_t id){ 539 void World::selectAtom(const atom *_atom){ 540 // atom * is unchanged in this function, but we do store entity as changeable 541 ASSERT(_atom,"Invalid pointer in selection of atom"); 542 selectedAtoms[_atom->getId()]=const_cast<atom *>(_atom); 543 } 544 545 void World::selectAtom(const atomId_t id){ 543 546 ASSERT(atoms.count(id),"Atom Id selected that was not in the world"); 544 547 selectedAtoms[id]=atoms[id]; … … 548 551 internal_AtomIterator begin = getAtomIter_internal(descr); 549 552 internal_AtomIterator end = atomEnd_internal(); 550 void (World::*func)( atom*) = &World::selectAtom; // needed for type resolution of overloaded function553 void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function 551 554 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above 552 555 } 553 556 554 void World::selectAtomsOfMolecule( molecule *_mol){557 void World::selectAtomsOfMolecule(const molecule *_mol){ 555 558 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule"); 556 559 // need to make it const to get the fast iterators 557 560 const molecule *mol = _mol; 558 void (World::*func)( atom*) = &World::selectAtom; // needed for type resolution of overloaded function561 void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function 559 562 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above 560 563 } 561 564 562 void World::selectAtomsOfMolecule( moleculeId_t id){565 void World::selectAtomsOfMolecule(const moleculeId_t id){ 563 566 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule"); 564 567 selectAtomsOfMolecule(molecules[id]); 565 568 } 566 569 567 void World::unselectAtom( atom *atom){568 ASSERT( atom,"Invalid pointer in unselection of atom");569 unselectAtom( atom->getId());570 } 571 572 void World::unselectAtom( atomId_t id){570 void World::unselectAtom(const atom *_atom){ 571 ASSERT(_atom,"Invalid pointer in unselection of atom"); 572 unselectAtom(_atom->getId()); 573 } 574 575 void World::unselectAtom(const atomId_t id){ 573 576 ASSERT(atoms.count(id),"Atom Id unselected that was not in the world"); 574 577 selectedAtoms.erase(id); … … 578 581 internal_AtomIterator begin = getAtomIter_internal(descr); 579 582 internal_AtomIterator end = atomEnd_internal(); 580 void (World::*func)( atom*) = &World::unselectAtom; // needed for type resolution of overloaded function583 void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function 581 584 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above 582 585 } 583 586 584 void World::unselectAtomsOfMolecule( molecule *_mol){587 void World::unselectAtomsOfMolecule(const molecule *_mol){ 585 588 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule"); 586 589 // need to make it const to get the fast iterators 587 590 const molecule *mol = _mol; 588 void (World::*func)( atom*) = &World::unselectAtom; // needed for type resolution of overloaded function591 void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function 589 592 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above 590 593 } 591 594 592 void World::unselectAtomsOfMolecule( moleculeId_t id){595 void World::unselectAtomsOfMolecule(const moleculeId_t id){ 593 596 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule"); 594 597 unselectAtomsOfMolecule(molecules[id]); … … 602 605 } 603 606 604 bool World::isSelected( atom *atom) const {605 return selectedAtoms.find( atom->getId()) != selectedAtoms.end();607 bool World::isSelected(const atom *_atom) const { 608 return selectedAtoms.find(_atom->getId()) != selectedAtoms.end(); 606 609 } 607 610 … … 622 625 } 623 626 624 void World::selectMolecule(molecule *mol){ 625 ASSERT(mol,"Invalid pointer to molecule in selection"); 626 selectedMolecules[mol->getId()]=mol; 627 } 628 629 void World::selectMolecule(moleculeId_t id){ 627 void World::selectMolecule(const molecule *_mol){ 628 // molecule * is unchanged in this function, but we do store entity as changeable 629 ASSERT(_mol,"Invalid pointer to molecule in selection"); 630 selectedMolecules[_mol->getId()]=const_cast<molecule *>(_mol); 631 } 632 633 void World::selectMolecule(const moleculeId_t id){ 630 634 ASSERT(molecules.count(id),"Molecule Id selected that was not in the world"); 631 635 selectedMolecules[id]=molecules[id]; … … 635 639 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 636 640 internal_MoleculeIterator end = moleculeEnd_internal(); 637 void (World::*func)( molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function641 void (World::*func)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function 638 642 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above 639 643 } 640 644 641 void World::selectMoleculeOfAtom( atom *atom){642 ASSERT( atom,"Invalid atom pointer in selection of MoleculeOfAtom");643 molecule *mol= atom->getMolecule();645 void World::selectMoleculeOfAtom(const atom *_atom){ 646 ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom"); 647 molecule *mol=_atom->getMolecule(); 644 648 // the atom might not be part of a molecule 645 649 if(mol){ … … 648 652 } 649 653 650 void World::selectMoleculeOfAtom( atomId_t id){654 void World::selectMoleculeOfAtom(const atomId_t id){ 651 655 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 652 656 selectMoleculeOfAtom(atoms[id]); 653 657 } 654 658 655 void World::unselectMolecule( molecule *mol){656 ASSERT( mol,"invalid pointer in unselection of molecule");657 unselectMolecule( mol->getId());658 } 659 660 void World::unselectMolecule( moleculeId_t id){659 void World::unselectMolecule(const molecule *_mol){ 660 ASSERT(_mol,"invalid pointer in unselection of molecule"); 661 unselectMolecule(_mol->getId()); 662 } 663 664 void World::unselectMolecule(const moleculeId_t id){ 661 665 ASSERT(molecules.count(id),"No such molecule with ID in unselection"); 662 666 selectedMolecules.erase(id); … … 666 670 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 667 671 internal_MoleculeIterator end = moleculeEnd_internal(); 668 void (World::*func)( molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function672 void (World::*func)(const molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function 669 673 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above 670 674 } 671 675 672 void World::unselectMoleculeOfAtom( atom *atom){673 ASSERT( atom,"Invalid atom pointer in selection of MoleculeOfAtom");674 molecule *mol= atom->getMolecule();676 void World::unselectMoleculeOfAtom(const atom *_atom){ 677 ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom"); 678 molecule *mol=_atom->getMolecule(); 675 679 // the atom might not be part of a molecule 676 680 if(mol){ … … 679 683 } 680 684 681 void World::unselectMoleculeOfAtom( atomId_t id){685 void World::unselectMoleculeOfAtom(const atomId_t id){ 682 686 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 683 687 unselectMoleculeOfAtom(atoms[id]); … … 691 695 } 692 696 693 bool World::isSelected( molecule *mol) const {694 return selectedMolecules.find( mol->getId()) != selectedMolecules.end();697 bool World::isSelected(const molecule *_mol) const { 698 return selectedMolecules.find(_mol->getId()) != selectedMolecules.end(); 695 699 } 696 700
Note:
See TracChangeset
for help on using the changeset viewer.