Changeset 41e287 for src/UIElements/Qt4/InstanceBoard
- Timestamp:
- Feb 12, 2016, 11:15:23 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:
- 65c323
- Parents:
- 98c35c
- git-author:
- Frederik Heber <heber@…> (10/29/15 09:52:10)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:23)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
r98c35c r41e287 23 23 24 24 #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp" 25 #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp" 25 26 #include "types.hpp" 26 27 … … 41 42 Q_OBJECT 42 43 44 //!> ObservedValuesContainer needs to access private cstor and dstor 45 friend class ObservedValuesContainer<QtObservedAtom, atomId_t>; 43 46 //!> QtObservedInstanceBoard needs to access private cstor and dstor 44 47 friend class QtObservedInstanceBoard; -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp
r98c35c r41e287 47 47 #include "Descriptors/MoleculeIdDescriptor.hpp" 48 48 #include "molecule.hpp" 49 #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp" 49 50 #include "World.hpp" 50 51 … … 53 54 Observer("QtObservedInstanceBoard"), 54 55 WorldSignedOn(false), 56 atomObservedValues("atom"), 57 moleculeObservedValues("molecule"), 55 58 atomSubjectKilled( 56 59 boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)), … … 139 142 moleculeSubjectKilled); 140 143 #ifndef NDEBUG 141 std::pair<moleculeObservedValues_t::iterator, bool> inserter=144 bool status = 142 145 #endif 143 moleculeObservedValues.insert( 144 std::make_pair( _id, std::make_pair(ObservedValues,0) )); 145 ASSERT( inserter.second, 146 moleculeObservedValues.insert(_id, ObservedValues); 147 ASSERT( status, 146 148 "QtObservedInstanceBoard::recieveNotification() - could not insert ObservedValues for" 147 149 +toString(_id)+"."); … … 187 189 atomSubjectKilled); 188 190 #ifndef NDEBUG 189 std::pair<atomObservedValues_t::iterator, bool> inserter=191 bool status = 190 192 #endif 191 atomObservedValues.insert( 192 std::make_pair( _id, std::make_pair(ObservedValues,0) )); 193 ASSERT( inserter.second, 193 atomObservedValues.insert(_id, ObservedValues); 194 ASSERT( status, 194 195 "QtObservedInstanceBoard::recieveNotification() - could not insert ObservedValues for" 195 196 +toString(_id)+"."); … … 227 228 << atomid << " from molecule " << molid); 228 229 // check whether atom's observedvalues are present 229 ASSERT( atomObservedValues. find(atomid) != atomObservedValues.end(),230 ASSERT( atomObservedValues.isPresent(atomid), 230 231 "QtObservedInstanceBoard::recieveNotification() - ObservedValues for atom " 231 232 +toString(atomid)+" are not present yet."); … … 255 256 const moleculeId_t newmoleculeId = dynamic_cast<molecule *>(publisher)->getId(); 256 257 LOG(3, "DEBUG: InformationBoard got IndexChanged from molecule " << molid << " to " << newmoleculeId); 257 { 258 moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(molid); 259 // change id here only if still present 260 if (iter != moleculeObservedValues.end()) { 261 RefCountedObservedValues_t obsvalues = iter->second; 262 moleculeObservedValues.erase(iter); 263 ASSERT( moleculeObservedValues.find(newmoleculeId) == moleculeObservedValues.end(), 264 "QtObservedInstanceBoard::recieveNotification() - ObservedValues for atom " 265 +toString(newmoleculeId)+" already present."); 266 moleculeObservedValues.insert( std::make_pair(newmoleculeId, obsvalues) ); 267 // if (!inserter.second) 268 // ELOG(1, "QtInformationBoard could not insert molecule id change " 269 // << molid << "->" << newmoleculeId); 270 } 271 } 258 #ifndef NDEBUG 259 bool status = 260 #endif 261 moleculeObservedValues.changeIdentifier(molid, newmoleculeId); 262 ASSERT( status, 263 "QtObservedInstanceBoard::recieveNotification() - cannot change molecule's id " 264 +toString(molid)+" "+toString(newmoleculeId)+" in moleculeObservedValues."); 272 265 // no need update SignedOn, ref does not change 273 266 emit moleculeIndexChanged(molid, newmoleculeId); … … 285 278 const atomId_t newatomId = dynamic_cast<atom *>(publisher)->getId(); 286 279 LOG(3, "DEBUG: InformationBoard got IndexChanged from atom " << oldatomId << " to " << newatomId); 287 // update atomObservedValues 288 { 289 atomObservedValues_t::iterator iter = atomObservedValues.find(oldatomId); 290 // change id here only if still present 291 if (iter != atomObservedValues.end()) { 292 RefCountedObservedValues_t obsvalues = iter->second; 293 atomObservedValues.erase(iter); 294 ASSERT( atomObservedValues.find(newatomId) == atomObservedValues.end(), 295 "QtObservedInstanceBoard::recieveNotification() - ObservedValues for atom " 296 +toString(newatomId)+" already present."); 297 atomObservedValues.insert( std::make_pair(newatomId, obsvalues) ); 298 // if (!inserter.second) 299 // ELOG(1, "QtInformationBoard could not insert atom id change " 300 // << oldatomId << "->" << newatomId); 301 } 302 } 280 atomObservedValues.changeIdentifier(oldatomId, newatomId); 303 281 // no need update SignedOn, ref does not change 304 282 emit atomIndexChanged(oldatomId, newatomId); … … 326 304 327 305 if (iter->second > GLMoleculeObject_atom::MAX_ObservedTypes) { 328 ASSERT( atomObservedValues [_atomid].second== 0,306 ASSERT( atomObservedValues.getRefCount(_atomid) == 0, 329 307 "QtObservedInstanceBoard::atomcountsubjectKilled() - observed Values for atom " 330 308 +toString(_atomid)+" are still being held somewhere."); … … 350 328 351 329 if (iter->second > GLMoleculeObject_molecule::MAX_ObservedTypes) { 352 ASSERT( moleculeObservedValues [_molid].second== 0,330 ASSERT( moleculeObservedValues.getRefCount(_molid) == 0, 353 331 "QtObservedInstanceBoard::moleculecountsubjectKilled() - observed Values for molecule " 354 332 +toString(_molid)+" are still being held somewhere."); … … 359 337 } 360 338 361 ObservedValues_t 362 QtObservedInstanceBoard::getAtomObservedValues(const atomId_t _id) 363 { 364 ObservedValues_t returnvalues; 365 const atomObservedValues_t::iterator iter = atomObservedValues.find(_id); 366 ASSERT(iter != atomObservedValues.end(), 367 "QtObservedInstanceBoard::getAtomObservedValues() - atom values not present for id" 368 +toString(_id)); 369 if (iter->first == _id) { 370 returnvalues = iter->second.first; 371 atomObservedValues.erase(iter); 372 } 373 return returnvalues; 374 } 375 376 ObservedValues_t 377 QtObservedInstanceBoard::getMoleculeObservedValues(const moleculeId_t _id) 378 { 379 ObservedValues_t returnvalues; 380 const moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(_id); 381 ASSERT(iter != moleculeObservedValues.end(), 382 "getMoleculeObservedValues::getAtomObservedValues() - molecule values not present for id" 383 +toString(_id)); 384 if (iter->first == _id) { 385 returnvalues = iter->second.first; 386 moleculeObservedValues.erase(iter); 387 } 388 return returnvalues; 339 QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id) 340 { 341 return atomObservedValues.get(_id); 342 } 343 344 QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id) 345 { 346 return moleculeObservedValues.get(_id); 347 } 348 349 void QtObservedInstanceBoard::returnObservedAtom(const atomId_t _id) 350 { 351 atomObservedValues.yield(_id); 352 } 353 354 void QtObservedInstanceBoard::returnObservedMolecule(const moleculeId_t _id) 355 { 356 moleculeObservedValues.yield(_id); 357 } 358 359 ObservedValues_t QtObservedInstanceBoard::getAtomObservedValues(const atomId_t _id) 360 { 361 return atomObservedValues.getObservedValues(_id); 362 } 363 ObservedValues_t QtObservedInstanceBoard::getMoleculeObservedValues(const moleculeId_t _id) 364 { 365 return moleculeObservedValues.getObservedValues(_id); 389 366 } 390 367 … … 394 371 { 395 372 if (lastremovedatom != _id) { 396 #ifndef NDEBUG 397 std::pair<atomObservedValues_t::iterator, bool> inserter = 398 #endif 399 atomObservedValues.insert( 400 std::make_pair( _id, std::make_pair(_observedvalues,0) ) ); 401 ASSERT( inserter.second, 402 "QtObservedInstanceBoard::returnAtomObservedValues() - could not insert ObservedValues for" 403 +toString(_id)+"."); 404 } else 373 atomObservedValues.returnObservedValues(_id, _observedvalues); 374 } else { 405 375 lastremovedatom = (atomId_t)-1; 376 atomObservedValues.erase(_id); 377 } 406 378 } 407 379 … … 411 383 { 412 384 if (lastremovedmolecule != _id) { 413 #ifndef NDEBUG 414 std::pair<moleculeObservedValues_t::iterator, bool> inserter = 415 #endif 416 moleculeObservedValues.insert( 417 std::make_pair( _id, std::make_pair(_observedvalues,0) ) ); 418 ASSERT( inserter.second, 419 "QtObservedInstanceBoard::returnMoleculeObservedValues() - could not insert ObservedValues for" 420 +toString(_id)+"."); 421 } else 385 moleculeObservedValues.returnObservedValues(_id, _observedvalues); 386 } else { 422 387 lastremovedmolecule = (moleculeId_t)-1; 423 } 424 425 QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id) 426 { 427 atomObservedValues_t::iterator iter = atomObservedValues.find(_id); 428 ASSERT( iter != atomObservedValues.end(), 429 "QtObservedInstanceBoard::getObservedAtom() - no observed values present for atom " 430 +toString(_id)); 431 const ObservedValues_t &obsvalues = iter->second.first; 432 // increase refcount 433 ++(iter->second.second); 434 QtObservedAtom::ptr _atom(new QtObservedAtom(obsvalues)); 435 436 return _atom; 437 } 438 439 QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id) 440 { 441 moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(_id); 442 ASSERT( iter != moleculeObservedValues.end(), 443 "QtObservedInstanceBoard::getObservedMolecule() - no observed values present for molecule " 444 +toString(_id)); 445 const ObservedValues_t &obsvalues = iter->second.first; 446 // increase refcount 447 ++(iter->second.second); 448 QtObservedMolecule::ptr _molecule(new QtObservedMolecule(obsvalues)); 449 450 return _molecule; 451 } 452 453 void QtObservedInstanceBoard::returnObservedAtom(const atomId_t _id) 454 { 455 atomObservedValues_t::iterator iter = atomObservedValues.find(_id); 456 ASSERT( iter != atomObservedValues.end(), 457 "QtObservedInstanceBoard::returnObservedAtom() - no observed values present for atom " 458 +toString(_id)); 459 ASSERT( iter->second.second != 0, 460 "QtObservedInstanceBoard::returnObservedAtom() - all ObservedAtoms for atom " 461 +toString(_id)+" have already been returned."); 462 // decrease refcount 463 --(iter->second.second); 464 if (iter->second.second == 0) { 465 // free instance 466 } 467 } 468 469 void QtObservedInstanceBoard::returnObservedMolecule(const moleculeId_t _id) 470 { 471 moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(_id); 472 ASSERT( iter != moleculeObservedValues.end(), 473 "QtObservedInstanceBoard::returnObservedMolecule() - no observed values present for molecule " 474 +toString(_id)); 475 ASSERT( iter->second.second != 0, 476 "QtObservedInstanceBoard::returnObservedMolecule() - all ObservedMolecules for molecule " 477 +toString(_id)+" have already been returned."); 478 // decrease refcount 479 --(iter->second.second); 480 if (iter->second.second == 0) { 481 // free instance 482 } 483 } 484 388 moleculeObservedValues.erase(_id); 389 } 390 } 391 -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp
r98c35c r41e287 26 26 27 27 #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp" 28 #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp" 28 29 #include "types.hpp" 29 30 … … 81 82 QtObservedAtom::ptr getObservedAtom(const atomId_t _id); 82 83 QtObservedMolecule::ptr getObservedMolecule(const moleculeId_t _id); 84 void returnObservedAtom(const atomId_t _id); 85 void returnObservedMolecule(const moleculeId_t _id); 83 86 84 87 ObservedValues_t getAtomObservedValues(const atomId_t _id); 85 88 ObservedValues_t getMoleculeObservedValues(const moleculeId_t _id); 86 87 void returnObservedAtom(const atomId_t _id);88 void returnObservedMolecule(const moleculeId_t _id);89 89 90 90 void returnAtomObservedValues(const atomId_t _id, ObservedValues_t &_observedvalues); … … 146 146 moleculesubjectKilledCount_t moleculesubjectKilledCount; 147 147 148 typedef std::pair<ObservedValues_t, size_t> RefCountedObservedValues_t; 149 150 //!> typedef for the map of id to each one's ObservedValues 151 typedef typename std::map<atomId_t, RefCountedObservedValues_t> atomObservedValues_t; 152 //!> map containing all ObservedValues for each atom, associated by id 153 atomObservedValues_t atomObservedValues; 154 155 //!> typedef for the map of id to each one's ObservedValues 156 typedef typename std::map<moleculeId_t, RefCountedObservedValues_t> moleculeObservedValues_t; 157 //!> map containing all ObservedValues for each molecule, associated by id 158 moleculeObservedValues_t moleculeObservedValues; 148 //!> container with all ObservedValues for each atom, associated by id 149 ObservedValuesContainer<QtObservedAtom, atomId_t> atomObservedValues; 150 //!> container with all ObservedValues for each molecule, associated by id 151 ObservedValuesContainer<QtObservedMolecule, moleculeId_t> moleculeObservedValues; 159 152 160 153 //!> stored callback function for notifying QtObservedInstanceBoard about subjectKilled in atom -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
r98c35c r41e287 22 22 23 23 #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp" 24 #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp" 24 25 #include "types.hpp" 25 26 … … 40 41 Q_OBJECT 41 42 43 //!> ObservedValuesContainer needs to access private cstor and dstor 44 friend class ObservedValuesContainer<QtObservedMolecule, moleculeId_t>; 42 45 //!> QtObservedInstanceBoard needs to access private cstor and dstor 43 46 friend class QtObservedInstanceBoard;
Note:
See TracChangeset
for help on using the changeset viewer.