- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/SelectionAction/Molecules/NotMoleculeByIdAction.cpp
r26b4d62 rd7cad1 53 53 /** =========== define the function ====================== */ 54 54 ActionState::ptr SelectionNotMoleculeByIdAction::performCall() { 55 const molecule *mol = World::getInstance().getMolecule(MoleculeById(params.molindex.get())); 56 if (mol != NULL) { 57 if (World::getInstance().isSelected(mol)) { 58 LOG(1, "Unselecting molecule " << mol->name); 59 World::getInstance().unselectAllMolecules(MoleculeById(params.molindex.get())); 60 LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected."); 61 return ActionState::ptr(new SelectionNotMoleculeByIdState(params)); 55 enum Sucess { 56 NoStatus, 57 AllMoleculesSelected, 58 MoleculesUnselected, 59 MoleculeMissing 60 } status = NoStatus; 61 62 const molids_t molids = params.molids.get(); 63 molids_t undomolids; 64 undomolids.reserve(molids.size()); 65 for (molids_t::const_iterator iter = molids.begin(); iter != molids.end(); ++iter) { 66 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 67 if (Walker != NULL) { 68 if (World::getInstance().isSelected(Walker)) { 69 LOG(1, "Unselecting mol " << Walker->getName()); 70 World::getInstance().unselectMolecule(Walker); 71 undomolids.push_back(*iter); 72 if (status < MoleculeMissing) 73 status = MoleculesUnselected; 74 } else { 75 if (status == NoStatus) 76 status = AllMoleculesSelected; 77 } 62 78 } else { 63 return Action::success;79 status = MoleculeMissing; 64 80 } 65 } else {66 STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+".");67 return Action::failure;68 81 } 82 LOG(0, World::getInstance().countSelectedMolecules() << " mols remain selected."); 83 84 switch (status) { 85 case MoleculeMissing: 86 STATUS("Cannot find all mols by given ids."); 87 return Action::failure; 88 break; 89 case AllMoleculesSelected: 90 case MoleculesUnselected: 91 return ActionState::ptr(new SelectionNotMoleculeByIdState(undomolids, params)); 92 break; 93 default: 94 STATUS("No mols have been selected."); 95 return Action::failure; 96 break; 97 } 98 return Action::failure; 69 99 } 70 100 … … 72 102 SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get()); 73 103 74 World::getInstance().selectAllMolecules(MoleculeById(state->params.molindex.get())); 104 for (molids_t::const_iterator iter = state->undomolids.begin(); 105 iter != state->undomolids.end(); ++iter) { 106 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 107 World::getInstance().selectMolecule(Walker); 108 } 75 109 76 110 return ActionState::ptr(_state); … … 80 114 SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get()); 81 115 82 World::getInstance().unselectAllMolecules(MoleculeById(state->params.molindex.get())); 116 for (molids_t::const_iterator iter = state->undomolids.begin(); 117 iter != state->undomolids.end(); ++iter) { 118 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 119 World::getInstance().unselectMolecule(Walker); 120 } 83 121 84 122 return ActionState::ptr(_state);
Note:
See TracChangeset
for help on using the changeset viewer.