source: src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp@ 62a0ee

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

QtObserved... now count the subjectKilled() from the containes values.

  • Property mode set to 100644
File size: 19.7 KB
Line 
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
38#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
39
40#include "CodePatterns/MemDebug.hpp"
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,
61 molecule::AtomMoved,
62 molecule::AtomRemoved,
63 molecule::FormulaChanged,
64 molecule::IndexChanged,
65 molecule::MoleculeNameChanged,
66 molecule::BoundingBoxChanged,
67 molecule::SelectionChanged;
68 return channels;
69}
70
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
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
90// static instances
91const Observable::channels_t QtObservedMolecule::AtomCountChannels(getAllAtomCountChannels());
92const Observable::channels_t QtObservedMolecule::BondCountChannels(getAllAtomCountChannels());
93const Observable::channels_t QtObservedMolecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged);
94const Observable::channels_t QtObservedMolecule::FormulaStringChannels(1, molecule::FormulaChanged);
95const Observable::channels_t QtObservedMolecule::CenterChannels(getAllCenterChannels());
96const Observable::channels_t QtObservedMolecule::IndexChannels(1, molecule::IndexChanged);
97const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged);
98const Observable::channels_t QtObservedMolecule::NonHydrogenCountChannels(1, molecule::FormulaChanged);
99const Observable::channels_t QtObservedMolecule::SelectedChannels(1, molecule::SelectionChanged);
100
101QtObservedMolecule::QtObservedMolecule(
102 const moleculeId_t _id,
103 const molecule * const _mol,
104 QtObservedInstanceBoard &_board,
105 QWidget * _parent) :
106 QWidget(_parent),
107 Observer("QtObservedMolecule"),
108 subjectKilledCount(0),
109 AllsignedOnChannels(getAllObservedChannels().size()),
110 signedOffChannels(0),
111 owner(NULL),
112 board(_board),
113 BoardIsGone(false),
114 ObservedValues(QtObservedMolecule::MAX_ObservedTypes)
115{
116 boost::function<void (const atomId_t)> moleculeSubjectKilled(
117 boost::bind(&QtObservedMolecule::countValuesSubjectKilled,
118 boost::ref(*this),
119 _1));
120 initObservedValues(ObservedValues, _id, _mol, moleculeSubjectKilled);
121
122 // activating Observer is done by ObservedValueContainer when it's prepared
123}
124
125QtObservedMolecule::~QtObservedMolecule()
126{
127 boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->noteCallBackIsGone();
128 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->noteCallBackIsGone();
129 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->noteCallBackIsGone();
130 boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->noteCallBackIsGone();
131 boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->noteCallBackIsGone();
132 boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->noteCallBackIsGone();
133 boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->noteCallBackIsGone();
134 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->noteCallBackIsGone();
135 boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->noteCallBackIsGone();
136
137 deactivateObserver();
138}
139
140void QtObservedMolecule::deactivateObserver()
141{
142 if (owner != NULL) {
143 Observable::channels_t channels = getAllObservedChannels();
144 for (Observable::channels_t::const_iterator iter = channels.begin();
145 iter != channels.end(); ++iter)
146 owner->signOff(this, *iter);
147 owner = NULL;
148 signedOffChannels = AllsignedOnChannels;
149 if (!BoardIsGone)
150 board.markObservedMoleculeAsDisconnected(getMolIndex());
151 }
152}
153
154void QtObservedMolecule::activateObserver()
155{
156 // sign on as observer (obtain non-const instance before)
157 const molecule * const _molecule = getMolecule(getMolIndex());
158 if (_molecule != NULL) {
159 Observable::channels_t channels = getAllObservedChannels();
160 owner = static_cast<const Observable *>(_molecule);
161 for (Observable::channels_t::const_iterator iter = channels.begin();
162 iter != channels.end(); ++iter)
163 owner->signOn(this, *iter);
164 if (!BoardIsGone)
165 board.markObservedMoleculeAsConnected(getMolIndex());
166 } else
167 signedOffChannels = AllsignedOnChannels;
168}
169
170void QtObservedMolecule::update(Observable *publisher)
171{
172 ASSERT(0,
173 "QtObservedMolecule::update() - general update from unexpected source.");
174}
175
176void QtObservedMolecule::subjectKilled(Observable *publisher)
177{
178 ++signedOffChannels;
179
180 checkForRemoval();
181}
182
183void QtObservedMolecule::countValuesSubjectKilled(const moleculeId_t _id)
184{
185 ASSERT( _id == getMolIndex(),
186 "QtObservedAtom::countValuesSubjectKilled() - molecule "+toString(getMolIndex())
187 +" received countValuesSubjectKilled for molecule id "+toString(_id)+".");
188
189 ++subjectKilledCount;
190
191 checkForRemoval();
192}
193
194void QtObservedMolecule::checkForRemoval()
195{
196 if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) {
197 // remove owner: no more signOff needed
198 owner = NULL;
199
200 emit moleculeRemoved();
201
202 if (!BoardIsGone) {
203 board.markObservedMoleculeAsDisconnected(getMolIndex());
204 board.markObservedMoleculeForErase(getMolIndex());
205 }
206 }
207}
208
209void QtObservedMolecule::recieveNotification(Observable *publisher, Notification_ptr notification)
210{
211 const molecule * const _molecule = getMolecule(getMolIndex());
212 // when molecule is NULL we will soon get destroyed anyway
213 if (_molecule == NULL)
214 return;
215 if (publisher == dynamic_cast<const Observable*>(_molecule)){
216 // notification from atom
217#ifdef LOG_OBSERVER
218 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))
219 << " received notification from molecule " << getMolIndex() << " for channel "
220 << notification->getChannelNo() << ".";
221#endif
222 switch (notification->getChannelNo()) {
223 case molecule::AtomInserted:
224 {
225 const atomId_t _id = _molecule->lastChangedAtomId();
226 QtObservedAtom::ptr _atom = board.getObservedAtom(_id);
227 emit atomcountChanged();
228 emit atomInserted(_atom);
229 emit bondcountChanged();
230 emit boundingboxChanged();
231 emit centerChanged();
232 emit tesselationhullChanged();
233 break;
234 }
235 case molecule::AtomMoved:
236 {
237 emit boundingboxChanged();
238 emit centerChanged();
239 emit tesselationhullChanged();
240 break;
241 }
242 case molecule::AtomRemoved:
243 {
244 const atomId_t _id = _molecule->lastChangedAtomId();
245 emit atomcountChanged();
246 emit atomRemoved(_id);
247 emit bondcountChanged();
248 emit boundingboxChanged();
249 emit centerChanged();
250 emit tesselationhullChanged();
251 break;
252 }
253 case molecule::BoundingBoxChanged:
254 {
255 #ifdef LOG_OBSERVER
256 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that bounding box has changed.";
257 #endif
258 emit tesselationhullChanged();
259 emit boundingboxChanged();
260 break;
261 }
262 case molecule::FormulaChanged:
263 {
264 emit formulaChanged();
265 emit nononhydrogenChanged();
266 break;
267 }
268 case molecule::IndexChanged:
269 {
270 #ifdef LOG_OBSERVER
271 const atomId_t _id = _molecule->lastChangedAtomId();
272 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+"'s index has changed.";
273 #endif
274 emit indexChanged();
275 break;
276 }
277 case molecule::MoleculeNameChanged:
278 {
279 #ifdef LOG_OBSERVER
280 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that name has changed.";
281 #endif
282 emit nameChanged();
283 break;
284 }
285 case molecule::SelectionChanged:
286 {
287 #ifdef LOG_OBSERVER
288 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that selected has changed.";
289 #endif
290 emit selectedChanged();
291 break;
292 }
293 default:
294 break;
295 }
296 }
297}
298
299const molecule * const QtObservedMolecule::getMolecule(const moleculeId_t _id)
300{
301 const molecule * const mol = const_cast<const World &>(World::getInstance()).
302 getMolecule(MoleculeById(_id));
303 return mol;
304}
305
306static molecule::BoundingBoxInfo initBoundingBox()
307{
308 molecule::BoundingBoxInfo info;
309 info.position = zeroVec;
310 info.radius = 0.;
311 return info;
312}
313
314void QtObservedMolecule::initObservedValues(
315 ObservedValues_t &_ObservedValues,
316 const moleculeId_t _molid,
317 const molecule * const _molref,
318 const boost::function<void(const moleculeId_t)> &_subjectKilled)
319{
320 /* This is an old note from when the code was still part of cstor's initializer body.
321 * TODO: Probably does not apply anymore but has not yet been tested.
322 *
323 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly
324 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because
325 * the class has not been fully constructed yet. "This" itself seems to be working fine.
326 */
327
328 ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
329 "QtObservedMolecule::initObservedValues() - given ObservedValues has not correct size.");
330
331 // fill ObservedValues: index first
332 const boost::function<moleculeId_t ()> MolIndexUpdater(
333 boost::bind(&QtObservedMolecule::updateIndex));
334
335 ObservedValue_wCallback<moleculeId_t> * const IndexObservable =
336 new ObservedValue_wCallback<moleculeId_t>(
337 _molref,
338 MolIndexUpdater,
339 "MoleculeIndex_"+toString(_molid),
340 _molid,
341 IndexChannels,
342 _subjectKilled);
343 _ObservedValues[MolIndex] = IndexObservable;
344
345 const boost::function<const moleculeId_t ()> MolIndexGetter =
346 boost::bind(&ObservedValue_wCallback<moleculeId_t>::get,
347 IndexObservable);
348
349 // fill ObservedValues: then all the other that need index
350 const boost::function<int ()> AtomCountUpdater(
351 boost::bind(&QtObservedMolecule::updateAtomCount, MolIndexGetter));
352 const boost::function<int ()> BondCountUpdater(
353 boost::bind(&QtObservedMolecule::updateBondCount, MolIndexGetter));
354 const boost::function<Vector ()> MolCenterUpdater(
355 boost::bind(&QtObservedMolecule::updateCenter, MolIndexGetter));
356 const boost::function<std::string ()> MolFormulaUpdater(
357 boost::bind(&QtObservedMolecule::updateFormulaString, MolIndexGetter));
358 const boost::function<std::string ()> MolNameUpdater(
359 boost::bind(&QtObservedMolecule::updateName, MolIndexGetter));
360 const boost::function<int ()> NonHydrogenCountUpdater(
361 boost::bind(&QtObservedMolecule::updateNonHydrogenCount, MolIndexGetter));
362 const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater(
363 boost::bind(&QtObservedMolecule::updateBoundingBox, MolIndexGetter));
364 const boost::function<bool ()> SelectedUpdater(
365 boost::bind(&QtObservedMolecule::updateSelected, MolIndexGetter));
366
367 _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, moleculeId_t>(
368 _molref,
369 AtomCountUpdater,
370 "MoleculeAtomCount_"+toString(_molid),
371 AtomCountUpdater(),
372 AtomCountChannels,
373 _subjectKilled,
374 MolIndexGetter);
375 _ObservedValues[BondCount] = new ObservedValue_wCallback<int, moleculeId_t>(
376 _molref,
377 BondCountUpdater,
378 "MoleculeBondCount_"+toString(_molid),
379 BondCountUpdater(),
380 BondCountChannels,
381 _subjectKilled,
382 MolIndexGetter);
383 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>(
384 _molref,
385 BoundingBoxUpdater,
386 "MoleculeBoundingBox_"+toString(_molid),
387 initBoundingBox(),
388 BoundingBoxChannels,
389 _subjectKilled,
390 MolIndexGetter);
391 _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, moleculeId_t>(
392 _molref,
393 MolFormulaUpdater,
394 "MoleculeFormula_"+toString(_molid),
395 MolFormulaUpdater(),
396 FormulaStringChannels,
397 _subjectKilled,
398 MolIndexGetter);
399 _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, moleculeId_t>(
400 _molref,
401 MolCenterUpdater,
402 "MoleculeCenter_"+toString(_molid),
403 MolCenterUpdater(),
404 CenterChannels,
405 _subjectKilled,
406 MolIndexGetter);
407 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(
408 _molref,
409 MolNameUpdater,
410 "MoleculeName_"+toString(_molid),
411 MolNameUpdater(),
412 NameChannels,
413 _subjectKilled,
414 MolIndexGetter);
415 _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, moleculeId_t>(
416 _molref,
417 NonHydrogenCountUpdater,
418 "MoleculeNonHydrogenCount_"+toString(_molid),
419 NonHydrogenCountUpdater(),
420 NonHydrogenCountChannels,
421 _subjectKilled,
422 MolIndexGetter);
423 _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, moleculeId_t>(
424 _molref,
425 SelectedUpdater,
426 "MoleculeSelected_"+toString(_molid),
427 SelectedUpdater(),
428 SelectedChannels,
429 _subjectKilled,
430 MolIndexGetter);
431}
432
433void QtObservedMolecule::destroyObservedValues(
434 std::vector<boost::any> &_ObservedValues)
435{
436 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]);
437 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]);
438 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[BondCount]);
439 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);
440 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]);
441 delete boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(_ObservedValues[MolCenter]);
442 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);
443 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[NonHydrogenCount]);
444 delete boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(_ObservedValues[MolSelected]);
445 _ObservedValues.clear();
446}
447
448int QtObservedMolecule::updateAtomCount(
449 const boost::function<const moleculeId_t ()> &_getMolIndex)
450{
451 const molecule * const mol = getMolecule(_getMolIndex());
452 if (mol != NULL)
453 return mol->getAtomCount();
454 else
455 return (int)0;
456}
457
458int QtObservedMolecule::updateBondCount(
459 const boost::function<const moleculeId_t ()> &_getMolIndex)
460{
461 const molecule * const mol = getMolecule(_getMolIndex());
462 if (mol != NULL)
463 return mol->getBondCount();
464 else
465 return (int)0;
466}
467
468molecule::BoundingBoxInfo QtObservedMolecule::updateBoundingBox(
469 const boost::function<const moleculeId_t ()> &_getMolIndex)
470{
471 const molecule * const mol = getMolecule(_getMolIndex());
472 if (mol != NULL)
473 return mol->getBoundingBox();
474 else
475 return molecule::BoundingBoxInfo();
476}
477
478std::string QtObservedMolecule::updateFormulaString(
479 const boost::function<const moleculeId_t ()> &_getMolIndex)
480{
481 const molecule * const mol = getMolecule(_getMolIndex());
482 if (mol != NULL)
483 return mol->getFormula().toString();
484 else
485 return std::string("");
486}
487
488Vector QtObservedMolecule::updateCenter(
489 const boost::function<const moleculeId_t ()> &_getMolIndex)
490{
491 const molecule * const mol = getMolecule(_getMolIndex());
492 if (mol != NULL)
493 return mol->DetermineCenterOfAll();
494 else
495 return zeroVec;
496}
497
498moleculeId_t QtObservedMolecule::updateIndex()
499{
500 return const_cast<const World &>(World::getInstance()).lastChangedMolId();
501}
502
503std::string QtObservedMolecule::updateName(
504 const boost::function<const moleculeId_t ()> &_getMolIndex)
505{
506 const molecule * const mol = getMolecule(_getMolIndex());
507 if (mol != NULL)
508 return mol->getName();
509 else
510 return std::string("");
511}
512
513int QtObservedMolecule::updateNonHydrogenCount(
514 const boost::function<const moleculeId_t ()> &_getMolIndex)
515{
516 const molecule * const mol = getMolecule(_getMolIndex());
517 if (mol != NULL)
518 return mol->getNoNonHydrogen();
519 else
520 return (int)0;
521}
522
523bool QtObservedMolecule::updateSelected(
524 const boost::function<const moleculeId_t ()> &_getMolIndex)
525{
526 const molecule * const mol = getMolecule(_getMolIndex());
527 if (mol != NULL)
528 return mol->getSelected();
529 else
530 return false;
531}
532
533const int& QtObservedMolecule::getAtomCount() const
534{
535 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->get();
536}
537
538const int& QtObservedMolecule::getBondCount() const
539{
540 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->get();
541}
542
543const std::string& QtObservedMolecule::getMolFormula() const
544{
545 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->get();
546}
547
548const Vector& QtObservedMolecule::getMolCenter() const
549{
550 return boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->get();
551}
552
553const moleculeId_t& QtObservedMolecule::getMolIndex() const
554{
555 return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get();
556}
557
558const std::string& QtObservedMolecule::getMolName() const
559{
560 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->get();
561}
562
563const int& QtObservedMolecule::getNonHydrogenCount() const
564{
565 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->get();
566}
567
568const molecule::BoundingBoxInfo& QtObservedMolecule::getBoundingBox() const
569{
570 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get();
571}
572
573const bool& QtObservedMolecule::getMolSelected() const
574{
575 return boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->get();
576}
Note: See TracBrowser for help on using the repository browser.