[15c8a9] | 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 | /*
|
---|
[2f7988] | 24 | * QtObservedInstanceBoard.cpp
|
---|
[15c8a9] | 25 | *
|
---|
| 26 | * Created on: Oct 17, 2015
|
---|
| 27 | * Author: heber
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | // include config.h
|
---|
| 32 | #ifdef HAVE_CONFIG_H
|
---|
| 33 | #include <config.h>
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
[2f7988] | 36 | #include "QtObservedInstanceBoard.hpp"
|
---|
[15c8a9] | 37 |
|
---|
[04c3a3] | 38 | #include <QtCore/QMetaType>
|
---|
| 39 |
|
---|
[65c323] | 40 | #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
|
---|
[494478] | 41 | #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
|
---|
[15c8a9] | 42 |
|
---|
| 43 | #include "CodePatterns/MemDebug.hpp"
|
---|
| 44 |
|
---|
[68418e] | 45 | #include <boost/bind.hpp>
|
---|
| 46 |
|
---|
[15c8a9] | 47 | #include "CodePatterns/Log.hpp"
|
---|
| 48 |
|
---|
| 49 | #include "Atom/atom.hpp"
|
---|
| 50 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
| 51 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
| 52 | #include "molecule.hpp"
|
---|
[41e287] | 53 | #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp"
|
---|
[15c8a9] | 54 | #include "World.hpp"
|
---|
| 55 |
|
---|
[2f7988] | 56 | QtObservedInstanceBoard::QtObservedInstanceBoard(QWidget * _parent) :
|
---|
[15c8a9] | 57 | QWidget(_parent),
|
---|
[2f7988] | 58 | Observer("QtObservedInstanceBoard"),
|
---|
[15c8a9] | 59 | WorldSignedOn(false),
|
---|
[68418e] | 60 | atomObservedValues(
|
---|
| 61 | "atom",
|
---|
| 62 | *this,
|
---|
| 63 | boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)),
|
---|
[b4bd0e] | 64 | bondObservedValues(
|
---|
| 65 | "bond",
|
---|
| 66 | *this,
|
---|
| 67 | boost::bind(&QtObservedInstanceBoard::bondcountsubjectKilled, this, _1)),
|
---|
[68418e] | 68 | moleculeObservedValues(
|
---|
| 69 | "molecule",
|
---|
| 70 | *this,
|
---|
[8b59dd] | 71 | boost::bind(&QtObservedInstanceBoard::moleculecountsubjectKilled, this, _1))
|
---|
[68418e] | 72 | {
|
---|
[59eabc] | 73 | qRegisterMetaType<ObservedValue_Index_t>("ObservedValue_Index_t");
|
---|
[04c3a3] | 74 | qRegisterMetaType<QtObservedAtom::ptr>("QtObservedAtom::ptr");
|
---|
[b4bd0e] | 75 | qRegisterMetaType<QtObservedBond::ptr>("QtObservedBond::ptr");
|
---|
[04c3a3] | 76 | qRegisterMetaType<QtObservedMolecule::ptr>("QtObservedMolecule::ptr");
|
---|
| 77 |
|
---|
[15c8a9] | 78 | // be first (besides ObservedValues to know about new insertions)
|
---|
| 79 | World::getInstance().signOn(this, World::AtomInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
|
---|
| 80 | World::getInstance().signOn(this, World::MoleculeInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
|
---|
| 81 | WorldSignedOn = true;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[2f7988] | 84 | QtObservedInstanceBoard::~QtObservedInstanceBoard()
|
---|
[15c8a9] | 85 | {
|
---|
| 86 | if (WorldSignedOn) {
|
---|
| 87 | World::getInstance().signOff(this, World::AtomInserted);
|
---|
| 88 | World::getInstance().signOff(this, World::MoleculeInserted);
|
---|
| 89 | }
|
---|
[b4bd0e] | 90 | // sign off from all remaining molecules, bonds, and atoms
|
---|
[15c8a9] | 91 | for (SignedOn_t::iterator iter = AtomSignedOn.begin(); !AtomSignedOn.empty();
|
---|
| 92 | iter = AtomSignedOn.begin()) {
|
---|
| 93 | (*iter)->signOff(this, atom::IndexChanged);
|
---|
[b4bd0e] | 94 | (*iter)->signOff(this, atom::BondsAdded);
|
---|
| 95 | AtomSignedOn.erase(*iter);
|
---|
[15c8a9] | 96 | }
|
---|
| 97 |
|
---|
| 98 | for (SignedOn_t::iterator iter = MoleculeSignedOn.begin(); !MoleculeSignedOn.empty();
|
---|
| 99 | iter = MoleculeSignedOn.begin()) {
|
---|
[5c9604] | 100 | (*iter)->signOff(this, molecule::IndexChanged);
|
---|
| 101 | MoleculeSignedOn.erase(iter);
|
---|
[15c8a9] | 102 | }
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[2f7988] | 105 | void QtObservedInstanceBoard::update(Observable *publisher)
|
---|
[15c8a9] | 106 | {
|
---|
| 107 | ASSERT(0,
|
---|
[2f7988] | 108 | "QtObservedInstanceBoard::update() - we are not signed on to general updates.");
|
---|
[15c8a9] | 109 | }
|
---|
| 110 |
|
---|
[2f7988] | 111 | void QtObservedInstanceBoard::subjectKilled(Observable *publisher)
|
---|
[15c8a9] | 112 | {
|
---|
| 113 | SignedOn_t::iterator iter = AtomSignedOn.find(publisher);
|
---|
| 114 | if ( iter != AtomSignedOn.end()) {
|
---|
| 115 | LOG(3, "DEBUG: InstanceBoard got subjectKilled() from atom " << publisher);
|
---|
[b4bd0e] | 116 | AtomSignedOn.erase(iter); // only remove one
|
---|
[15c8a9] | 117 | } else {
|
---|
| 118 | iter = MoleculeSignedOn.find(publisher);
|
---|
| 119 | if ( iter != MoleculeSignedOn.end()) {
|
---|
| 120 | LOG(3, "DEBUG: InstanceBoard got subjectKilled() from molecule " << publisher);
|
---|
| 121 | MoleculeSignedOn.erase(iter);
|
---|
| 122 | } else {
|
---|
| 123 | ASSERT(0,
|
---|
| 124 | "QtObservedInstanceBoard::subjectKilled() - could not find signedOn for atom/molecule "+toString(publisher));
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[2f7988] | 129 | void QtObservedInstanceBoard::recieveNotification(Observable *publisher, Notification_ptr notification)
|
---|
[15c8a9] | 130 | {
|
---|
| 131 | if (static_cast<World *>(publisher) == World::getPointer()) {
|
---|
| 132 | switch (notification->getChannelNo()) {
|
---|
| 133 | case World::MoleculeInserted:
|
---|
| 134 | {
|
---|
| 135 | const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
---|
| 136 | #ifdef LOG_OBSERVER
|
---|
| 137 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been inserted.";
|
---|
| 138 | #endif
|
---|
| 139 | LOG(3, "DEBUG: InformationBoard got moleculeInserted signal for molecule " << _id);
|
---|
| 140 | const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
|
---|
| 141 | getMolecule(MoleculeById(_id));
|
---|
| 142 | if (_molecule != NULL) {
|
---|
[62a0ee] | 143 | LOG(3, "DEBUG: InformationBoard initializes QtObservedMolecule for " << _id);
|
---|
| 144 | QtObservedMolecule::ptr observedmolecule(
|
---|
| 145 | new QtObservedMolecule(
|
---|
| 146 | _id,
|
---|
| 147 | _molecule,
|
---|
| 148 | *this));
|
---|
[bfd5d5f] | 149 | observedmolecule->setSelfRef(observedmolecule);
|
---|
[59eabc] | 150 | const ObservedValue_Index_t index = static_cast<const Observable *>(_molecule);
|
---|
| 151 | moleculeObservedValues.insert(index, observedmolecule);
|
---|
[1a58ce] | 152 | moleculeids_lookup.left.insert( std::make_pair(_id, index) );
|
---|
[15c8a9] | 153 | // we need to check for index changes
|
---|
| 154 | LOG(3, "DEBUG: InformationBoard signOn()s to molecule " << _id);
|
---|
| 155 | _molecule->signOn(this, molecule::IndexChanged);
|
---|
| 156 | MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
|
---|
| 157 |
|
---|
[1b07b1] | 158 | emit moleculeInserted(observedmolecule);
|
---|
[15c8a9] | 159 | } else {
|
---|
[2f7988] | 160 | ELOG(1, "QtObservedInstanceBoard got MoleculeInserted for unknown molecule id " << _id);
|
---|
[15c8a9] | 161 | }
|
---|
| 162 | break;
|
---|
| 163 | }
|
---|
| 164 | case World::AtomInserted:
|
---|
| 165 | {
|
---|
| 166 | const atomId_t _id = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
---|
| 167 | #ifdef LOG_OBSERVER
|
---|
| 168 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
---|
| 169 | #endif
|
---|
| 170 | LOG(3, "DEBUG: InformationBoard got atomInserted signal for atom " << _id);
|
---|
| 171 | const atom * const _atom = const_cast<const World &>(World::getInstance()).
|
---|
| 172 | getAtom(AtomById(_id));
|
---|
| 173 | if (_atom!= NULL) {
|
---|
[62a0ee] | 174 | LOG(3, "DEBUG: InformationBoard initializes QtObservedAtom for " << _id);
|
---|
| 175 | QtObservedAtom::ptr observedatom(
|
---|
| 176 | new QtObservedAtom(_id, _atom, *this));
|
---|
[bfd5d5f] | 177 | observedatom->setSelfRef(observedatom);
|
---|
[59eabc] | 178 | const ObservedValue_Index_t index = static_cast<const Observable *>(_atom);
|
---|
| 179 | atomObservedValues.insert(index, observedatom);
|
---|
[1a58ce] | 180 | atomids_lookup.left.insert( std::make_pair(_id, index) );
|
---|
[15c8a9] | 181 | // we need to check for index changes
|
---|
| 182 | LOG(3, "DEBUG: InformationBoard signOn()s to atom " << _id);
|
---|
| 183 | _atom->signOn(this, atom::IndexChanged);
|
---|
[b4bd0e] | 184 | _atom->signOn(this, atom::BondsAdded);
|
---|
| 185 | AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
|
---|
[15c8a9] | 186 | AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
|
---|
[1b07b1] | 187 | emit atomInserted(observedatom);
|
---|
[15c8a9] | 188 | } else {
|
---|
[2f7988] | 189 | ELOG(1, "QtObservedInstanceBoard got AtomInserted for unknown atom id " << _id);
|
---|
[15c8a9] | 190 | }
|
---|
| 191 | break;
|
---|
| 192 | }
|
---|
| 193 | default:
|
---|
[2f7988] | 194 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for World.");
|
---|
[15c8a9] | 195 | break;
|
---|
| 196 | }
|
---|
| 197 | } else if (dynamic_cast<molecule *>(publisher) != NULL) {
|
---|
| 198 | const moleculeId_t molid = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
---|
| 199 | switch (notification->getChannelNo()) {
|
---|
| 200 | case molecule::IndexChanged:
|
---|
| 201 | {
|
---|
| 202 | // molecule has changed its index
|
---|
| 203 | const moleculeId_t newmoleculeId = dynamic_cast<molecule *>(publisher)->getId();
|
---|
| 204 | LOG(3, "DEBUG: InformationBoard got IndexChanged from molecule " << molid << " to " << newmoleculeId);
|
---|
[59eabc] | 205 | {
|
---|
[1a58ce] | 206 | typename IdtoIndex_t<moleculeId_t>::left_iterator iter = moleculeids_lookup.left.find(molid);
|
---|
| 207 | ASSERT( iter != moleculeids_lookup.left.end(),
|
---|
[59eabc] | 208 | "QtObservedInstanceBoard::recieveNotification() - mol id "
|
---|
| 209 | +toString(molid)+" unknown to lookup.");
|
---|
| 210 | const ObservedValue_Index_t index = iter->second;
|
---|
[1a58ce] | 211 | moleculeids_lookup.left.erase(iter);
|
---|
| 212 | moleculeids_lookup.left.insert( std::pair<moleculeId_t, ObservedValue_Index_t>(newmoleculeId, index) );
|
---|
[59eabc] | 213 | }
|
---|
[15c8a9] | 214 | // no need update SignedOn, ref does not change
|
---|
| 215 | emit moleculeIndexChanged(molid, newmoleculeId);
|
---|
| 216 | break;
|
---|
| 217 | }
|
---|
| 218 | default:
|
---|
[2f7988] | 219 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here.");
|
---|
[15c8a9] | 220 | break;
|
---|
| 221 | }
|
---|
| 222 | } else if (dynamic_cast<atom *>(publisher) != NULL) {
|
---|
| 223 | const atomId_t oldatomId = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
---|
| 224 | switch (notification->getChannelNo()) {
|
---|
| 225 | case AtomObservable::IndexChanged:
|
---|
| 226 | {
|
---|
| 227 | const atomId_t newatomId = dynamic_cast<atom *>(publisher)->getId();
|
---|
| 228 | LOG(3, "DEBUG: InformationBoard got IndexChanged from atom " << oldatomId << " to " << newatomId);
|
---|
[59eabc] | 229 | {
|
---|
[1a58ce] | 230 | typename IdtoIndex_t<atomId_t>::left_iterator iter = atomids_lookup.left.find(oldatomId);
|
---|
| 231 | ASSERT( iter != atomids_lookup.left.end(),
|
---|
[59eabc] | 232 | "QtObservedInstanceBoard::recieveNotification() - atom id "
|
---|
| 233 | +toString(oldatomId)+" unknown to lookup.");
|
---|
| 234 | const ObservedValue_Index_t index = iter->second;
|
---|
[1a58ce] | 235 | atomids_lookup.left.erase(iter);
|
---|
| 236 | atomids_lookup.left.insert( std::pair<atomId_t, ObservedValue_Index_t>(newatomId, index) );
|
---|
[59eabc] | 237 | }
|
---|
[15c8a9] | 238 | // no need update SignedOn, ref does not change
|
---|
| 239 | emit atomIndexChanged(oldatomId, newatomId);
|
---|
| 240 | break;
|
---|
| 241 | }
|
---|
[b4bd0e] | 242 | case AtomObservable::BondsAdded:
|
---|
| 243 | {
|
---|
| 244 | const atom * _atom = dynamic_cast<atom *>(publisher);
|
---|
| 245 | const atomId_t _id = _atom->getId();
|
---|
| 246 | #ifdef LOG_OBSERVER
|
---|
| 247 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
---|
| 248 | #endif
|
---|
| 249 | LOG(3, "DEBUG: InformationBoard got bondInserted signal for atom " << _id);
|
---|
| 250 | if (_atom != NULL) {
|
---|
| 251 | // find the new bond by simply taking the last added to the list
|
---|
| 252 | const BondList &ListOfBonds = _atom->getListOfBonds();
|
---|
| 253 | const bond::ptr bondref = ListOfBonds.back();
|
---|
[4112691] | 254 |
|
---|
| 255 | // check whether bond is already present, cause we get BondsAdded from both atoms
|
---|
| 256 | const ObservedValue_Index_t index = static_cast<const Observable *>(bondref.get());
|
---|
| 257 | if (!bondObservedValues.isPresent(index)) {
|
---|
| 258 | const QtObservedAtom::ptr leftatom = getObservedAtom(
|
---|
| 259 | static_cast<const Observable *>(bondref->leftatom));
|
---|
| 260 | ASSERT( leftatom,
|
---|
| 261 | "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
|
---|
| 262 | const QtObservedAtom::ptr rightatom = getObservedAtom(
|
---|
| 263 | static_cast<const Observable *>(bondref->rightatom));
|
---|
| 264 | ASSERT( rightatom,
|
---|
| 265 | "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
|
---|
| 266 | const bondId_t bondid =
|
---|
| 267 | std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId());
|
---|
| 268 | LOG(3, "DEBUG: InformationBoard initializes QtObservedBond for " << bondid);
|
---|
| 269 | QtObservedBond::ptr observedbond(
|
---|
| 270 | new QtObservedBond(bondid, bondref, leftatom, rightatom, *this));
|
---|
| 271 | bondObservedValues.insert(index, observedbond);
|
---|
| 272 | bondids_lookup.left.insert( std::make_pair(bondid, index) );
|
---|
| 273 | emit bondInserted(observedbond);
|
---|
| 274 | }
|
---|
[b4bd0e] | 275 | } else {
|
---|
| 276 | ELOG(1, "QtObservedInstanceBoard got BondsAdded for unknown atom id " << _id);
|
---|
| 277 | }
|
---|
| 278 | break;
|
---|
| 279 | }
|
---|
[15c8a9] | 280 | default:
|
---|
[2f7988] | 281 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here.");
|
---|
[15c8a9] | 282 | break;
|
---|
| 283 | }
|
---|
| 284 | } else {
|
---|
[2f7988] | 285 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - notification from unknown source.");
|
---|
[15c8a9] | 286 | }
|
---|
| 287 | }
|
---|
| 288 |
|
---|
[1a58ce] | 289 | const atomId_t QtObservedInstanceBoard::getAtomIdToIndex(ObservedValue_Index_t _id) const
|
---|
| 290 | {
|
---|
| 291 | typename IdtoIndex_t<atomId_t>::right_const_iterator iter = atomids_lookup.right.find(_id);
|
---|
| 292 | ASSERT( iter != atomids_lookup.right.end(),
|
---|
| 293 | "QtObservedInstanceBoard::getAtomIdToIndex() - index "
|
---|
| 294 | +toString(_id)+" is unknown.");
|
---|
| 295 | return iter->second;
|
---|
| 296 | }
|
---|
| 297 |
|
---|
[b4bd0e] | 298 | const QtObservedInstanceBoard::bondId_t
|
---|
| 299 | QtObservedInstanceBoard::getBondIdToIndex(ObservedValue_Index_t _id) const
|
---|
| 300 | {
|
---|
| 301 | typename IdtoIndex_t<bondId_t>::right_const_iterator iter = bondids_lookup.right.find(_id);
|
---|
| 302 | ASSERT( iter != bondids_lookup.right.end(),
|
---|
| 303 | "QtObservedInstanceBoard::getBondIdToIndex() - index "
|
---|
| 304 | +toString(_id)+" is unknown.");
|
---|
| 305 | return iter->second;
|
---|
| 306 | }
|
---|
| 307 |
|
---|
[1a58ce] | 308 | const moleculeId_t QtObservedInstanceBoard::getMoleculeIdToIndex(ObservedValue_Index_t _id) const
|
---|
| 309 | {
|
---|
| 310 | typename IdtoIndex_t<moleculeId_t>::right_const_iterator iter = moleculeids_lookup.right.find(_id);
|
---|
| 311 | ASSERT( iter != moleculeids_lookup.right.end(),
|
---|
| 312 | "QtObservedInstanceBoard::getMoleculeIdToIndex() - index "
|
---|
| 313 | +toString(_id)+" is unknown.");
|
---|
| 314 | return iter->second;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[b4bd0e] | 317 | void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id)
|
---|
| 318 | {
|
---|
| 319 | LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << getAtomIdToIndex(_id));
|
---|
| 320 | emit atomRemoved(_id);
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 | void QtObservedInstanceBoard::bondcountsubjectKilled(ObservedValue_Index_t _id)
|
---|
| 324 | {
|
---|
| 325 | LOG(3, "DEBUG: InstanceBoard emits bondRemoved for " << getBondIdToIndex(_id));
|
---|
| 326 | emit bondRemoved(_id);
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id)
|
---|
| 330 | {
|
---|
| 331 | LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << getMoleculeIdToIndex(_id));
|
---|
| 332 | emit moleculeRemoved(_id);
|
---|
| 333 | }
|
---|
| 334 |
|
---|
[41e287] | 335 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id)
|
---|
[15c8a9] | 336 | {
|
---|
[e4b13a] | 337 | typename IdtoIndex_t<atomId_t>::left_iterator iter = atomids_lookup.left.find(_id);
|
---|
| 338 | if (iter == atomids_lookup.left.end())
|
---|
| 339 | return QtObservedAtom::ptr();
|
---|
| 340 | else
|
---|
| 341 | return atomObservedValues.get(iter->second);
|
---|
[7f1c00] | 342 | }
|
---|
| 343 |
|
---|
[3054f4a] | 344 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(ObservedValue_Index_t _id)
|
---|
| 345 | {
|
---|
| 346 | return atomObservedValues.get(_id);
|
---|
| 347 | }
|
---|
| 348 |
|
---|
[b4bd0e] | 349 | QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(const bondId_t _id)
|
---|
| 350 | {
|
---|
[e4b13a] | 351 | typename IdtoIndex_t<bondId_t>::left_iterator iter = bondids_lookup.left.find(_id);
|
---|
| 352 | if (iter == bondids_lookup.left.end())
|
---|
| 353 | return QtObservedBond::ptr();
|
---|
| 354 | else
|
---|
| 355 | return bondObservedValues.get(iter->second);
|
---|
[b4bd0e] | 356 | }
|
---|
| 357 |
|
---|
| 358 | QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(ObservedValue_Index_t _id)
|
---|
| 359 | {
|
---|
| 360 | return bondObservedValues.get(_id);
|
---|
| 361 | }
|
---|
| 362 |
|
---|
[41e287] | 363 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id)
|
---|
[15c8a9] | 364 | {
|
---|
[e4b13a] | 365 | typename IdtoIndex_t<moleculeId_t>::left_iterator iter = moleculeids_lookup.left.find(_id);
|
---|
| 366 | if (iter == moleculeids_lookup.left.end())
|
---|
| 367 | return QtObservedMolecule::ptr();
|
---|
| 368 | else
|
---|
| 369 | return moleculeObservedValues.get(iter->second);
|
---|
[7f1c00] | 370 | }
|
---|
| 371 |
|
---|
[3054f4a] | 372 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(ObservedValue_Index_t _id)
|
---|
| 373 | {
|
---|
| 374 | return moleculeObservedValues.get(_id);
|
---|
| 375 | }
|
---|
| 376 |
|
---|
[59eabc] | 377 | void QtObservedInstanceBoard::markObservedAtomAsConnected(ObservedValue_Index_t _id)
|
---|
[15c8a9] | 378 | {
|
---|
[68418e] | 379 | atomObservedValues.markObservedValuesAsConnected(_id);
|
---|
[15c8a9] | 380 | }
|
---|
| 381 |
|
---|
[59eabc] | 382 | void QtObservedInstanceBoard::markObservedAtomAsDisconnected(ObservedValue_Index_t _id)
|
---|
[15c8a9] | 383 | {
|
---|
[68418e] | 384 | atomObservedValues.markObservedValuesAsDisconnected(_id);
|
---|
[15c8a9] | 385 | }
|
---|
[98c35c] | 386 |
|
---|
[59eabc] | 387 | void QtObservedInstanceBoard::markObservedAtomForErase(ObservedValue_Index_t _id)
|
---|
[4e6ffe] | 388 | {
|
---|
| 389 | atomObservedValues.eraseObservedValues(_id);
|
---|
[1a58ce] | 390 | atomids_lookup.right.erase(_id);
|
---|
[4e6ffe] | 391 | }
|
---|
| 392 |
|
---|
[b4bd0e] | 393 | void QtObservedInstanceBoard::markObservedBondAsConnected(ObservedValue_Index_t _id)
|
---|
| 394 | {
|
---|
| 395 | bondObservedValues.markObservedValuesAsConnected(_id);
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | void QtObservedInstanceBoard::markObservedBondAsDisconnected(ObservedValue_Index_t _id)
|
---|
| 399 | {
|
---|
| 400 | bondObservedValues.markObservedValuesAsDisconnected(_id);
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | void QtObservedInstanceBoard::markObservedBondForErase(ObservedValue_Index_t _id)
|
---|
| 404 | {
|
---|
| 405 | bondObservedValues.eraseObservedValues(_id);
|
---|
| 406 | bondids_lookup.right.erase(_id);
|
---|
| 407 | }
|
---|
| 408 |
|
---|
[59eabc] | 409 | void QtObservedInstanceBoard::markObservedMoleculeAsConnected(ObservedValue_Index_t _id)
|
---|
[98c35c] | 410 | {
|
---|
[68418e] | 411 | moleculeObservedValues.markObservedValuesAsConnected(_id);
|
---|
[98c35c] | 412 | }
|
---|
| 413 |
|
---|
[59eabc] | 414 | void QtObservedInstanceBoard::markObservedMoleculeAsDisconnected(ObservedValue_Index_t _id)
|
---|
[98c35c] | 415 | {
|
---|
[68418e] | 416 | moleculeObservedValues.markObservedValuesAsDisconnected(_id);
|
---|
[98c35c] | 417 | }
|
---|
[4e6ffe] | 418 |
|
---|
[59eabc] | 419 | void QtObservedInstanceBoard::markObservedMoleculeForErase(ObservedValue_Index_t _id)
|
---|
[4e6ffe] | 420 | {
|
---|
| 421 | moleculeObservedValues.eraseObservedValues(_id);
|
---|
[1a58ce] | 422 | moleculeids_lookup.right.erase(_id);
|
---|
[4e6ffe] | 423 | }
|
---|