Changeset 7cf0eb for src/UIElements


Ignore:
Timestamp:
Feb 12, 2016, 11:15:04 PM (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:
e25448
Parents:
4ab5dc
git-author:
Frederik Heber <heber@…> (10/16/15 08:58:31)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:04)
Message:

FIX: GLWorldScene has additional moleculePrepared... slots and signals.

  • i.e. we first insert into MoleculesInMap via direct connection and then signal is emitted (queued) to construct the actual GLMoleculeObject_molecule.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
3 edited

Legend:

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

    r4ab5dc r7cf0eb  
    9090    GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true);
    9191  }
     92  connect(this, SIGNAL(moleculePreparedInserted(const moleculeId_t)), this, SLOT(moleculeInserted(const moleculeId_t)));
     93  connect(this, SIGNAL(moleculePreparedRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t)));
    9294
    9395//  connect(this, SIGNAL(updated()), this, SLOT(update()));
     
    217219}
    218220
    219 /** Inserts a molecule into the scene.
     221/** Prepres insertion of a molecule into the scene.
     222 *
     223 * This function takes up the insertion information, i.e. a molecule has been
     224 * inserted and its id, and takes some immediate action (writing id into a map).
     225 * But the request is then transmitted indirectly (i.e. not necessarily being
     226 * processed in the same thread). Hence, we first take the request via a direction
     227 * connection in the thread where the actual World::createMolecule() was called.
     228 * However, the creation of the visual representation must occur in the thread
     229 * who also contains GLWorldScene and GLWorldView and all further parents.
     230 *
     231 * That's the reason why we split here into moleculePrepareInserted and
     232 * moleculeInserted.
    220233 *
    221234 * @param _mol molecule to insert
    222235 */
    223 void GLWorldScene::moleculeInserted(const moleculeId_t _id)
    224 {
    225   LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "+toString(_id)+".");
     236void GLWorldScene::moleculePrepareInserted(const moleculeId_t _id)
     237{
     238  LOG(3, "INFO: GLWorldScene: Received signal moleculePrepareInserted for molecule "+toString(_id)+".");
     239
     240  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
     241
    226242  MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(_id);
    227243  ASSERT( iter == MoleculesinSceneMap.end(),
    228244      "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" already present.");
     245
     246  emit moleculePreparedInserted(_id);
     247}
     248
     249/** Inserts a molecule into the scene.
     250 *
     251 * \sa moleculePrepareInserted()
     252 *
     253 * @param _mol molecule to insert
     254 */
     255void GLWorldScene::moleculeInserted(const moleculeId_t _id)
     256{
     257  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    229258
    230259  // check whether molecule is still present
     
    233262    return;
    234263  }
    235   if (const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(_id)) == NULL)
     264  if (const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(_id)) == NULL) {
     265    ELOG(2, "Molecule with id " << _id << " has disappeared.");
    236266    return;
     267  }
    237268
    238269  // add new object
     
    319350}
    320351
    321 /** Removes a molecule from the scene.
     352/** Prepares removing a molecule from the scene.
     353 *
     354 * \sa moleculePrepareInserted()
    322355 *
    323356 * @param _id id of molecule to remove
    324357 */
    325 void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
    326 {
    327   LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_id)+".");
     358void GLWorldScene::moleculePrepareRemoved(const moleculeId_t _id)
     359{
     360  LOG(3, "INFO: GLWorldScene: Received signal moleculePrepareRemoved for molecule "+toString(_id)+".");
     361
     362  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
     363
    328364  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    329365  if ( iter == MoleculesinSceneMap.end())
    330366    RemovalMolecules.insert(_id);
    331   else {
    332 
    333     GLMoleculeObject_molecule *molObject = iter->second;
    334     molObject->disconnect();
    335     MoleculesinSceneMap.erase(iter);
    336     delete molObject;
     367
     368  emit moleculePreparedRemoved(_id);
     369}
     370
     371/** Removes a molecule from the scene.
     372 *
     373 * * \sa moleculePrepareRemoved()
     374 *
     375 * @param _id id of molecule to remove
     376 */
     377void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
     378{
     379  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
     380
     381  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
     382  GLMoleculeObject_molecule *molObject = iter->second;
     383  molObject->disconnect();
     384  MoleculesinSceneMap.erase(iter);
     385  delete molObject;
    337386
    338387  // remove any possible state changes left
     
    342391  }
    343392
    344     emit changed();
    345     emit changeOccured();
    346   }
     393  emit changed();
     394  emit changeOccured();
    347395}
    348396
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r4ab5dc r7cf0eb  
    8282  void hoverChanged(const atomId_t);
    8383  void hoverChanged(const moleculeId_t, int);
     84  void moleculePreparedInserted(const moleculeId_t _id);
     85  void moleculePreparedRemoved(const moleculeId_t _id);
    8486
    8587private slots:
    8688  void atomClicked(atomId_t no);
    8789  void moleculeClicked(moleculeId_t no);
     90  void moleculePrepareRemoved(const moleculeId_t _id);
     91  void moleculePrepareInserted(const moleculeId_t _id);
    8892  void moleculeRemoved(const moleculeId_t _id);
    8993  void moleculeInserted(const moleculeId_t _id);
     
    116120  MoleculeNodeMap MoleculesinSceneMap;
    117121  ShapeNodeMap ShapesinSceneMap;
     122  //!> flag to indicate whether state map is currently worked on
     123  boost::recursive_mutex MoleculeinSceneMap_mutex;
    118124
    119125  //!> enumeration of all possible changes molecule might have missed before instantiation
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    r4ab5dc r7cf0eb  
    9292  connect(this, SIGNAL(atomRemoved(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomRemoved(const moleculeId_t, const atomId_t)), Qt::DirectConnection);
    9393  connect(this, SIGNAL(atomInserted(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomInserted(const moleculeId_t, const atomId_t)), Qt::DirectConnection);
    94   connect(this, SIGNAL(moleculeInserted(const moleculeId_t)), worldscene, SLOT(moleculeInserted(const moleculeId_t)), Qt::DirectConnection);
    95   connect(this, SIGNAL(moleculeRemoved(const moleculeId_t)), worldscene, SLOT(moleculeRemoved(const moleculeId_t)), Qt::DirectConnection);
     94  connect(this, SIGNAL(moleculeInserted(const moleculeId_t)), worldscene, SLOT(moleculePrepareInserted(const moleculeId_t)), Qt::DirectConnection);
     95  connect(this, SIGNAL(moleculeRemoved(const moleculeId_t)), worldscene, SLOT(moleculePrepareRemoved(const moleculeId_t)), Qt::DirectConnection);
    9696  //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
    9797  connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
Note: See TracChangeset for help on using the changeset viewer.