Ignore:
Timestamp:
Feb 12, 2016, 11:15:07 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:
2f7988
Parents:
8d5fbf1
git-author:
Frederik Heber <heber@…> (01/25/16 09:09:33)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:07)
Message:

Changed connections between GLWorldScene, GLWorldView and GLMoleculeObject_molecule.

File:
1 edited

Legend:

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

    r8d5fbf1 r0f7ffe  
    102102  // sign on to changes in the world
    103103  World::getInstance().signOn(this);
    104   World::getInstance().signOn(this, World::MoleculeInserted);
    105104  World::getInstance().signOn(this, World::SelectionChanged);
    106105//  WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);
     
    117116GLWorldView::~GLWorldView()
    118117{
    119   // remove me from all observed molecules
    120   for (ObservedMolecules_t::iterator iter = ObservedMolecules.begin();
    121       !ObservedMolecules.empty();
    122       iter = ObservedMolecules.begin())
    123     signOffFromMolecule(*iter);
    124 
    125118  QSettings settings;
    126119  settings.beginGroup("WorldView");
     
    131124
    132125  World::getInstance().signOff(this);
    133   World::getInstance().signOff(this, World::MoleculeInserted);
    134126  World::getInstance().signOff(this, World::SelectionChanged);
    135127//  WorldTime::getInstance().signOff(this, WorldTime::TimeChanged);
     
    335327}
    336328
    337 void GLWorldView::signOnToMolecule(const molecule *_mol)
    338 {
    339   ASSERT( _mol != NULL,
    340       "GLWorldView::signOnToMolecule() - molecule ref is NULL.");
    341   _mol->signOn(this, molecule::AtomInserted);
    342   _mol->signOn(this, molecule::AtomRemoved);
    343 
    344   ObservedMolecules.insert(const_cast<molecule *>(_mol));
    345 }
    346 
    347 void GLWorldView::signOffFromMolecule(const molecule *_mol)
    348 {
    349   ObservedMolecules_t::const_iterator iter = ObservedMolecules.find(
    350       const_cast<molecule *>(_mol));
    351   ASSERT( iter != ObservedMolecules.end(),
    352       "GLWorldView::signOffFromMolecule() - molecule "+toString(_mol)
    353       +" gave subjectKilled we are not signed on.");
    354 //    LOG(1, "INFO: Erasing " << mol << " from ObservedMolecules.");
    355   ObservedMolecules.erase(iter);
    356 
    357   ASSERT( _mol != NULL,
    358       "GLWorldView::signOffFromMolecule() - molecule ref is NULL.");
    359   _mol->signOff(this, molecule::AtomInserted);
    360   _mol->signOff(this, molecule::AtomRemoved);
    361 }
    362 
    363329/**
    364330 * The observable can tell when it dies.
     
    366332void GLWorldView::subjectKilled(Observable *publisher)
    367333{
    368   molecule * mol = static_cast<molecule *>(publisher);
    369 
    370 //  std::copy(ObservedMolecules.begin(), ObservedMolecules.end(),
    371 //      std::ostream_iterator<molecule *>(std::cout, "\n"));
    372 
    373   if (mol != NULL) {
    374     ObservedMolecules.erase(mol);
    375 //
    376 //    // sign off
    377 //    signOffFromMolecule(mol);
    378 
    379     // emit removed signal
    380     const moleculeId_t _id = mol->getId();
    381     emit moleculeRemoved(_id);
    382   }
     334  // world never dies
    383335}
    384336
     
    398350  #endif
    399351        emit worldSelectionChanged();
    400         break;
    401       }
    402       case World::MoleculeInserted:
    403       {
    404         const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
    405   #ifdef LOG_OBSERVER
    406         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been inserted.";
    407   #endif
    408         const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
    409             getMolecule(MoleculeById(_id));
    410         if (_molecule != NULL) {
    411           signOnToMolecule(_molecule);
    412 
    413           emit moleculeInserted(_id);
    414         }
    415352        break;
    416353      }
     
    432369      default:
    433370        ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for WorldTime.");
    434         break;
    435     }
    436   } else if (dynamic_cast<molecule *>(publisher) != NULL) {
    437     const molecule * mol = const_cast<const molecule * const>(dynamic_cast<molecule *>(publisher));
    438     const moleculeId_t molid = mol->getId();
    439     const atomId_t atomid = mol->lastChangedAtomId();
    440     switch (notification->getChannelNo()) {
    441       case molecule::AtomInserted:
    442       {
    443 #ifdef LOG_OBSERVER
    444         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this))
    445             << " received notification that atom "+toString(atomid)+" has been inserted into molecule "+toString(molid)+".";
    446 #endif
    447         emit atomInserted(molid, atomid);
    448         break;
    449       }
    450       case World::AtomRemoved:
    451       {
    452 #ifdef LOG_OBSERVER
    453         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this))
    454             << " received notification that atom "+toString(atomid)+" has been removed from molecule "+toString(molid)+".";
    455 #endif
    456         emit atomRemoved(molid, atomid);
    457         break;
    458       }
    459       default:
    460         ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for molecule.");
    461371        break;
    462372    }
Note: See TracChangeset for help on using the changeset viewer.