Ignore:
Timestamp:
Oct 6, 2011, 4:06:10 PM (14 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:
db7e6d
Parents:
e638f9
git-author:
Frederik Heber <heber@…> (09/01/11 13:49:14)
git-committer:
Frederik Heber <heber@…> (10/06/11 16:06:10)
Message:

Introduced atom_observables and GLWorldView observes World, GLMoleculeObject_atom observes its atom.

Observer changes:

  • new Channels pattern required from CodePatterns 1.1.5 and that Observable signing on and off is now with const instance possible.
  • class atom is now observable, encapsulated in class AtomObservable:
    • enums have notification types
    • we use NotificationChannels of Observable to emit these distinct types.
  • atominfo, particleinfo, bondedparticleinfo all have OBSERVE and NOTIFY(..) in their setter functions (thx encapsulation).
  • class GLMoleculeObject_atom signs on to atom to changes to position, element, and index.
  • World equally has notifications for atom (new,remove) and molecules (new, remove).
  • GLWorldView now observes World for these changes.

Other changes:

  • removed additional hierarchy level for GLWidget of molecules (i.e. GLMoleculeScene removed and incorporated into GLWorldScene).
File:
1 edited

Legend:

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

    re638f9 r7188b1  
    2626#include "CodePatterns/MemDebug.hpp"
    2727
     28#include "CodePatterns/Log.hpp"
     29
     30#include "World.hpp"
     31
    2832GLWorldView::GLWorldView(QWidget *parent)
    29    : QGLView(parent), worldscene(NULL)
     33   : QGLView(parent), Observer("GLWorldView"), worldscene(NULL)
    3034{
    3135   worldscene = new GLWorldScene(this);
     
    3438
    3539   connect(worldscene, SIGNAL(changed()), this, SLOT(updateGL()));
     40   connect(this, SIGNAL(atomInserted(const atom *)), worldscene, SLOT(atomInserted(const atom *)));
     41   connect(this, SIGNAL(atomRemoved(const atom *)), worldscene, SLOT(atomRemoved(const atom *)));
     42   connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
     43
     44   // sign on to changes in the world
     45   World::getInstance().signOn(this);
     46   World::getInstance().signOn(this, World::getInstance().getChannel(World::AtomInserted));
     47   World::getInstance().signOn(this, World::getInstance().getChannel(World::AtomRemoved));
    3648}
    3749
     
    4153}
    4254
     55/**
     56 * Update operation which can be invoked by the observable (which should be the
     57 * change tracker here).
     58 */
     59void GLWorldView::update(Observable *publisher)
     60{
     61  emit changed();
     62}
     63
     64/**
     65 * The observable can tell when it dies.
     66 */
     67void GLWorldView::subjectKilled(Observable *publisher) {}
     68
     69/** Listen to specific changes to the world.
     70 *
     71 * @param publisher ref to observable.
     72 * @param notification type of notification
     73 */
     74void GLWorldView::recieveNotification(Observable *publisher, Notification_ptr notification)
     75{
     76  switch (notification->getChannelNo()) {
     77    case World::AtomInserted:
     78    {
     79      const atom *_atom = World::getInstance().lastChanged<atom>();
     80      LOG(0, "GLWorldView: Received notification that atom "+toString(_atom->getId())+" has been inserted.");
     81      emit atomInserted(_atom);
     82      break;
     83    }
     84    case World::AtomRemoved:
     85    {
     86      const atom *_atom = World::getInstance().lastChanged<atom>();
     87      LOG(0, "GLWorldView: Received notification that atom "+toString(_atom->getId())+" has been removed.");
     88      emit atomRemoved(_atom);
     89      break;
     90    }
     91    default:
     92      ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here.");
     93      break;
     94  }
     95}
    4396
    4497void GLWorldView::initializeGL(QGLPainter *painter)
Note: See TracChangeset for help on using the changeset viewer.