Ignore:
Timestamp:
Jul 25, 2015, 1:01:44 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:
9b56f0a
Parents:
9737db
git-author:
Frederik Heber <heber@…> (06/17/15 16:59:19)
git-committer:
Frederik Heber <heber@…> (07/25/15 13:01:44)
Message:

Extracted signing on to molecule into activateObserver.

  • is called by GLWorldScene after all "missed" signals have been emitted.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
4 edited

Legend:

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

    r9737db r73b13c  
    156156  hoverAtomId(-1)
    157157{
     158  setMaterial(getMaterial(1));
     159  updateBoundingBox();
     160
     161  // initially, atoms and bonds should be visible
     162  m_visible = false;
     163
     164  connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
     165  connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
     166
     167  connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
     168}
     169
     170GLMoleculeObject_molecule::GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid) :
     171  GLMoleculeObject(mesh, parent),
     172  Observer(std::string("GLMoleculeObject_molecule")+toString(molid)),
     173  isBoundingBoxUptodate(true),
     174  isSignedOn(false),
     175  moleculeid(molid),
     176  TesselationHullUptodate(true),
     177  hoverAtomId(-1)
     178{
     179  setMaterial(getMaterial(1));
     180  updateBoundingBox();
     181
     182  // initially, atoms and bonds should be visible
     183  m_visible = false;
     184
     185  connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
     186  connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
     187
     188  connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
     189}
     190
     191GLMoleculeObject_molecule::~GLMoleculeObject_molecule()
     192{
     193  if (isSignedOn) {
     194    const molecule *_molecule = const_cast<const World &>(World::getInstance()).
     195        getMolecule(MoleculeById(moleculeid));
     196    if (_molecule != NULL) {
     197      _molecule->signOff(this, molecule::AtomInserted);
     198      _molecule->signOff(this, molecule::AtomRemoved);
     199      _molecule->signOff(this, molecule::AtomMoved);
     200    } else {
     201      ELOG(1, "GLMoleculeObject_molecule cannot sign off, molecule with "
     202          << moleculeid << " has disappeared.");
     203    }
     204  }
     205  /*_atom->signOff(this, AtomObservable::IndexChanged);
     206  _atom->signOff(this, AtomObservable::PositionChanged);
     207  _atom->signOff(this, AtomObservable::ElementChanged);
     208  _atom->signOff(this, AtomObservable::BondsAdded);*/
     209  World::getInstance().signOff(this, World::SelectionChanged);
     210}
     211
     212void GLMoleculeObject_molecule::activateObserver()
     213{
    158214  // sign on as observer (obtain non-const instance before)
    159215  const molecule *_molecule = const_cast<const World &>(World::getInstance()).
     
    171227  molref->signOn(this, AtomObservable::ElementChanged);
    172228  molref->signOn(this, AtomObservable::BondsAdded);*/
    173   setMaterial(getMaterial(1));
    174229  World::getInstance().signOn(this, World::SelectionChanged);
    175   updateBoundingBox();
    176 
    177   // initially, atoms and bonds should be visible
    178   m_visible = false;
    179 
    180   connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
    181   connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
    182 
    183   connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
    184 }
    185 
    186 GLMoleculeObject_molecule::GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid) :
    187   GLMoleculeObject(mesh, parent),
    188   Observer(std::string("GLMoleculeObject_molecule")+toString(molid)),
    189   isBoundingBoxUptodate(true),
    190   isSignedOn(false),
    191   moleculeid(molid),
    192   TesselationHullUptodate(true),
    193   hoverAtomId(-1)
    194 {
    195   // sign on as observer (obtain non-const instance before)
    196   const molecule *_molecule = const_cast<const World &>(World::getInstance()).
    197       getMolecule(MoleculeById(moleculeid));
    198   if (_molecule != NULL) {
    199     _molecule->signOn(this, molecule::AtomInserted);
    200     _molecule->signOn(this, molecule::AtomRemoved);
    201     _molecule->signOn(this, molecule::AtomMoved);
    202     isSignedOn = true;
    203   } else {
    204     ELOG(1, "GLMoleculeObject_molecule() - added null object for not present mol id " << moleculeid);
    205   }
    206   /*molref->signOn(this, AtomObservable::IndexChanged);
    207   molref->signOn(this, AtomObservable::PositionChanged);
    208   molref->signOn(this, AtomObservable::ElementChanged);
    209   molref->signOn(this, AtomObservable::BondsAdded);*/
    210   setMaterial(getMaterial(1));
    211   World::getInstance().signOn(this, World::SelectionChanged);
    212   updateBoundingBox();
    213 
    214   // initially, atoms and bonds should be visible
    215   m_visible = false;
    216 
    217   connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
    218   connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
    219 
    220   connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
    221 }
    222 
    223 GLMoleculeObject_molecule::~GLMoleculeObject_molecule()
    224 {
    225   if (isSignedOn) {
    226     const molecule *_molecule = const_cast<const World &>(World::getInstance()).
    227         getMolecule(MoleculeById(moleculeid));
    228     if (_molecule != NULL) {
    229       _molecule->signOff(this, molecule::AtomInserted);
    230       _molecule->signOff(this, molecule::AtomRemoved);
    231       _molecule->signOff(this, molecule::AtomMoved);
    232     } else {
    233       ELOG(1, "GLMoleculeObject_molecule cannot sign off, molecule with "
    234           << moleculeid << " has disappeared.");
    235     }
    236   }
    237   /*_atom->signOff(this, AtomObservable::IndexChanged);
    238   _atom->signOff(this, AtomObservable::PositionChanged);
    239   _atom->signOff(this, AtomObservable::ElementChanged);
    240   _atom->signOff(this, AtomObservable::BondsAdded);*/
    241   World::getInstance().signOff(this, World::SelectionChanged);
    242230}
    243231
     
    534522  AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
    535523  ASSERT(iter != AtomsinSceneMap.end(),
    536       "GLWorldScene::atomRemoved() - atom "+toString(_id)+" not on display.");
     524      "GLMoleculeObject_molecule::atomRemoved() - atom "+toString(_id)+" not on display.");
    537525  GLMoleculeObject_atom *atomObject = iter->second;
    538526  AtomsinSceneMap.erase(iter);
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp

    r9737db r73b13c  
    7676  void setVisible(bool value);
    7777
     78  void activateObserver();
     79
    7880private:
    7981  void addAtomBonds(
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r9737db r73b13c  
    7070using namespace MoleCuilder;
    7171
    72 GLWorldScene::GLWorldScene(QObject *parent)
    73    : QObject(parent)
     72GLWorldScene::GLWorldScene(QObject *parent) :
     73    QObject(parent),
     74    selectionMode(SelectAtom)
    7475{
    7576  int sphereDetails[] = {5, 3, 2, 0};
     
    228229  LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+".");
    229230
     231  boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     232
    230233  // check of molecule is already present
    231234  if (MoleculesinSceneMap.count(_molid) != 0) {
     
    248251  LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_atomid)+".");
    249252
     253  boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     254
    250255  // check of molecule is already present
    251256  if (MoleculesinSceneMap.count(_molid) != 0) {
     
    276281  MoleculesinSceneMap.insert( make_pair(_id, molObject) );
    277282
    278   // now handle all state changes that came up before the instantiation
    279   if (MoleculeMissedStateMap.count(_id) != 0) {
     283  // now handle all state changes that came up before the instantiation7
     284  while (MoleculeMissedStateMap.count(_id) != 0) {
    280285    ASSERT( !MoleculeMissedStateMap[_id].empty(),
    281286        "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
    282287        +toString(_id));
     288    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    283289    for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
    284290        !MoleculeMissedStateMap[_id].empty();
     
    297303            "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
    298304            +toString(iter->first));
    299         if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState])
     305        if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
     306          LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
    300307          QMetaObject::invokeMethod(molObject,        // pointer to a QObject
    301308                                    "atomInserted",       // member name (no parameters here)
    302309                                    Qt::DirectConnection,     // connection type
    303310                                    Q_ARG(const atomId_t, iter->first));     // parameters
     311        } else {
     312          LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
     313        }
    304314      } else {
    305315        // can only be an insertion
     
    311321            break;
    312322          case atomInsertedState:
     323            LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
    313324            QMetaObject::invokeMethod(molObject,        // pointer to a QObject
    314325                                      "atomInserted",       // member name (no parameters here)
     
    329340  }
    330341
     342  // now let the molObject sign on to molecule
     343  molObject->activateObserver();
     344
    331345  connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
    332346  connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
     
    359373
    360374  // remove any possible state changes left
    361   MoleculeMissedStateMap.erase(_id);
     375  {
     376    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     377    MoleculeMissedStateMap.erase(_id);
     378  }
    362379
    363380  emit changed();
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r9737db r73b13c  
    1919
    2020#include <iosfwd>
     21
     22#include <boost/thread/recursive_mutex.hpp>
    2123
    2224#include "Bond/bond.hpp"
     
    116118  //!> map of all missed state changes
    117119  MoleculeMissedStateMap_t MoleculeMissedStateMap;
     120  //!> flag to indicate whether state map is currently worked on
     121  boost::recursive_mutex MoleculeMissedStateMap_mutex;
    118122
    119123  SelectionModeType selectionMode;
Note: See TracChangeset for help on using the changeset viewer.