source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp@ 15c8a9

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

Added QtInstanceInformationBoard that handles ObservedValues through the QtGui interface.

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