Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.cpp

    r654394 re4afb4  
    3434#include "Descriptors/MoleculeDescriptor_impl.hpp"
    3535#include "Descriptors/SelectiveIterator_impl.hpp"
     36#include "Actions/ActionTraits.hpp"
    3637#include "Actions/ManipulateAtomsProcess.hpp"
    3738#include "Helpers/Assert.hpp"
     
    245246
    246247ManipulateAtomsProcess* 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);
    248250}
    249251
     
    535537}
    536538
    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){
     539void 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
     545void World::selectAtom(const atomId_t id){
    543546  ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
    544547  selectedAtoms[id]=atoms[id];
     
    548551  internal_AtomIterator begin = getAtomIter_internal(descr);
    549552  internal_AtomIterator end = atomEnd_internal();
    550   void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
     553  void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
    551554  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
    552555}
    553556
    554 void World::selectAtomsOfMolecule(molecule *_mol){
     557void World::selectAtomsOfMolecule(const molecule *_mol){
    555558  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
    556559  // need to make it const to get the fast iterators
    557560  const molecule *mol = _mol;
    558   void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
     561  void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
    559562  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
    560563}
    561564
    562 void World::selectAtomsOfMolecule(moleculeId_t id){
     565void World::selectAtomsOfMolecule(const moleculeId_t id){
    563566  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
    564567  selectAtomsOfMolecule(molecules[id]);
    565568}
    566569
    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){
     570void World::unselectAtom(const atom *_atom){
     571  ASSERT(_atom,"Invalid pointer in unselection of atom");
     572  unselectAtom(_atom->getId());
     573}
     574
     575void World::unselectAtom(const atomId_t id){
    573576  ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
    574577  selectedAtoms.erase(id);
     
    578581  internal_AtomIterator begin = getAtomIter_internal(descr);
    579582  internal_AtomIterator end = atomEnd_internal();
    580   void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
     583  void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
    581584  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
    582585}
    583586
    584 void World::unselectAtomsOfMolecule(molecule *_mol){
     587void World::unselectAtomsOfMolecule(const molecule *_mol){
    585588  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
    586589  // need to make it const to get the fast iterators
    587590  const molecule *mol = _mol;
    588   void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
     591  void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
    589592  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above
    590593}
    591594
    592 void World::unselectAtomsOfMolecule(moleculeId_t id){
     595void World::unselectAtomsOfMolecule(const moleculeId_t id){
    593596  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
    594597  unselectAtomsOfMolecule(molecules[id]);
     
    602605}
    603606
    604 bool World::isSelected(atom *atom) const {
    605   return selectedAtoms.find(atom->getId()) != selectedAtoms.end();
     607bool World::isSelected(const atom *_atom) const {
     608  return selectedAtoms.find(_atom->getId()) != selectedAtoms.end();
    606609}
    607610
     
    622625}
    623626
    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){
     627void 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
     633void World::selectMolecule(const moleculeId_t id){
    630634  ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
    631635  selectedMolecules[id]=molecules[id];
     
    635639  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
    636640  internal_MoleculeIterator end = moleculeEnd_internal();
    637   void (World::*func)(molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
     641  void (World::*func)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
    638642  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
    639643}
    640644
    641 void World::selectMoleculeOfAtom(atom *atom){
    642   ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
    643   molecule *mol=atom->getMolecule();
     645void World::selectMoleculeOfAtom(const atom *_atom){
     646  ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
     647  molecule *mol=_atom->getMolecule();
    644648  // the atom might not be part of a molecule
    645649  if(mol){
     
    648652}
    649653
    650 void World::selectMoleculeOfAtom(atomId_t id){
     654void World::selectMoleculeOfAtom(const atomId_t id){
    651655  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
    652656  selectMoleculeOfAtom(atoms[id]);
    653657}
    654658
    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){
     659void World::unselectMolecule(const molecule *_mol){
     660  ASSERT(_mol,"invalid pointer in unselection of molecule");
     661  unselectMolecule(_mol->getId());
     662}
     663
     664void World::unselectMolecule(const moleculeId_t id){
    661665  ASSERT(molecules.count(id),"No such molecule with ID in unselection");
    662666  selectedMolecules.erase(id);
     
    666670  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
    667671  internal_MoleculeIterator end = moleculeEnd_internal();
    668   void (World::*func)(molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
     672  void (World::*func)(const molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
    669673  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
    670674}
    671675
    672 void World::unselectMoleculeOfAtom(atom *atom){
    673   ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
    674   molecule *mol=atom->getMolecule();
     676void World::unselectMoleculeOfAtom(const atom *_atom){
     677  ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
     678  molecule *mol=_atom->getMolecule();
    675679  // the atom might not be part of a molecule
    676680  if(mol){
     
    679683}
    680684
    681 void World::unselectMoleculeOfAtom(atomId_t id){
     685void World::unselectMoleculeOfAtom(const atomId_t id){
    682686  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
    683687  unselectMoleculeOfAtom(atoms[id]);
     
    691695}
    692696
    693 bool World::isSelected(molecule *mol) const {
    694   return selectedMolecules.find(mol->getId()) != selectedMolecules.end();
     697bool World::isSelected(const molecule *_mol) const {
     698  return selectedMolecules.find(_mol->getId()) != selectedMolecules.end();
    695699}
    696700
Note: See TracChangeset for help on using the changeset viewer.