source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp@ 16bd37

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
Last change on this file since 16bd37 was 8688ef, checked in by Frederik Heber <heber@…>, 9 years ago

GLMoleculeObject_molecule's ObservedValues is now all static.

  • this is preparatory for extracting their instantation to an external class InstanceInformationBoard that keeps track of the lives of instances in the World that are needed inside QtGui (e.g. for visual representation).
  • Property mode set to 100644
File size: 7.1 KB
Line 
1/*
2 * GLMoleculeObject_molecule.hpp
3 *
4 * Created on: Mar 30, 2012
5 * Author: ankele
6 */
7
8#ifndef GLMOLECULEOBJECT_MOLECULE_HPP_
9#define GLMOLECULEOBJECT_MOLECULE_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include "GLMoleculeObject.hpp"
17
18#include <Qt3D/qgeometrydata.h>
19
20#include <vector>
21#include <boost/any.hpp>
22#include <boost/function.hpp>
23
24#include "CodePatterns/Cacheable.hpp"
25#include "CodePatterns/Observer/Observer.hpp"
26#include "CodePatterns/ObservedValue.hpp"
27
28#include "GLMoleculeObject_bond.hpp"
29
30#include "molecule.hpp"
31
32class atom;
33class bond;
34class GLMoleculeObject_atom;
35class GLWorldScene;
36
37class GLMoleculeObject_molecule : public GLMoleculeObject, public Observer
38{
39 Q_OBJECT
40public:
41 GLMoleculeObject_molecule(QObject *parent, const moleculeId_t molid);
42 GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid);
43 virtual ~GLMoleculeObject_molecule();
44
45 // Observer functions
46 void update(Observable *publisher);
47 void subjectKilled(Observable *publisher);
48 void recieveNotification(Observable *publisher, Notification_ptr notification);
49
50 void initialize(QGLView *view, QGLPainter *painter);
51 void draw(QGLPainter *painter, const QVector4D &cameraPlane);
52
53 typedef std::pair< atomId_t, atomId_t> BondIds;
54 friend std::ostream &operator<<(std::ostream &ost, const BondIds &t);
55
56 static BondIds getBondIds(
57 const bond::ptr _bond,
58 const enum GLMoleculeObject_bond::SideOfBond side);
59
60signals:
61 void changed();
62 void changeOccured();
63 void hoverChanged(const atomId_t);
64 void hoverChanged(const moleculeId_t, int);
65 void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
66 void atomClicked(atomId_t no);
67 void moleculeClicked(moleculeId_t no);
68 void TesselationHullChanged();
69 void BoundingBoxChanged();
70 void IsSelectedChanged();
71 void AtomInserted(const atomId_t _id);
72 void AtomRemoved(const atomId_t _id);
73 void IdChanged();
74 void InstanceRemoved(const moleculeId_t);
75
76private slots:
77 //!> grant GLWorldScene access to private slots
78 friend class GLWorldScene;
79
80 void wasClicked();
81 void atomInserted(const atomId_t _id);
82 void atomRemoved(const atomId_t _id);
83 void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side);
84 void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
85 void hoverChangedSignalled(GLMoleculeObject *ob);
86 void changeAtomId(GLMoleculeObject_atom *, const atomId_t, const atomId_t);
87
88 void setVisible(bool value);
89
90 void activateObserver();
91 void deactivateObserver();
92
93 void resetTesselationHull();
94 void resetBoundingBox();
95 void resetAtoms();
96 void resetIndex();
97 void resetName();
98
99 void AtomSelected(const atomId_t _id);
100 void AtomUnselected(const atomId_t _id);
101 void Selected();
102 void Unselected();
103
104private:
105 static const molecule * const getMolecule(const moleculeId_t _id);
106
107private:
108 void addAtomBonds(
109 const bond::ptr &_bond,
110 const GLMoleculeObject_bond::SideOfBond _side
111 );
112 void addAtomBonds(const atomId_t _id);
113
114 //!> typedef for the internal set of atoms
115 typedef std::set<atomId_t> atoms_t;
116
117 static molecule::BoundingBoxInfo initBoundingBox();
118
119 QGeometryData updateTesselationHull() const;
120 static molecule::BoundingBoxInfo updateBoundingBox(
121 const boost::function<const moleculeId_t ()> &_getMolIndex);
122 static moleculeId_t updateIndex();
123 static std::string updateName(
124 const boost::function<const moleculeId_t ()> &_getMolIndex);
125
126 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
127 const Observable * owner;
128
129 //!> internal variable for caching molecule ref in cstor
130 const molecule * const molref;
131
132 //!> list of channels when contained atoms needs to update
133 static const Observable::channels_t AtomsChannels;
134 //!> list of channels when tesselation hull needs to update
135 static const Observable::channels_t HullChannels;
136 //!> list of channels when bounding box needs to update
137 static const Observable::channels_t BoundingBoxChannels;
138 //!> list of channels when the index needs to update
139 static const Observable::channels_t IndexChannels;
140 //!> list of channels when the name needs to update
141 static const Observable::channels_t NameChannels;
142
143private:
144 /** Observed Values **/
145
146 //!> enumeration of observed values to match with entries in ObservedValues
147 enum ObservedTypes {
148 //!> contains the current molecule index
149 MolIndex,
150 //!> contains the current molecule name
151 MolName,
152 //!> contains newest version of the bounding box on request
153 BoundingBox,
154 //!> contains the current live set of atoms for the molecule
155 PresentAtoms,
156 //!> gives the size of the enumeration
157 MAX_ObservedTypes
158 };
159
160 //!> vector with all observed values
161 std::vector<boost::any> ObservedValues;
162
163 /** Initializes all \a _ObservedValues entries.
164 *
165 * \param _ObservedValues vector of ObservedValue to be filled
166 * \param _moid molecule id
167 * \param _molref reference to molecule
168 * \param _subjectKilled ref to function to call on subjectKilled()
169 */
170 static void initObservedValues(
171 std::vector<boost::any> &_ObservedValues,
172 const moleculeId_t _molid,
173 const molecule * const _molref,
174 const boost::function<void()> &_subjectKilled);
175
176 /** Destroys all \a ObservedValues entries.
177 *
178 * \param _ObservedValues vector of ObservedValue to be destroyed
179 */
180 static void destroyObservedValues(
181 std::vector<boost::any> &_ObservedValues);
182
183 /** Getter to molecule index contained in \a ObservedValues.
184 *
185 * \return molecule's index
186 */
187 moleculeId_t getMolIndex() const;
188
189 /** Getter to molecule name contained in \a ObservedValues.
190 *
191 * \return molecule's name
192 */
193 std::string getMolName() const;
194
195 /** Getter to molecule's bounding box contained in \a ObservedValues.
196 *
197 * \return molecule's bounding box
198 */
199 molecule::BoundingBoxInfo getBoundingBox() const;
200
201 /** Getter to contained atoms contained in \a ObservedValues.
202 *
203 * \return molecule's contained atoms
204 */
205 atoms_t getPresentAtoms() const;
206
207 /** Counts how many ObservedValues got subjectKilled.
208 *
209 * This is used to give InstanceRemoved() signal only when each and every
210 * ObservedValue (and the instance itself) has been subjectKilled by the
211 * monitored Observable. Only then can we safely remove the instance.
212 *
213 */
214 void countsubjectKilled();
215
216 //!> counts how many ObservedValues have already been subjectKilled()
217 mutable size_t subjectKilledCount;
218
219private:
220
221 boost::function<QGeometryData ()> TesselationHullUpdater;
222
223 //!> contains current version of the tesselation hull on request
224 Cacheable<QGeometryData> TesselationHull;
225
226 //!> contains the set of atoms displayed
227 atoms_t DisplayedAtoms;
228
229 typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;
230 typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
231 AtomNodeMap AtomsinSceneMap;
232 BondNodeMap BondsinSceneMap;
233
234 atomId_t hoverAtomId;
235};
236
237std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);
238
239
240#endif /* GLMOLECULEOBJECT_MOLECULE_HPP_ */
Note: See TracBrowser for help on using the repository browser.