Changeset d2a077a for src/Actions
- Timestamp:
- May 9, 2017, 12:18:01 PM (8 years ago)
- Branches:
- ForceAnnealing_goodresults, ForceAnnealing_tocheck
- Children:
- 54293d
- Parents:
- e59735
- git-author:
- Frederik Heber <frederik.heber@…> (05/09/17 11:07:11)
- git-committer:
- Frederik Heber <frederik.heber@…> (05/09/17 12:18:01)
- Location:
- src/Actions/SelectionAction/Molecules
- Files:
-
- 2 edited
-
MoleculeByOrderAction.cpp (modified) (3 diffs)
-
MoleculeByOrderAction.def (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/SelectionAction/Molecules/MoleculeByOrderAction.cpp
re59735 rd2a077a 54 54 55 55 ActionState::ptr SelectionMoleculeByOrderAction::performCall() { 56 const molecule *mol = const_cast<const World &>(World::getInstance()). 57 getMolecule(MoleculeByOrder(params.molindex.get())); 56 size_t no_selected = 0; 57 const std::vector<int> &indices = params.molindices.get(); 58 std::vector<const molecule *> mols; 59 for( std::vector<int>::const_iterator iter = indices.begin(); 60 iter != indices.end(); ++iter) { 61 const molecule *mol = const_cast<const World &>(World::getInstance()). 62 getMolecule(MoleculeByOrder(*iter)); 58 63 59 if (mol != NULL) {60 if (!World::getInstance().isSelected(mol)) {61 LOG(1, "Selecting molecule " << mol->name);62 World::getInstance().selectMolecule(mol);63 LOG(0, World::getInstance().countSelectedMolecules() << " molecules selected.");64 return ActionState::ptr(new SelectionMoleculeByOrderState(mol, params));64 if (mol != NULL) { 65 if (!World::getInstance().isSelected(mol)) { 66 //LOG(1, "Selecting molecule " << mol->name); 67 World::getInstance().selectMolecule(mol); 68 mols.push_back(mol); 69 } 65 70 } else { 66 return Action::success; 71 STATUS("Cannot find molecule by given index "+toString(*iter)+"."); 72 return Action::failure; 67 73 } 74 } 75 76 LOG(0, no_selected << " molecules additionally selected."); 77 if (no_selected != 0) { 78 return ActionState::ptr(new SelectionMoleculeByOrderState(mols, params)); 68 79 } else { 69 STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+"."); 70 return Action::failure; 80 return Action::success; 71 81 } 72 82 } … … 75 85 SelectionMoleculeByOrderState *state = assert_cast<SelectionMoleculeByOrderState*>(_state.get()); 76 86 77 World::getInstance().unselectMolecule(state->mol); 87 for (std::vector<const molecule *>::const_iterator iter = state->mols.begin(); 88 iter != state->mols.end(); ++iter) 89 World::getInstance().unselectMolecule(*iter); 78 90 return ActionState::ptr(_state); 79 91 } … … 82 94 SelectionMoleculeByOrderState *state = assert_cast<SelectionMoleculeByOrderState*>(_state.get()); 83 95 84 World::getInstance().selectMolecule(state->mol); 96 for (std::vector<const molecule *>::const_iterator iter = state->mols.begin(); 97 iter != state->mols.end(); ++iter) 98 World::getInstance().selectMolecule(*iter); 85 99 return ActionState::ptr(_state); 86 100 } -
src/Actions/SelectionAction/Molecules/MoleculeByOrderAction.def
re59735 rd2a077a 9 9 class molecule; 10 10 11 #include "Parameters/Validators/ DummyValidator.hpp"11 #include "Parameters/Validators/STLVectorValidator.hpp" 12 12 13 13 // i.e. there is an integer with variable name Z that can be found in 14 14 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 15 15 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 16 #define paramtypes ( int)16 #define paramtypes (std::vector<int>) 17 17 #define paramtokens ("select-molecule-by-order") 18 #define paramdescriptions ("molecule order ind ex, startat 1 or -1")18 #define paramdescriptions ("molecule order indices, starting at 1 or -1") 19 19 #undef paramdefaults 20 #define paramreferences (molind ex)20 #define paramreferences (molindices) 21 21 #define paramvalids \ 22 ( DummyValidator< int >())22 (STLVectorValidator< std::vector< int > >(1, 99)) 23 23 24 #define statetypes ( const molecule *)25 #define statereferences (mol )24 #define statetypes (std::vector<const molecule *>) 25 #define statereferences (mols) 26 26 27 27 // some defines for all the names, you may use ACTION, STATE and PARAMS
Note:
See TracChangeset
for help on using the changeset viewer.
