source: src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp@ fe493f

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

Added AtomCount and FormulaChanged to QtObservedMolecule.

  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*
2 * QtObservedMolecule.hpp
3 *
4 * Created on: Oct 28, 2015
5 * Author: heber
6 */
7
8
9#ifndef QTOBSERVEDMOLECULE_HPP_
10#define QTOBSERVEDMOLECULE_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 "molecule.hpp"
26#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
27#include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp"
28#include "types.hpp"
29
30class QtObservedInstanceBoard;
31
32/** This instance is the ObservedValue representation of a World's molecule.
33 *
34 * Due to the signal/slot mechanism and its delays, lifetime of objects in the
35 * World and their QtGui representation cannot directly be related (without
36 * slowing down Actions just for having the representation up to speed).
37 * Hence, the required information for displaying and representing these
38 * objects must be contained in an extra instance.
39 *
40 * This is the instance for information about a particular molecule.
41 */
42class QtObservedMolecule : public QWidget, public Observer
43{
44 Q_OBJECT
45
46public:
47
48 //!> typedef for instance wrapped in shared ptr
49 typedef boost::shared_ptr<QtObservedMolecule> ptr;
50
51private:
52 //!> ObservedValuesContainer needs to access private cstor and dstor
53 friend class ObservedValuesContainer<QtObservedMolecule, moleculeId_t>;
54 //!> QtObservedInstanceBoard needs to access private cstor and dstor
55 friend class QtObservedInstanceBoard;
56
57 /** Cstor of QtObservedMolecule.
58 *
59 * \param _ObservedValues ref to set of observed values for this instance
60 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled()
61 * \param _parent Qt parent to automatically destroy when parent is destroyed
62 */
63 QtObservedMolecule(
64 const ObservedValues_t &_ObservedValues,
65 QtObservedInstanceBoard &_board,
66 QWidget * _parent=0);
67
68public:
69
70 /** Dstor of QtObservedMolecule.
71 *
72 */
73 ~QtObservedMolecule();
74
75 // Observer functions
76 void update(Observable *publisher);
77 void subjectKilled(Observable *publisher);
78 void recieveNotification(Observable *publisher, Notification_ptr notification);
79
80 /** Getter to molecule atom count contained in \a ObservedValues.
81 *
82 * \return molecule's atom count
83 */
84 int getAtomCount() const;
85
86 /** Getter to molecule index contained in \a ObservedValues.
87 *
88 * \return molecule's index
89 */
90 moleculeId_t getMolIndex() const;
91
92 /** Getter to molecule name contained in \a ObservedValues.
93 *
94 * \return molecule's name
95 */
96 std::string getMolName() const;
97
98 /** Getter to molecule formula contained in \a ObservedValues.
99 *
100 * \return molecule's formula
101 */
102 std::string getMolFormula() const;
103
104 /** Getter to molecule's bounding box contained in \a ObservedValues.
105 *
106 * \return molecule's bounding box
107 */
108 molecule::BoundingBoxInfo getBoundingBox() const;
109
110 static const molecule * const getMolecule(const moleculeId_t _id);
111
112signals:
113 void atomcountChanged();
114 void formulaChanged();
115 void indexChanged();
116 void nameChanged();
117 void tesselationhullChanged();
118 void boundingboxChanged();
119 void atomInserted(const atomId_t);
120 void atomRemoved(const atomId_t);
121
122private:
123
124 void activateObserver();
125 void deactivateObserver();
126
127private:
128 static int updateAtomCount(
129 const boost::function<const moleculeId_t ()> &_getMolIndex);
130 static molecule::BoundingBoxInfo updateBoundingBox(
131 const boost::function<const moleculeId_t ()> &_getMolIndex);
132 static std::string updateFormulaString(
133 const boost::function<const moleculeId_t ()> &_getMolIndex);
134 static moleculeId_t updateIndex();
135 static std::string updateName(
136 const boost::function<const moleculeId_t ()> &_getMolIndex);
137
138 //!> list of channels when atom count needs to update
139 static const Observable::channels_t AtomCountChannels;
140 //!> list of channels when bounding box needs to update
141 static const Observable::channels_t BoundingBoxChannels;
142 //!> list of channels when formula needs to update
143 static const Observable::channels_t FormulaStringChannels;
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 /** Observed Values **/
151
152 //!> enumeration of observed values to match with entries in ObservedValues
153 enum ObservedTypes {
154 //!> contains the current molecule's atom count
155 AtomCount,
156 //!> contains the current molecule's formula
157 FormulaString,
158 //!> contains the current molecule index
159 MolIndex,
160 //!> contains the current molecule name
161 MolName,
162 //!> contains newest version of the bounding box on request
163 BoundingBox,
164 //!> gives the size of the enumeration
165 MAX_ObservedTypes
166 };
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 ObservedValues_t &_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 //!> counts how many ObservedValues have already been subjectKilled()
189 mutable size_t subjectKilledCount;
190
191private:
192
193 //!> we get multiple subjectKilled(), count and call callback() only on last
194 const unsigned int AllsignedOnChannels;
195 unsigned int signedOffChannels;
196
197 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
198 const Observable *owner;
199
200private:
201
202 //!> reference to InstanceBoard for callbacks on subjectKilled()
203 QtObservedInstanceBoard & board;
204
205 //!> internal reference to ObservedValues held by QtObservedInstanceBoard
206 ObservedValues_t ObservedValues;
207};
208
209
210#endif /* QTOBSERVEDMOLECULE_HPP_ */
Note: See TracBrowser for help on using the repository browser.