Ignore:
Timestamp:
Feb 12, 2016, 11:15:23 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:
494478
Parents:
41e287
git-author:
Frederik Heber <heber@…> (10/29/15 10:46:45)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:23)
Message:

Extracted all ObservedValue functionality out of GLMoleculeObject_atom.

  • i.e. GLMoleculeObject_atom is reduced to simple displaying, updated via Qt signals. These signals are connected to a QtObservedAtom which in turn now contains all the ObservedValue functionality.
  • this is preparatory for having a single (Observed)Atom as representer of its associated World's atom in the QtGui part of the code.
File:
1 edited

Legend:

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

    r41e287 r65c323  
    2020
    2121#include "CodePatterns/ObservedValue.hpp"
    22 #include "CodePatterns/Observer/Observer.hpp"
    2322
    24 #include "LinearAlgebra/Vector.hpp"
    25 
    26 #include "Bond/bond.hpp"
    2723#include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp"
     24#include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
    2825#include "types.hpp"
    2926
     
    3128class QtObservedInstanceBoard;
    3229
    33 class GLMoleculeObject_atom : public GLMoleculeObject, Observer
     30class GLMoleculeObject_atom : public GLMoleculeObject
    3431{
    3532  Q_OBJECT
     
    3835      QGLSceneNode *mesh[],
    3936      QObject *parent,
    40       const atomId_t id,
    41       QtObservedInstanceBoard * _board,
    42       std::vector<boost::any> _ObservedValues
     37      QtObservedAtom::ptr _ObservedAtom
    4338      );
    4439  virtual ~GLMoleculeObject_atom();
    4540
    4641  void draw(QGLPainter *painter, const QVector4D &cameraPlane);
    47 
    48   // Observer functions
    49   void update(Observable *publisher);
    50   void subjectKilled(Observable *publisher);
    51   void recieveNotification(Observable *publisher, Notification_ptr notification);
    5242
    5343public slots:
     
    6757  void BondsRemoved(const atomId_t _left, const atomId_t _right);
    6858  void indexChanged(GLMoleculeObject_atom *ob, const atomId_t oldId, const atomId_t newId);
    69   void idChanged();
    70   void positionChanged();
    71   void elementChanged();
    72   void bondsChanged();
    7359
    7460private:
    75   //!> grant GLMoleculeObject_molecule acess to reset functions
    76   friend class GLMoleculeObject_molecule;
    77 
    78   //!> typedef for list of bonds, defined by pairs of atom ids
    79   typedef std::vector< std::pair<atomId_t, atomId_t> > ListOfBonds_t;
    80 
    81   static const atom * const getAtomConst(const atomId_t _id);
    82   static atom * const getAtom(const atomId_t _id);
    83 
    84   static atomId_t updateIndex();
    85   static Vector updatePosition(
    86       const boost::function<const atomId_t ()> &_getAtomIndex);
    87   static atomicNumber_t updateElement(
    88       const boost::function<const atomId_t ()> &_getAtomIndex);
    89   static ListOfBonds_t updateBonds(
    90       const boost::function<const atomId_t ()> &_getAtomIndex);
    91 
    92   void activateObserver();
    93   void deactivateObserver();
    94 
    9561  void init(const atomId_t _id);
    9662
    9763private:
     64  //!> current list of bonds to compare new onw against for changes
     65  QtObservedAtom::ListOfBonds_t ListOfBonds;
    9866
    99   //!> current list of bonds to compare new onw against for changes
    100   ListOfBonds_t ListOfBonds;
    101 
    102   //!> temporary variable used in cstor
    103   atom * const atomref;
    104 
    105 private:
    106   friend class QtObservedInstanceBoard;
    107   /** Observed Values **/
    108 
    109   //!> enumeration of observed values to match with entries in ObservedValues
    110   enum ObservedTypes {
    111     //!> contains the current atom index
    112     AtomIndex,
    113     //!> contains the current atom position
    114     AtomPosition,
    115     //!> contains the current atom element
    116     AtomElement,
    117     //!> contains the current set of bonds atoms fort the atom
    118     AtomBonds,
    119     //!> gives the size of the enumeration
    120     MAX_ObservedTypes
    121   };
    122 
    123   //!> vector with all observed values
    124   std::vector<boost::any> ObservedValues;
    125 
    126   /** Initializes all \a ObservedValues entries.
    127    *
    128    * \param _ObservedValues vector of ObservedValue to be filled
    129    * \param _id atom id
    130    * \param _atomref reference to atom
    131    * \param _subjectKilled ref to function to call on subjectKilled()
    132    */
    133   static void initObservedValues(
    134       std::vector<boost::any> &_ObservedValues,
    135       const atomId_t _id,
    136       const atom * const _atomref,
    137       const boost::function<void(const atomId_t)> &_subjectKilled);
    138 
    139   /** Destroys all \a ObservedValues entries.
    140    *
    141    * \param _ObservedValues vector of ObservedValue to be destroyed
    142    */
    143   static void destroyObservedValues(
    144       std::vector<boost::any> &_ObservedValues);
    145 
    146   /** Getter to atom index contained in \a ObservedValues.
    147    *
    148    * \return atom's index
    149    */
    150   atomId_t getAtomIndex() const;
    151 
    152   /** Getter to atom position contained in \a ObservedValues.
    153    *
    154    * \return atom's position
    155    */
    156   Vector getAtomPosition() const;
    157 
    158   /** Getter to atom element contained in \a ObservedValues.
    159    *
    160    * \return atom's elemnt
    161    */
    162   atomicNumber_t getAtomElement() const;
    163 
    164   /** Getter to atom bonds contained in \a ObservedValues.
    165    *
    166    * \return atom's bonds
    167    */
    168   ListOfBonds_t getAtomBonds() const;
    169 
    170   //!> counts how many ObservedValues have already been subjectKilled()
    171   mutable size_t subjectKilledCount;
    172 
    173 private:
    174 
    175   //!> list of channels when index needs to update
    176   static const Observable::channels_t AtomIndexChannels;
    177   //!> list of channels when position needs to update
    178   static const Observable::channels_t AtomPositionChannels;
    179   //!> list of channels when element needs to update
    180   static const Observable::channels_t AtomElementChannels;
    181   //!> list of channels when bonds needs to update
    182   static const Observable::channels_t AtomBondsChannels;
    183 
    184   //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
    185   const Observable *owner;
    186 
    187   //!> we get multiple subjectKilled(), count and call callback() only on last
    188   const unsigned int AllsignedOnChannels;
    189   unsigned int signedOnChannels;
    190 
    191   QtObservedInstanceBoard * board;
     67  QtObservedAtom::ptr ObservedAtom;
    19268};
    19369
Note: See TracChangeset for help on using the changeset viewer.