Changeset f7c7cf for src/Actions/SelectionAction/Atoms
- Timestamp:
- Oct 26, 2012, 1:11:18 PM (12 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- be6b3a
- Parents:
- 3a51bd
- git-author:
- Frederik Heber <heber@…> (09/21/12 13:07:26)
- git-committer:
- Frederik Heber <heber@…> (10/26/12 13:11:18)
- Location:
- src/Actions/SelectionAction/Atoms
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/SelectionAction/Atoms/AtomByIdAction.cpp
r3a51bd rf7c7cf 52 52 #include "Action_impl_pre.hpp" 53 53 /** =========== define the function ====================== */ 54 Action::state_ptr SelectionAtomByIdAction::performCall() { 55 const atom *Walker = World::getInstance().getAtom(AtomById(params.WalkerId.get())); 56 if (Walker != NULL) { 57 if (!World::getInstance().isSelected(Walker)) { 58 LOG(1, "Selecting atom " << *Walker); 59 World::getInstance().selectAtom(Walker); 60 LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected."); 61 return Action::state_ptr(new SelectionAtomByIdState(params)); 54 Action::state_ptr SelectionAtomByIdAction::performCall() 55 { 56 enum Sucess { 57 NoStatus, 58 AllAtomsUnselected, 59 AtomsSelected, 60 AtomMissing 61 } status = NoStatus; 62 const atomids_t atomids = params.atomids.get(); 63 atomids_t undoatomids; 64 undoatomids.reserve(atomids.size()); 65 for (atomids_t::const_iterator iter = atomids.begin(); iter != atomids.end(); ++iter) { 66 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 67 if (Walker != NULL) { 68 if (!World::getInstance().isSelected(Walker)) { 69 LOG(1, "Selecting atom " << *Walker); 70 World::getInstance().selectAtom(Walker); 71 undoatomids.push_back(*iter); 72 if (status < AtomMissing) 73 status = AtomsSelected; 74 } else { 75 if (status == NoStatus) 76 status = AllAtomsUnselected; 77 } 62 78 } else { 79 status = AtomMissing; 80 } 81 } 82 LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected."); 83 84 switch (status) { 85 case AtomMissing: 86 return Action::failure; 87 break; 88 case AllAtomsUnselected: 63 89 return Action::success; 64 } 65 } else { 66 return Action::failure; 90 break; 91 case AtomsSelected: 92 return Action::state_ptr(new SelectionAtomByIdState(undoatomids, params)); 93 break; 94 default: 95 ASSERT(0, "SelectionAtomByIdAction::performCall() - this must not happen."); 96 return Action::failure; 97 break; 67 98 } 68 99 } … … 71 102 SelectionAtomByIdState *state = assert_cast<SelectionAtomByIdState*>(_state.get()); 72 103 73 const atom *Walker = World::getInstance().getAtom(AtomById(state->params.WalkerId.get())); 74 World::getInstance().unselectAtom(Walker); 104 for (atomids_t::const_iterator iter = state->undoatomids.begin(); 105 iter != state->undoatomids.end(); ++iter) { 106 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 107 World::getInstance().unselectAtom(Walker); 108 } 75 109 76 110 return Action::state_ptr(_state); … … 80 114 SelectionAtomByIdState *state = assert_cast<SelectionAtomByIdState*>(_state.get()); 81 115 82 const atom *Walker = World::getInstance().getAtom(AtomById(state->params.WalkerId.get())); 83 World::getInstance().selectAtom(Walker); 116 for (atomids_t::const_iterator iter = state->undoatomids.begin(); 117 iter != state->undoatomids.end(); ++iter) { 118 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 119 World::getInstance().selectAtom(Walker); 120 } 84 121 85 122 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/AtomByIdAction.def
r3a51bd rf7c7cf 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 class atom; 9 #include <vector> 10 #include "types.hpp" 10 11 12 typedef std::vector<atomId_t> atomids_t; 13 14 #include "Parameters/Validators/STLVectorValidator.hpp" 11 15 #include "Parameters/Validators/Specific/AtomIdValidator.hpp" 12 16 … … 14 18 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 15 19 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 16 #define paramtypes (atom Id_t)20 #define paramtypes (atomids_t) 17 21 #define paramtokens ("select-atom-by-id") 18 #define paramdescriptions ("atom ind ex")22 #define paramdescriptions ("atom indices to select") 19 23 #undef paramdefaults 20 #define paramreferences ( WalkerId)24 #define paramreferences (atomids) 21 25 #define paramvalids \ 22 ( AtomIdValidator())26 (STLVectorValidator< std::vector<atomId_t> >(AtomIdValidator())) 23 27 24 #undef statetypes 25 #undef statereferences 28 29 #define statetypes (atomids_t) 30 #define statereferences (undoatomids) 26 31 27 32 // some defines for all the names, you may use ACTION, STATE and PARAMS … … 34 39 35 40 // finally the information stored in the ActionTrait specialization 36 #define DESCRIPTION "select a n atomby index"41 #define DESCRIPTION "select atom(s) by index" 37 42 #undef SHORTFORM -
src/Actions/SelectionAction/Atoms/NotAtomByIdAction.cpp
r3a51bd rf7c7cf 52 52 #include "Action_impl_pre.hpp" 53 53 /** =========== define the function ====================== */ 54 Action::state_ptr SelectionNotAtomByIdAction::performCall() { 55 const atom * Walker = World::getInstance().getAtom(AtomById(params.WalkerId.get())); 56 if (Walker != NULL) { 57 if (World::getInstance().isSelected(Walker)) { 58 LOG(1, "Unselecting atom " << *Walker); 59 World::getInstance().unselectAtom(Walker); 60 LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected."); 61 return Action::state_ptr(new SelectionNotAtomByIdState(params)); 54 Action::state_ptr SelectionNotAtomByIdAction::performCall() 55 { 56 enum Sucess { 57 NoStatus, 58 AllAtomsSelected, 59 AtomsUnselected, 60 AtomMissing 61 } status = NoStatus; 62 const atomids_t atomids = params.atomids.get(); 63 atomids_t undoatomids; 64 undoatomids.reserve(atomids.size()); 65 for (atomids_t::const_iterator iter = atomids.begin(); iter != atomids.end(); ++iter) { 66 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 67 if (Walker != NULL) { 68 if (World::getInstance().isSelected(Walker)) { 69 LOG(1, "Unselecting atom " << *Walker); 70 World::getInstance().unselectAtom(Walker); 71 undoatomids.push_back(*iter); 72 if (status < AtomMissing) 73 status = AtomsUnselected; 74 } else { 75 if (status == NoStatus) 76 status = AllAtomsSelected; 77 } 62 78 } else { 79 status = AtomMissing; 80 } 81 } 82 LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected."); 83 84 switch (status) { 85 case AtomMissing: 86 return Action::failure; 87 break; 88 case AllAtomsSelected: 63 89 return Action::success; 64 } 65 } else { 66 return Action::failure; 90 break; 91 case AtomsUnselected: 92 return Action::state_ptr(new SelectionNotAtomByIdState(undoatomids, params)); 93 break; 94 default: 95 ASSERT(0, "SelectionAtomByIdAction::performCall() - this must not happen."); 96 return Action::failure; 97 break; 67 98 } 68 99 } … … 71 102 SelectionNotAtomByIdState *state = assert_cast<SelectionNotAtomByIdState*>(_state.get()); 72 103 73 const atom * Walker = World::getInstance().getAtom(AtomById(state->params.WalkerId.get())); 74 World::getInstance().selectAtom(Walker); 104 for (atomids_t::const_iterator iter = state->undoatomids.begin(); 105 iter != state->undoatomids.end(); ++iter) { 106 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 107 World::getInstance().selectAtom(Walker); 108 } 75 109 76 110 return Action::state_ptr(_state); … … 80 114 SelectionNotAtomByIdState *state = assert_cast<SelectionNotAtomByIdState*>(_state.get()); 81 115 82 const atom * Walker = World::getInstance().getAtom(AtomById(state->params.WalkerId.get())); 83 World::getInstance().unselectAtom(Walker); 116 for (atomids_t::const_iterator iter = state->undoatomids.begin(); 117 iter != state->undoatomids.end(); ++iter) { 118 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 119 World::getInstance().unselectAtom(Walker); 120 } 84 121 85 122 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/NotAtomByIdAction.def
r3a51bd rf7c7cf 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 class atom; 9 #include <vector> 10 #include "types.hpp" 10 11 12 typedef std::vector<atomId_t> atomids_t; 13 14 #include "Parameters/Validators/STLVectorValidator.hpp" 11 15 #include "Parameters/Validators/Specific/AtomIdValidator.hpp" 12 16 … … 14 18 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 15 19 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 16 #define paramtypes (atom Id_t)20 #define paramtypes (atomids_t) 17 21 #define paramtokens ("unselect-atom-by-id") 18 #define paramdescriptions ("atom ind ex")22 #define paramdescriptions ("atom indices to unselect") 19 23 #undef paramdefaults 20 #define paramreferences ( WalkerId)24 #define paramreferences (atomids) 21 25 #define paramvalids \ 22 ( AtomIdValidator())26 (STLVectorValidator< std::vector<atomId_t> >(AtomIdValidator())) 23 27 24 #undef statetypes 25 #undef statereferences 28 29 #define statetypes (atomids_t) 30 #define statereferences (undoatomids) 26 31 27 32 // some defines for all the names, you may use ACTION, STATE and PARAMS
Note:
See TracChangeset
for help on using the changeset viewer.