Changeset b4bd0e for src/UIElements/Qt4/InstanceBoard
- Timestamp:
- Apr 20, 2016, 10:58:42 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:
- 96f14a
- Parents:
- 6af6a62
- git-author:
- Frederik Heber <heber@…> (03/15/16 10:10:54)
- git-committer:
- Frederik Heber <heber@…> (04/20/16 22:58:42)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp
r6af6a62 rb4bd0e 62 62 *this, 63 63 boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)), 64 bondObservedValues( 65 "bond", 66 *this, 67 boost::bind(&QtObservedInstanceBoard::bondcountsubjectKilled, this, _1)), 64 68 moleculeObservedValues( 65 69 "molecule", … … 69 73 qRegisterMetaType<ObservedValue_Index_t>("ObservedValue_Index_t"); 70 74 qRegisterMetaType<QtObservedAtom::ptr>("QtObservedAtom::ptr"); 75 qRegisterMetaType<QtObservedBond::ptr>("QtObservedBond::ptr"); 71 76 qRegisterMetaType<QtObservedMolecule::ptr>("QtObservedMolecule::ptr"); 72 77 … … 83 88 World::getInstance().signOff(this, World::MoleculeInserted); 84 89 } 85 // sign off from all remaining molecules and atoms90 // sign off from all remaining molecules, bonds, and atoms 86 91 for (SignedOn_t::iterator iter = AtomSignedOn.begin(); !AtomSignedOn.empty(); 87 92 iter = AtomSignedOn.begin()) { 88 93 (*iter)->signOff(this, atom::IndexChanged); 89 AtomSignedOn.erase(iter); 94 (*iter)->signOff(this, atom::BondsAdded); 95 AtomSignedOn.erase(*iter); 90 96 } 91 97 … … 108 114 if ( iter != AtomSignedOn.end()) { 109 115 LOG(3, "DEBUG: InstanceBoard got subjectKilled() from atom " << publisher); 110 AtomSignedOn.erase(iter); 116 AtomSignedOn.erase(iter); // only remove one 111 117 } else { 112 118 iter = MoleculeSignedOn.find(publisher); … … 176 182 LOG(3, "DEBUG: InformationBoard signOn()s to atom " << _id); 177 183 _atom->signOn(this, atom::IndexChanged); 184 _atom->signOn(this, atom::BondsAdded); 185 AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) ); 178 186 AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) ); 179 187 emit atomInserted(observedatom); … … 232 240 break; 233 241 } 242 case AtomObservable::BondsAdded: 243 { 244 const atom * _atom = dynamic_cast<atom *>(publisher); 245 const atomId_t _id = _atom->getId(); 246 #ifdef LOG_OBSERVER 247 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted."; 248 #endif 249 LOG(3, "DEBUG: InformationBoard got bondInserted signal for atom " << _id); 250 if (_atom != NULL) { 251 // find the new bond by simply taking the last added to the list 252 const BondList &ListOfBonds = _atom->getListOfBonds(); 253 const bond::ptr bondref = ListOfBonds.back(); 254 const bondId_t bondid = 255 std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId()); 256 LOG(3, "DEBUG: InformationBoard initializes QtObservedBond for " << bondid); 257 QtObservedBond::ptr observedbond( 258 new QtObservedBond(bondid, bondref, *this)); 259 const ObservedValue_Index_t index = observedbond->getIndex(); 260 bondObservedValues.insert(index, observedbond); 261 bondids_lookup.left.insert( std::make_pair(bondid, index) ); 262 emit bondInserted(observedbond); 263 } else { 264 ELOG(1, "QtObservedInstanceBoard got BondsAdded for unknown atom id " << _id); 265 } 266 break; 267 } 234 268 default: 235 269 ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here."); … … 239 273 ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - notification from unknown source."); 240 274 } 241 }242 243 void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id)244 {245 LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << _id);246 emit atomRemoved(_id);247 }248 249 void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id)250 {251 LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << _id);252 emit moleculeRemoved(_id);253 275 } 254 276 … … 262 284 } 263 285 286 const QtObservedInstanceBoard::bondId_t 287 QtObservedInstanceBoard::getBondIdToIndex(ObservedValue_Index_t _id) const 288 { 289 typename IdtoIndex_t<bondId_t>::right_const_iterator iter = bondids_lookup.right.find(_id); 290 ASSERT( iter != bondids_lookup.right.end(), 291 "QtObservedInstanceBoard::getBondIdToIndex() - index " 292 +toString(_id)+" is unknown."); 293 return iter->second; 294 } 295 264 296 const moleculeId_t QtObservedInstanceBoard::getMoleculeIdToIndex(ObservedValue_Index_t _id) const 265 297 { … … 271 303 } 272 304 305 void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id) 306 { 307 LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << getAtomIdToIndex(_id)); 308 emit atomRemoved(_id); 309 } 310 311 void QtObservedInstanceBoard::bondcountsubjectKilled(ObservedValue_Index_t _id) 312 { 313 LOG(3, "DEBUG: InstanceBoard emits bondRemoved for " << getBondIdToIndex(_id)); 314 emit bondRemoved(_id); 315 } 316 317 void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id) 318 { 319 LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << getMoleculeIdToIndex(_id)); 320 emit moleculeRemoved(_id); 321 } 322 273 323 QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id) 274 324 { … … 279 329 { 280 330 return atomObservedValues.get(_id); 331 } 332 333 QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(const bondId_t _id) 334 { 335 return bondObservedValues.get(bondids_lookup.left.at(_id)); 336 } 337 338 QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(ObservedValue_Index_t _id) 339 { 340 return bondObservedValues.get(_id); 281 341 } 282 342 … … 307 367 } 308 368 369 void QtObservedInstanceBoard::markObservedBondAsConnected(ObservedValue_Index_t _id) 370 { 371 bondObservedValues.markObservedValuesAsConnected(_id); 372 } 373 374 void QtObservedInstanceBoard::markObservedBondAsDisconnected(ObservedValue_Index_t _id) 375 { 376 bondObservedValues.markObservedValuesAsDisconnected(_id); 377 } 378 379 void QtObservedInstanceBoard::markObservedBondForErase(ObservedValue_Index_t _id) 380 { 381 bondObservedValues.eraseObservedValues(_id); 382 bondids_lookup.right.erase(_id); 383 } 384 309 385 void QtObservedInstanceBoard::markObservedMoleculeAsConnected(ObservedValue_Index_t _id) 310 386 { -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp
r6af6a62 rb4bd0e 18 18 19 19 #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp" 20 #include "UIElements/Qt4/InstanceBoard/QtObservedBond.hpp" 20 21 #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp" 21 22 … … 64 65 65 66 public: 67 //!> copy bond id type from QtObservedBond 68 typedef QtObservedBond::bondId_t bondId_t; 69 66 70 /** Cstor of QtObservedInstanceBoard. 67 71 * … … 81 85 82 86 const atomId_t getAtomIdToIndex(ObservedValue_Index_t _id) const; 87 const bondId_t getBondIdToIndex(ObservedValue_Index_t _id) const; 83 88 const moleculeId_t getMoleculeIdToIndex(ObservedValue_Index_t _id) const; 84 89 85 90 QtObservedAtom::ptr getObservedAtom(const atomId_t _id); 86 91 QtObservedAtom::ptr getObservedAtom(ObservedValue_Index_t _id); 92 QtObservedBond::ptr getObservedBond(const bondId_t _id); 93 QtObservedBond::ptr getObservedBond(ObservedValue_Index_t _id); 87 94 QtObservedMolecule::ptr getObservedMolecule(const moleculeId_t _id); 88 95 QtObservedMolecule::ptr getObservedMolecule(ObservedValue_Index_t _id); … … 90 97 void markObservedAtomAsDisconnected(ObservedValue_Index_t _id); 91 98 void markObservedAtomForErase(ObservedValue_Index_t _id); 99 void markObservedBondAsConnected(ObservedValue_Index_t _id); 100 void markObservedBondAsDisconnected(ObservedValue_Index_t _id); 101 void markObservedBondForErase(ObservedValue_Index_t _id); 92 102 void markObservedMoleculeAsConnected(ObservedValue_Index_t _id); 93 103 void markObservedMoleculeAsDisconnected(ObservedValue_Index_t _id); … … 98 108 void atomRemoved(ObservedValue_Index_t _atomid); 99 109 void atomIndexChanged(const atomId_t _oldid, const atomId_t _newid); 110 void bondInserted(QtObservedBond::ptr _bond); 111 void bondRemoved(ObservedValue_Index_t _bondid); 112 void bondIndexChanged(const bondId_t _oldid, const bondId_t _newid); 100 113 void moleculeInserted(QtObservedMolecule::ptr _mol); 101 114 void moleculeRemoved(ObservedValue_Index_t _molid); … … 111 124 bool WorldSignedOn; 112 125 113 typedef std:: set<Observable *> SignedOn_t;126 typedef std::multiset<Observable *> SignedOn_t; 114 127 //!> map indicating to which atom we are currently signed on 115 128 SignedOn_t AtomSignedOn; … … 121 134 struct IdtoIndex_t : boost::bimap<id, ObservedValue_Index_t> {}; 122 135 IdtoIndex_t<atomId_t> atomids_lookup; 136 IdtoIndex_t<bondId_t> bondids_lookup; 123 137 IdtoIndex_t<moleculeId_t> moleculeids_lookup; 124 138 … … 132 146 */ 133 147 void atomcountsubjectKilled(ObservedValue_Index_t _id); 148 149 /** Counts how many bond's ObservedValues got subjectKilled. 150 * 151 * This is used to give removal signal only when each and every 152 * ObservedValue (and the instance itself) has been subjectKilled by the 153 * monitored Observable. Only then can we safely remove the instance. 154 * 155 * \param _bondid id of the bond 156 */ 157 void bondcountsubjectKilled(ObservedValue_Index_t _bondid); 134 158 135 159 /** Counts how many molecule's ObservedValues got subjectKilled. … … 145 169 //!> container with all ObservedValues for each atom, associated by id 146 170 ObservedValuesContainer<QtObservedAtom, ObservedValue_Index_t> atomObservedValues; 171 //!> container with all ObservedValues for each bond, associated by id pairs 172 ObservedValuesContainer<QtObservedBond, ObservedValue_Index_t> bondObservedValues; 147 173 //!> container with all ObservedValues for each molecule, associated by id 148 174 ObservedValuesContainer<QtObservedMolecule, ObservedValue_Index_t> moleculeObservedValues;
Note:
See TracChangeset
for help on using the changeset viewer.