source: src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp@ 0af22d

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

Added ObservedValue for selection status of atoms and molecules to QtObserved...

  • Property mode set to 100644
File size: 8.4 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
[5a9e34]25#include "LinearAlgebra/Vector.hpp"
26
[494478]27#include "molecule.hpp"
[98c35c]28#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
[41e287]29#include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp"
[0070aa]30#include "types.hpp"
31
[98c35c]32class QtObservedInstanceBoard;
33
[0070aa]34/** This instance is the ObservedValue representation of a World's molecule.
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 molecule.
43 */
44class QtObservedMolecule : public QWidget, public Observer
45{
46 Q_OBJECT
47
[494478]48public:
49
50 //!> typedef for instance wrapped in shared ptr
51 typedef boost::shared_ptr<QtObservedMolecule> ptr;
52
53private:
[41e287]54 //!> ObservedValuesContainer needs to access private cstor and dstor
55 friend class ObservedValuesContainer<QtObservedMolecule, moleculeId_t>;
[98c35c]56 //!> QtObservedInstanceBoard needs to access private cstor and dstor
57 friend class QtObservedInstanceBoard;
58
[0070aa]59 /** Cstor of QtObservedMolecule.
60 *
[494478]61 * \param _ObservedValues ref to set of observed values for this instance
62 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled()
[0070aa]63 * \param _parent Qt parent to automatically destroy when parent is destroyed
64 */
[98c35c]65 QtObservedMolecule(
[494478]66 const ObservedValues_t &_ObservedValues,
67 QtObservedInstanceBoard &_board,
[98c35c]68 QWidget * _parent=0);
69
70public:
[0070aa]71
72 /** Dstor of QtObservedMolecule.
73 *
74 */
75 ~QtObservedMolecule();
76
[98c35c]77 // Observer functions
78 void update(Observable *publisher);
79 void subjectKilled(Observable *publisher);
80 void recieveNotification(Observable *publisher, Notification_ptr notification);
81
[1b6415a]82 /** Getter to molecule atom count contained in \a ObservedValues.
83 *
84 * \return molecule's atom count
85 */
[3b9aa1]86 const int& getAtomCount() const;
[1b6415a]87
[5a9e34]88 /** Getter to molecule bond count contained in \a ObservedValues.
89 *
90 * \return molecule's bond count
91 */
[3b9aa1]92 const int& getBondCount() const;
[5a9e34]93
94 /** Getter to molecule center contained in \a ObservedValues.
95 *
96 * \return molecule's center
97 */
[3b9aa1]98 const Vector& getMolCenter() const;
[5a9e34]99
[494478]100 /** Getter to molecule index contained in \a ObservedValues.
101 *
102 * \return molecule's index
103 */
[3b9aa1]104 const moleculeId_t& getMolIndex() const;
[494478]105
106 /** Getter to molecule name contained in \a ObservedValues.
107 *
108 * \return molecule's name
109 */
[3b9aa1]110 const std::string& getMolName() const;
[494478]111
[1b6415a]112 /** Getter to molecule formula contained in \a ObservedValues.
113 *
114 * \return molecule's formula
115 */
[3b9aa1]116 const std::string& getMolFormula() const;
[1b6415a]117
[5a9e34]118 /** Getter to molecule non-hydrogen atom count contained in \a ObservedValues.
119 *
120 * \return molecule's non-hydrogen atom count
121 */
[3b9aa1]122 const int& getNonHydrogenCount() const;
[5a9e34]123
[494478]124 /** Getter to molecule's bounding box contained in \a ObservedValues.
125 *
126 * \return molecule's bounding box
127 */
[3b9aa1]128 const molecule::BoundingBoxInfo& getBoundingBox() const;
[494478]129
[9e9100]130 /** Getter to molecule's selected status.
131 *
132 * \return true - molecule selected, false - else
133 */
134 const bool& getMolSelected() const;
135
[494478]136 static const molecule * const getMolecule(const moleculeId_t _id);
137
[0070aa]138signals:
[1b6415a]139 void atomcountChanged();
[5a9e34]140 void bondcountChanged();
[1b6415a]141 void formulaChanged();
[494478]142 void indexChanged();
143 void nameChanged();
[5a9e34]144 void nononhydrogenChanged();
145 void centerChanged();
[494478]146 void tesselationhullChanged();
147 void boundingboxChanged();
148 void atomInserted(const atomId_t);
149 void atomRemoved(const atomId_t);
[5a9e34]150 void moleculeRemoved();
[9e9100]151 void selectedChanged();
[494478]152
153private:
154
155 void activateObserver();
156 void deactivateObserver();
157
158private:
[1b6415a]159 static int updateAtomCount(
160 const boost::function<const moleculeId_t ()> &_getMolIndex);
[5a9e34]161 static int updateBondCount(
162 const boost::function<const moleculeId_t ()> &_getMolIndex);
[494478]163 static molecule::BoundingBoxInfo updateBoundingBox(
164 const boost::function<const moleculeId_t ()> &_getMolIndex);
[1b6415a]165 static std::string updateFormulaString(
166 const boost::function<const moleculeId_t ()> &_getMolIndex);
[5a9e34]167 static Vector updateCenter(
168 const boost::function<const moleculeId_t ()> &_getMolIndex);
[494478]169 static moleculeId_t updateIndex();
170 static std::string updateName(
171 const boost::function<const moleculeId_t ()> &_getMolIndex);
[5a9e34]172 static int updateNonHydrogenCount(
173 const boost::function<const moleculeId_t ()> &_getMolIndex);
[9e9100]174 static bool updateSelected(
175 const boost::function<const moleculeId_t ()> &_getMolIndex);
[494478]176
[1b6415a]177 //!> list of channels when atom count needs to update
178 static const Observable::channels_t AtomCountChannels;
[5a9e34]179 //!> list of channels when bond count needs to update
180 static const Observable::channels_t BondCountChannels;
[494478]181 //!> list of channels when bounding box needs to update
182 static const Observable::channels_t BoundingBoxChannels;
[1b6415a]183 //!> list of channels when formula needs to update
184 static const Observable::channels_t FormulaStringChannels;
[5a9e34]185 //!> list of channels when the center needs to update
186 static const Observable::channels_t CenterChannels;
[494478]187 //!> list of channels when the index needs to update
188 static const Observable::channels_t IndexChannels;
189 //!> list of channels when the name needs to update
190 static const Observable::channels_t NameChannels;
[5a9e34]191 //!> list of channels when the name needs to update
192 static const Observable::channels_t NonHydrogenCountChannels;
[9e9100]193 //!> list of channels when the name needs to update
194 static const Observable::channels_t SelectedChannels;
[494478]195
196private:
197 /** Observed Values **/
198
199 //!> enumeration of observed values to match with entries in ObservedValues
200 enum ObservedTypes {
[04c3a3]201 //!> contains the current molecule index
202 MolIndex,
[1b6415a]203 //!> contains the current molecule's atom count
204 AtomCount,
[5a9e34]205 //!> contains the current molecule's number of bonds
206 BondCount,
207 //!> contains newest version of the bounding box on request
208 BoundingBox,
[1b6415a]209 //!> contains the current molecule's formula
210 FormulaString,
[5a9e34]211 //!> contains the current molecule's center
212 MolCenter,
[494478]213 //!> contains the current molecule name
214 MolName,
[5a9e34]215 //!> contains the current molecule's non-hydrogen atom count
216 NonHydrogenCount,
[9e9100]217 //!> contains the current molecule's selection status
218 MolSelected,
[494478]219 //!> gives the size of the enumeration
220 MAX_ObservedTypes
221 };
222
223 /** Initializes all \a _ObservedValues entries.
224 *
225 * \param _ObservedValues vector of ObservedValue to be filled
226 * \param _moid molecule id
227 * \param _molref reference to molecule
228 * \param _subjectKilled ref to function to call on subjectKilled()
229 */
230 static void initObservedValues(
231 ObservedValues_t &_ObservedValues,
232 const moleculeId_t _molid,
233 const molecule * const _molref,
234 const boost::function<void(const moleculeId_t)> &_subjectKilled);
[0070aa]235
[494478]236 /** Destroys all \a ObservedValues entries.
237 *
238 * \param _ObservedValues vector of ObservedValue to be destroyed
239 */
240 static void destroyObservedValues(
241 std::vector<boost::any> &_ObservedValues);
[0070aa]242
[04c3a3]243 /** Function is called by InstanceBoard to inform about its destruction.
244 *
245 * \note callbacks must not be used after this
246 */
247 void noteBoardIsGone()
248 { BoardIsGone = true; }
249
[494478]250 //!> counts how many ObservedValues have already been subjectKilled()
251 mutable size_t subjectKilledCount;
[0070aa]252
253private:
[494478]254
255 //!> we get multiple subjectKilled(), count and call callback() only on last
256 const unsigned int AllsignedOnChannels;
257 unsigned int signedOffChannels;
258
259 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
260 const Observable *owner;
261
262private:
263
264 //!> reference to InstanceBoard for callbacks on subjectKilled()
265 QtObservedInstanceBoard & board;
266
[04c3a3]267 //!> is board still alive or not, impacts callbacks
268 bool BoardIsGone;
269
[98c35c]270 //!> internal reference to ObservedValues held by QtObservedInstanceBoard
[494478]271 ObservedValues_t ObservedValues;
[0070aa]272};
273
274
275#endif /* QTOBSERVEDMOLECULE_HPP_ */
Note: See TracBrowser for help on using the repository browser.