| [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 | 
 | 
|---|
| [9eb71b3] | 43 | //#include "CodePatterns/MemDebug.hpp"
 | 
|---|
| [15c8a9] | 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);
 | 
|---|
| [08a7ecc] | 150 |           const ObservedValue_Index_t index = observedmolecule->getIndex();
 | 
|---|
| [59eabc] | 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);
 | 
|---|
| [08a7ecc] | 178 |           const ObservedValue_Index_t index = observedatom->getIndex();
 | 
|---|
| [59eabc] | 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
 | 
|---|
| [08a7ecc] | 256 |           const bondId_t bondid =
 | 
|---|
 | 257 |               std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId());
 | 
|---|
 | 258 |           if (!bondids_lookup.left.count(bondid)) {
 | 
|---|
 | 259 |             const QtObservedAtom::ptr leftatom = getObservedAtom(bondref->leftatom->getId());
 | 
|---|
| [4112691] | 260 |             ASSERT( leftatom,
 | 
|---|
 | 261 |                 "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
 | 
|---|
| [08a7ecc] | 262 |             const QtObservedAtom::ptr rightatom = getObservedAtom(bondref->rightatom->getId());
 | 
|---|
| [4112691] | 263 |             ASSERT( rightatom,
 | 
|---|
 | 264 |                 "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
 | 
|---|
 | 265 |             LOG(3, "DEBUG: InformationBoard initializes QtObservedBond for " << bondid);
 | 
|---|
 | 266 |             QtObservedBond::ptr observedbond(
 | 
|---|
 | 267 |                 new QtObservedBond(bondid, bondref, leftatom, rightatom, *this));
 | 
|---|
| [08a7ecc] | 268 |             const ObservedValue_Index_t index = observedbond->getIndex();
 | 
|---|
| [4112691] | 269 |             bondObservedValues.insert(index, observedbond);
 | 
|---|
 | 270 |             bondids_lookup.left.insert( std::make_pair(bondid, index) );
 | 
|---|
 | 271 |             emit bondInserted(observedbond);
 | 
|---|
 | 272 |           }
 | 
|---|
| [b4bd0e] | 273 |         } else {
 | 
|---|
 | 274 |           ELOG(1, "QtObservedInstanceBoard got BondsAdded for unknown atom id " << _id);
 | 
|---|
 | 275 |         }
 | 
|---|
 | 276 |         break;
 | 
|---|
 | 277 |       }
 | 
|---|
| [15c8a9] | 278 |       default:
 | 
|---|
| [2f7988] | 279 |         ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here.");
 | 
|---|
| [15c8a9] | 280 |         break;
 | 
|---|
 | 281 |     }
 | 
|---|
 | 282 |   } else {
 | 
|---|
| [2f7988] | 283 |     ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - notification from unknown source.");
 | 
|---|
| [15c8a9] | 284 |   }
 | 
|---|
 | 285 | }
 | 
|---|
 | 286 | 
 | 
|---|
| [1a58ce] | 287 | const atomId_t QtObservedInstanceBoard::getAtomIdToIndex(ObservedValue_Index_t _id) const
 | 
|---|
 | 288 | {
 | 
|---|
 | 289 |   typename IdtoIndex_t<atomId_t>::right_const_iterator iter = atomids_lookup.right.find(_id);
 | 
|---|
| [006f6a] | 290 |   if (iter != atomids_lookup.right.end())
 | 
|---|
 | 291 |     return iter->second;
 | 
|---|
 | 292 |   else
 | 
|---|
 | 293 |     return (atomId_t)-1;
 | 
|---|
| [1a58ce] | 294 | }
 | 
|---|
 | 295 | 
 | 
|---|
| [b4bd0e] | 296 | const QtObservedInstanceBoard::bondId_t
 | 
|---|
 | 297 | QtObservedInstanceBoard::getBondIdToIndex(ObservedValue_Index_t _id) const
 | 
|---|
 | 298 | {
 | 
|---|
 | 299 |   typename IdtoIndex_t<bondId_t>::right_const_iterator iter = bondids_lookup.right.find(_id);
 | 
|---|
| [006f6a] | 300 |   if (iter != bondids_lookup.right.end())
 | 
|---|
 | 301 |     return iter->second;
 | 
|---|
 | 302 |   else
 | 
|---|
 | 303 |     return QtObservedInstanceBoard::bondId_t(std::make_pair( (atomId_t)-1, (atomId_t)-1) );
 | 
|---|
| [b4bd0e] | 304 | }
 | 
|---|
 | 305 | 
 | 
|---|
| [1a58ce] | 306 | const moleculeId_t QtObservedInstanceBoard::getMoleculeIdToIndex(ObservedValue_Index_t _id) const
 | 
|---|
 | 307 | {
 | 
|---|
 | 308 |   typename IdtoIndex_t<moleculeId_t>::right_const_iterator iter = moleculeids_lookup.right.find(_id);
 | 
|---|
| [006f6a] | 309 |   if (iter != moleculeids_lookup.right.end())
 | 
|---|
 | 310 |     return iter->second;
 | 
|---|
 | 311 |   else
 | 
|---|
 | 312 |     return (moleculeId_t)-1;
 | 
|---|
| [1a58ce] | 313 | }
 | 
|---|
 | 314 | 
 | 
|---|
| [b4bd0e] | 315 | void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id)
 | 
|---|
 | 316 | {
 | 
|---|
 | 317 |   LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << getAtomIdToIndex(_id));
 | 
|---|
 | 318 |   emit atomRemoved(_id);
 | 
|---|
 | 319 | }
 | 
|---|
 | 320 | 
 | 
|---|
 | 321 | void QtObservedInstanceBoard::bondcountsubjectKilled(ObservedValue_Index_t _id)
 | 
|---|
 | 322 | {
 | 
|---|
 | 323 |   LOG(3, "DEBUG: InstanceBoard emits bondRemoved for " << getBondIdToIndex(_id));
 | 
|---|
 | 324 |   emit bondRemoved(_id);
 | 
|---|
 | 325 | }
 | 
|---|
 | 326 | 
 | 
|---|
 | 327 | void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id)
 | 
|---|
 | 328 | {
 | 
|---|
 | 329 |   LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << getMoleculeIdToIndex(_id));
 | 
|---|
 | 330 |   emit moleculeRemoved(_id);
 | 
|---|
 | 331 | }
 | 
|---|
 | 332 | 
 | 
|---|
| [41e287] | 333 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id)
 | 
|---|
| [15c8a9] | 334 | {
 | 
|---|
| [e4b13a] | 335 |   typename IdtoIndex_t<atomId_t>::left_iterator iter = atomids_lookup.left.find(_id);
 | 
|---|
 | 336 |   if (iter == atomids_lookup.left.end())
 | 
|---|
 | 337 |     return QtObservedAtom::ptr();
 | 
|---|
 | 338 |   else
 | 
|---|
 | 339 |     return atomObservedValues.get(iter->second);
 | 
|---|
| [7f1c00] | 340 | }
 | 
|---|
 | 341 | 
 | 
|---|
| [3054f4a] | 342 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(ObservedValue_Index_t _id)
 | 
|---|
 | 343 | {
 | 
|---|
 | 344 |   return atomObservedValues.get(_id);
 | 
|---|
 | 345 | }
 | 
|---|
 | 346 | 
 | 
|---|
| [b4bd0e] | 347 | QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(const bondId_t _id)
 | 
|---|
 | 348 | {
 | 
|---|
| [e4b13a] | 349 |   typename IdtoIndex_t<bondId_t>::left_iterator iter = bondids_lookup.left.find(_id);
 | 
|---|
 | 350 |   if (iter == bondids_lookup.left.end())
 | 
|---|
 | 351 |     return QtObservedBond::ptr();
 | 
|---|
 | 352 |   else
 | 
|---|
 | 353 |     return bondObservedValues.get(iter->second);
 | 
|---|
| [b4bd0e] | 354 | }
 | 
|---|
 | 355 | 
 | 
|---|
 | 356 | QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(ObservedValue_Index_t _id)
 | 
|---|
 | 357 | {
 | 
|---|
 | 358 |   return bondObservedValues.get(_id);
 | 
|---|
 | 359 | }
 | 
|---|
 | 360 | 
 | 
|---|
| [41e287] | 361 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id)
 | 
|---|
| [15c8a9] | 362 | {
 | 
|---|
| [e4b13a] | 363 |   typename IdtoIndex_t<moleculeId_t>::left_iterator iter = moleculeids_lookup.left.find(_id);
 | 
|---|
 | 364 |   if (iter == moleculeids_lookup.left.end())
 | 
|---|
 | 365 |     return QtObservedMolecule::ptr();
 | 
|---|
 | 366 |   else
 | 
|---|
 | 367 |     return moleculeObservedValues.get(iter->second);
 | 
|---|
| [7f1c00] | 368 | }
 | 
|---|
 | 369 | 
 | 
|---|
| [3054f4a] | 370 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(ObservedValue_Index_t _id)
 | 
|---|
 | 371 | {
 | 
|---|
 | 372 |   return moleculeObservedValues.get(_id);
 | 
|---|
 | 373 | }
 | 
|---|
 | 374 | 
 | 
|---|
| [59eabc] | 375 | void QtObservedInstanceBoard::markObservedAtomAsConnected(ObservedValue_Index_t _id)
 | 
|---|
| [15c8a9] | 376 | {
 | 
|---|
| [68418e] | 377 |   atomObservedValues.markObservedValuesAsConnected(_id);
 | 
|---|
| [15c8a9] | 378 | }
 | 
|---|
 | 379 | 
 | 
|---|
| [59eabc] | 380 | void QtObservedInstanceBoard::markObservedAtomAsDisconnected(ObservedValue_Index_t _id)
 | 
|---|
| [15c8a9] | 381 | {
 | 
|---|
| [68418e] | 382 |   atomObservedValues.markObservedValuesAsDisconnected(_id);
 | 
|---|
| [15c8a9] | 383 | }
 | 
|---|
| [98c35c] | 384 | 
 | 
|---|
| [59eabc] | 385 | void QtObservedInstanceBoard::markObservedAtomForErase(ObservedValue_Index_t _id)
 | 
|---|
| [4e6ffe] | 386 | {
 | 
|---|
 | 387 |   atomObservedValues.eraseObservedValues(_id);
 | 
|---|
| [1a58ce] | 388 |   atomids_lookup.right.erase(_id);
 | 
|---|
| [4e6ffe] | 389 | }
 | 
|---|
 | 390 | 
 | 
|---|
| [b4bd0e] | 391 | void QtObservedInstanceBoard::markObservedBondAsConnected(ObservedValue_Index_t _id)
 | 
|---|
 | 392 | {
 | 
|---|
 | 393 |   bondObservedValues.markObservedValuesAsConnected(_id);
 | 
|---|
 | 394 | }
 | 
|---|
 | 395 | 
 | 
|---|
 | 396 | void QtObservedInstanceBoard::markObservedBondAsDisconnected(ObservedValue_Index_t _id)
 | 
|---|
 | 397 | {
 | 
|---|
 | 398 |   bondObservedValues.markObservedValuesAsDisconnected(_id);
 | 
|---|
 | 399 | }
 | 
|---|
 | 400 | 
 | 
|---|
 | 401 | void QtObservedInstanceBoard::markObservedBondForErase(ObservedValue_Index_t _id)
 | 
|---|
 | 402 | {
 | 
|---|
 | 403 |   bondObservedValues.eraseObservedValues(_id);
 | 
|---|
 | 404 |   bondids_lookup.right.erase(_id);
 | 
|---|
 | 405 | }
 | 
|---|
 | 406 | 
 | 
|---|
| [59eabc] | 407 | void QtObservedInstanceBoard::markObservedMoleculeAsConnected(ObservedValue_Index_t _id)
 | 
|---|
| [98c35c] | 408 | {
 | 
|---|
| [68418e] | 409 |   moleculeObservedValues.markObservedValuesAsConnected(_id);
 | 
|---|
| [98c35c] | 410 | }
 | 
|---|
 | 411 | 
 | 
|---|
| [59eabc] | 412 | void QtObservedInstanceBoard::markObservedMoleculeAsDisconnected(ObservedValue_Index_t _id)
 | 
|---|
| [98c35c] | 413 | {
 | 
|---|
| [68418e] | 414 |   moleculeObservedValues.markObservedValuesAsDisconnected(_id);
 | 
|---|
| [98c35c] | 415 | }
 | 
|---|
| [4e6ffe] | 416 | 
 | 
|---|
| [59eabc] | 417 | void QtObservedInstanceBoard::markObservedMoleculeForErase(ObservedValue_Index_t _id)
 | 
|---|
| [4e6ffe] | 418 | {
 | 
|---|
 | 419 |   moleculeObservedValues.eraseObservedValues(_id);
 | 
|---|
| [1a58ce] | 420 |   moleculeids_lookup.right.erase(_id);
 | 
|---|
| [4e6ffe] | 421 | }
 | 
|---|