source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp@ 5aec20

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

FIX: All ObservedValue getters now return const references.

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