Ignore:
Timestamp:
Feb 12, 2016, 11:15:24 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:
90821d
Parents:
65c323
git-author:
Frederik Heber <heber@…> (10/29/15 12:52:29)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:24)
Message:

Extracted all ObservedValue functionality out of GLMoleculeObject_molecule.

  • see previous commit for explanations.
File:
1 edited

Legend:

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

    r65c323 r494478  
    1818#include <Qt3D/qgeometrydata.h>
    1919
    20 #include <vector>
    21 #include <boost/any.hpp>
     20#include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
     21
     22#include <map>
     23
    2224#include <boost/function.hpp>
    2325
    2426#include "CodePatterns/Cacheable.hpp"
    25 #include "CodePatterns/Observer/Observer.hpp"
    26 #include "CodePatterns/ObservedValue.hpp"
     27#include "CodePatterns/Observer/Observable.hpp"
    2728
    2829#include "GLMoleculeObject_bond.hpp"
    2930
    30 #include "molecule.hpp"
     31#include "types.hpp"
    3132
    3233class atom;
    3334class bond;
     35class molecule;
    3436class GLMoleculeObject_atom;
    3537class GLWorldScene;
    3638class QtObservedInstanceBoard;
    3739
    38 class GLMoleculeObject_molecule : public GLMoleculeObject, public Observer
     40class GLMoleculeObject_molecule : public GLMoleculeObject
    3941{
    4042  Q_OBJECT
     
    4244  GLMoleculeObject_molecule(
    4345      QObject *parent,
    44       const moleculeId_t molid,
    45       QtObservedInstanceBoard * _board,
    46       std::vector<boost::any> _ObservedValues);
     46      QtObservedInstanceBoard &_board,
     47      QtObservedMolecule::ptr _ObservedMolecule);
    4748  GLMoleculeObject_molecule(
    4849      QGLSceneNode *mesh[],
    4950      QObject *parent,
    50       const moleculeId_t molid,
    51       QtObservedInstanceBoard * _board,
    52       std::vector<boost::any> _ObservedValues);
     51      QtObservedInstanceBoard &_board,
     52      QtObservedMolecule::ptr _ObservedMolecule);
    5353  virtual ~GLMoleculeObject_molecule();
    54 
    55   // Observer functions
    56   void update(Observable *publisher);
    57   void subjectKilled(Observable *publisher);
    58   void recieveNotification(Observable *publisher, Notification_ptr notification);
    5954
    6055  void initialize(QGLView *view, QGLPainter *painter);
     
    7671  void atomClicked(atomId_t no);
    7772  void moleculeClicked(moleculeId_t no);
    78   void TesselationHullChanged();
    79   void BoundingBoxChanged();
    8073  void IsSelectedChanged();
    81   void AtomInserted(const atomId_t _id);
    82   void AtomRemoved(const atomId_t _id);
    83   void IdChanged();
    8474
    8575private slots:
     
    9787  void setVisible(bool value);
    9888
    99   void activateObserver();
    100   void deactivateObserver();
    101 
    10289  void resetTesselationHull();
    10390  void resetBoundingBox();
    10491  void resetIndex();
    105   void resetName();
    10692
    10793  void AtomSelected(const atomId_t _id);
     
    11197
    11298private:
    113   static const molecule * const getMolecule(const moleculeId_t _id);
    114 
    115   void init(const moleculeId_t _molid);
    116 
    117 private:
    11899  void addAtomBonds(
    119100      const bond::ptr &_bond,
     
    121102      );
    122103
     104  void init(const moleculeId_t _molid);
     105
    123106  //!> typedef for the internal set of atoms
    124107  typedef std::set<atomId_t> atoms_t;
    125 
    126   static molecule::BoundingBoxInfo initBoundingBox();
    127 
    128   QGeometryData updateTesselationHull() const;
    129   static molecule::BoundingBoxInfo updateBoundingBox(
    130       const boost::function<const moleculeId_t ()> &_getMolIndex);
    131   static moleculeId_t updateIndex();
    132   static std::string updateName(
    133       const boost::function<const moleculeId_t ()> &_getMolIndex);
    134108
    135109  /** Getter to contained atoms contained in \a ObservedValues.
     
    139113  atoms_t getPresentAtoms() const;
    140114
     115private:
     116
    141117  //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
    142118  const Observable * owner;
    143119
    144   //!> internal variable for caching molecule ref in cstor
    145   const molecule * const molref;
     120  QGeometryData updateTesselationHull() const;
    146121
    147122  //!> list of channels when tesselation hull needs to update
    148123  static const Observable::channels_t HullChannels;
    149   //!> list of channels when bounding box needs to update
    150   static const Observable::channels_t BoundingBoxChannels;
    151   //!> list of channels when the index needs to update
    152   static const Observable::channels_t IndexChannels;
    153   //!> list of channels when the name needs to update
    154   static const Observable::channels_t NameChannels;
    155124
    156 private:
    157   friend class QtObservedInstanceBoard;
    158   /** Observed Values **/
    159 
    160   //!> enumeration of observed values to match with entries in ObservedValues
    161   enum ObservedTypes {
    162     //!> contains the current molecule index
    163     MolIndex,
    164     //!> contains the current molecule name
    165     MolName,
    166     //!> contains newest version of the bounding box on request
    167     BoundingBox,
    168     //!> gives the size of the enumeration
    169     MAX_ObservedTypes
    170   };
    171 
    172   //!> vector with all observed values
    173   std::vector<boost::any> ObservedValues;
    174 
    175   /** Initializes all \a _ObservedValues entries.
    176    *
    177    * \param _ObservedValues vector of ObservedValue to be filled
    178    * \param _moid molecule id
    179    * \param _molref reference to molecule
    180    * \param _subjectKilled ref to function to call on subjectKilled()
    181    */
    182   static void initObservedValues(
    183       std::vector<boost::any> &_ObservedValues,
    184       const moleculeId_t _molid,
    185       const molecule * const _molref,
    186       const boost::function<void(const moleculeId_t)> &_subjectKilled);
    187 
    188   /** Destroys all \a ObservedValues entries.
    189    *
    190    * \param _ObservedValues vector of ObservedValue to be destroyed
    191    */
    192   static void destroyObservedValues(
    193       std::vector<boost::any> &_ObservedValues);
    194 
    195   /** Getter to molecule index contained in \a ObservedValues.
    196    *
    197    * \return molecule's index
    198    */
    199   moleculeId_t getMolIndex() const;
    200 
    201   /** Getter to molecule name contained in \a ObservedValues.
    202    *
    203    * \return molecule's name
    204    */
    205   std::string getMolName() const;
    206 
    207   /** Getter to molecule's bounding box contained in \a ObservedValues.
    208    *
    209    * \return molecule's bounding box
    210    */
    211   molecule::BoundingBoxInfo getBoundingBox() const;
    212 
    213   //!> counts how many ObservedValues have already been subjectKilled()
    214   mutable size_t subjectKilledCount;
    215 
    216 private:
     125  //!> internal variable for caching molecule ref in cstor
     126  const molecule * const molref;
    217127
    218128  boost::function<QGeometryData ()> TesselationHullUpdater;
     
    231141  atomId_t hoverAtomId;
    232142
    233   //!> we get multiple subjectKilled(), count and call callback() only on last
    234   const unsigned int AllsignedOnChannels;
    235   unsigned int signedOnChannels;
     143  QtObservedInstanceBoard &board;
    236144
    237   QtObservedInstanceBoard * board;
     145  QtObservedMolecule::ptr ObservedMolecule;
    238146};
    239147
Note: See TracChangeset for help on using the changeset viewer.