source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp@ 099f67

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

GLMoleculeObject_bond's ObservedValues is now all static.

  • again, the same change as with .._molecule and .._atom.
  • Property mode set to 100644
File size: 6.4 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 static atomId_t updateIndex();
78 static Vector updateLeftPosition(
79 const boost::function<const atomId_t ()> &_getLeftAtomIndex);
80 static Vector updateRightPosition(
81 const boost::function<const atomId_t ()> &_getRightAtomIndex);
82 static atomicNumber_t updateLeftElement(
83 const boost::function<const atomId_t ()> &_getLeftAtomIndex);
84 static atomicNumber_t updateRightElement(
85 const boost::function<const atomId_t ()> &_getRightAtomIndex);
86 static int updateDegree(
87 const boost::function<const atomId_t ()> &_getLeftAtomIndex,
88 const boost::function<const atomId_t ()> &_getRightAtomIndex);
89
90 static const atom * const getAtomConst(const atomId_t _id);
91 static atom * const getAtom(const atomId_t _id);
92
93private:
94 //!> contains ref to Observable of left atom
95 const Observable * const leftowner;
96 //!> contains ref to Observable of right atom
97 const Observable * const rightowner;
98 //!> temporary variable used in cstor
99 const Observable * const bondowner;
100
101 const enum SideOfBond BondSide;
102
103
104private:
105 /** Observed Values **/
106
107 //!> enumeration of observed values to match with entries in ObservedValues
108 enum ObservedTypes {
109 //!> contains the id of the left atom
110 leftIndex,
111 //!> contains the id of the right atom
112 rightIndex,
113 //!> contains the position of the left atom
114 leftPosition,
115 //!> contains the position of the right atom
116 rightPosition,
117 //!> contains the element of the left atom
118 leftElement,
119 //!> contains the element of the right atom
120 rightElement,
121 //!> contains the degree of the bond
122 Degree,
123 //!> gives the size of the enumeration
124 MAX_ObservedTypes
125 };
126
127 //!> vector with all observed values
128 std::vector<boost::any> ObservedValues;
129
130 /** Initializes all \a ObservedValues entries.
131 *
132 * \param _ObservedValues vector of ObservedValue to be filled
133 * \param _leftatomId left atom id
134 * \param _rightatomId right atom id
135 * \param _leftowner reference to left atom
136 * \param _rightowner reference to right atom
137 * \param _bondowner reference to bond
138 * \param _subjectKilled ref to function to call on subjectKilled()
139 */
140 static void initObservedValues(
141 std::vector<boost::any> &_ObservedValues,
142 const atomId_t _leftatomId,
143 const atomId_t _rightatomId,
144 const Observable * const _leftowner,
145 const Observable * const _rightowner,
146 const Observable * const _bondowner,
147 const boost::function<void()> &_subjectKilled);
148
149 /** Destroys all \a ObservedValues entries.
150 *
151 * \param _ObservedValues vector of ObservedValue to be destroyed
152 */
153 static void destroyObservedValues(
154 std::vector<boost::any> &_ObservedValues);
155
156 /** Getter to left atom's id contained in \a ObservedValues.
157 *
158 * \return left atom's id
159 */
160 atomId_t getleftIndex() const;
161
162 /** Getter to right atom's id contained in \a ObservedValues.
163 *
164 * \return right atom's id
165 */
166 atomId_t getrightIndex() const;
167
168 /** Getter to left atom's position contained in \a ObservedValues.
169 *
170 * \return left atom's position
171 */
172 Vector getleftPosition() const;
173
174 /** Getter to right atom's position contained in \a ObservedValues.
175 *
176 * \return right atom's position
177 */
178 Vector getrightPosition() const;
179
180 /** Getter to left atom's element contained in \a ObservedValues.
181 *
182 * \return left atom's element
183 */
184 atomicNumber_t getleftElement() const;
185
186 /** Getter to rightatom's element contained in \a ObservedValues.
187 *
188 * \return right atom's element
189 */
190 atomicNumber_t getrightElement() const;
191
192 /** Getter to bond's degree contained in \a ObservedValues.
193 *
194 * \return bond's degree
195 */
196 int getDegree() const;
197
198 /** Counts how many ObservedValues got subjectKilled.
199 *
200 * This is used to give InstanceRemoved() signal only when each and every
201 * ObservedValue (and the instance itself) has been subjectKilled by the
202 * monitored Observable. Only then can we safely remove the instance.
203 *
204 */
205 void countsubjectKilled();
206
207 //!> counts how many ObservedValues have already been subjectKilled()
208 mutable size_t subjectKilledCount;
209
210private:
211
212 //!> indicate whether we are signed in to leftobservable
213 bool leftobservable_enabled;
214 //!> indicate whether we are signed in to rightobservable
215 bool rightobservable_enabled;
216 //!> indicate whether we are signed in to bond itself
217 bool bond_enabled;
218
219 //!> list of channels when id needs to update
220 static const Observable::channels_t IndexChannels;
221 //!> list of channels when position needs to update
222 static const Observable::channels_t BondPositionChannels;
223 //!>list of channels when degree needs to update
224 static const Observable::channels_t BondDegreeChannels;
225 //!> list of channels when element needs to update
226 static const Observable::channels_t BondElementChannels;
227};
228
229
230
231#endif /* GLMOLECULEOBJECT_BOND_HPP_ */
Note: See TracBrowser for help on using the repository browser.