source: src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp@ ca1535

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

Extracted all ObservedValue functionality out of GLMoleculeObject_atom.

  • i.e. GLMoleculeObject_atom is reduced to simple displaying, updated via Qt signals. These signals are connected to a QtObservedAtom which in turn now contains all the ObservedValue functionality.
  • this is preparatory for having a single (Observed)Atom as representer of its associated World's atom in the QtGui part of the code.
  • Property mode set to 100644
File size: 5.8 KB
Line 
1/*
2 * QtObservedAtom.hpp
3 *
4 * Created on: Oct 28, 2015
5 * Author: heber
6 */
7
8
9#ifndef QTOBSERVEDATOM_HPP_
10#define QTOBSERVEDATOM_HPP_
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <QtGui/QWidget>
18
19#include <boost/function.hpp>
20#include <boost/shared_ptr.hpp>
21
22#include "CodePatterns/Observer/Observable.hpp"
23#include "CodePatterns/Observer/Observer.hpp"
24
25#include "LinearAlgebra/Vector.hpp"
26
27#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
28#include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp"
29#include "types.hpp"
30
31class atom;
32class QtObservedInstanceBoard;
33
34/** This instance is the ObservedValue representation of a World's atom.
35 *
36 * Due to the signal/slot mechanism and its delays, lifetime of objects in the
37 * World and their QtGui representation cannot directly be related (without
38 * slowing down Actions just for having the representation up to speed).
39 * Hence, the required information for displaying and representing these
40 * objects must be contained in an extra instance.
41 *
42 * This is the instance for information about a particular atom.
43 *
44 * Essentially, this is the interface between molecuilder's World (and a
45 * particular atom) and the QtGui part of the code.
46 */
47class QtObservedAtom : public QWidget, public Observer
48{
49 Q_OBJECT
50
51public:
52
53 //!> typedef for instance wrapped in shared ptr
54 typedef boost::shared_ptr<QtObservedAtom> ptr;
55
56private:
57 //!> ObservedValuesContainer needs to access private cstor and dstor
58 friend class ObservedValuesContainer<QtObservedAtom, atomId_t>;
59 //!> QtObservedInstanceBoard needs to access private cstor and dstor
60 friend class QtObservedInstanceBoard;
61
62 /** Cstor of QtObservedAtom.
63 *
64 * \param _ObservedValues ref to set of observed values for this instance
65 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled()
66 * \param _parent Qt parent to automatically destroy when parent is destroyed
67 */
68 QtObservedAtom(
69 const ObservedValues_t &_ObservedValues,
70 QtObservedInstanceBoard &_board,
71 QWidget * _parent=0);
72
73public:
74
75 /** Dstor of QtObservedAtom.
76 *
77 */
78 ~QtObservedAtom();
79
80 // Observer functions
81 void update(Observable *publisher);
82 void subjectKilled(Observable *publisher);
83 void recieveNotification(Observable *publisher, Notification_ptr notification);
84
85 /** Getter to atom index contained in \a ObservedValues.
86 *
87 * \return atom's index
88 */
89 atomId_t getAtomIndex() const;
90
91 /** Getter to atom position contained in \a ObservedValues.
92 *
93 * \return atom's position
94 */
95 Vector getAtomPosition() const;
96
97 /** Getter to atom element contained in \a ObservedValues.
98 *
99 * \return atom's elemnt
100 */
101 atomicNumber_t getAtomElement() const;
102
103 //!> typedef for list of bonds, defined by pairs of atom ids
104 typedef std::vector< std::pair<atomId_t, atomId_t> > ListOfBonds_t;
105
106 /** Getter to atom bonds contained in \a ObservedValues.
107 *
108 * \return atom's bonds
109 */
110 ListOfBonds_t getAtomBonds() const;
111
112signals:
113 void indexChanged();
114 void positionChanged();
115 void elementChanged();
116 void bondsChanged();
117
118//private slots:
119
120private:
121 void activateObserver();
122 void deactivateObserver();
123
124 static const atom * const getAtomConst(const atomId_t _id);
125 static atom * const getAtom(const atomId_t _id);
126
127private:
128 static atomId_t updateIndex();
129 static Vector updatePosition(
130 const boost::function<const atomId_t ()> &_getAtomIndex);
131 static atomicNumber_t updateElement(
132 const boost::function<const atomId_t ()> &_getAtomIndex);
133 static ListOfBonds_t updateBonds(
134 const boost::function<const atomId_t ()> &_getAtomIndex);
135
136 //!> enumeration of observed values to match with entries in ObservedValues
137 enum ObservedTypes {
138 //!> contains the current atom index
139 AtomIndex,
140 //!> contains the current atom position
141 AtomPosition,
142 //!> contains the current atom element
143 AtomElement,
144 //!> contains the current set of bonds atoms fort the atom
145 AtomBonds,
146 //!> gives the size of the enumeration
147 MAX_ObservedTypes
148 };
149
150 /** Initializes all \a ObservedValues entries.
151 *
152 * \param _ObservedValues vector of ObservedValue to be filled
153 * \param _id atom id
154 * \param _atomref reference to atom
155 * \param _subjectKilled ref to function to call on subjectKilled()
156 */
157 static void initObservedValues(
158 ObservedValues_t &_ObservedValues,
159 const atomId_t _id,
160 const atom * const _atomref,
161 const boost::function<void(const atomId_t)> &_subjectKilled);
162
163 /** Destroys all \a ObservedValues entries.
164 *
165 * \param _ObservedValues vector of ObservedValue to be destroyed
166 */
167 static void destroyObservedValues(
168 std::vector<boost::any> &_ObservedValues);
169
170 //!> counts how many ObservedValues have already been subjectKilled()
171 mutable size_t subjectKilledCount;
172
173private:
174
175 //!> list of channels when index needs to update
176 static const Observable::channels_t AtomIndexChannels;
177 //!> list of channels when position needs to update
178 static const Observable::channels_t AtomPositionChannels;
179 //!> list of channels when element needs to update
180 static const Observable::channels_t AtomElementChannels;
181 //!> list of channels when bonds needs to update
182 static const Observable::channels_t AtomBondsChannels;
183
184 //!> we get multiple subjectKilled(), count and call callback() only on last
185 const unsigned int AllsignedOnChannels;
186 unsigned int signedOffChannels;
187
188 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
189 const Observable *owner;
190
191private:
192
193 //!> reference to InstanceBoard for callbacks on subjectKilled()
194 QtObservedInstanceBoard & board;
195
196 //!> internal reference to ObservedValues held by QtObservedInstanceBoard
197 ObservedValues_t ObservedValues;
198};
199
200
201#endif /* QTOBSERVEDATOM_HPP_ */
Note: See TracBrowser for help on using the repository browser.