Changeset 62a0ee for src/UIElements
- Timestamp:
- Feb 14, 2016, 12:34:29 PM (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:
- 1c0961
- Parents:
- 1b07b1
- git-author:
- Frederik Heber <heber@…> (01/07/16 10:28:10)
- git-committer:
- Frederik Heber <heber@…> (02/14/16 12:34:29)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp
r1b07b1 r62a0ee 74 74 void markObservedValuesAsDisconnected(const id _id); 75 75 76 /** Inform this container that subjectKilled() was received by one of the ObservedValues.77 *78 * \param _id identifier of the receiving instance79 */80 void countsubjectKilled(const id _id);81 82 76 /** Prepares removeal a vector of observed values of an instance identified by \a _id. 83 77 * … … 195 189 CountedObservedValues_t ObservedValues; 196 190 197 //!> typedef for map with subjectKilledCounts for each instance198 typedef std::map<id, size_t> subjectKilledCount_t;199 200 //!> counts how many ObservedValues have already been subjectKilled()201 subjectKilledCount_t subjectKilledCount;202 203 191 //!> typedef for the set with ids to be erase 204 192 typedef std::set<id> MarkedForErase_t; … … 228 216 bool checkRefCount(const id _id) const; 229 217 230 /** Internal function to check whether any ObservedValue identified by231 * \a _id is still signOn() to its associated World instance.232 *233 * \param _id identifier of instance234 * \return true - no more signOn()s, false - else235 */236 bool checksubjectKilled(const id _id) const;237 238 218 /** Internal function to check whether the vector of ObservedValue's 239 219 * identified by \a _id has been marked for erase. -
src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp
r1b07b1 r62a0ee 53 53 void ObservedValuesContainer<T,id>::checkRemoval(const id _id) 54 54 { 55 if (checkRefCount(_id) && check subjectKilled(_id) && checkMarkedForErase(_id))55 if (checkRefCount(_id) && checkMarkedForErase(_id)) 56 56 removeObservedValues(_id); 57 57 } … … 113 113 114 114 template <class T, typename id> 115 #ifdef HAVE_INLINE116 inline117 #endif118 bool ObservedValuesContainer<T,id>::checksubjectKilled(119 const id _id) const120 {121 boost::recursive_mutex::scoped_lock lock(atomic_mutex);122 typename subjectKilledCount_t::const_iterator iter = subjectKilledCount.find(_id);123 return ((iter != subjectKilledCount.end()) && (iter->second == T::MAX_ObservedTypes));124 }125 126 template <class T, typename id>127 void ObservedValuesContainer<T,id>::countsubjectKilled(const id _id)128 {129 boost::recursive_mutex::scoped_lock lock(atomic_mutex);130 LOG(3, "DEBUG: ObservedValuesContainer got subjectKilled() for an observed value of "131 << NameOfType << " " << _id);132 typename subjectKilledCount_t::iterator iter = subjectKilledCount.find(_id);133 if (iter == subjectKilledCount.end()) {134 std::pair<typename subjectKilledCount_t::iterator, bool> inserter =135 subjectKilledCount.insert( std::make_pair(_id, 0) );136 iter = inserter.first;137 }138 ASSERT (iter->second < T::MAX_ObservedTypes,139 "ObservedValuesContainer<T,id>::countsubjectKilled() - all subjectKilled() for "140 +NameOfType+" "+toString(_id)+" for each observed channel came in already.");141 ++(iter->second);142 143 checkRemoval(_id);144 }145 146 template <class T, typename id>147 115 void ObservedValuesContainer<T,id>::removeObservedValues(const id _id) 148 116 { … … 151 119 // call callback function 152 120 onDestroy(_id); 153 subjectKilledCount.erase(_id);154 121 typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id); 155 122 iter->second.eraseCurrentValue(); … … 213 180 const typename CountedObservedValues_t::iterator Colditer = ObservedValues.find(_oldid); 214 181 const typename CountedObservedValues_t::iterator Cnewiter = ObservedValues.find(_newid); 215 const typename subjectKilledCount_t::iterator Solditer = subjectKilledCount.find(_oldid);216 const typename subjectKilledCount_t::iterator Snewiter = subjectKilledCount.find(_newid);217 182 const typename MarkedForErase_t::iterator Eolditer = MarkedForErase.find(_oldid); 218 183 const typename MarkedForErase_t::iterator Enewiter = MarkedForErase.find(_newid); 219 184 bool status = ((Colditer != ObservedValues.end()) && (Cnewiter == ObservedValues.end())); 220 status &= ((Solditer != subjectKilledCount.end()) && (Snewiter == subjectKilledCount.end()));221 185 status &= ((Eolditer != MarkedForErase.end()) && (Enewiter == MarkedForErase.end())); 222 186 // change id here only if still present … … 233 197 } 234 198 { 235 const size_t countvalue = Solditer->second;236 subjectKilledCount.erase(Solditer);237 subjectKilledCount.insert( std::make_pair(_newid, countvalue) );238 }239 {240 199 MarkedForErase.erase(Eolditer); 241 200 MarkedForErase.insert(_newid); -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
r1b07b1 r62a0ee 91 91 92 92 QtObservedAtom::QtObservedAtom( 93 const ObservedValues_t &_ObservedValues, 93 const atomId_t _id, 94 const atom * const _atom, 94 95 QtObservedInstanceBoard &_board, 95 96 QWidget * _parent) : … … 102 103 board(_board), 103 104 BoardIsGone(false), 104 ObservedValues(_ObservedValues) 105 { 106 // activating Observer is done by ObservedValueContainer when it's prepared 105 ObservedValues(QtObservedAtom::MAX_ObservedTypes) 106 { 107 boost::function<void (const atomId_t)> atomSubjectKilled( 108 boost::bind(&QtObservedAtom::countValuesSubjectKilled, 109 boost::ref(*this), 110 _1)); 111 initObservedValues( ObservedValues, _id, _atom, atomSubjectKilled); 112 113 // activating Observer is done by ObservedValueContainer when it's inserted 107 114 } 108 115 … … 220 227 ++signedOffChannels; 221 228 222 if (signedOffChannels == AllsignedOnChannels) { 229 checkForRemoval(); 230 } 231 232 void QtObservedAtom::countValuesSubjectKilled(const atomId_t _id) 233 { 234 ASSERT( _id == getAtomIndex(), 235 "QtObservedAtom::countValuesSubjectKilled() - atom "+toString(getAtomIndex()) 236 +" received countValuesSubjectKilled for atom id "+toString(_id)+"."); 237 238 ++subjectKilledCount; 239 240 checkForRemoval(); 241 } 242 243 #ifdef HAVE_INLINE 244 inline 245 #endif 246 void QtObservedAtom::checkForRemoval() 247 { 248 if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) { 223 249 // remove owner: no more signOff needed 224 250 owner = NULL; -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
r1b07b1 r62a0ee 62 62 /** Cstor of QtObservedAtom. 63 63 * 64 * \param _ObservedValues ref to set of observed values for this instance 64 * \param _id id of observed atom 65 * \param _atom ref to observed atom 65 66 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled() 66 67 * \param _parent Qt parent to automatically destroy when parent is destroyed 67 68 */ 68 69 QtObservedAtom( 69 const ObservedValues_t &_ObservedValues, 70 const atomId_t _id, 71 const atom * const _atom, 70 72 QtObservedInstanceBoard &_board, 71 73 QWidget * _parent=0); … … 189 191 * \param _subjectKilled ref to function to call on subjectKilled() 190 192 */ 191 staticvoid initObservedValues(193 void initObservedValues( 192 194 ObservedValues_t &_ObservedValues, 193 195 const atomId_t _id, … … 209 211 { BoardIsGone = true; } 210 212 213 /** Counts the number of subject killed received from the observed values. 214 * 215 * \param _id id to check against ours 216 */ 217 void countValuesSubjectKilled(const atomId_t _id); 218 211 219 //!> counts how many ObservedValues have already been subjectKilled() 212 220 mutable size_t subjectKilledCount; 221 222 /** Helper function to check that all subjectKilled have been received for both 223 * this instance and all its internal observed values. 224 * 225 */ 226 void checkForRemoval(); 213 227 214 228 private: -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp
r1b07b1 r62a0ee 66 66 *this, 67 67 boost::bind(&QtObservedInstanceBoard::moleculecountsubjectKilled, this, _1)), 68 atomSubjectKilled(69 boost::bind(&ObservedValuesContainer<QtObservedAtom, atomId_t>::countsubjectKilled,70 boost::ref(atomObservedValues),71 _1)),72 moleculeSubjectKilled(73 boost::bind(&ObservedValuesContainer<QtObservedMolecule, moleculeId_t>::countsubjectKilled,74 boost::ref(moleculeObservedValues),75 _1)),76 68 lastremovedatom((atomId_t)-1), 77 69 lastremovedmolecule((moleculeId_t)-1) … … 105 97 for (SignedOn_t::iterator iter = MoleculeSignedOn.begin(); !MoleculeSignedOn.empty(); 106 98 iter = MoleculeSignedOn.begin()) { 107 (*iter)->signOff(this, molecule::IndexChanged); 108 (*iter)->signOff(this, molecule::AtomInserted); 109 (*iter)->signOff(this, molecule::AtomRemoved); 110 MoleculeSignedOn.erase(*iter); //erase all instances 99 Observable * const _observable = *iter; 100 _observable->signOff(this, molecule::IndexChanged); 101 // remove all three remaining instances in multiset 102 for (SignedOn_t::iterator sameiter = MoleculeSignedOn.find(_observable); 103 sameiter != MoleculeSignedOn.end(); 104 sameiter = MoleculeSignedOn.find(_observable)) 105 MoleculeSignedOn.erase(*sameiter); //erase all instances 111 106 } 112 107 } … … 150 145 getMolecule(MoleculeById(_id)); 151 146 if (_molecule != NULL) { 152 ObservedValues_t ObservedValues(QtObservedMolecule::MAX_ObservedTypes); 153 LOG(3, "DEBUG: InformationBoard initializes ObservedValues for molecule " << _id); 154 QtObservedMolecule::initObservedValues( 155 ObservedValues, 156 _id, 157 _molecule, 158 moleculeSubjectKilled); 159 QtObservedMolecule::ptr observedmolecule(new QtObservedMolecule(ObservedValues, *this)); 147 LOG(3, "DEBUG: InformationBoard initializes QtObservedMolecule for " << _id); 148 QtObservedMolecule::ptr observedmolecule( 149 new QtObservedMolecule( 150 _id, 151 _molecule, 152 *this)); 160 153 moleculeObservedValues.insert(_id, observedmolecule); 161 154 // we need to check for index changes 162 155 LOG(3, "DEBUG: InformationBoard signOn()s to molecule " << _id); 163 156 _molecule->signOn(this, molecule::IndexChanged); 164 MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );165 _molecule->signOn(this, molecule::AtomInserted);166 MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );167 _molecule->signOn(this, molecule::AtomRemoved);168 157 MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) ); 169 158 … … 192 181 getAtom(AtomById(_id)); 193 182 if (_atom!= NULL) { 194 ObservedValues_t ObservedValues(QtObservedAtom::MAX_ObservedTypes); 195 LOG(3, "DEBUG: InformationBoard initializes ObservedValues for atom " << _id); 196 QtObservedAtom::initObservedValues( 197 ObservedValues, 198 _id, 199 _atom, 200 atomSubjectKilled); 201 QtObservedAtom::ptr observedatom(new QtObservedAtom(ObservedValues, *this)); 183 LOG(3, "DEBUG: InformationBoard initializes QtObservedAtom for " << _id); 184 QtObservedAtom::ptr observedatom( 185 new QtObservedAtom(_id, _atom, *this)); 202 186 atomObservedValues.insert(_id, observedatom); 203 187 // we need to check for index changes -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp
r1b07b1 r62a0ee 136 136 ObservedValuesContainer<QtObservedMolecule, moleculeId_t> moleculeObservedValues; 137 137 138 //!> stored callback function for notifying QtObservedInstanceBoard about subjectKilled in atom139 boost::function<void (const atomId_t)> atomSubjectKilled;140 //!> stored callback function for notifying QtObservedInstanceBoard about subjectKilled in molecule141 boost::function<void (const moleculeId_t)> moleculeSubjectKilled;142 138 //!> note down atom id of last removed atom to drop its ObservedValues 143 139 atomId_t lastremovedatom; -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp
r1b07b1 r62a0ee 100 100 101 101 QtObservedMolecule::QtObservedMolecule( 102 const ObservedValues_t &_ObservedValues, 102 const moleculeId_t _id, 103 const molecule * const _mol, 103 104 QtObservedInstanceBoard &_board, 104 105 QWidget * _parent) : … … 111 112 board(_board), 112 113 BoardIsGone(false), 113 ObservedValues(_ObservedValues) 114 { 114 ObservedValues(QtObservedMolecule::MAX_ObservedTypes) 115 { 116 boost::function<void (const atomId_t)> moleculeSubjectKilled( 117 boost::bind(&QtObservedMolecule::countValuesSubjectKilled, 118 boost::ref(*this), 119 _1)); 120 initObservedValues(ObservedValues, _id, _mol, moleculeSubjectKilled); 121 115 122 // activating Observer is done by ObservedValueContainer when it's prepared 116 123 } … … 171 178 ++signedOffChannels; 172 179 173 if (signedOffChannels == AllsignedOnChannels) { 180 checkForRemoval(); 181 } 182 183 void QtObservedMolecule::countValuesSubjectKilled(const moleculeId_t _id) 184 { 185 ASSERT( _id == getMolIndex(), 186 "QtObservedAtom::countValuesSubjectKilled() - molecule "+toString(getMolIndex()) 187 +" received countValuesSubjectKilled for molecule id "+toString(_id)+"."); 188 189 ++subjectKilledCount; 190 191 checkForRemoval(); 192 } 193 194 void QtObservedMolecule::checkForRemoval() 195 { 196 if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) { 174 197 // remove owner: no more signOff needed 175 198 owner = NULL; -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
r1b07b1 r62a0ee 60 60 /** Cstor of QtObservedMolecule. 61 61 * 62 * \param _ObservedValues ref to set of observed values for this instance 62 * \param _id id of observed molecule 63 * \param _mol ref to observed molecule 63 64 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled() 64 65 * \param _parent Qt parent to automatically destroy when parent is destroyed 65 66 */ 66 67 QtObservedMolecule( 67 const ObservedValues_t &_ObservedValues, 68 const moleculeId_t _id, 69 const molecule * const _mol, 68 70 QtObservedInstanceBoard &_board, 69 71 QWidget * _parent=0); … … 249 251 { BoardIsGone = true; } 250 252 253 254 /** Counts the number of subject killed received from the observed values. 255 * 256 * \param _id id to check against ours 257 */ 258 void countValuesSubjectKilled(const atomId_t _id); 259 251 260 //!> counts how many ObservedValues have already been subjectKilled() 252 261 mutable size_t subjectKilledCount; 262 263 /** Helper function to check that all subjectKilled have been received for both 264 * this instance and all its internal observed values. 265 * 266 */ 267 void checkForRemoval(); 253 268 254 269 private:
Note:
See TracChangeset
for help on using the changeset viewer.