Changeset 7ded1c for src/UIElements


Ignore:
Timestamp:
Feb 14, 2016, 12:34:27 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:
4cac6c
Parents:
3fe318
git-author:
Frederik Heber <heber@…> (01/05/16 22:22:13)
git-committer:
Frederik Heber <heber@…> (02/14/16 12:34:27)
Message:

GLMoleculeObject_atom and .._molecule don't get QtObserved... right away.

  • needs to be checked for empty instance first.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
2 edited

Legend:

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

    r3fe318 r7ded1c  
    361361  LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomInserted for atom "+toString(_id)+".");
    362362
    363   GLMoleculeObject_atom *atomObject =
    364       new GLMoleculeObject_atom(
    365           GLMoleculeObject::meshSphere,
    366           this,
    367           board.getObservedAtom(_id));
    368   ASSERT( atomObject != NULL,
    369       "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(_id));
    370   AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
    371   ASSERT(iter == AtomsinSceneMap.end(),
    372       "GLMoleculeObject_molecule::atomInserted - same atom with id "+toString(_id)+" added again.");
    373   AtomsinSceneMap.insert( make_pair(_id, atomObject) );
    374 
    375   qRegisterMetaType<atomId_t>("atomId_t");
    376   qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");
    377   connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t)));
    378   connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
    379   connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
    380   connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
    381 //  connect (atomObject, SIGNAL(bondsChanged()), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
    382   connect (atomObject, SIGNAL(BondsAdded(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
    383   connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
    384   connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t)));
    385 
    386   if (m_objectId  == -1)
    387     setObjectId(_id);
    388 
    389   emit changed();
    390   emit changeOccured();
     363  const QtObservedAtom::ptr _atom = board.getObservedAtom(_id);
     364  if (_atom) {
     365    GLMoleculeObject_atom *atomObject =
     366        new GLMoleculeObject_atom(
     367            GLMoleculeObject::meshSphere,
     368            this,
     369            _atom);
     370    ASSERT( atomObject != NULL,
     371        "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(_id));
     372    AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
     373    ASSERT(iter == AtomsinSceneMap.end(),
     374        "GLMoleculeObject_molecule::atomInserted - same atom with id "+toString(_id)+" added again.");
     375    AtomsinSceneMap.insert( make_pair(_id, atomObject) );
     376
     377    qRegisterMetaType<atomId_t>("atomId_t");
     378    qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");
     379    connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t)));
     380    connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
     381    connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
     382    connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
     383  //  connect (atomObject, SIGNAL(bondsChanged()), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
     384    connect (atomObject, SIGNAL(BondsAdded(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
     385    connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
     386    connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t)));
     387
     388    if (m_objectId  == -1)
     389      setObjectId(_id);
     390
     391    emit changed();
     392    emit changeOccured();
     393  }
    391394}
    392395
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r3fe318 r7ded1c  
    223223  // add new object
    224224  LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id);
    225   GLMoleculeObject_molecule *molObject =
    226       new GLMoleculeObject_molecule(
    227           GLMoleculeObject::meshEmpty,
    228           this,
    229           *board,
    230           board->getObservedMolecule(_id));
    231   ASSERT( molObject != NULL,
    232       "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
    233   MoleculesinSceneMap.insert( make_pair(_id, molObject) );
    234 
    235   // now handle all state changes that came up before the instantiation
    236   while (MoleculeMissedStateMap.count(_id) != 0) {
    237     ASSERT( !MoleculeMissedStateMap[_id].empty(),
    238         "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
    239         +toString(_id));
    240     boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    241     for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
    242         !MoleculeMissedStateMap[_id].empty();
    243         iter = MoleculeMissedStateMap[_id].begin()) {
    244       std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter =
    245           MoleculeMissedStateMap[_id].equal_range(iter->first);
    246       const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second);
    247       if (StateCounts > 1) {
    248         // more than one state change, have to combine
    249         typedef std::map<StateChangeType, size_t> StateChangeAmounts_t;
    250         StateChangeAmounts_t StateChangeAmounts;
    251         for (StateChangeMap_t::const_iterator stateiter = rangeiter.first;
    252             stateiter != rangeiter.second; ++stateiter)
    253           ++StateChangeAmounts[stateiter->second];
    254         ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState],
    255             "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
    256             +toString(iter->first));
    257         if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
    258           LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
    259           QMetaObject::invokeMethod(molObject,        // pointer to a QObject
    260                                     "atomInserted",       // member name (no parameters here)
    261                                     Qt::QueuedConnection,     // connection type
    262                                     Q_ARG(const atomId_t, iter->first));     // parameters
    263         } else {
    264           LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
    265         }
    266       } else {
    267         // can only be an insertion
    268         switch (rangeiter.first->second) {
    269           case atomRemovedState:
    270             ASSERT( 0,
    271                 "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom "
    272                 +toString(iter->first));
    273             break;
    274           case atomInsertedState:
     225  const QtObservedMolecule::ptr mol = board->getObservedMolecule(_id);
     226  if (mol) {
     227    GLMoleculeObject_molecule *molObject =
     228        new GLMoleculeObject_molecule(
     229            GLMoleculeObject::meshEmpty,
     230            this,
     231            *board,
     232            mol);
     233    ASSERT( molObject != NULL,
     234        "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
     235    MoleculesinSceneMap.insert( make_pair(_id, molObject) );
     236
     237    // now handle all state changes that came up before the instantiation
     238    while (MoleculeMissedStateMap.count(_id) != 0) {
     239      ASSERT( !MoleculeMissedStateMap[_id].empty(),
     240          "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
     241          +toString(_id));
     242      boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     243      for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
     244          !MoleculeMissedStateMap[_id].empty();
     245          iter = MoleculeMissedStateMap[_id].begin()) {
     246        std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter =
     247            MoleculeMissedStateMap[_id].equal_range(iter->first);
     248        const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second);
     249        if (StateCounts > 1) {
     250          // more than one state change, have to combine
     251          typedef std::map<StateChangeType, size_t> StateChangeAmounts_t;
     252          StateChangeAmounts_t StateChangeAmounts;
     253          for (StateChangeMap_t::const_iterator stateiter = rangeiter.first;
     254              stateiter != rangeiter.second; ++stateiter)
     255            ++StateChangeAmounts[stateiter->second];
     256          ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState],
     257              "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
     258              +toString(iter->first));
     259          if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
    275260            LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
    276261            QMetaObject::invokeMethod(molObject,        // pointer to a QObject
     
    278263                                      Qt::QueuedConnection,     // connection type
    279264                                      Q_ARG(const atomId_t, iter->first));     // parameters
    280             break;
    281           default:
    282             ASSERT( 0,
    283                 "GLWorldScene::moleculeInserted() - there are unknown change states.");
    284             break;
     265          } else {
     266            LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
     267          }
     268        } else {
     269          // can only be an insertion
     270          switch (rangeiter.first->second) {
     271            case atomRemovedState:
     272              ASSERT( 0,
     273                  "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom "
     274                  +toString(iter->first));
     275              break;
     276            case atomInsertedState:
     277              LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
     278              QMetaObject::invokeMethod(molObject,        // pointer to a QObject
     279                                        "atomInserted",       // member name (no parameters here)
     280                                        Qt::QueuedConnection,     // connection type
     281                                        Q_ARG(const atomId_t, iter->first));     // parameters
     282              break;
     283            default:
     284              ASSERT( 0,
     285                  "GLWorldScene::moleculeInserted() - there are unknown change states.");
     286              break;
     287          }
    285288        }
     289        // removed state changes for this atom
     290        MoleculeMissedStateMap[_id].erase(iter);
    286291      }
    287       // removed state changes for this atom
    288       MoleculeMissedStateMap[_id].erase(iter);
    289292    }
    290     // remove state change map for the molecule
     293
     294    connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
     295    connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
     296    connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
     297    connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
     298    connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
     299    connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
     300    connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
     301    connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
     302    connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
     303
     304    emit changed();
     305    emit changeOccured();
     306  }
     307
     308  // remove state change map for the molecule
     309  {
     310    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    291311    MoleculeMissedStateMap.erase(_id);
    292312  }
    293 
    294   connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
    295   connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
    296   connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
    297   connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
    298   connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
    299   connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
    300   connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
    301   connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
    302   connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
    303 
    304   emit changed();
    305   emit changeOccured();
    306313}
    307314
Note: See TracChangeset for help on using the changeset viewer.