| 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 | * QtObservedAtom.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 "QtObservedAtom.hpp"
|
|---|
| 37 |
|
|---|
| 38 | #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
|
|---|
| 39 |
|
|---|
| 40 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 41 |
|
|---|
| 42 | #include <boost/assign.hpp>
|
|---|
| 43 |
|
|---|
| 44 | #include "Atom/atom.hpp"
|
|---|
| 45 | #include "Bond/bond.hpp"
|
|---|
| 46 | #include "Descriptors/AtomIdDescriptor.hpp"
|
|---|
| 47 | #include "Element/element.hpp"
|
|---|
| 48 | #include "World.hpp"
|
|---|
| 49 |
|
|---|
| 50 | #include "UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp"
|
|---|
| 51 |
|
|---|
| 52 | using namespace boost::assign;
|
|---|
| 53 |
|
|---|
| 54 | static const Observable::channels_t getAtomBondsChannels()
|
|---|
| 55 | {
|
|---|
| 56 | Observable::channels_t channels;
|
|---|
| 57 | channels += AtomObservable::BondsAdded, AtomObservable::BondsRemoved;
|
|---|
| 58 | return channels;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | static const Observable::channels_t getAllObservedChannels()
|
|---|
| 62 | {
|
|---|
| 63 | Observable::channels_t channels;
|
|---|
| 64 | channels +=
|
|---|
| 65 | AtomObservable::IndexChanged,
|
|---|
| 66 | AtomObservable::BondsAdded,
|
|---|
| 67 | AtomObservable::BondsRemoved,
|
|---|
| 68 | AtomObservable::MoleculeChanged,
|
|---|
| 69 | AtomObservable::NameChanged,
|
|---|
| 70 | AtomObservable::ElementChanged,
|
|---|
| 71 | AtomObservable::PositionChanged,
|
|---|
| 72 | AtomObservable::SelectionChanged;
|
|---|
| 73 | return channels;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | // static entities
|
|---|
| 77 | const Observable::channels_t
|
|---|
| 78 | QtObservedAtom::AtomIndexChannels(1, AtomObservable::IndexChanged);
|
|---|
| 79 | const Observable::channels_t
|
|---|
| 80 | QtObservedAtom::AtomBondsChannels(getAtomBondsChannels());
|
|---|
| 81 | const Observable::channels_t
|
|---|
| 82 | QtObservedAtom::AtomElementChannels(1, AtomObservable::ElementChanged);
|
|---|
| 83 | const Observable::channels_t
|
|---|
| 84 | QtObservedAtom::MoleculeChangedChannels(1, AtomObservable::MoleculeChanged);
|
|---|
| 85 | const Observable::channels_t
|
|---|
| 86 | QtObservedAtom::AtomNameChannels(1, AtomObservable::NameChanged);
|
|---|
| 87 | const Observable::channels_t
|
|---|
| 88 | QtObservedAtom::AtomPositionChannels(1, AtomObservable::PositionChanged);
|
|---|
| 89 | const Observable::channels_t
|
|---|
| 90 | QtObservedAtom::AtomSelectedChannels(1, AtomObservable::SelectionChanged);
|
|---|
| 91 |
|
|---|
| 92 | QtObservedAtom::QtObservedAtom(
|
|---|
| 93 | const atomId_t _id,
|
|---|
| 94 | const atom * const _atom,
|
|---|
| 95 | QtObservedInstanceBoard &_board,
|
|---|
| 96 | QWidget * _parent) :
|
|---|
| 97 | QWidget(_parent),
|
|---|
| 98 | Observer("QtObservedAtom"),
|
|---|
| 99 | subjectKilledCount(0),
|
|---|
| 100 | AllsignedOnChannels(getAllObservedChannels().size()),
|
|---|
| 101 | signedOffChannels(0),
|
|---|
| 102 | owner(NULL),
|
|---|
| 103 | index(static_cast<const ObservedValue_Index_t>(const_cast<const QtObservedAtom * const>(this))),
|
|---|
| 104 | board(_board),
|
|---|
| 105 | BoardIsGone(false),
|
|---|
| 106 | ObservedValues(QtObservedAtom::MAX_ObservedTypes)
|
|---|
| 107 | {
|
|---|
| 108 | boost::function<void ()> atomSubjectKilled(
|
|---|
| 109 | boost::bind(&QtObservedAtom::countValuesSubjectKilled,
|
|---|
| 110 | boost::ref(*this),
|
|---|
| 111 | boost::bind(&QtObservedAtom::getIndex, boost::ref(*this))));
|
|---|
| 112 | initObservedValues( ObservedValues, _id, _atom, atomSubjectKilled);
|
|---|
| 113 |
|
|---|
| 114 | // activating Observer is done by ObservedValueContainer when it's inserted
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | QtObservedAtom::~QtObservedAtom()
|
|---|
| 118 | {
|
|---|
| 119 | boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(ObservedValues[AtomIndex])->noteCallBackIsGone();
|
|---|
| 120 | boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(ObservedValues[AtomBonds])->noteCallBackIsGone();
|
|---|
| 121 | boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(ObservedValues[AtomElement])->noteCallBackIsGone();
|
|---|
| 122 | boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(ObservedValues[MoleculeRef])->noteCallBackIsGone();
|
|---|
| 123 | boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->noteCallBackIsGone();
|
|---|
| 124 | boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone();
|
|---|
| 125 | boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone();
|
|---|
| 126 |
|
|---|
| 127 | deactivateObserver();
|
|---|
| 128 |
|
|---|
| 129 | destroyObservedValues(ObservedValues);
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | const atom * const QtObservedAtom::getAtomConst(const atomId_t _id)
|
|---|
| 133 | {
|
|---|
| 134 | const atom * const _atom = const_cast<const World &>(World::getInstance()).
|
|---|
| 135 | getAtom(AtomById(_id));
|
|---|
| 136 | return _atom;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | atom * const QtObservedAtom::getAtom(const atomId_t _id)
|
|---|
| 140 | {
|
|---|
| 141 | atom * const _atom = World::getInstance().getAtom(AtomById(_id));
|
|---|
| 142 | return _atom;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | #ifdef HAVE_INLINE
|
|---|
| 146 | inline
|
|---|
| 147 | #endif
|
|---|
| 148 | atomId_t QtObservedAtom::updateIndex(const atom &_atomref)
|
|---|
| 149 | {
|
|---|
| 150 | return _atomref.getId();
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | QtObservedAtom::ListOfBonds_t QtObservedAtom::updateBonds(
|
|---|
| 154 | const atom &_atom)
|
|---|
| 155 | {
|
|---|
| 156 | ListOfBonds_t ListOfBonds;
|
|---|
| 157 | // make sure bonds is up-to-date
|
|---|
| 158 | const BondList ListBonds = _atom.getListOfBonds();
|
|---|
| 159 | for (BondList::const_iterator iter = ListBonds.begin();
|
|---|
| 160 | iter != ListBonds.end();
|
|---|
| 161 | ++iter)
|
|---|
| 162 | ListOfBonds.insert( ListOfBonds.end(), std::make_pair(
|
|---|
| 163 | (*iter)->leftatom->getId(),
|
|---|
| 164 | (*iter)->rightatom->getId()) );
|
|---|
| 165 | return ListOfBonds;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | #ifdef HAVE_INLINE
|
|---|
| 169 | inline
|
|---|
| 170 | #endif
|
|---|
| 171 | atomicNumber_t QtObservedAtom::updateElement(
|
|---|
| 172 | const atom &_atom)
|
|---|
| 173 | {
|
|---|
| 174 | return _atom.getElementNo();
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | #ifdef HAVE_INLINE
|
|---|
| 178 | inline
|
|---|
| 179 | #endif
|
|---|
| 180 | QtObservedMolecule* QtObservedAtom::updateMoleculeRef(
|
|---|
| 181 | const atom &_atom)
|
|---|
| 182 | {
|
|---|
| 183 | if (_atom.getMolecule() != NULL) {
|
|---|
| 184 | const moleculeId_t molid = _atom.getMolecule()->getId();
|
|---|
| 185 | const QtObservedMolecule::ptr mol = board.getObservedMolecule(molid);
|
|---|
| 186 | ASSERT(mol,
|
|---|
| 187 | "QtObservedAtom::updateMoleculeRef() - could not update the ref, "
|
|---|
| 188 | +toString(molid)+" unknown to Instance board?");
|
|---|
| 189 | return mol.get();
|
|---|
| 190 | } else {
|
|---|
| 191 | return (QtObservedMolecule*)NULL;
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | #ifdef HAVE_INLINE
|
|---|
| 196 | inline
|
|---|
| 197 | #endif
|
|---|
| 198 | std::string QtObservedAtom::updateName(
|
|---|
| 199 | const atom &_atom)
|
|---|
| 200 | {
|
|---|
| 201 | return _atom.getName();
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | #ifdef HAVE_INLINE
|
|---|
| 205 | inline
|
|---|
| 206 | #endif
|
|---|
| 207 | Vector QtObservedAtom::updatePosition(
|
|---|
| 208 | const atom &_atom)
|
|---|
| 209 | {
|
|---|
| 210 | return _atom.getPosition();
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | #ifdef HAVE_INLINE
|
|---|
| 214 | inline
|
|---|
| 215 | #endif
|
|---|
| 216 | bool QtObservedAtom::updateSelected(
|
|---|
| 217 | const atom &_atom)
|
|---|
| 218 | {
|
|---|
| 219 | return _atom.getSelected();
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | void QtObservedAtom::update(Observable *publisher)
|
|---|
| 223 | {
|
|---|
| 224 | ASSERT(0, "QtObservedAtom::update() - we are not signed on for global updates.");
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | void QtObservedAtom::subjectKilled(Observable *publisher)
|
|---|
| 228 | {
|
|---|
| 229 | ++signedOffChannels;
|
|---|
| 230 |
|
|---|
| 231 | checkForRemoval(getIndex());
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | void QtObservedAtom::countValuesSubjectKilled(ObservedValue_Index_t _id)
|
|---|
| 235 | {
|
|---|
| 236 | ASSERT( _id == getIndex(),
|
|---|
| 237 | "QtObservedAtom::countValuesSubjectKilled() - atom "+toString(getIndex())
|
|---|
| 238 | +" received countValuesSubjectKilled for atom id "+toString(_id)+".");
|
|---|
| 239 |
|
|---|
| 240 | ++subjectKilledCount;
|
|---|
| 241 |
|
|---|
| 242 | checkForRemoval(_id);
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | #ifdef HAVE_INLINE
|
|---|
| 246 | inline
|
|---|
| 247 | #endif
|
|---|
| 248 | void QtObservedAtom::checkForRemoval(ObservedValue_Index_t _id)
|
|---|
| 249 | {
|
|---|
| 250 | if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) {
|
|---|
| 251 | // remove owner: no more signOff needed
|
|---|
| 252 | owner = NULL;
|
|---|
| 253 |
|
|---|
| 254 | emit atomRemoved();
|
|---|
| 255 |
|
|---|
| 256 | if (!BoardIsGone) {
|
|---|
| 257 | board.markObservedAtomAsDisconnected(_id);
|
|---|
| 258 | board.markObservedAtomForErase(_id);
|
|---|
| 259 | }
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | void QtObservedAtom::recieveNotification(Observable *publisher, Notification_ptr notification)
|
|---|
| 264 | {
|
|---|
| 265 | // ObservedValues have been updated before, hence convert updates to Qt's signals
|
|---|
| 266 | switch (notification->getChannelNo()) {
|
|---|
| 267 | case AtomObservable::IndexChanged:
|
|---|
| 268 | {
|
|---|
| 269 | emit indexChanged();
|
|---|
| 270 | break;
|
|---|
| 271 | }
|
|---|
| 272 | case AtomObservable::BondsAdded:
|
|---|
| 273 | case AtomObservable::BondsRemoved:
|
|---|
| 274 | emit bondsChanged();
|
|---|
| 275 | break;
|
|---|
| 276 | case AtomObservable::ElementChanged:
|
|---|
| 277 | emit elementChanged();
|
|---|
| 278 | break;
|
|---|
| 279 | case AtomObservable::MoleculeChanged:
|
|---|
| 280 | emit moleculeChanged();
|
|---|
| 281 | break;
|
|---|
| 282 | case AtomObservable::NameChanged:
|
|---|
| 283 | emit nameChanged();
|
|---|
| 284 | break;
|
|---|
| 285 | case AtomObservable::PositionChanged:
|
|---|
| 286 | emit positionChanged();
|
|---|
| 287 | break;
|
|---|
| 288 | case AtomObservable::SelectionChanged:
|
|---|
| 289 | emit selectedChanged();
|
|---|
| 290 | break;
|
|---|
| 291 | default:
|
|---|
| 292 | ASSERT(0, "QtObservedAtom::recieveNotification() - we are not signed on to channel "
|
|---|
| 293 | +toString(notification->getChannelNo())+" of the atom.");
|
|---|
| 294 | break;
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | void QtObservedAtom::activateObserver()
|
|---|
| 299 | {
|
|---|
| 300 | atom * atomref = getAtom(getAtomIndex());
|
|---|
| 301 | if (atomref != NULL) {
|
|---|
| 302 | Observable::channels_t channels = getAllObservedChannels();
|
|---|
| 303 | owner = static_cast<const Observable *>(atomref);
|
|---|
| 304 | for (Observable::channels_t::const_iterator iter = channels.begin();
|
|---|
| 305 | iter != channels.end(); ++iter)
|
|---|
| 306 | owner->signOn(this, *iter);
|
|---|
| 307 | if (!BoardIsGone)
|
|---|
| 308 | board.markObservedAtomAsConnected(getIndex());
|
|---|
| 309 | } else
|
|---|
| 310 | signedOffChannels = AllsignedOnChannels;
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | void QtObservedAtom::deactivateObserver()
|
|---|
| 314 | {
|
|---|
| 315 | // sign Off
|
|---|
| 316 | if (owner != NULL) {
|
|---|
| 317 | Observable::channels_t channels = getAllObservedChannels();
|
|---|
| 318 | for (Observable::channels_t::const_iterator iter = channels.begin();
|
|---|
| 319 | iter != channels.end(); ++iter)
|
|---|
| 320 | owner->signOff(this, *iter);
|
|---|
| 321 | owner = NULL;
|
|---|
| 322 | signedOffChannels = AllsignedOnChannels;
|
|---|
| 323 | if (!BoardIsGone)
|
|---|
| 324 | board.markObservedAtomAsDisconnected(getIndex());
|
|---|
| 325 | }
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | void QtObservedAtom::initObservedValues(
|
|---|
| 329 | ObservedValues_t &_ObservedValues,
|
|---|
| 330 | const atomId_t _id,
|
|---|
| 331 | const atom * const _atomref,
|
|---|
| 332 | const boost::function<void()> &_subjectKilled)
|
|---|
| 333 | {
|
|---|
| 334 | ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
|
|---|
| 335 | "QtObservedAtom::initObservedValues() - given ObservedValues has not correct size.");
|
|---|
| 336 |
|
|---|
| 337 | // fill ObservedValues: then all the other that need index
|
|---|
| 338 | const boost::function<atomId_t ()> AtomIndexUpdater(
|
|---|
| 339 | boost::bind(&QtObservedAtom::updateIndex, boost::cref(*_atomref)));
|
|---|
| 340 | const boost::function<ListOfBonds_t ()> AtomBondsUpdater(
|
|---|
| 341 | boost::bind(&QtObservedAtom::updateBonds, boost::cref(*_atomref)));
|
|---|
| 342 | const boost::function<atomicNumber_t ()> AtomElementUpdater(
|
|---|
| 343 | boost::bind(&QtObservedAtom::updateElement, boost::cref(*_atomref)));
|
|---|
| 344 | const boost::function<std::string ()> AtomNameUpdater(
|
|---|
| 345 | boost::bind(&QtObservedAtom::updateName, boost::cref(*_atomref)));
|
|---|
| 346 | const boost::function<Vector ()> AtomPositionUpdater(
|
|---|
| 347 | boost::bind(&QtObservedAtom::updatePosition, boost::cref(*_atomref)));
|
|---|
| 348 | const boost::function<bool ()> AtomSelectedUpdater(
|
|---|
| 349 | boost::bind(&QtObservedAtom::updateSelected, boost::cref(*_atomref)));
|
|---|
| 350 | const boost::function<QtObservedMolecule* ()> MoleculeRefUpdater(
|
|---|
| 351 | boost::bind(&QtObservedAtom::updateMoleculeRef, this, boost::cref(*_atomref)));
|
|---|
| 352 |
|
|---|
| 353 | _ObservedValues[AtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>(
|
|---|
| 354 | _atomref,
|
|---|
| 355 | AtomIndexUpdater,
|
|---|
| 356 | "AtomIndex_"+toString(_id),
|
|---|
| 357 | _id,
|
|---|
| 358 | AtomIndexChannels,
|
|---|
| 359 | _subjectKilled);
|
|---|
| 360 | _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t>(
|
|---|
| 361 | _atomref,
|
|---|
| 362 | AtomBondsUpdater,
|
|---|
| 363 | "AtomBonds_"+toString(_id),
|
|---|
| 364 | AtomBondsUpdater(),
|
|---|
| 365 | AtomBondsChannels,
|
|---|
| 366 | _subjectKilled);
|
|---|
| 367 | _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>(
|
|---|
| 368 | _atomref,
|
|---|
| 369 | AtomElementUpdater,
|
|---|
| 370 | "AtomElement"+toString(_id),
|
|---|
| 371 | AtomElementUpdater(),
|
|---|
| 372 | AtomElementChannels,
|
|---|
| 373 | _subjectKilled);
|
|---|
| 374 | _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
|
|---|
| 375 | _atomref,
|
|---|
| 376 | AtomNameUpdater,
|
|---|
| 377 | "AtomName"+toString(_id),
|
|---|
| 378 | AtomNameUpdater(),
|
|---|
| 379 | AtomNameChannels,
|
|---|
| 380 | _subjectKilled);
|
|---|
| 381 | _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
|
|---|
| 382 | _atomref,
|
|---|
| 383 | AtomPositionUpdater,
|
|---|
| 384 | "AtomPosition_"+toString(_id),
|
|---|
| 385 | AtomPositionUpdater(),
|
|---|
| 386 | AtomPositionChannels,
|
|---|
| 387 | _subjectKilled);
|
|---|
| 388 | _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>(
|
|---|
| 389 | _atomref,
|
|---|
| 390 | AtomSelectedUpdater,
|
|---|
| 391 | "AtomSelected_"+toString(_id),
|
|---|
| 392 | AtomSelectedUpdater(),
|
|---|
| 393 | AtomSelectedChannels,
|
|---|
| 394 | _subjectKilled);
|
|---|
| 395 | _ObservedValues[MoleculeRef] = new ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t>(
|
|---|
| 396 | _atomref,
|
|---|
| 397 | MoleculeRefUpdater,
|
|---|
| 398 | "AtomMoleculeIndex"+toString(_id),
|
|---|
| 399 | MoleculeRefUpdater(),
|
|---|
| 400 | MoleculeChangedChannels,
|
|---|
| 401 | _subjectKilled);
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | void QtObservedAtom::destroyObservedValues(
|
|---|
| 405 | std::vector<boost::any> &_ObservedValues)
|
|---|
| 406 | {
|
|---|
| 407 | delete boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(_ObservedValues[AtomIndex]);
|
|---|
| 408 | delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(_ObservedValues[AtomBonds]);
|
|---|
| 409 | delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(_ObservedValues[AtomElement]);
|
|---|
| 410 | delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[AtomName]);
|
|---|
| 411 | delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[AtomPosition]);
|
|---|
| 412 | delete boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(_ObservedValues[AtomSelected]);
|
|---|
| 413 | delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(_ObservedValues[MoleculeRef]);
|
|---|
| 414 | _ObservedValues.clear();
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | ObservedValue_Index_t QtObservedAtom::getIndex() const
|
|---|
| 418 | {
|
|---|
| 419 | ASSERT( index != NULL,
|
|---|
| 420 | "QtObservedAtom::getIndex() - index is NULL");
|
|---|
| 421 | return index;
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | const atomId_t& QtObservedAtom::getAtomIndex() const
|
|---|
| 425 | {
|
|---|
| 426 | return boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(ObservedValues[AtomIndex])->get();
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | const QtObservedAtom::ListOfBonds_t& QtObservedAtom::getAtomBonds() const
|
|---|
| 430 | {
|
|---|
| 431 | return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(ObservedValues[AtomBonds])->get();
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | const atomicNumber_t& QtObservedAtom::getAtomElement() const
|
|---|
| 435 | {
|
|---|
| 436 | return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(ObservedValues[AtomElement])->get();
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| 439 | const std::string& QtObservedAtom::getAtomName() const
|
|---|
| 440 | {
|
|---|
| 441 | return boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->get();
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 | const Vector& QtObservedAtom::getAtomPosition() const
|
|---|
| 445 | {
|
|---|
| 446 | return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->get();
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | const bool QtObservedAtom::getAtomSelected() const
|
|---|
| 450 | {
|
|---|
| 451 | return boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->get();
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | const QtObservedMolecule* const QtObservedAtom::getMoleculeRef() const
|
|---|
| 455 | {
|
|---|
| 456 | return boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(ObservedValues[MoleculeRef])->get();
|
|---|
| 457 | }
|
|---|