Changeset 7f1865d
- Timestamp:
- Feb 11, 2016, 8:06:49 AM (9 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:
- 4a328f
- Parents:
- b71881
- git-author:
- Frederik Heber <heber@…> (12/28/15 06:28:10)
- git-committer:
- Frederik Heber <heber@…> (02/11/16 08:06:49)
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/World.cpp
rb71881 r7f1865d 601 601 /************************** Selection of Atoms and molecules ******************/ 602 602 603 // translate type's selection member functions to overloaded with specific type 604 605 template <class T> 606 void World::selectVectorOfInstances(const typename T::iterator _begin, const typename T::iterator _end) 607 { 608 std::for_each(_begin,_end, 609 boost::bind(&World::selectInstance<typename T::value_type::second_type>, 610 boost::bind(_take<typename T::value_type::second_type,typename T::value_type>::get, _1))); 611 } 612 613 template <class T> 614 void World::unselectVectorOfInstances(const typename T::iterator _begin, const typename T::iterator _end) 615 { 616 std::for_each(_begin,_end, 617 boost::bind(&World::unselectInstance<typename T::value_type::second_type>, 618 boost::bind(_take<typename T::value_type::second_type,typename T::value_type>::get, _1))); 619 } 620 603 621 // Atoms 604 622 … … 606 624 OBSERVE; 607 625 NOTIFY(SelectionChanged); 626 unselectVectorOfInstances<AtomSet>(selectedAtoms.begin(), selectedAtoms.end()); 608 627 selectedAtoms.clear(); 609 628 } … … 618 637 invertedSelection.erase(iter, invertedSelection.end()); 619 638 // apply new selection 639 unselectVectorOfInstances<AtomSet>(selectedAtoms.begin(), selectedAtoms.end()); 620 640 selectedAtoms.clear(); 621 641 void (World::*selector)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function … … 630 650 boost::function<void (const atomId_t)> IdSelector = 631 651 boost::bind(static_cast<void (World::*)(const atomId_t)>(&World::selectAtom), this, _1); 652 unselectVectorOfInstances<AtomSet>(selectedAtoms.begin(), selectedAtoms.end()); 632 653 selectedAtoms.clear(); 633 654 std::for_each(atomids.begin(),atomids.end(), IdSelector); … … 644 665 atomids.begin()); 645 666 selectedAtoms_Stack.push( atomids ); 667 unselectVectorOfInstances<AtomSet>(selectedAtoms.begin(), selectedAtoms.end()); 646 668 selectedAtoms.clear(); 647 669 } … … 652 674 // atom * is unchanged in this function, but we do store entity as changeable 653 675 ASSERT(_atom,"Invalid pointer in selection of atom"); 654 select edAtoms[_atom->getId()]=const_cast<atom *>(_atom);676 selectAtom(_atom->getId()); 655 677 } 656 678 … … 660 682 ASSERT(atoms.count(id),"Atom Id selected that was not in the world"); 661 683 selectedAtoms[id]=atoms[id]; 684 atoms[id]->select(); 662 685 } 663 686 … … 699 722 NOTIFY(SelectionChanged); 700 723 ASSERT(atoms.count(id),"Atom Id unselected that was not in the world"); 724 atoms[id]->unselect(); 701 725 selectedAtoms.erase(id); 702 726 } … … 736 760 737 761 bool World::isSelected(const atom *_atom) const { 738 return isAtomSelected(_atom->getId()); 762 const bool status = isAtomSelected(_atom->getId()); 763 ASSERT( status == _atom->selected, 764 "World::isSelected() - mismatch between selection state in atom "+ 765 toString(_atom->getId())+" and World."); 766 return status; 739 767 } 740 768 … … 778 806 OBSERVE; 779 807 NOTIFY(SelectionChanged); 808 unselectVectorOfInstances<MoleculeSet>(selectedMolecules.begin(), selectedMolecules.end()); 780 809 selectedMolecules.clear(); 781 810 } … … 791 820 invertedSelection.erase(iter, invertedSelection.end()); 792 821 // apply new selection 822 unselectVectorOfInstances<MoleculeSet>(selectedMolecules.begin(), selectedMolecules.end()); 793 823 selectedMolecules.clear(); 794 824 void (World::*selector)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function … … 803 833 boost::function<void (const moleculeId_t)> IdSelector = 804 834 boost::bind(static_cast<void (World::*)(const moleculeId_t)>(&World::selectMolecule), this, _1); 835 unselectVectorOfInstances<MoleculeSet>(selectedMolecules.begin(), selectedMolecules.end()); 805 836 selectedMolecules.clear(); 806 837 std::for_each(moleculeids.begin(),moleculeids.end(), IdSelector); … … 819 850 moleculeids.begin()); 820 851 selectedMolecules_Stack.push( moleculeids ); 852 unselectVectorOfInstances<MoleculeSet>(selectedMolecules.begin(), selectedMolecules.end()); 821 853 selectedMolecules.clear(); 822 854 } … … 827 859 // molecule * is unchanged in this function, but we do store entity as changeable 828 860 ASSERT(_mol,"Invalid pointer to molecule in selection"); 829 select edMolecules[_mol->getId()]=const_cast<molecule *>(_mol);861 selectMolecule(_mol->getId()); 830 862 } 831 863 … … 834 866 NOTIFY(SelectionChanged); 835 867 ASSERT(molecules.count(id),"Molecule Id selected that was not in the world"); 868 molecules[id]->select(); 836 869 selectedMolecules[id]=molecules[id]; 837 870 } … … 875 908 NOTIFY(SelectionChanged); 876 909 ASSERT(molecules.count(id),"No such molecule with ID in unselection"); 910 molecules[id]->unselect(); 877 911 selectedMolecules.erase(id); 878 912 } … … 913 947 914 948 bool World::isSelected(const molecule *_mol) const { 915 return isMoleculeSelected(_mol->getId()); 949 const bool status = isMoleculeSelected(_mol->getId()); 950 ASSERT( status == _mol->selected, 951 "World::isSelected() - mismatch in selection status between mol "+ 952 toString(_mol->getId())+" and World."); 953 return status; 916 954 } 917 955 -
src/World.hpp
rb71881 r7f1865d 536 536 537 537 private: 538 /** Helper to access atom::select() and molecule::select() only by type. 539 * 540 */ 541 template <class T> 542 static void selectInstance(T _instance) 543 { _instance->select(); } 544 545 /** Helper to access atom::unselect() and molecule::unselect() only by type. 546 * 547 */ 548 template <class T> 549 static void unselectInstance(T _instance) 550 { _instance->unselect(); } 551 552 /** Forward declaration of a helper function for selecting a vector of instances. 553 * 554 * \note only implemented inside World. 555 * 556 */ 557 template <class T> 558 void selectVectorOfInstances(const typename T::iterator _begin, const typename T::iterator _end); 559 560 /** Forward declaration of a helper function for unselecting a vector of instances. 561 * 562 * \note only implemented inside World. 563 * 564 */ 565 template <class T> 566 void unselectVectorOfInstances(const typename T::iterator _begin, const typename T::iterator _end); 567 568 private: 538 569 539 570 friend const atom *detail::lastChanged<atom>();
Note:
See TracChangeset
for help on using the changeset viewer.