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).
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp

    re638f9 r7188b1  
    3535
    3636   //!> Allow it to call cleanMaterialMap()
    37    friend class GLMoleculeScene;
     37   friend class GLWorldScene;
    3838public:
    3939   explicit GLMoleculeObject(QGLSceneNode *GLMoleculeObject, QObject *parent=0);
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp

    re638f9 r7188b1  
    2727
    2828#include "CodePatterns/Assert.hpp"
     29#include "CodePatterns/Log.hpp"
    2930
     31#include "Descriptors/AtomIdDescriptor.hpp"
    3032#include "element.hpp"
    3133#include "LinearAlgebra/Vector.hpp"
    32 
     34#include "World.hpp"
    3335
    3436static QGLSceneNode * createAtom(QObject *parent)
     
    4244
    4345GLMoleculeObject_atom::GLMoleculeObject_atom(QObject *parent, const atom *atomref) :
    44   GLMoleculeObject(createAtom(parent), parent), _atom(atomref)
     46  GLMoleculeObject(createAtom(parent), parent), Observer("GLMoleculeObject_atom"), _atom(atomref)
     47{
     48  // sign on as observer (obtain non-const instance before)
     49  atomref->signOn(this, atomref->getChannel(AtomObservable::IndexChanged));
     50  atomref->signOn(this, atomref->getChannel(AtomObservable::PositionChanged));
     51  atomref->signOn(this, atomref->getChannel(AtomObservable::ElementChanged));
     52
     53  // set the object's id
     54  resetProperties();
     55
     56  std::cout << "Created sphere for atom " << _atom->getId() << "." << endl;
     57
     58  connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
     59}
     60
     61void GLMoleculeObject_atom::update(Observable *publisher)
     62{
     63  LOG(0, "GLMoleculeObject_atom::update() - called fro atom "+toString(_atom->getId())+".");
     64  resetProperties();
     65}
     66
     67void GLMoleculeObject_atom::resetPosition()
    4568{
    4669  const Vector Position = _atom->getPosition();
    47   const size_t elementno = _atom->getType()->getNumber();
     70  LOG(1, "GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+".");
     71  setPosition(QVector3D(Position[0], Position[1], Position[2]));
     72}
     73
     74void GLMoleculeObject_atom::resetElement()
     75{
     76  size_t elementno = 0;
     77  if (_atom->getType() != NULL) {
     78    elementno = _atom->getType()->getNumber();
     79  } else { // if no element yet, set to hydrogen
     80    elementno = 1;
     81  }
     82  LOG(1, "GLMoleculeObject_atom::resetIndex() - new element number is "+toString(elementno)+".");
    4883
    4984  // set materials
     
    5792  setHoverMaterial(hovermaterial);
    5893
     94  // set scale
     95  double radius = 0.;
     96  if (_atom->getType() != NULL) {
     97    radius = _atom->getType()->getVanDerWaalsRadius();
     98  } else {
     99    radius = 0.5;
     100  }
     101  setScale( radius );
     102}
     103
     104void GLMoleculeObject_atom::resetIndex()
     105{
     106  const size_t atomno = _atom->getId();
     107  LOG(1, "GLMoleculeObject_atom::resetIndex() - new index is "+toString(atomno)+".");
     108  setObjectId(atomno);
     109}
     110
     111void GLMoleculeObject_atom::resetProperties()
     112{
    59113  // set position
    60   setPosition(QVector3D(Position[0], Position[1], Position[2]));
     114  resetPosition();
    61115
    62   // set scale
    63   setScale( _atom->getType()->getVanDerWaalsRadius());
     116  // set element
     117  resetElement();
    64118
    65119  // set the object's id
    66   setObjectId(_atom->getId());
     120  resetIndex();
     121}
    67122
    68   std::cout << "Created sphere at " << Position << " with elementno " << elementno << "." << endl;
     123void GLMoleculeObject_atom::subjectKilled(Observable *publisher)
     124{}
    69125
    70   connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
     126void GLMoleculeObject_atom::recieveNotification(Observable *publisher, Notification_ptr notification)
     127{
     128  LOG(0, "GLMoleculeObject_atom::recieveNotification() - notification type "
     129      +toString(notification->getChannelNo())+".");
     130  switch (notification->getChannelNo()) {
     131    case AtomObservable::ElementChanged:
     132      resetElement();
     133      break;
     134    case AtomObservable::IndexChanged:
     135      resetIndex();
     136      break;
     137    case AtomObservable::PositionChanged:
     138      resetPosition();
     139      break;
     140    default:
     141      //setProperties();
     142      break;
     143  }
    71144}
    72145
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp

    re638f9 r7188b1  
    1616#include "GLMoleculeObject.hpp"
    1717
     18#include "CodePatterns/Observer.hpp"
     19
    1820#include "atom.hpp"
    1921
    20 class GLMoleculeObject_atom : public GLMoleculeObject
     22class GLMoleculeObject_atom : public GLMoleculeObject, public Observer
    2123{
    2224  Q_OBJECT
    2325public:
    2426  GLMoleculeObject_atom(QObject *parent, const atom *atomref);
    25   ~GLMoleculeObject_atom() {}
     27  virtual ~GLMoleculeObject_atom() {}
     28
     29  // Observer functions
     30  void update(Observable *publisher);
     31  void subjectKilled(Observable *publisher);
     32  void recieveNotification(Observable *publisher, Notification_ptr notification);
    2633
    2734private slots:
     
    3239
    3340private:
     41  void resetPosition();
     42  void resetElement();
     43  void resetIndex();
     44  void resetProperties();
     45
    3446  const atom *_atom;
    3547};
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    re638f9 r7188b1  
    5858      Position = _bond->leftatom->getPosition();
    5959      OtherPosition = _bond->rightatom->getPosition();
    60       elementno = _bond->leftatom->getType()->getNumber();
     60      if (_bond->leftatom->getType() != NULL) {
     61        elementno = _bond->leftatom->getType()->getNumber();
     62      } else { // if not element yet set, set to hydrogen
     63        elementno = 1;
     64      }
    6165      break;
    6266    case right:
    6367      Position = _bond->rightatom->getPosition();
    6468      OtherPosition = _bond->leftatom->getPosition();
    65       elementno = _bond->rightatom->getType()->getNumber();
     69      if (_bond->rightatom->getType() != NULL) {
     70        elementno = _bond->rightatom->getType()->getNumber();
     71      } else { // if not element yet set, set to hydrogen
     72        elementno = 1;
     73      }
     74
    6675      break;
    6776    default:
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp

    re638f9 r7188b1  
    2525
    2626  GLMoleculeObject_bond(QObject *parent, const bond *bondref, double distance, enum SideOfBond side);
    27   ~GLMoleculeObject_bond() {}
     27  virtual ~GLMoleculeObject_bond() {}
    2828
    2929
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    re638f9 r7188b1  
    2222#include "GLWorldScene.hpp"
    2323
    24 #include "GLMoleculeScene.hpp"
    2524#include "GLMoleculeObject.hpp"
     25#include "GLMoleculeObject_atom.hpp"
     26#include "GLMoleculeObject_bond.hpp"
    2627
    2728#include "CodePatterns/MemDebug.hpp"
    2829
     30#include "CodePatterns/Log.hpp"
     31
    2932#include "atom.hpp"
     33#include "Bond/bond.hpp"
    3034#include "molecule.hpp"
    3135#include "World.hpp"
     
    4145
    4246GLWorldScene::~GLWorldScene()
    43 {}
     47{
     48  // remove all elements
     49  GLMoleculeObject::cleanMaterialMap();
     50}
    4451
    4552/** Initialise the WorldScene with molecules and atoms from World.
     
    5562        Runner++) {
    5663      // create molecule
    57       GLMoleculeScene * const molObject = new GLMoleculeScene(this, *Runner);
    58       MoleculeSceneList.push_back(molObject);
    59       connect (molObject, SIGNAL(clicked(atomId_t, moleculeId_t)), this, SLOT(molClicked(atomId_t, moleculeId_t)));
    60       connect (molObject, SIGNAL(hoverChanged()), this, SIGNAL(changed()));
     64      for (molecule::const_iterator atomiter = (*Runner)->begin();
     65          atomiter != (*Runner)->end();
     66          ++atomiter) {
     67        // create atom objects in scene
     68        atomInserted(*atomiter);
     69
     70        // create its bonds
     71        const BondList &bonds = (*atomiter)->getListOfBonds();
     72        for (BondList::const_iterator bonditer = bonds.begin();
     73            bonditer != bonds.end();
     74            ++bonditer) {
     75          if ((*bonditer)->leftatom->getId() == (*atomiter)->getId()) {
     76            // create bond objects in scene
     77            bondInserted(*bonditer);
     78          }
     79        }
     80      }
    6181    }
    6282  }
    6383}
    6484
     85/** Adds an atom to the scene.
     86 *
     87 * @param _atom atom to add
     88 */
     89void GLWorldScene::atomInserted(const atom *_atom)
     90{
     91  LOG(0, "GLWorldScene: Received signal atomInserted for atom "+toString(_atom->getId())+".");
     92  GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(this, _atom);
     93  AtomNodeMap::iterator iter = AtomsinMoleculeMap.find(_atom->getId());
     94  ASSERT(iter == AtomsinMoleculeMap.end(),
     95      "GLWorldScene::atomAdded() - same atom "+_atom->getName()+" added again.");
     96  AtomsinMoleculeMap.insert( make_pair(_atom->getId(), atomObject) );
     97  connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
     98  connect (atomObject, SIGNAL(hoverChanged()), this, SIGNAL(hoverChanged()));
     99  emit changed();
     100}
     101
     102/** Removes an atom from the scene.
     103 *
     104 * @param _atom atom to remove
     105 */
     106void GLWorldScene::atomRemoved(const atom *_atom)
     107{
     108  LOG(0, "GLWorldScene: Received signal atomRemoved for atom "+toString(_atom->getId())+".");
     109  // remove all its bonds
     110  const BondList& bondlist = _atom->getListOfBonds();
     111  for (BondList::const_iterator iter = bondlist.begin(); iter != bondlist.end(); ++iter) {
     112    bondRemoved(*iter);
     113  }
     114  // remove atoms
     115  AtomNodeMap::iterator iter = AtomsinMoleculeMap.find(_atom->getId());
     116  ASSERT(iter != AtomsinMoleculeMap.end(),
     117      "GLWorldScene::atomRemoved() - atom "+_atom->getName()+" not on display.");
     118  GLMoleculeObject_atom *atomObject = iter->second;
     119  atomObject->disconnect();
     120  AtomsinMoleculeMap.erase(iter);
     121  delete atomObject;
     122  emit changed();
     123}
     124
     125/** Adds an bond to the scene.
     126 *
     127 * @param _bond bond to add
     128 */
     129void GLWorldScene::bondInserted(const bond *_bond)
     130{
     131  const double distance =
     132      _bond->leftatom->getPosition().distance(_bond->rightatom->getPosition())/2.;
     133  {
     134    // left bond
     135    const BondIds Leftids( make_pair(_bond->leftatom->getId(), _bond->rightatom->getId()) );
     136    BondNodeMap::iterator iter = BondsinMoleculeMap.find(Leftids);
     137    ASSERT(iter == BondsinMoleculeMap.end(),
     138        "GLWorldScene::bondAdded() - same left-sided bond "+toString(*_bond)+" added again.");
     139    GLMoleculeObject_bond *bondObject =
     140        new GLMoleculeObject_bond(this, _bond, distance, GLMoleculeObject_bond::left);
     141    BondsinMoleculeMap.insert( make_pair(Leftids, bondObject) );
     142  }
     143  {
     144    // right bond
     145    const BondIds Rightids( make_pair(_bond->rightatom->getId(), _bond->leftatom->getId()) );
     146    BondNodeMap::iterator iter = BondsinMoleculeMap.find(Rightids);
     147    ASSERT(iter == BondsinMoleculeMap.end(),
     148        "GLWorldScene::bondAdded() - same right-sided bond "+toString(*_bond)+" added again.");
     149    GLMoleculeObject_bond *bondObject =
     150        new GLMoleculeObject_bond(this, _bond, distance, GLMoleculeObject_bond::right);
     151    BondsinMoleculeMap.insert( make_pair(Rightids, bondObject) );
     152  }
     153  emit changed();
     154}
     155
     156/** Removes an bond from the scene.
     157 *
     158 * @param _bond bond to remove
     159 */
     160void GLWorldScene::bondRemoved(const bond *_bond)
     161{
     162  {
     163    // left bond
     164    const BondIds Leftids( make_pair(_bond->leftatom->getId(), _bond->rightatom->getId()) );
     165    BondNodeMap::iterator leftiter = BondsinMoleculeMap.find( Leftids );
     166    ASSERT(leftiter != BondsinMoleculeMap.end(),
     167        "GLWorldScene::bondRemoved() - bond "+toString(*_bond)+" not on display.");
     168    GLMoleculeObject_bond *bondObject = leftiter->second;
     169    BondsinMoleculeMap.erase(leftiter);
     170    delete bondObject;
     171  }
     172  {
     173    // right bond
     174    const BondIds Rightids( make_pair(_bond->rightatom->getId(), _bond->leftatom->getId()) );
     175    BondNodeMap::iterator rightiter = BondsinMoleculeMap.find( Rightids );
     176    ASSERT(rightiter != BondsinMoleculeMap.end(),
     177        "GLWorldScene::bondRemoved() - bond "+toString(*_bond)+" not on display.");
     178    GLMoleculeObject_bond *bondObject = rightiter->second;
     179    BondsinMoleculeMap.erase(rightiter);
     180    delete bondObject;
     181  }
     182  emit changed();
     183}
     184
    65185void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const
    66186{
    67   for (List_MoleculeScene::const_iterator iter = MoleculeSceneList.begin();
    68       iter != MoleculeSceneList.end();
    69       ++iter) {
    70     (*iter)->initialize(view, painter);
    71   }
    72 }
    73 
     187  // Initialize all of the mesh objects that we have as children.
     188   foreach (QObject *obj, children()) {
     189     GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
     190       if (meshobj)
     191         meshobj->initialize(view, painter);
     192   }
     193}
    74194
    75195void GLWorldScene::draw(QGLPainter *painter) const
    76196{
    77   for (List_MoleculeScene::const_iterator iter = MoleculeSceneList.begin();
    78       iter != MoleculeSceneList.end();
    79       ++iter) {
    80     (*iter)->draw(painter);
    81   }
    82 }
    83 
    84 void GLWorldScene::molClicked(atomId_t atom_no, moleculeId_t mol_no)
    85 {
    86    qDebug("WorldScene: atom %d of molecule %d has been clicked", atom_no, mol_no);
    87 }
    88 
     197   // Draw all of the mesh objects that we have as children.
     198   foreach (QObject *obj, children()) {
     199     GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
     200       if (meshobj)
     201         meshobj->draw(painter);
     202   }
     203}
     204
     205void GLWorldScene::atomClicked(atomId_t no)
     206{
     207   qDebug("GLWorldScene: atom %d has been clicked.", no);
     208   emit clicked(no);
     209}
     210
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    re638f9 r7188b1  
    1818#include <Qt/qobject.h>
    1919
    20 #include "atom.hpp"
    2120#include "molecule.hpp"
     21
     22class atom;
    2223
    2324class QGLPainter;
     
    2829class GLMoleculeObject_atom;
    2930class GLMoleculeObject_bond;
    30 class GLMoleculeScene;
    3131
    3232/** This class contains a list of all molecules in the world.
     
    5353signals:
    5454  void changed();
     55  void pressed();
     56  void released();
     57  void clicked();
     58  void clicked(atomId_t);
     59  void doubleClicked();
     60  void hoverChanged();
    5561
    5662private slots:
    57   void molClicked(atomId_t atom_no, moleculeId_t mol_no);
     63  void atomClicked(atomId_t no);
     64  void atomInserted(const atom *_atom);
     65  void atomRemoved(const atom *_atom);
     66  void bondInserted(const bond *_bond);
     67  void bondRemoved(const bond *_bond);
    5868
    5969private:
    6070  void init();
    6171
    62   typedef std::list< GLMoleculeScene * > List_MoleculeScene;
    63 
    64   List_MoleculeScene MoleculeSceneList;
     72  typedef std::pair< size_t, size_t> BondIds;
     73  typedef std::map< size_t, GLMoleculeObject_atom* > AtomNodeMap;
     74  typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
     75  AtomNodeMap AtomsinMoleculeMap;
     76  BondNodeMap BondsinMoleculeMap;
    6577};
    6678
  • 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)
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp

    re638f9 r7188b1  
    1616#include "qglview.h"
    1717
     18#include "CodePatterns/Observer.hpp"
     19
     20#include "World.hpp"
     21
    1822class QKeyEvent;
    1923class GLWorldScene;
     
    2428 *
    2529 */
    26 class GLWorldView : public QGLView
     30class GLWorldView : public QGLView, public Observer
    2731{
    2832  Q_OBJECT
     
    3135  virtual ~GLWorldView();
    3236
     37  // Observer functions
     38  void update(Observable *publisher);
     39  void subjectKilled(Observable *publisher);
     40  void recieveNotification(Observable *publisher, Notification_ptr notification);
     41
    3342public slots:
     43
     44signals:
     45  void changed();
     46  void atomInserted(const atom *_atom);
     47  void atomRemoved(const atom *_atom);
     48  void moleculeInserted(const molecule *_mol);
     49  void moleculeRemoved(const molecule *_mol);
    3450
    3551protected:
Note: See TracChangeset for help on using the changeset viewer.