source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp@ 2831b3

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 2831b3 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: 5.0 KB
Line 
1/*
2 * GLMoleculeObject_bond.hpp
3 *
4 * Created on: Aug 17, 2011
5 * Author: heber
6 */
7
8#ifndef GLMOLECULEOBJECT_BOND_HPP_
9#define GLMOLECULEOBJECT_BOND_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 <vector>
19#include <boost/any.hpp>
20
21#include "CodePatterns/Observer/Observer.hpp"
22#include "CodePatterns/ObservedValue.hpp"
23
24#include "LinearAlgebra/Vector.hpp"
25
26#include "Bond/bond.hpp"
27#include "types.hpp"
28
29class atom;
30
31class GLWorldScene;
32
33class GLMoleculeObject_bond : public GLMoleculeObject, public Observer
34{
35 Q_OBJECT
36public:
37 enum SideOfBond { left, right };
38
39 typedef std::pair<atomId_t, atomId_t> bondIds_t;
40
41 GLMoleculeObject_bond(QGLSceneNode *mesh[], QObject *parent, const bondIds_t bondIds, const enum SideOfBond side);
42 virtual ~GLMoleculeObject_bond();
43
44 // Observer functions
45 void update(Observable *publisher);
46 void subjectKilled(Observable *publisher);
47 void recieveNotification(Observable *publisher, Notification_ptr notification);
48
49signals:
50 void BondRemoved(const atomId_t leftnr, const atomId_t rightnr);
51 void elementChanged();
52 void positionChanged();
53 void degreeChanged();
54
55private slots:
56 //!> grant GLMoleculeObject_molecule acess to reset functions
57 friend class GLMoleculeObject_molecule;
58
59 /** Recalculates the element of the cylinder representing the bond.
60 *
61 */
62 void resetElement();
63
64 /** Recalculates the position of the cylinder representing the bond.
65 *
66 */
67 void resetPosition();
68
69 /** Recalculates the width of the cylinder representing the bond's degree.
70 *
71 */
72 void resetWidth();
73
74private:
75 void removeChannels();
76
77 Vector updateLeftPosition() const;
78 Vector updateRightPosition() const;
79 atomicNumber_t updateLeftElement() const;
80 atomicNumber_t updateRightElement() const;
81 int updateDegree() const;
82
83 static const atom * const getAtomConst(const atomId_t _id);
84 static atom * const getAtom(const atomId_t _id);
85
86private:
87 //!> id of left bond partner for safely emitting BondRemoved signal
88 const atomId_t leftatomId;
89 //!> id of right bond partner for safely emitting BondRemoved signal
90 const atomId_t rightatomId;
91
92 //!> contains ref to Observable of left atom
93 const Observable * const leftowner;
94 //!> contains ref to Observable of right atom
95 const Observable * const rightowner;
96 //!> temporary variable used in cstor
97 const Observable * const bondowner;
98
99 const enum SideOfBond BondSide;
100
101
102private:
103 /** Observed Values **/
104
105 //!> enumeration of observed values to match with entries in ObservedValues
106 enum ObservedTypes {
107 //!> contains the position of the left atom
108 leftPosition,
109 //!> contains the position of the right atom
110 rightPosition,
111 //!> contains the element of the left atom
112 leftElement,
113 //!> contains the element of the right atom
114 rightElement,
115 //!> contains the degree of the bond
116 Degree,
117 //!> gives the size of the enumeration
118 MAX_ObservedTypes
119 };
120
121 //!> vector with all observed values
122 std::vector<boost::any> ObservedValues;
123
124 /** Initializes all \a ObservedValues entries.
125 *
126 */
127 void initObservedValues();
128
129 /** Destroys all \a ObservedValues entries.
130 *
131 */
132 void destroyObservedValues();
133
134 /** Getter to left atom's position contained in \a ObservedValues.
135 *
136 * \return left atom's position
137 */
138 Vector getleftPosition() const;
139
140 /** Getter to right atom's position contained in \a ObservedValues.
141 *
142 * \return right atom's position
143 */
144 Vector getrightPosition() const;
145
146 /** Getter to left atom's element contained in \a ObservedValues.
147 *
148 * \return left atom's element
149 */
150 atomicNumber_t getleftElement() const;
151
152 /** Getter to rightatom's element contained in \a ObservedValues.
153 *
154 * \return right atom's element
155 */
156 atomicNumber_t getrightElement() const;
157
158 /** Getter to bond's degree contained in \a ObservedValues.
159 *
160 * \return bond's degree
161 */
162 int getDegree() const;
163
164 /** Counts how many ObservedValues got subjectKilled.
165 *
166 * This is used to give InstanceRemoved() signal only when each and every
167 * ObservedValue (and the instance itself) has been subjectKilled by the
168 * monitored Observable. Only then can we safely remove the instance.
169 *
170 */
171 void countsubjectKilled();
172
173 //!> counts how many ObservedValues have already been subjectKilled()
174 mutable size_t subjectKilledCount;
175
176private:
177
178 //!> indicate whether we are signed in to leftobservable
179 bool leftobservable_enabled;
180 //!> indicate whether we are signed in to rightobservable
181 bool rightobservable_enabled;
182 //!> indicate whether we are signed in to bond itself
183 bool bond_enabled;
184
185 //!> list of channels when position needs to update
186 static const Observable::channels_t BondPositionChannels;
187 //!>list of channels when degree needs to update
188 static const Observable::channels_t BondDegreeChannels;
189 //!> list of channels when element needs to update
190 static const Observable::channels_t BondElementChannels;
191};
192
193
194
195#endif /* GLMOLECULEOBJECT_BOND_HPP_ */
Note: See TracBrowser for help on using the repository browser.