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