source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp@ 7c7c4a

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 7c7c4a was 7c7c4a, checked in by Frederik Heber <heber@…>, 9 years ago

FIX: All ObservedValue's of GLMoleculeObject_atom/bond/molecule wrapped into vector.

  • the idea is that a GLMoleculeObject may only remove itself _after_ each and every contained Observer has gotten the subjectKilled() signal from the Observables. Only then will destroying the Object and its members thereby not cause any signOff() which try to access Observables or their channels which are no longer present. This can be imagined as a graph where we have to start destroying object at the very bottom.
  • This is the avoid the following conflict: A superior object gets note of a molecule to be removed. It sends the visual representation a signal to remove itself, which causes it to use signOff(). On a parallel track (in another thread) we have the observed object calling subjectKilled() to inform any Observer about its immediate destruction. These two tracks collide. Now, we let first pass all subjectKilled() and when the last Observable has gotten its signal, we begin destroying the visual rep.
  • rerouted signal/slots accordingly.
  • Property mode set to 100644
File size: 6.7 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
23#include "CodePatterns/Cacheable.hpp"
24#include "CodePatterns/Observer/Observer.hpp"
25#include "CodePatterns/ObservedValue.hpp"
26
27#include "GLMoleculeObject_bond.hpp"
28
29#include "molecule.hpp"
30
31class atom;
32class bond;
33class GLMoleculeObject_atom;
34class GLWorldScene;
35
36class GLMoleculeObject_molecule : public GLMoleculeObject, public Observer
37{
38 Q_OBJECT
39public:
40 GLMoleculeObject_molecule(QObject *parent, const moleculeId_t molid);
41 GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid);
42 virtual ~GLMoleculeObject_molecule();
43
44 // Observer functions
45 void update(Observable *publisher);
46 void subjectKilled(Observable *publisher);
47 void recieveNotification(Observable *publisher, Notification_ptr notification);
48
49 void initialize(QGLView *view, QGLPainter *painter);
50 void draw(QGLPainter *painter, const QVector4D &cameraPlane);
51
52 typedef std::pair< atomId_t, atomId_t> BondIds;
53 friend std::ostream &operator<<(std::ostream &ost, const BondIds &t);
54
55 static BondIds getBondIds(
56 const bond::ptr _bond,
57 const enum GLMoleculeObject_bond::SideOfBond side);
58
59signals:
60 void changed();
61 void changeOccured();
62 void hoverChanged(const atomId_t);
63 void hoverChanged(const moleculeId_t, int);
64 void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
65 void atomClicked(atomId_t no);
66 void moleculeClicked(moleculeId_t no);
67 void TesselationHullChanged();
68 void BoundingBoxChanged();
69 void IsSelectedChanged();
70 void AtomInserted(const atomId_t _id);
71 void AtomRemoved(const atomId_t _id);
72 void IdChanged();
73 void InstanceRemoved(const moleculeId_t);
74
75private slots:
76 //!> grant GLWorldScene access to private slots
77 friend class GLWorldScene;
78
79 void wasClicked();
80 void atomInserted(const atomId_t _id);
81 void atomRemoved(const atomId_t _id);
82 void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side);
83 void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
84 void hoverChangedSignalled(GLMoleculeObject *ob);
85 void changeAtomId(GLMoleculeObject_atom *, const atomId_t, const atomId_t);
86
87 void setVisible(bool value);
88
89 void activateObserver();
90 void deactivateObserver();
91
92 void resetTesselationHull();
93 void resetBoundingBox();
94 void resetAtoms();
95 void resetIndex();
96 void resetName();
97
98 void AtomSelected(const atomId_t _id);
99 void AtomUnselected(const atomId_t _id);
100 void Selected();
101 void Unselected();
102
103private:
104 static const molecule * const getMolecule(const moleculeId_t _id);
105
106private:
107 void addAtomBonds(
108 const bond::ptr &_bond,
109 const GLMoleculeObject_bond::SideOfBond _side
110 );
111 void addAtomBonds(const atomId_t _id);
112
113 //!> typedef for the internal set of atoms
114 typedef std::set<atomId_t> atoms_t;
115
116 molecule::BoundingBoxInfo initBoundingBox() const;
117
118 QGeometryData updateTesselationHull() const;
119 molecule::BoundingBoxInfo updateBoundingBox() const;
120 atoms_t updateAtoms();
121 moleculeId_t updateIndex() const;
122 std::string updateName() const;
123
124 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
125 const Observable * owner;
126
127 //!> internal variable for caching molecule ref in cstor
128 const molecule * const molref;
129
130 //!> list of channels when contained atoms needs to update
131 static const Observable::channels_t AtomsChannels;
132 //!> list of channels when tesselation hull needs to update
133 static const Observable::channels_t HullChannels;
134 //!> list of channels when bounding box needs to update
135 static const Observable::channels_t BoundingBoxChannels;
136 //!> list of channels when the index needs to update
137 static const Observable::channels_t IndexChannels;
138 //!> list of channels when the name needs to update
139 static const Observable::channels_t NameChannels;
140
141 boost::function<moleculeId_t ()> MolIndexUpdater;
142 boost::function<std::string ()> MolNameUpdater;
143 boost::function<QGeometryData ()> TesselationHullUpdater;
144 boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater;
145 boost::function<atoms_t ()> PresentAtomsUpdater;
146
147private:
148 /** Observed Values **/
149
150 //!> enumeration of observed values to match with entries in ObservedValues
151 enum ObservedTypes {
152 //!> contains the current molecule index
153 MolIndex,
154 //!> contains the current molecule name
155 MolName,
156 //!> contains newest version of the bounding box on request
157 BoundingBox,
158 //!> contains the current live set of atoms for the molecule
159 PresentAtoms,
160 //!> gives the size of the enumeration
161 MAX_ObservedTypes
162 };
163
164 //!> vector with all observed values
165 std::vector<boost::any> ObservedValues;
166
167 /** Initializes all \a ObservedValues entries.
168 *
169 * \param _moid molecule id
170 */
171 void initObservedValues(const moleculeId_t _molid);
172
173 /** Destroys all \a ObservedValues entries.
174 *
175 */
176 void destroyObservedValues();
177
178 /** Getter to molecule index contained in \a ObservedValues.
179 *
180 * \return molecule's index
181 */
182 moleculeId_t getMolIndex() const;
183
184 /** Getter to molecule name contained in \a ObservedValues.
185 *
186 * \return molecule's name
187 */
188 std::string getMolName() const;
189
190 /** Getter to molecule's bounding box contained in \a ObservedValues.
191 *
192 * \return molecule's bounding box
193 */
194 molecule::BoundingBoxInfo getBoundingBox() const;
195
196 /** Getter to contained atoms contained in \a ObservedValues.
197 *
198 * \return molecule's contained atoms
199 */
200 atoms_t getPresentAtoms() const;
201
202 /** Counts how many ObservedValues got subjectKilled.
203 *
204 * This is used to give InstanceRemoved() signal only when each and every
205 * ObservedValue (and the instance itself) has been subjectKilled by the
206 * monitored Observable. Only then can we safely remove the instance.
207 *
208 */
209 void countsubjectKilled();
210
211 //!> counts how many ObservedValues have already been subjectKilled()
212 mutable size_t subjectKilledCount;
213
214 //!> contains current version of the tesselation hull on request
215 Cacheable<QGeometryData> TesselationHull;
216
217private:
218 //!> contains the set of atoms displayed
219 atoms_t DisplayedAtoms;
220
221 typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;
222 typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
223 AtomNodeMap AtomsinSceneMap;
224 BondNodeMap BondsinSceneMap;
225
226 atomId_t hoverAtomId;
227};
228
229std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);
230
231
232#endif /* GLMOLECULEOBJECT_MOLECULE_HPP_ */
Note: See TracBrowser for help on using the repository browser.