source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp@ 057c8a

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 057c8a was 6fe4f7, checked in by Frederik Heber <heber@…>, 10 years ago

FIX: updateBoundingBox() must not call molecule::getBoundingBox() on every update.

  • this is O(N2). We now update by using the current center and radius and looking at the last changed atom's position. This diverges with respect to the radius after some time. Hence, a true getBoundingBox() should be called after a while.
  • Property mode set to 100644
File size: 5.4 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 "CodePatterns/Cacheable.hpp"
21#include "CodePatterns/Observer/Observer.hpp"
22#include "CodePatterns/ObservedValue.hpp"
23
24#include "GLMoleculeObject_bond.hpp"
25
26class atom;
27class bond;
28class GLMoleculeObject_atom;
29class GLWorldScene;
30class molecule;
31
32class GLMoleculeObject_molecule : public GLMoleculeObject, public Observer
33{
34 Q_OBJECT
35public:
36 GLMoleculeObject_molecule(QObject *parent, const moleculeId_t molid);
37 GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid);
38 virtual ~GLMoleculeObject_molecule();
39
40 // Observer functions
41 void update(Observable *publisher);
42 void subjectKilled(Observable *publisher);
43 void recieveNotification(Observable *publisher, Notification_ptr notification);
44
45 void initialize(QGLView *view, QGLPainter *painter);
46 void draw(QGLPainter *painter, const QVector4D &cameraPlane);
47
48 typedef std::pair< atomId_t, atomId_t> BondIds;
49 friend std::ostream &operator<<(std::ostream &ost, const BondIds &t);
50
51 static BondIds getBondIds(
52 const bond::ptr _bond,
53 const enum GLMoleculeObject_bond::SideOfBond side);
54
55signals:
56 void changed();
57 void changeOccured();
58 void hoverChanged(const atomId_t);
59 void hoverChanged(const moleculeId_t, int);
60 void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
61 void atomClicked(atomId_t no);
62 void moleculeClicked(moleculeId_t no);
63 void TesselationHullChanged();
64 void BoundingBoxChanged();
65 void IsSelectedChanged();
66 void AtomInserted(const atomId_t _id);
67 void AtomRemoved(const atomId_t _id);
68 void IdChanged();
69
70private slots:
71 //!> grant GLWorldScene access to private slots
72 friend class GLWorldScene;
73
74 void wasClicked();
75 void atomInserted(const atomId_t _id);
76 void atomRemoved(const atomId_t _id);
77 void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side);
78 void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
79 void hoverChangedSignalled(GLMoleculeObject *ob);
80 void changeAtomId(GLMoleculeObject_atom *, const atomId_t, const atomId_t);
81
82 void setVisible(bool value);
83
84 void activateObserver();
85 void deactivateObserver();
86
87 void resetTesselationHull();
88 void resetBoundingBox();
89 void resetAtoms();
90 void resetIndex();
91 void resetName();
92
93 void AtomSelected(const atomId_t _id);
94 void AtomUnselected(const atomId_t _id);
95 void Selected();
96 void Unselected();
97
98private:
99 static const molecule * const getMolecule(const moleculeId_t _id);
100
101private:
102 void addAtomBonds(
103 const bond::ptr &_bond,
104 const GLMoleculeObject_bond::SideOfBond _side
105 );
106 void addAtomBonds(const atomId_t _id);
107
108 //!> typedef for the internal set of atoms
109 typedef std::set<atomId_t> atoms_t;
110
111 /** Structure for the required information on the bounding box.
112 *
113 */
114 struct BoundingBoxInfo {
115 //!> position of center
116 Vector position;
117 //!> radius of sphere
118 double radius;
119 };
120
121 /** Structure for the required information on the tesselation hull.
122 *
123 */
124 struct TesselationHullInfo {
125 };
126
127 BoundingBoxInfo initBoundingBox() const;
128
129 QGeometryData updateTesselationHull() const;
130 BoundingBoxInfo updateBoundingBox() const;
131 atoms_t updateAtoms();
132 moleculeId_t updateIndex() const;
133 std::string updateName() const;
134
135 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
136 const Observable * owner;
137
138 //!> internal variable for caching molecule ref in cstor
139 const molecule * const molref;
140
141 //!> list of channels when contained atoms needs to update
142 static const Observable::channels_t AtomsChannels;
143 //!> list of channels when tesselation hull needs to update
144 static const Observable::channels_t HullChannels;
145 //!> list of channels when bounding box needs to update
146 static const Observable::channels_t BoundingBoxChannels;
147 //!> list of channels when the index needs to update
148 static const Observable::channels_t IndexChannels;
149 //!> list of channels when the name needs to update
150 static const Observable::channels_t NameChannels;
151
152 boost::function<moleculeId_t ()> MolIndexUpdater;
153 boost::function<std::string ()> MolNameUpdater;
154 boost::function<QGeometryData ()> TesselationHullUpdater;
155 boost::function<BoundingBoxInfo ()> BoundingBoxUpdater;
156 boost::function<atoms_t ()> PresentAtomsUpdater;
157
158 //!> contains the current molecule index
159 ObservedValue<moleculeId_t> MolIndex;
160 //!> contains the current molecule name
161 ObservedValue<std::string> MolName;
162 //!> contains current version of the tesselation hull on request
163 Cacheable<QGeometryData> TesselationHull;
164 //!> contains newest version of the bounding box on request
165 ObservedValue<BoundingBoxInfo> BoundingBox;
166 //!> contains the current live set of atoms for the molecule
167 ObservedValue<atoms_t> PresentAtoms;
168
169 //!> contains the set of atoms displayed
170 atoms_t DisplayedAtoms;
171
172 typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;
173 typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
174 AtomNodeMap AtomsinSceneMap;
175 BondNodeMap BondsinSceneMap;
176
177 atomId_t hoverAtomId;
178};
179
180std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);
181
182
183#endif /* GLMOLECULEOBJECT_MOLECULE_HPP_ */
Note: See TracBrowser for help on using the repository browser.