source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp@ 026bef

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

Changed GLMoleculeObject_...:countSubjectKilled() to taking id parameter.

  • this is a precursor for when the ObservedValues reside with QtInstanceInformationBoard.
  • enhanced ObservedValue_wCallback to take a bound getIndex function().
  • additionally, we route internally to ObservedValue::get() and this gets us out of the painful situation where we need to supply an index getter to the ObservedValue that monitors the index (and hence must be present already to bind to its get function).
  • Property mode set to 100644
File size: 7.3 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(
42 QGLSceneNode *mesh[],
43 QObject *parent,
44 const bondIds_t bondIds,
45 const enum SideOfBond side);
46 GLMoleculeObject_bond(
47 QGLSceneNode *mesh[],
48 QObject *parent,
49 const bondIds_t bondIds,
50 const enum SideOfBond side,
51 std::vector<boost::any> &_ObservedValues);
52 virtual ~GLMoleculeObject_bond();
53
54 // Observer functions
55 void update(Observable *publisher);
56 void subjectKilled(Observable *publisher);
57 void recieveNotification(Observable *publisher, Notification_ptr notification);
58
59signals:
60 void BondRemoved(const atomId_t leftnr, const atomId_t rightnr);
61 void elementChanged();
62 void positionChanged();
63 void degreeChanged();
64
65private slots:
66 //!> grant GLMoleculeObject_molecule acess to reset functions
67 friend class GLMoleculeObject_molecule;
68
69 /** Recalculates the element of the cylinder representing the bond.
70 *
71 */
72 void resetElement();
73
74 /** Recalculates the position of the cylinder representing the bond.
75 *
76 */
77 void resetPosition();
78
79 /** Recalculates the width of the cylinder representing the bond's degree.
80 *
81 */
82 void resetWidth();
83
84private:
85
86 void init();
87
88 void removeChannels();
89
90 static atomId_t updateIndex();
91 static Vector updateLeftPosition(
92 const boost::function<const atomId_t ()> &_getLeftAtomIndex);
93 static Vector updateRightPosition(
94 const boost::function<const atomId_t ()> &_getRightAtomIndex);
95 static atomicNumber_t updateLeftElement(
96 const boost::function<const atomId_t ()> &_getLeftAtomIndex);
97 static atomicNumber_t updateRightElement(
98 const boost::function<const atomId_t ()> &_getRightAtomIndex);
99 static int updateDegree(
100 const boost::function<const atomId_t ()> &_getLeftAtomIndex,
101 const boost::function<const atomId_t ()> &_getRightAtomIndex);
102
103 static const atom * const getAtomConst(const atomId_t _id);
104 static atom * const getAtom(const atomId_t _id);
105
106private:
107 //!> contains ref to Observable of left atom
108 const Observable * const leftowner;
109 //!> contains ref to Observable of right atom
110 const Observable * const rightowner;
111 //!> temporary variable used in cstor
112 const Observable * const bondowner;
113
114 const enum SideOfBond BondSide;
115
116
117private:
118 /** Observed Values **/
119
120 //!> enumeration of observed values to match with entries in ObservedValues
121 enum ObservedTypes {
122 //!> contains the id of the left atom
123 leftIndex,
124 //!> contains the id of the right atom
125 rightIndex,
126 //!> contains the position of the left atom
127 leftPosition,
128 //!> contains the position of the right atom
129 rightPosition,
130 //!> contains the element of the left atom
131 leftElement,
132 //!> contains the element of the right atom
133 rightElement,
134 //!> contains the degree of the bond
135 Degree,
136 //!> gives the size of the enumeration
137 MAX_ObservedTypes
138 };
139
140 //!> vector with all observed values
141 std::vector<boost::any> ObservedValues;
142
143 /** Initializes all \a ObservedValues entries.
144 *
145 * \param _ObservedValues vector of ObservedValue to be filled
146 * \param _leftatomId left atom id
147 * \param _rightatomId right atom id
148 * \param _leftowner reference to left atom
149 * \param _rightowner reference to right atom
150 * \param _bondowner reference to bond
151 * \param _leftsubjectKilled ref to function to call on subjectKilled() for left atom
152 * \param _rightsubjectKilled ref to function to call on subjectKilled() for right atom
153 * \param _bondsubjectKilled ref to function to call on subjectKilled() for bond
154 */
155 static void initObservedValues(
156 std::vector<boost::any> &_ObservedValues,
157 const atomId_t _leftatomId,
158 const atomId_t _rightatomId,
159 const Observable * const _leftowner,
160 const Observable * const _rightowner,
161 const Observable * const _bondowner,
162 const boost::function<void(const atomId_t &)> &_leftsubjectKilled,
163 const boost::function<void(const atomId_t &)> &_rightsubjectKilled,
164 const boost::function<void(const bondIds_t &)> &_bondsubjectKilled);
165
166 /** Destroys all \a ObservedValues entries.
167 *
168 * \param _ObservedValues vector of ObservedValue to be destroyed
169 */
170 static void destroyObservedValues(
171 std::vector<boost::any> &_ObservedValues);
172
173 /** Getter to left atom's id contained in \a ObservedValues.
174 *
175 * \return left atom's id
176 */
177 atomId_t getleftIndex() const;
178
179 /** Getter to right atom's id contained in \a ObservedValues.
180 *
181 * \return right atom's id
182 */
183 atomId_t getrightIndex() const;
184
185 /** Getter to left atom's position contained in \a ObservedValues.
186 *
187 * \return left atom's position
188 */
189 Vector getleftPosition() const;
190
191 /** Getter to right atom's position contained in \a ObservedValues.
192 *
193 * \return right atom's position
194 */
195 Vector getrightPosition() const;
196
197 /** Getter to left atom's element contained in \a ObservedValues.
198 *
199 * \return left atom's element
200 */
201 atomicNumber_t getleftElement() const;
202
203 /** Getter to rightatom's element contained in \a ObservedValues.
204 *
205 * \return right atom's element
206 */
207 atomicNumber_t getrightElement() const;
208
209 /** Getter to bond's degree contained in \a ObservedValues.
210 *
211 * \return bond's degree
212 */
213 int getDegree() const;
214
215 /** Counts how many ObservedValues got subjectKilled.
216 *
217 * This is used to give InstanceRemoved() signal only when each and every
218 * ObservedValue (and the instance itself) has been subjectKilled by the
219 * monitored Observable. Only then can we safely remove the instance.
220 *
221 * \param _bondIds bond ids whose bond has called subjectKilled()
222 */
223 void countsubjectKilled(
224 const bondIds_t &_bondIds)
225 {
226 countsubjectKilled();
227 }
228
229 void countsubjectKilled(
230 const atomId_t &_atomid)
231 {
232 countsubjectKilled();
233 }
234
235 void countsubjectKilled();
236
237 //!> counts how many ObservedValues have already been subjectKilled()
238 mutable size_t subjectKilledCount;
239
240private:
241
242 //!> indicate whether we are signed in to leftobservable
243 bool leftobservable_enabled;
244 //!> indicate whether we are signed in to rightobservable
245 bool rightobservable_enabled;
246 //!> indicate whether we are signed in to bond itself
247 bool bond_enabled;
248
249 //!> list of channels when id needs to update
250 static const Observable::channels_t IndexChannels;
251 //!> list of channels when position needs to update
252 static const Observable::channels_t BondPositionChannels;
253 //!>list of channels when degree needs to update
254 static const Observable::channels_t BondDegreeChannels;
255 //!> list of channels when element needs to update
256 static const Observable::channels_t BondElementChannels;
257};
258
259
260
261#endif /* GLMOLECULEOBJECT_BOND_HPP_ */
Note: See TracBrowser for help on using the repository browser.