source: src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp@ 59eabc

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

Introduced unique and permanent ObservedValue_Index_t.

  • this is currently the address of the observable which is not perfectly secure but might work for the moment.
  • QtObservedInstanceBoard uses the index internally and only has an additional map to serve instances on request for the their atomId_t, moleculeId_t, .... However, this id should nowhere else be used because it may change during the lifetime of the object.
  • this should prevent the hazzle with the possibly changing atomId_t, moleculeId_t, ... in all classes that work with QtObserved... instances.
  • Property mode set to 100644
File size: 19.1 KB
RevLine 
[0070aa]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2015 Frederik Heber. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * QtObservedMolecule.cpp
25 *
26 * Created on: Oct 28, 2015
27 * Author: heber
28 */
29
30
31// include config.h
32#ifdef HAVE_CONFIG_H
33#include <config.h>
34#endif
35
36#include "QtObservedMolecule.hpp"
37
[494478]38#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
39
[0070aa]40#include "CodePatterns/MemDebug.hpp"
[494478]41#include "CodePatterns/Assert.hpp"
42#include "CodePatterns/Log.hpp"
43
44#include <boost/assign.hpp>
45#include <boost/bind.hpp>
46
47#include "UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp"
48#include "UIElements/Qt4/InstanceBoard/ObservedValue_UpdateAtoms.hpp"
49
50#include "Atom/atom.hpp"
51#include "Descriptors/MoleculeIdDescriptor.hpp"
52#include "World.hpp"
53
54using namespace boost::assign;
55
56static const Observable::channels_t getAllObservedChannels()
57{
58 Observable::channels_t channels;
59 channels +=
60 molecule::AtomInserted,
[5a9e34]61 molecule::AtomMoved,
[494478]62 molecule::AtomRemoved,
[1b6415a]63 molecule::FormulaChanged,
[494478]64 molecule::IndexChanged,
65 molecule::MoleculeNameChanged,
[9e9100]66 molecule::BoundingBoxChanged,
67 molecule::SelectionChanged;
[494478]68 return channels;
69}
70
[1b6415a]71static const Observable::channels_t getAllAtomCountChannels()
72{
73 Observable::channels_t channels;
74 channels +=
75 molecule::AtomInserted,
76 molecule::AtomRemoved;
77 return channels;
78}
79
[5a9e34]80static const Observable::channels_t getAllCenterChannels()
81{
82 Observable::channels_t channels;
83 channels +=
84 molecule::AtomInserted,
85 molecule::AtomMoved,
86 molecule::AtomRemoved;
87 return channels;
88}
89
[494478]90// static instances
[1b6415a]91const Observable::channels_t QtObservedMolecule::AtomCountChannels(getAllAtomCountChannels());
[5a9e34]92const Observable::channels_t QtObservedMolecule::BondCountChannels(getAllAtomCountChannels());
[494478]93const Observable::channels_t QtObservedMolecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged);
[1b6415a]94const Observable::channels_t QtObservedMolecule::FormulaStringChannels(1, molecule::FormulaChanged);
[5a9e34]95const Observable::channels_t QtObservedMolecule::CenterChannels(getAllCenterChannels());
[494478]96const Observable::channels_t QtObservedMolecule::IndexChannels(1, molecule::IndexChanged);
97const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged);
[5a9e34]98const Observable::channels_t QtObservedMolecule::NonHydrogenCountChannels(1, molecule::FormulaChanged);
[9e9100]99const Observable::channels_t QtObservedMolecule::SelectedChannels(1, molecule::SelectionChanged);
[0070aa]100
[98c35c]101QtObservedMolecule::QtObservedMolecule(
[62a0ee]102 const moleculeId_t _id,
103 const molecule * const _mol,
[494478]104 QtObservedInstanceBoard &_board,
[98c35c]105 QWidget * _parent) :
[0070aa]106 QWidget(_parent),
[98c35c]107 Observer("QtObservedMolecule"),
[494478]108 subjectKilledCount(0),
109 AllsignedOnChannels(getAllObservedChannels().size()),
110 signedOffChannels(0),
111 owner(NULL),
[1c0961]112 oldId(_id),
[494478]113 board(_board),
[04c3a3]114 BoardIsGone(false),
[62a0ee]115 ObservedValues(QtObservedMolecule::MAX_ObservedTypes)
[494478]116{
[62a0ee]117 boost::function<void (const atomId_t)> moleculeSubjectKilled(
118 boost::bind(&QtObservedMolecule::countValuesSubjectKilled,
119 boost::ref(*this),
120 _1));
121 initObservedValues(ObservedValues, _id, _mol, moleculeSubjectKilled);
122
[68418e]123 // activating Observer is done by ObservedValueContainer when it's prepared
[494478]124}
[0070aa]125
126QtObservedMolecule::~QtObservedMolecule()
[494478]127{
[04c3a3]128 boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->noteCallBackIsGone();
129 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->noteCallBackIsGone();
130 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->noteCallBackIsGone();
131 boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->noteCallBackIsGone();
132 boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->noteCallBackIsGone();
133 boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->noteCallBackIsGone();
134 boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->noteCallBackIsGone();
135 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->noteCallBackIsGone();
[9e9100]136 boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->noteCallBackIsGone();
[04c3a3]137
[494478]138 deactivateObserver();
[c44763]139
140 destroyObservedValues(ObservedValues);
[494478]141}
142
143void QtObservedMolecule::deactivateObserver()
144{
145 if (owner != NULL) {
146 Observable::channels_t channels = getAllObservedChannels();
147 for (Observable::channels_t::const_iterator iter = channels.begin();
148 iter != channels.end(); ++iter)
149 owner->signOff(this, *iter);
150 owner = NULL;
151 signedOffChannels = AllsignedOnChannels;
[04c3a3]152 if (!BoardIsGone)
[59eabc]153 board.markObservedMoleculeAsDisconnected(getIndex());
[494478]154 }
155}
156
157void QtObservedMolecule::activateObserver()
158{
159 // sign on as observer (obtain non-const instance before)
160 const molecule * const _molecule = getMolecule(getMolIndex());
161 if (_molecule != NULL) {
162 Observable::channels_t channels = getAllObservedChannels();
163 owner = static_cast<const Observable *>(_molecule);
164 for (Observable::channels_t::const_iterator iter = channels.begin();
165 iter != channels.end(); ++iter)
166 owner->signOn(this, *iter);
[04c3a3]167 if (!BoardIsGone)
[59eabc]168 board.markObservedMoleculeAsConnected(getIndex());
[494478]169 } else
170 signedOffChannels = AllsignedOnChannels;
171}
[98c35c]172
173void QtObservedMolecule::update(Observable *publisher)
[494478]174{
175 ASSERT(0,
176 "QtObservedMolecule::update() - general update from unexpected source.");
177}
[98c35c]178
179void QtObservedMolecule::subjectKilled(Observable *publisher)
[494478]180{
181 ++signedOffChannels;
182
[62a0ee]183 checkForRemoval();
184}
185
186void QtObservedMolecule::countValuesSubjectKilled(const moleculeId_t _id)
187{
188 ASSERT( _id == getMolIndex(),
189 "QtObservedAtom::countValuesSubjectKilled() - molecule "+toString(getMolIndex())
190 +" received countValuesSubjectKilled for molecule id "+toString(_id)+".");
191
192 ++subjectKilledCount;
193
194 checkForRemoval();
195}
196
197void QtObservedMolecule::checkForRemoval()
198{
199 if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) {
[494478]200 // remove owner: no more signOff needed
201 owner = NULL;
202
[5a9e34]203 emit moleculeRemoved();
[4e6ffe]204
205 if (!BoardIsGone) {
[59eabc]206 board.markObservedMoleculeAsDisconnected(getIndex());
207 board.markObservedMoleculeForErase(getIndex());
[4e6ffe]208 }
[494478]209 }
210}
[98c35c]211
212void QtObservedMolecule::recieveNotification(Observable *publisher, Notification_ptr notification)
[494478]213{
214 const molecule * const _molecule = getMolecule(getMolIndex());
215 // when molecule is NULL we will soon get destroyed anyway
216 if (_molecule == NULL)
217 return;
218 if (publisher == dynamic_cast<const Observable*>(_molecule)){
219 // notification from atom
220#ifdef LOG_OBSERVER
221 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))
222 << " received notification from molecule " << getMolIndex() << " for channel "
223 << notification->getChannelNo() << ".";
224#endif
225 switch (notification->getChannelNo()) {
226 case molecule::AtomInserted:
227 {
228 const atomId_t _id = _molecule->lastChangedAtomId();
[1b07b1]229 QtObservedAtom::ptr _atom = board.getObservedAtom(_id);
[1b6415a]230 emit atomcountChanged();
[96e145]231 emit atomInserted(_atom, this);
[5a9e34]232 emit bondcountChanged();
233 emit boundingboxChanged();
234 emit centerChanged();
235 emit tesselationhullChanged();
236 break;
237 }
238 case molecule::AtomMoved:
239 {
240 emit boundingboxChanged();
241 emit centerChanged();
242 emit tesselationhullChanged();
[494478]243 break;
244 }
245 case molecule::AtomRemoved:
246 {
247 const atomId_t _id = _molecule->lastChangedAtomId();
[1b6415a]248 emit atomcountChanged();
[96e145]249 emit atomRemoved(_id, this);
[5a9e34]250 emit bondcountChanged();
251 emit boundingboxChanged();
252 emit centerChanged();
253 emit tesselationhullChanged();
[494478]254 break;
255 }
256 case molecule::BoundingBoxChanged:
257 {
258 #ifdef LOG_OBSERVER
259 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that bounding box has changed.";
260 #endif
261 emit tesselationhullChanged();
262 emit boundingboxChanged();
263 break;
264 }
[1b6415a]265 case molecule::FormulaChanged:
266 {
267 emit formulaChanged();
[5a9e34]268 emit nononhydrogenChanged();
[1b6415a]269 break;
270 }
[494478]271 case molecule::IndexChanged:
272 {
273 #ifdef LOG_OBSERVER
274 const atomId_t _id = _molecule->lastChangedAtomId();
275 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+"'s index has changed.";
276 #endif
[1c0961]277 const moleculeId_t newId = getMolIndex();
278 emit indexChanged(oldId, newId);
279 oldId = newId;
[494478]280 break;
281 }
282 case molecule::MoleculeNameChanged:
283 {
284 #ifdef LOG_OBSERVER
285 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that name has changed.";
286 #endif
287 emit nameChanged();
288 break;
289 }
[9e9100]290 case molecule::SelectionChanged:
291 {
292 #ifdef LOG_OBSERVER
293 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that selected has changed.";
294 #endif
295 emit selectedChanged();
296 break;
297 }
[494478]298 default:
299 break;
300 }
301 }
302}
303
304const molecule * const QtObservedMolecule::getMolecule(const moleculeId_t _id)
305{
306 const molecule * const mol = const_cast<const World &>(World::getInstance()).
307 getMolecule(MoleculeById(_id));
308 return mol;
309}
310
311static molecule::BoundingBoxInfo initBoundingBox()
312{
313 molecule::BoundingBoxInfo info;
314 info.position = zeroVec;
315 info.radius = 0.;
316 return info;
317}
318
319void QtObservedMolecule::initObservedValues(
320 ObservedValues_t &_ObservedValues,
321 const moleculeId_t _molid,
322 const molecule * const _molref,
323 const boost::function<void(const moleculeId_t)> &_subjectKilled)
324{
325 /* This is an old note from when the code was still part of cstor's initializer body.
326 * TODO: Probably does not apply anymore but has not yet been tested.
327 *
328 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly
329 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because
330 * the class has not been fully constructed yet. "This" itself seems to be working fine.
331 */
332
333 ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
334 "QtObservedMolecule::initObservedValues() - given ObservedValues has not correct size.");
335
336 // fill ObservedValues: index first
337 const boost::function<moleculeId_t ()> MolIndexUpdater(
[f35f7e]338 boost::bind(&QtObservedMolecule::updateIndex, boost::cref(*_molref)));
[494478]339
340 ObservedValue_wCallback<moleculeId_t> * const IndexObservable =
341 new ObservedValue_wCallback<moleculeId_t>(
342 _molref,
343 MolIndexUpdater,
344 "MoleculeIndex_"+toString(_molid),
345 _molid,
346 IndexChannels,
347 _subjectKilled);
348 _ObservedValues[MolIndex] = IndexObservable;
349
350 const boost::function<const moleculeId_t ()> MolIndexGetter =
351 boost::bind(&ObservedValue_wCallback<moleculeId_t>::get,
352 IndexObservable);
353
354 // fill ObservedValues: then all the other that need index
[1b6415a]355 const boost::function<int ()> AtomCountUpdater(
[f35f7e]356 boost::bind(&QtObservedMolecule::updateAtomCount, boost::cref(*_molref)));
[5a9e34]357 const boost::function<int ()> BondCountUpdater(
[f35f7e]358 boost::bind(&QtObservedMolecule::updateBondCount, boost::cref(*_molref)));
[5a9e34]359 const boost::function<Vector ()> MolCenterUpdater(
[f35f7e]360 boost::bind(&QtObservedMolecule::updateCenter, boost::cref(*_molref)));
[1b6415a]361 const boost::function<std::string ()> MolFormulaUpdater(
[f35f7e]362 boost::bind(&QtObservedMolecule::updateFormulaString, boost::cref(*_molref)));
[494478]363 const boost::function<std::string ()> MolNameUpdater(
[f35f7e]364 boost::bind(&QtObservedMolecule::updateName, boost::cref(*_molref)));
[5a9e34]365 const boost::function<int ()> NonHydrogenCountUpdater(
[f35f7e]366 boost::bind(&QtObservedMolecule::updateNonHydrogenCount, boost::cref(*_molref)));
[494478]367 const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater(
[f35f7e]368 boost::bind(&QtObservedMolecule::updateBoundingBox, boost::cref(*_molref)));
[9e9100]369 const boost::function<bool ()> SelectedUpdater(
[f35f7e]370 boost::bind(&QtObservedMolecule::updateSelected, boost::cref(*_molref)));
[494478]371
[1b6415a]372 _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, moleculeId_t>(
[494478]373 _molref,
[1b6415a]374 AtomCountUpdater,
375 "MoleculeAtomCount_"+toString(_molid),
376 AtomCountUpdater(),
377 AtomCountChannels,
[494478]378 _subjectKilled,
379 MolIndexGetter);
[5a9e34]380 _ObservedValues[BondCount] = new ObservedValue_wCallback<int, moleculeId_t>(
381 _molref,
382 BondCountUpdater,
383 "MoleculeBondCount_"+toString(_molid),
384 BondCountUpdater(),
385 BondCountChannels,
386 _subjectKilled,
387 MolIndexGetter);
[494478]388 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>(
389 _molref,
390 BoundingBoxUpdater,
391 "MoleculeBoundingBox_"+toString(_molid),
392 initBoundingBox(),
393 BoundingBoxChannels,
394 _subjectKilled,
395 MolIndexGetter);
[1b6415a]396 _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, moleculeId_t>(
397 _molref,
398 MolFormulaUpdater,
399 "MoleculeFormula_"+toString(_molid),
400 MolFormulaUpdater(),
401 FormulaStringChannels,
402 _subjectKilled,
403 MolIndexGetter);
[5a9e34]404 _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, moleculeId_t>(
405 _molref,
406 MolCenterUpdater,
407 "MoleculeCenter_"+toString(_molid),
408 MolCenterUpdater(),
409 CenterChannels,
410 _subjectKilled,
411 MolIndexGetter);
[1b6415a]412 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(
413 _molref,
414 MolNameUpdater,
415 "MoleculeName_"+toString(_molid),
416 MolNameUpdater(),
417 NameChannels,
418 _subjectKilled,
419 MolIndexGetter);
[5a9e34]420 _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, moleculeId_t>(
421 _molref,
422 NonHydrogenCountUpdater,
423 "MoleculeNonHydrogenCount_"+toString(_molid),
424 NonHydrogenCountUpdater(),
425 NonHydrogenCountChannels,
426 _subjectKilled,
427 MolIndexGetter);
[9e9100]428 _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, moleculeId_t>(
429 _molref,
430 SelectedUpdater,
431 "MoleculeSelected_"+toString(_molid),
432 SelectedUpdater(),
433 SelectedChannels,
434 _subjectKilled,
435 MolIndexGetter);
[494478]436}
437
438void QtObservedMolecule::destroyObservedValues(
439 std::vector<boost::any> &_ObservedValues)
440{
441 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]);
[1b6415a]442 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]);
[5a9e34]443 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[BondCount]);
[04c3a3]444 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);
[1b6415a]445 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]);
[5a9e34]446 delete boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(_ObservedValues[MolCenter]);
[1b6415a]447 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);
[5a9e34]448 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[NonHydrogenCount]);
[9e9100]449 delete boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(_ObservedValues[MolSelected]);
[494478]450 _ObservedValues.clear();
451}
452
[f35f7e]453#ifdef HAVE_INLINE
454inline
455#endif
456int QtObservedMolecule::updateAtomCount(const molecule &mol)
[1b6415a]457{
[f35f7e]458 return mol.getAtomCount();
[1b6415a]459}
460
[f35f7e]461#ifdef HAVE_INLINE
462inline
463#endif
464int QtObservedMolecule::updateBondCount(const molecule &mol)
[5a9e34]465{
[f35f7e]466 return mol.getBondCount();
[5a9e34]467}
468
[f35f7e]469#ifdef HAVE_INLINE
470inline
471#endif
472molecule::BoundingBoxInfo QtObservedMolecule::updateBoundingBox(const molecule &mol)
[494478]473{
[f35f7e]474 return mol.getBoundingBox();
[494478]475}
476
[f35f7e]477#ifdef HAVE_INLINE
478inline
479#endif
480std::string QtObservedMolecule::updateFormulaString(const molecule &mol)
[1b6415a]481{
[f35f7e]482 return mol.getFormula().toString();
[1b6415a]483}
484
[f35f7e]485#ifdef HAVE_INLINE
486inline
487#endif
488Vector QtObservedMolecule::updateCenter(const molecule &mol)
[5a9e34]489{
[f35f7e]490 return mol.DetermineCenterOfAll();
[5a9e34]491}
492
[f35f7e]493#ifdef HAVE_INLINE
494inline
495#endif
496moleculeId_t QtObservedMolecule::updateIndex(const molecule &mol)
[494478]497{
[f35f7e]498 return mol.getId();
[494478]499}
500
[f35f7e]501#ifdef HAVE_INLINE
502inline
503#endif
504std::string QtObservedMolecule::updateName(const molecule &mol)
[494478]505{
[f35f7e]506 return mol.getName();
[494478]507}
508
[f35f7e]509#ifdef HAVE_INLINE
510inline
511#endif
512int QtObservedMolecule::updateNonHydrogenCount(const molecule &mol)
[5a9e34]513{
[f35f7e]514 return mol.getNoNonHydrogen();
[5a9e34]515}
516
[f35f7e]517#ifdef HAVE_INLINE
518inline
519#endif
520bool QtObservedMolecule::updateSelected(const molecule &mol)
[9e9100]521{
[f35f7e]522 return mol.getSelected();
[9e9100]523}
524
[59eabc]525ObservedValue_Index_t QtObservedMolecule::getIndex() const
526{
527 ASSERT( owner != NULL,
528 "QtObservedMolecule::getIndex() - index is NULL");
529 return owner;
530}
531
[3b9aa1]532const int& QtObservedMolecule::getAtomCount() const
[1b6415a]533{
534 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->get();
535}
536
[3b9aa1]537const int& QtObservedMolecule::getBondCount() const
[5a9e34]538{
539 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->get();
540}
541
[3b9aa1]542const std::string& QtObservedMolecule::getMolFormula() const
[1b6415a]543{
544 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->get();
545}
546
[3b9aa1]547const Vector& QtObservedMolecule::getMolCenter() const
[5a9e34]548{
549 return boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->get();
550}
551
[3b9aa1]552const moleculeId_t& QtObservedMolecule::getMolIndex() const
[494478]553{
554 return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get();
555}
556
[3b9aa1]557const std::string& QtObservedMolecule::getMolName() const
[494478]558{
559 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->get();
560}
561
[3b9aa1]562const int& QtObservedMolecule::getNonHydrogenCount() const
[5a9e34]563{
564 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->get();
565}
566
[3b9aa1]567const molecule::BoundingBoxInfo& QtObservedMolecule::getBoundingBox() const
[494478]568{
569 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get();
570}
[9e9100]571
572const bool& QtObservedMolecule::getMolSelected() const
573{
574 return boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->get();
575}
Note: See TracBrowser for help on using the repository browser.