Changeset e29427 for src/UIElements


Ignore:
Timestamp:
Feb 26, 2016, 9:46:19 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:
640cbd
Parents:
805fdc
git-author:
Frederik Heber <heber@…> (02/13/16 15:43:33)
git-committer:
Frederik Heber <heber@…> (02/26/16 09:46:19)
Message:

GLWorldScene RemovedMolecules now uses QtObservedMolecule* as key.

  • moleculeId_t is not unique, a new molecule of the same id might have already been instantiated. The shared_ptrs live till the end, hence the memory address can be safely used as unique key to the respective molecule instance.
  • signatures of signal removeMolecule() and slots moleculeRemoved() and moleculeEmptied() changed from id to this ptr.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
4 edited

Legend:

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

    r805fdc re29427  
    420420
    421421  if (AtomsinSceneMap.empty())
    422     emit moleculeEmptied(ObservedMolecule->getMolIndex());
     422    emit moleculeEmptied(ObservedMolecule);
    423423
    424424  emit changed();
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp

    r805fdc re29427  
    6969  void hoverChanged(const moleculeId_t, int);
    7070  void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
    71   void atomClicked(atomId_t no);
    72   void moleculeClicked(moleculeId_t no);
    73   void moleculeEmptied(moleculeId_t no);
     71  void atomClicked(atomId_t);
     72  void moleculeClicked(moleculeId_t);
     73  void moleculeEmptied(QtObservedMolecule::ptr);
    7474  void IsSelectedChanged();
    7575
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r805fdc re29427  
    105105  connect(this, SIGNAL(insertMolecule(QtObservedMolecule::ptr)),
    106106      this, SLOT(moleculeInserted(QtObservedMolecule::ptr)) );
    107   connect(this, SIGNAL(removeMolecule(const moleculeId_t)),
    108       this, SLOT(moleculeRemoved(const moleculeId_t)) );
     107  connect(this, SIGNAL(removeMolecule(QtObservedMolecule*)),
     108      this, SLOT(moleculeRemoved(QtObservedMolecule*)) );
    109109
    110110//  connect(this, SIGNAL(updated()), this, SLOT(update()));
     
    197197{
    198198  const atomId_t atomid = _atom->getAtomIndex();
    199   const atomId_t molid = _atom->getAtomMoleculeIndex();
     199  const atomId_t atommolid = _atom->getAtomMoleculeIndex();
     200  const atomId_t molid = _mol->getMolIndex();
     201  ASSERT( molid == atommolid,
     202      "GLWorldScene::moleculesAtomInserted() - atom "+toString(atomid)+" claims to belong to mol "
     203       +toString(atommolid)+" but signal came from QtObservedMolecule with id "
     204       +toString(molid)+".");
    200205  LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(atomid)+".");
    201206
     
    216221//      LOG(3, "INFO: GLWorldScene: Sending signal moleculesAtomInserted for atom "+toString(_atomid)
    217222//          +" to molecule in RemovedMolecules.");
    218 //      const MoleculeNodeMap::iterator removedmoliter = RemovedMolecules.find(molid);
     223//      const RemovedMoleculesMap_t::iterator removedmoliter = RemovedMolecules.find(molid);
    219224//      ASSERT( removedmoliter != RemovedMolecules.end(),
    220225//          "GLWorldScene::moleculesAtomInserted() - signal from old mol "
     
    228233    }
    229234  } else {
    230     boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    231     // only record missed state for molecule if (still) present but not instantiated
    232     if (QtObservedMoleculeMap.count(molid)) {
    233       // store signal for when it is instantiated
    234       if (MoleculeMissedStateMap.count(molid) == 0)
    235         MoleculeMissedStateMap.insert( std::make_pair(molid ,StateChangeMap_t()) );
    236       MoleculeMissedStateMap[molid].insert( std::make_pair(atomid, atomInsertedState) );
    237       ASSERT( QtObservedAtomMap[atomid] == _atom,
    238           "GLWorldScene::moleculesAtomInserted() - atom "+toString(atomid)
    239           +" inserted in molecule "+toString(molid)
    240           +" which does not match atom in QtObservedAtomMap.");
    241       LOG(3, "INFO: GLWorldScene: Placing atomInserted for atom " << atomid
    242            << " and molecule " << molid << " into missed state map.");
     235    const RemovedMoleculesMap_t::iterator removedmoliter = RemovedMolecules.find(_mol);
     236    if (removedmoliter != RemovedMolecules.end()) {
     237      ASSERT( 0,
     238          "GLWorldScene::moleculesAtomInserted() - would need to send atomInserted to already removed molecule.");
     239    } else {
     240      boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     241      // only record missed state for molecule if (still) present but not instantiated
     242      if (QtObservedMoleculeMap.count(molid)) {
     243        // store signal for when it is instantiated
     244        if (MoleculeMissedStateMap.count(molid) == 0)
     245          MoleculeMissedStateMap.insert( std::make_pair(molid ,StateChangeMap_t()) );
     246        MoleculeMissedStateMap[molid].insert( std::make_pair(atomid, atomInsertedState) );
     247        ASSERT( QtObservedAtomMap[atomid] == _atom,
     248            "GLWorldScene::moleculesAtomInserted() - atom "+toString(atomid)
     249            +" inserted in molecule "+toString(molid)
     250            +" which does not match atom in QtObservedAtomMap.");
     251        LOG(3, "INFO: GLWorldScene: Placing atomInserted for atom " << atomid
     252             << " and molecule " << molid << " into missed state map.");
     253      }
    243254    }
    244255  }
     
    269280      LOG(3, "INFO: GLWorldScene: Sending signal moleculesAtomRemoved for atom "+toString(_atomid)
    270281          +" to molecule in RemovedMolecules.");
    271       const MoleculeNodeMap::iterator removedmoliter = RemovedMolecules.find(molid);
     282      const RemovedMoleculesMap_t::iterator removedmoliter = RemovedMolecules.find(_mol);
    272283      ASSERT( removedmoliter != RemovedMolecules.end(),
    273284          "GLWorldScene::moleculesAtomRemoved() - signal from old molecule "
     
    286297    }
    287298  } else {
    288     const MoleculeNodeMap::iterator removedmoliter = RemovedMolecules.find(molid);
     299    const RemovedMoleculesMap_t::iterator removedmoliter = RemovedMolecules.find(_mol);
    289300    if (removedmoliter != RemovedMolecules.end()) {
    290301      ASSERT( removedmoliter != RemovedMolecules.end(),
     
    345356  disconnect(eraseiter->second.get(), SIGNAL(indexChanged(const moleculeId_t,const moleculeId_t)),
    346357      this, SLOT(moleculeIndexChanged(const moleculeId_t,const moleculeId_t)) );
     358  QtObservedMolecule * mol = eraseiter->second.get();
    347359  QtObservedMoleculeMap.erase(eraseiter);
    348360
    349361  LOG(3, "INFO: GLWorldScene: Received signal moleculeSignOff for molecule "+toString(_id)+".");
    350362
    351   emit removeMolecule(_id);
     363  emit removeMolecule(mol);
    352364}
    353365
     
    452464  connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
    453465  connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
    454   connect (molObject, SIGNAL(moleculeEmptied(moleculeId_t)), this, SLOT(moleculeEmpty(moleculeId_t)));
     466  connect (molObject, SIGNAL(moleculeEmptied(QtObservedMolecule::ptr)), this, SLOT(moleculeEmpty(QtObservedMolecule::ptr)));
    455467  connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
    456468  connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
     
    471483/** Removes a molecule from the scene.
    472484 *
    473  * @param _id id of molecule to remove
    474  */
    475 void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
    476 {
    477   LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_id)+".");
     485 * @param _mol QtObservedMolecule instance of molecule to remove
     486 */
     487void GLWorldScene::moleculeRemoved(QtObservedMolecule* _mol)
     488{
     489  const moleculeId_t molid = _mol->getMolIndex();
     490  LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(molid)+".");
    478491
    479492  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    480493
    481   MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
     494  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(molid);
    482495  if ( iter != MoleculesinSceneMap.end()) {
    483     LOG(1, "DEBUG: Removing GLMoleculeObject_molecule to id " << _id << " from scene.");
    484     RemovedMolecules.insert( std::make_pair(_id, iter->second) );
     496    LOG(1, "DEBUG: Removing GLMoleculeObject_molecule to id " << molid << " from scene.");
     497    RemovedMolecules.insert( std::make_pair(_mol, iter->second) );
    485498    MoleculesinSceneMap.erase(iter);
    486499  }
     
    489502  {
    490503    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    491     MoleculeMissedStateMap.erase(_id);
    492   }
    493 }
    494 
    495 void GLWorldScene::moleculeEmpty(const moleculeId_t _id)
    496 {
    497   LOG(3, "INFO: GLWorldScene: Received signal moleculeEmpty for molecule "+toString(_id)+".");
     504    MoleculeMissedStateMap.erase(molid);
     505  }
     506}
     507
     508void GLWorldScene::moleculeEmpty(QtObservedMolecule::ptr _mol)
     509{
     510  const moleculeId_t molid = _mol->getMolIndex();
     511  LOG(3, "INFO: GLWorldScene: Received signal moleculeEmpty for molecule "+toString(molid)+".");
    498512
    499513  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    500514
    501   MoleculeNodeMap::iterator iter = RemovedMolecules.find(_id);
     515  RemovedMoleculesMap_t::iterator iter = RemovedMolecules.find(_mol.get());
    502516  if ( iter != RemovedMolecules.end()) {
    503     LOG(1, "DEBUG: Deleting GLMoleculeObject_molecule to id " << _id);
     517    LOG(1, "DEBUG: Deleting GLMoleculeObject_molecule to id " << molid);
    504518    GLMoleculeObject_molecule *molObject = iter->second;
    505519    RemovedMolecules.erase(iter);
     
    508522  } else {
    509523    ASSERT(0,
    510         "GLWorldScene::moleculeEmpty() - molecule "+toString(_id)+" is empty that is not present.");
     524        "GLWorldScene::moleculeEmpty() - molecule "+toString(molid)+" is empty that is not present.");
    511525  }
    512526
     
    514528  {
    515529    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    516     MoleculeMissedStateMap.erase(_id);
     530    MoleculeMissedStateMap.erase(molid);
    517531  }
    518532
     
    563577    }
    564578  }
    565   {
    566     MoleculeNodeMap::iterator const olditer = RemovedMolecules.find(_oldid);
    567     if ( olditer != RemovedMolecules.end()) {
    568 #ifndef NDEBUG
    569       MoleculeNodeMap::iterator const newiter = RemovedMolecules.find(_newid);
    570       ASSERT ( newiter == RemovedMolecules.end(),
    571           "GLWorldScene::moleculeIndexChanged() - molecule "
    572           +toString(_newid)+" already present in RemovedMolecules.");
    573 #endif
    574       LOG(1, "DEBUG: Changing GLMoleculeObject_molecule in RemovedMolecules from "
    575           << _oldid << " to id " << _newid);
    576       GLMoleculeObject_molecule* const molObject = olditer->second;
    577       RemovedMolecules.erase(olditer);
    578       RemovedMolecules[_newid] = molObject;
    579     }
    580   }
    581579}
    582580
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r805fdc re29427  
    8585  void hoverChanged(const moleculeId_t, int);
    8686  void insertMolecule(QtObservedMolecule::ptr);
    87   void removeMolecule(const moleculeId_t);
     87  void removeMolecule(QtObservedMolecule*);
    8888
    8989private slots:
    9090  void atomClicked(atomId_t no);
    9191  void moleculeClicked(moleculeId_t no);
    92   void moleculeRemoved(const moleculeId_t _id);
     92  void moleculeRemoved(QtObservedMolecule* _mol);
    9393  void moleculeSignOff(const moleculeId_t _id);
    94   void moleculeEmpty(const moleculeId_t _id);
     94  void moleculeEmpty(QtObservedMolecule::ptr _mol);
    9595  void moleculeInserted(QtObservedMolecule::ptr);
    9696  void moleculeSignOn(QtObservedMolecule::ptr);
     
    137137  QtObservedMoleculeMap_t QtObservedMoleculeMap;
    138138
     139  //!> map to get from QtObservedMolecule to the visual representant
     140  typedef std::map< QtObservedMolecule* , GLMoleculeObject_molecule* > RemovedMoleculesMap_t;
    139141  //!> set of all currently removed molecules
    140   MoleculeNodeMap RemovedMolecules;
     142  RemovedMoleculesMap_t RemovedMolecules;
    141143
    142144  //!> flag to indicate whether state map is currently worked on
Note: See TracChangeset for help on using the changeset viewer.