Changeset 136842 for src/UIElements


Ignore:
Timestamp:
Apr 25, 2016, 7:05:31 AM (9 years ago)
Author:
Frederik Heber <heber@…>
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:
649f59
Parents:
d16a06
git-author:
Frederik Heber <heber@…> (04/14/16 07:55:41)
git-committer:
Frederik Heber <heber@…> (04/25/16 07:05:31)
Message:

GLWorldScene needs to store observed values to ensure duration of their lifetime.

Location:
src/UIElements/Views/Qt4/Qt3D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    rd16a06 r136842  
    162162  connect(_atom.get(), SIGNAL(moleculeChanged()), this, SLOT(reparentAtom()));
    163163
     164  // store the object, as we need it on reparenting
     165#ifndef NDEBUG
     166  std::pair< ObservedAtoms_t::iterator, bool > inserter =
     167#endif
     168      ObservedAtoms.insert( std::make_pair(_atom->getIndex(), _atom) );
     169  ASSERT( inserter.second,
     170      "GLWorldScene::connectAtom() - observed atom "+toString(_atom)+" already stored?");
     171
    164172  {
    165173    const ObservedValue_Index_t atomid = _atom->getIndex();
     
    228236
    229237  // remove atoms
    230   AtomNodeMap::iterator iter = AtomsinSceneMap.find(_atomid);
    231   ASSERT(iter != AtomsinSceneMap.end(),
    232       "GLWorldScene::removeAtom() - atom "+toString(_atomid)+" not on display.");
    233   GLMoleculeObject_atom *atomObject = iter->second;
    234   AtomsinSceneMap.erase(iter);
    235   delete atomObject;
     238  {
     239    AtomNodeMap::iterator iter = AtomsinSceneMap.find(_atomid);
     240    ASSERT(iter != AtomsinSceneMap.end(),
     241        "GLWorldScene::removeAtom() - atom "+toString(_atomid)+" not on display.");
     242    GLMoleculeObject_atom *atomObject = iter->second;
     243    AtomsinSceneMap.erase(iter);
     244    delete atomObject;
     245  }
    236246  {
    237247    boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
    238248    AtomNodeParentMap.left.erase(_atomid);
    239249  }
     250  {
     251    const size_t erased = ObservedAtoms.erase(_atomid);
     252    ASSERT( erased == 1,
     253        "GLWorldScene::removeAtom() - could not erase stored observed value "+toString(_atomid));
     254  }
    240255  emit changed();
    241256  emit changeOccured();
     
    253268  connect(_bond.get(), SIGNAL(leftmoleculeChanged()), this, SLOT(reparentBondLeft()));
    254269  connect(_bond.get(), SIGNAL(rightmoleculeChanged()), this, SLOT(reparentBondRight()));
     270
     271  // store the object, as we need it on reparenting
     272#ifndef NDEBUG
     273  std::pair< ObservedBonds_t::iterator, bool > inserter =
     274#endif
     275      ObservedBonds.insert( std::make_pair(_bond->getIndex(), _bond) );
     276  ASSERT( inserter.second,
     277      "GLWorldScene::connectBond() - observed bond "+toString(_bond)+" already stored?");
    255278
    256279  {
     
    328351
    329352  // left bond
    330   std::pair<BondNodeMap::iterator, BondNodeMap::iterator> iters =
    331       BondsinSceneMap.equal_range(_bondid);
    332   ASSERT( iters.first != iters.second,
    333       "GLWorldScene::removedBond() - could not find bond to id "+toString(_bondid));
    334   for (BondNodeMap::iterator iter = iters.first; iter != iters.second; ++iter) {
    335     GLMoleculeObject_bond *bondObject = iter->second;
    336     delete bondObject; // is done by signal from bond itself
    337     //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << ".");
    338   }
    339   BondsinSceneMap.erase(_bondid);
     353  {
     354    std::pair<BondNodeMap::iterator, BondNodeMap::iterator> iters =
     355        BondsinSceneMap.equal_range(_bondid);
     356    ASSERT( iters.first != iters.second,
     357        "GLWorldScene::removedBond() - could not find bond to id "+toString(_bondid));
     358    for (BondNodeMap::iterator iter = iters.first; iter != iters.second; ++iter) {
     359      GLMoleculeObject_bond *bondObject = iter->second;
     360      delete bondObject; // is done by signal from bond itself
     361      //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << ".");
     362    }
     363    BondsinSceneMap.erase(_bondid);
     364  }
    340365  {
    341366    boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
    342367    BondNodeParentMaps[0].left.erase(_bondid);
    343368    BondNodeParentMaps[1].left.erase(_bondid);
     369  }
     370  {
     371    const size_t erased = ObservedAtoms.erase(_bondid);
     372    ASSERT( erased == 1,
     373        "GLWorldScene::removeBond() - could not erase stored observed value "+toString(_bondid));
    344374  }
    345375
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    rd16a06 r136842  
    143143  atomId_t hoverAtomId;
    144144
    145   typedef std::map< ObservedValue_Index_t , GLMoleculeObject_molecule* > MoleculeNodeMap;
     145  typedef std::map< ObservedValue_Index_t, GLMoleculeObject_molecule* > MoleculeNodeMap;
    146146  typedef std::map< ObservedValue_Index_t, GLMoleculeObject_atom* > AtomNodeMap;
    147147  typedef std::multimap< ObservedValue_Index_t, GLMoleculeObject_bond* > BondNodeMap;
     
    159159  > BondNodeParentMap_t;
    160160
     161  typedef std::map< ObservedValue_Index_t, QtObservedAtom::ptr > ObservedAtoms_t;
     162  typedef std::map< ObservedValue_Index_t, QtObservedBond::ptr > ObservedBonds_t;
     163
    161164  //!> mutex to ascertain atomic access to NodeParentMaps
    162165  boost::recursive_mutex AtomNodeParentMap_mutex;
     
    170173  std::vector<BondNodeParentMap_t> BondNodeParentMaps;
    171174
     175  //!> stored observed atom such that its signals may always be safely evaluated
     176  ObservedAtoms_t ObservedAtoms;
     177  //!> stored observed bond such that its signals may always be safely evaluated
     178  ObservedBonds_t ObservedBonds;
     179
    172180  SelectionModeType selectionMode;
    173181
Note: See TracChangeset for help on using the changeset viewer.