source: src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp@ 68418e

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 Candidate_v1.7.0 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 68418e was 494478, checked in by Frederik Heber <heber@…>, 10 years ago

Extracted all ObservedValue functionality out of GLMoleculeObject_molecule.

  • see previous commit for explanations.
  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[0070aa]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
[494478]19#include <boost/function.hpp>
[98c35c]20#include <boost/shared_ptr.hpp>
[0070aa]21
[494478]22#include "CodePatterns/Observer/Observable.hpp"
[0070aa]23#include "CodePatterns/Observer/Observer.hpp"
24
[494478]25#include "molecule.hpp"
[98c35c]26#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
[41e287]27#include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp"
[0070aa]28#include "types.hpp"
29
[98c35c]30class QtObservedInstanceBoard;
31
[0070aa]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
[494478]46public:
47
48 //!> typedef for instance wrapped in shared ptr
49 typedef boost::shared_ptr<QtObservedMolecule> ptr;
50
51private:
[41e287]52 //!> ObservedValuesContainer needs to access private cstor and dstor
53 friend class ObservedValuesContainer<QtObservedMolecule, moleculeId_t>;
[98c35c]54 //!> QtObservedInstanceBoard needs to access private cstor and dstor
55 friend class QtObservedInstanceBoard;
56
[0070aa]57 /** Cstor of QtObservedMolecule.
58 *
[494478]59 * \param _ObservedValues ref to set of observed values for this instance
60 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled()
[0070aa]61 * \param _parent Qt parent to automatically destroy when parent is destroyed
62 */
[98c35c]63 QtObservedMolecule(
[494478]64 const ObservedValues_t &_ObservedValues,
65 QtObservedInstanceBoard &_board,
[98c35c]66 QWidget * _parent=0);
67
68public:
[0070aa]69
70 /** Dstor of QtObservedMolecule.
71 *
72 */
73 ~QtObservedMolecule();
74
[98c35c]75 // Observer functions
76 void update(Observable *publisher);
77 void subjectKilled(Observable *publisher);
78 void recieveNotification(Observable *publisher, Notification_ptr notification);
79
[494478]80 /** Getter to molecule index contained in \a ObservedValues.
81 *
82 * \return molecule's index
83 */
84 moleculeId_t getMolIndex() const;
85
86 /** Getter to molecule name contained in \a ObservedValues.
87 *
88 * \return molecule's name
89 */
90 std::string getMolName() const;
91
92 /** Getter to molecule's bounding box contained in \a ObservedValues.
93 *
94 * \return molecule's bounding box
95 */
96 molecule::BoundingBoxInfo getBoundingBox() const;
97
98 static const molecule * const getMolecule(const moleculeId_t _id);
99
[0070aa]100signals:
[494478]101 void indexChanged();
102 void nameChanged();
103 void tesselationhullChanged();
104 void boundingboxChanged();
105 void atomInserted(const atomId_t);
106 void atomRemoved(const atomId_t);
107
108private:
109
110 void activateObserver();
111 void deactivateObserver();
112
113private:
114 static molecule::BoundingBoxInfo updateBoundingBox(
115 const boost::function<const moleculeId_t ()> &_getMolIndex);
116 static moleculeId_t updateIndex();
117 static std::string updateName(
118 const boost::function<const moleculeId_t ()> &_getMolIndex);
119
120 //!> list of channels when bounding box needs to update
121 static const Observable::channels_t BoundingBoxChannels;
122 //!> list of channels when the index needs to update
123 static const Observable::channels_t IndexChannels;
124 //!> list of channels when the name needs to update
125 static const Observable::channels_t NameChannels;
126
127private:
128 /** Observed Values **/
129
130 //!> enumeration of observed values to match with entries in ObservedValues
131 enum ObservedTypes {
132 //!> contains the current molecule index
133 MolIndex,
134 //!> contains the current molecule name
135 MolName,
136 //!> contains newest version of the bounding box on request
137 BoundingBox,
138 //!> gives the size of the enumeration
139 MAX_ObservedTypes
140 };
141
142 /** Initializes all \a _ObservedValues entries.
143 *
144 * \param _ObservedValues vector of ObservedValue to be filled
145 * \param _moid molecule id
146 * \param _molref reference to molecule
147 * \param _subjectKilled ref to function to call on subjectKilled()
148 */
149 static void initObservedValues(
150 ObservedValues_t &_ObservedValues,
151 const moleculeId_t _molid,
152 const molecule * const _molref,
153 const boost::function<void(const moleculeId_t)> &_subjectKilled);
[0070aa]154
[494478]155 /** Destroys all \a ObservedValues entries.
156 *
157 * \param _ObservedValues vector of ObservedValue to be destroyed
158 */
159 static void destroyObservedValues(
160 std::vector<boost::any> &_ObservedValues);
[0070aa]161
[494478]162 //!> counts how many ObservedValues have already been subjectKilled()
163 mutable size_t subjectKilledCount;
[0070aa]164
165private:
[494478]166
167 //!> we get multiple subjectKilled(), count and call callback() only on last
168 const unsigned int AllsignedOnChannels;
169 unsigned int signedOffChannels;
170
171 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
172 const Observable *owner;
173
174private:
175
176 //!> reference to InstanceBoard for callbacks on subjectKilled()
177 QtObservedInstanceBoard & board;
178
[98c35c]179 //!> internal reference to ObservedValues held by QtObservedInstanceBoard
[494478]180 ObservedValues_t ObservedValues;
[0070aa]181};
182
183
184#endif /* QTOBSERVEDMOLECULE_HPP_ */
Note: See TracBrowser for help on using the repository browser.