Changeset 0716eac for src/Actions
- Timestamp:
- Jul 12, 2017, 7:10:22 PM (8 years ago)
- Branches:
- Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- 3b74fa
- Parents:
- f56e14
- git-author:
- Frederik Heber <frederik.heber@…> (05/09/17 11:07:11)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/12/17 19:10:22)
- Location:
- src/Actions/SelectionAction
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/SelectionAction/Atoms/AtomByOrderAction.cpp
rf56e14 r0716eac 54 54 /** =========== define the function ====================== */ 55 55 ActionState::ptr SelectionAtomByOrderAction::performCall() { 56 const atom *Walker = const_cast<const World &>(World::getInstance()). 57 getAtom(AtomByOrder(params.order.get())); 58 if (Walker != NULL) { 59 if (!World::getInstance().isSelected(Walker)) { 60 LOG(1, "Selecting atom " << *Walker); 61 World::getInstance().selectAtom(Walker); 62 LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected."); 63 return ActionState::ptr(new SelectionAtomByOrderState(Walker->getId(), params)); 56 size_t no_selected = 0; 57 const std::vector<int> &indices = params.orders.get(); 58 std::vector<atomId_t> atomids; 59 const World &const_world = World::getConstInstance(); 60 World &world = World::getInstance(); 61 for( std::vector<int>::const_iterator iter = indices.begin(); 62 iter != indices.end(); ++iter) { 63 const atom * const walker = const_world.getAtom(AtomByOrder(*iter)); 64 65 if (walker != NULL) { 66 if (!const_world.isSelected(walker)) { 67 //LOG(1, "Selecting atom " << *walker); 68 world.selectAtom(walker); 69 atomids.push_back(walker->getId()); 70 ++no_selected; 71 } 64 72 } else { 65 return Action::success; 73 STATUS("Cannot find atom by given index "+toString(*iter)+"."); 74 return Action::failure; 66 75 } 76 } 77 78 LOG(0, no_selected << " atoms additionally selected."); 79 if (no_selected != 0) { 80 return ActionState::ptr(new SelectionAtomByOrderState(atomids, params)); 67 81 } else { 68 STATUS("Cannot find atom by given order of "+toString(params.order.get())+"."); 69 return Action::failure; 82 return Action::success; 70 83 } 71 84 } … … 74 87 SelectionAtomByOrderState *state = assert_cast<SelectionAtomByOrderState*>(_state.get()); 75 88 76 World::getInstance().unselectAllAtoms(AtomById(state->WalkerId)); 89 World &world = World::getInstance(); 90 for (std::vector<atomId_t>::const_iterator iter = state->WalkerIds.begin(); 91 iter != state->WalkerIds.end(); ++iter) 92 world.unselectAllAtoms(AtomById(*iter)); 77 93 78 94 return ActionState::ptr(_state); … … 82 98 SelectionAtomByOrderState *state = assert_cast<SelectionAtomByOrderState*>(_state.get()); 83 99 84 World::getInstance().selectAllAtoms(AtomById(state->WalkerId)); 100 World &world = World::getInstance(); 101 for (std::vector<atomId_t>::const_iterator iter = state->WalkerIds.begin(); 102 iter != state->WalkerIds.end(); ++iter) 103 world.selectAllAtoms(AtomById(*iter)); 85 104 86 105 return ActionState::ptr(_state); -
src/Actions/SelectionAction/Atoms/AtomByOrderAction.def
rf56e14 r0716eac 9 9 class atom; 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-atom-by-order") 18 #define paramdescriptions ("order index")18 #define paramdescriptions ("order order indices, starting at 1 or -1") 19 19 #undef paramdefaults 20 #define paramreferences (order )20 #define paramreferences (orders) 21 21 #define paramvalids \ 22 ( DummyValidator< int >())22 (STLVectorValidator< std::vector< int > >(1, 99)) 23 23 24 #define statetypes ( atomId_t)25 #define statereferences (WalkerId )24 #define statetypes (std::vector<atomId_t>) 25 #define statereferences (WalkerIds) 26 26 27 27 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp
rf56e14 r0716eac 54 54 /** =========== define the function ====================== */ 55 55 ActionState::ptr SelectionNotAtomByOrderAction::performCall() { 56 const atom * Walker = const_cast<const World &>(World::getInstance()). 57 getAtom(AtomByOrder(params.order.get())); 58 if (Walker != NULL) { 59 if (World::getInstance().isSelected(Walker)) { 60 LOG(1, "Unselecting atom " << *Walker); 61 World::getInstance().unselectAtom(Walker); 62 LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected."); 63 return ActionState::ptr(new SelectionNotAtomByOrderState(Walker->getId(), params)); 56 size_t no_unselected = 0; 57 const std::vector<int> &indices = params.orders.get(); 58 std::vector<atomId_t> atomids; 59 const World &const_world = World::getConstInstance(); 60 World &world = World::getInstance(); 61 for( std::vector<int>::const_iterator iter = indices.begin(); 62 iter != indices.end(); ++iter) { 63 const atom * const walker = const_world.getAtom(AtomByOrder(*iter)); 64 65 if (walker != NULL) { 66 if (const_world.isSelected(walker)) { 67 //LOG(1, "Unselecting atom " << *walker); 68 world.unselectAtom(walker); 69 atomids.push_back(walker->getId()); 70 ++no_unselected; 71 } 64 72 } else { 65 return Action::success; 73 STATUS("Cannot find atom by given index "+toString(*iter)+"."); 74 return Action::failure; 66 75 } 76 } 77 78 LOG(0, no_unselected << " atoms additionally unselected."); 79 if (no_unselected != 0) { 80 return ActionState::ptr(new SelectionNotAtomByOrderState(atomids, params)); 67 81 } else { 68 STATUS("Cannot find atom by given order of "+toString(params.order.get())+"."); 69 return Action::failure; 82 return Action::success; 70 83 } 71 84 } … … 74 87 SelectionNotAtomByOrderState *state = assert_cast<SelectionNotAtomByOrderState*>(_state.get()); 75 88 76 World::getInstance().selectAllAtoms(AtomById(state->WalkerId)); 89 World &world = World::getInstance(); 90 for (std::vector<atomId_t>::const_iterator iter = state->WalkerIds.begin(); 91 iter != state->WalkerIds.end(); ++iter) 92 world.selectAllAtoms(AtomById(*iter)); 77 93 78 94 return ActionState::ptr(_state); … … 82 98 SelectionNotAtomByOrderState *state = assert_cast<SelectionNotAtomByOrderState*>(_state.get()); 83 99 84 World::getInstance().unselectAllAtoms(AtomById(state->WalkerId)); 100 World &world = World::getInstance(); 101 for (std::vector<atomId_t>::const_iterator iter = state->WalkerIds.begin(); 102 iter != state->WalkerIds.end(); ++iter) 103 world.unselectAllAtoms(AtomById(*iter)); 85 104 86 105 return ActionState::ptr(_state); -
src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.def
rf56e14 r0716eac 9 9 class atom; 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 ("unselect-atom-by-order") 18 #define paramdescriptions ("order index")18 #define paramdescriptions ("order order indices, starting at 1 or -1") 19 19 #undef paramdefaults 20 #define paramreferences (order )20 #define paramreferences (orders) 21 21 #define paramvalids \ 22 ( DummyValidator< int >())22 (STLVectorValidator< std::vector< int > >(1, 99)) 23 23 24 #define statetypes ( atomId_t)25 #define statereferences (WalkerId )24 #define statetypes (std::vector<atomId_t>) 25 #define statereferences (WalkerIds) 26 26 27 27 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/SelectionAction/Molecules/MoleculeByOrderAction.cpp
rf56e14 r0716eac 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 const World &const_world = World::getConstInstance(); 60 World &world = World::getInstance(); 61 for( std::vector<int>::const_iterator iter = indices.begin(); 62 iter != indices.end(); ++iter) { 63 const molecule *mol = const_world.getMolecule(MoleculeByOrder(*iter)); 58 64 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)); 65 if (mol != NULL) { 66 if (!const_world.isSelected(mol)) { 67 //LOG(1, "Selecting molecule " << mol->name); 68 world.selectMolecule(mol); 69 mols.push_back(mol); 70 ++no_selected; 71 } 65 72 } else { 66 return Action::success; 73 STATUS("Cannot find molecule by given index "+toString(*iter)+"."); 74 return Action::failure; 67 75 } 76 } 77 78 LOG(0, no_selected << " molecules additionally selected."); 79 if (no_selected != 0) { 80 return ActionState::ptr(new SelectionMoleculeByOrderState(mols, params)); 68 81 } else { 69 STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+"."); 70 return Action::failure; 82 return Action::success; 71 83 } 72 84 } … … 75 87 SelectionMoleculeByOrderState *state = assert_cast<SelectionMoleculeByOrderState*>(_state.get()); 76 88 77 World::getInstance().unselectMolecule(state->mol); 89 World &world = World::getInstance(); 90 for (std::vector<const molecule *>::const_iterator iter = state->mols.begin(); 91 iter != state->mols.end(); ++iter) 92 world.unselectMolecule(*iter); 93 78 94 return ActionState::ptr(_state); 79 95 } … … 82 98 SelectionMoleculeByOrderState *state = assert_cast<SelectionMoleculeByOrderState*>(_state.get()); 83 99 84 World::getInstance().selectMolecule(state->mol); 100 World &world = World::getInstance(); 101 for (std::vector<const molecule *>::const_iterator iter = state->mols.begin(); 102 iter != state->mols.end(); ++iter) 103 world.selectMolecule(*iter); 85 104 return ActionState::ptr(_state); 86 105 } -
src/Actions/SelectionAction/Molecules/MoleculeByOrderAction.def
rf56e14 r0716eac 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 -
src/Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.cpp
rf56e14 r0716eac 54 54 55 55 ActionState::ptr SelectionNotMoleculeByOrderAction::performCall() { 56 const molecule *mol = const_cast<const World &>(World::getInstance()). 57 getMolecule(MoleculeByOrder(params.molindex.get())); 56 size_t no_unselected = 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, "Unselecting molecule " << mol->name); 62 World::getInstance().unselectMolecule(mol); 63 LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected."); 64 return ActionState::ptr(new SelectionNotMoleculeByOrderState(mol, params)); 64 if (mol != NULL) { 65 if (World::getInstance().isSelected(mol)) { 66 //LOG(1, "Unselecting molecule " << mol->name); 67 World::getInstance().unselectMolecule(mol); 68 mols.push_back(mol); 69 ++no_unselected; 70 } 65 71 } else { 66 return Action::success; 72 STATUS("Cannot find molecule by given index "+toString(*iter)+"."); 73 return Action::failure; 67 74 } 75 } 76 77 LOG(0, no_unselected << " molecules additionally unselected."); 78 if (no_unselected != 0) { 79 return ActionState::ptr(new SelectionNotMoleculeByOrderState(mols, params)); 68 80 } else { 69 STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+"."); 70 return Action::failure; 81 return Action::success; 71 82 } 72 83 } … … 75 86 SelectionNotMoleculeByOrderState *state = assert_cast<SelectionNotMoleculeByOrderState*>(_state.get()); 76 87 77 World::getInstance().selectMolecule(state->mol); 88 World &world = World::getInstance(); 89 for (std::vector<const molecule *>::const_iterator iter = state->mols.begin(); 90 iter != state->mols.end(); ++iter) 91 world.selectMolecule(*iter); 92 78 93 return ActionState::ptr(_state); 79 94 } … … 82 97 SelectionNotMoleculeByOrderState *state = assert_cast<SelectionNotMoleculeByOrderState*>(_state.get()); 83 98 84 World::getInstance().unselectMolecule(state->mol); 99 World &world = World::getInstance(); 100 for (std::vector<const molecule *>::const_iterator iter = state->mols.begin(); 101 iter != state->mols.end(); ++iter) 102 world.unselectMolecule(*iter); 103 85 104 return ActionState::ptr(_state); 86 105 } -
src/Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.def
rf56e14 r0716eac 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 ("unselect-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.