| [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 | 
 | 
|---|
| [65c323] | 38 | #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
 | 
|---|
| [494478] | 39 | #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
 | 
|---|
| [15c8a9] | 40 | 
 | 
|---|
 | 41 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
 | 42 | 
 | 
|---|
| [68418e] | 43 | #include <boost/bind.hpp>
 | 
|---|
 | 44 | 
 | 
|---|
| [15c8a9] | 45 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | #include "Atom/atom.hpp"
 | 
|---|
 | 48 | #include "Descriptors/AtomIdDescriptor.hpp"
 | 
|---|
 | 49 | #include "Descriptors/MoleculeIdDescriptor.hpp"
 | 
|---|
 | 50 | #include "molecule.hpp"
 | 
|---|
| [41e287] | 51 | #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp"
 | 
|---|
| [15c8a9] | 52 | #include "World.hpp"
 | 
|---|
 | 53 | 
 | 
|---|
| [2f7988] | 54 | QtObservedInstanceBoard::QtObservedInstanceBoard(QWidget * _parent) :
 | 
|---|
| [15c8a9] | 55 |   QWidget(_parent),
 | 
|---|
| [2f7988] | 56 |   Observer("QtObservedInstanceBoard"),
 | 
|---|
| [15c8a9] | 57 |   WorldSignedOn(false),
 | 
|---|
| [68418e] | 58 |   atomObservedValues(
 | 
|---|
 | 59 |       "atom",
 | 
|---|
 | 60 |       *this,
 | 
|---|
 | 61 |       boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)),
 | 
|---|
 | 62 |   moleculeObservedValues(
 | 
|---|
 | 63 |       "molecule",
 | 
|---|
 | 64 |       *this,
 | 
|---|
 | 65 |       boost::bind(&QtObservedInstanceBoard::moleculecountsubjectKilled, this, _1)),
 | 
|---|
 | 66 |   atomSubjectKilled(
 | 
|---|
| [90821d] | 67 |       boost::bind(&ObservedValuesContainer<QtObservedAtom, atomId_t>::countsubjectKilled,
 | 
|---|
 | 68 |           boost::ref(atomObservedValues),
 | 
|---|
| [68418e] | 69 |           _1)),
 | 
|---|
 | 70 |   moleculeSubjectKilled(
 | 
|---|
| [90821d] | 71 |       boost::bind(&ObservedValuesContainer<QtObservedMolecule, moleculeId_t>::countsubjectKilled,
 | 
|---|
 | 72 |           boost::ref(moleculeObservedValues),
 | 
|---|
| [68418e] | 73 |           _1)),
 | 
|---|
 | 74 |   lastremovedatom((atomId_t)-1),
 | 
|---|
 | 75 |   lastremovedatomsmolecule( std::make_pair((moleculeId_t)-1,(atomId_t)-1) ),
 | 
|---|
 | 76 |   lastremovedmolecule((moleculeId_t)-1)
 | 
|---|
 | 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::AtomRemoved, GlobalObservableInfo::PriorityLevel(int(-10)));
 | 
|---|
 | 81 |   World::getInstance().signOn(this, World::MoleculeInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
 | 
|---|
 | 82 |   World::getInstance().signOn(this, World::MoleculeRemoved, GlobalObservableInfo::PriorityLevel(int(-10)));
 | 
|---|
 | 83 |   WorldSignedOn = true;
 | 
|---|
 | 84 | }
 | 
|---|
 | 85 | 
 | 
|---|
| [2f7988] | 86 | QtObservedInstanceBoard::~QtObservedInstanceBoard()
 | 
|---|
| [15c8a9] | 87 | {
 | 
|---|
 | 88 |   if (WorldSignedOn) {
 | 
|---|
 | 89 |     World::getInstance().signOff(this, World::AtomInserted);
 | 
|---|
 | 90 |     World::getInstance().signOff(this, World::AtomRemoved);
 | 
|---|
 | 91 |     World::getInstance().signOff(this, World::MoleculeInserted);
 | 
|---|
 | 92 |     World::getInstance().signOff(this, World::MoleculeRemoved);
 | 
|---|
 | 93 |   }
 | 
|---|
 | 94 |   // sign off from all remaining molecules and atoms
 | 
|---|
 | 95 |   for (SignedOn_t::iterator iter = AtomSignedOn.begin(); !AtomSignedOn.empty();
 | 
|---|
 | 96 |       iter = AtomSignedOn.begin()) {
 | 
|---|
 | 97 |     (*iter)->signOff(this, atom::IndexChanged);
 | 
|---|
 | 98 |     AtomSignedOn.erase(iter);
 | 
|---|
 | 99 |   }
 | 
|---|
 | 100 | 
 | 
|---|
 | 101 |   for (SignedOn_t::iterator iter = MoleculeSignedOn.begin(); !MoleculeSignedOn.empty();
 | 
|---|
 | 102 |       iter = MoleculeSignedOn.begin()) {
 | 
|---|
 | 103 |     (*iter)->signOff(this, molecule::IndexChanged);
 | 
|---|
| [8d5fbf1] | 104 |     (*iter)->signOff(this, molecule::AtomInserted);
 | 
|---|
 | 105 |     (*iter)->signOff(this, molecule::AtomRemoved);
 | 
|---|
 | 106 |     MoleculeSignedOn.erase(*iter); //erase all instances
 | 
|---|
| [15c8a9] | 107 |   }
 | 
|---|
 | 108 | }
 | 
|---|
 | 109 | 
 | 
|---|
| [2f7988] | 110 | void QtObservedInstanceBoard::update(Observable *publisher)
 | 
|---|
| [15c8a9] | 111 | {
 | 
|---|
 | 112 |   ASSERT(0,
 | 
|---|
| [2f7988] | 113 |       "QtObservedInstanceBoard::update() - we are not signed on to general updates.");
 | 
|---|
| [15c8a9] | 114 | }
 | 
|---|
 | 115 | 
 | 
|---|
| [2f7988] | 116 | void QtObservedInstanceBoard::subjectKilled(Observable *publisher)
 | 
|---|
| [15c8a9] | 117 | {
 | 
|---|
 | 118 |   SignedOn_t::iterator iter = AtomSignedOn.find(publisher);
 | 
|---|
 | 119 |   if ( iter != AtomSignedOn.end()) {
 | 
|---|
 | 120 |     LOG(3, "DEBUG: InstanceBoard got subjectKilled() from atom " << publisher);
 | 
|---|
 | 121 |     AtomSignedOn.erase(iter);
 | 
|---|
 | 122 |   } else {
 | 
|---|
 | 123 |     iter = MoleculeSignedOn.find(publisher);
 | 
|---|
 | 124 |     if ( iter != MoleculeSignedOn.end()) {
 | 
|---|
 | 125 |       LOG(3, "DEBUG: InstanceBoard got subjectKilled() from molecule " << publisher);
 | 
|---|
 | 126 |       MoleculeSignedOn.erase(iter);
 | 
|---|
 | 127 |     } else {
 | 
|---|
 | 128 |       ASSERT(0,
 | 
|---|
 | 129 |           "QtObservedInstanceBoard::subjectKilled() - could not find signedOn for atom/molecule "+toString(publisher));
 | 
|---|
 | 130 |     }
 | 
|---|
 | 131 |   }
 | 
|---|
 | 132 | }
 | 
|---|
 | 133 | 
 | 
|---|
| [2f7988] | 134 | void QtObservedInstanceBoard::recieveNotification(Observable *publisher, Notification_ptr notification)
 | 
|---|
| [15c8a9] | 135 | {
 | 
|---|
 | 136 |   if (static_cast<World *>(publisher) == World::getPointer()) {
 | 
|---|
 | 137 |     switch (notification->getChannelNo()) {
 | 
|---|
 | 138 |       case World::MoleculeInserted:
 | 
|---|
 | 139 |       {
 | 
|---|
 | 140 |         const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
 | 
|---|
 | 141 |   #ifdef LOG_OBSERVER
 | 
|---|
 | 142 |         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been inserted.";
 | 
|---|
 | 143 |   #endif
 | 
|---|
 | 144 |         LOG(3, "DEBUG: InformationBoard got moleculeInserted signal for molecule " << _id);
 | 
|---|
 | 145 |         const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
 | 
|---|
 | 146 |             getMolecule(MoleculeById(_id));
 | 
|---|
 | 147 |         if (_molecule != NULL) {
 | 
|---|
| [494478] | 148 |           ObservedValues_t ObservedValues(QtObservedMolecule::MAX_ObservedTypes);
 | 
|---|
| [15c8a9] | 149 |           LOG(3, "DEBUG: InformationBoard initializes ObservedValues for molecule " << _id);
 | 
|---|
| [494478] | 150 |           QtObservedMolecule::initObservedValues(
 | 
|---|
| [15c8a9] | 151 |               ObservedValues,
 | 
|---|
 | 152 |               _id,
 | 
|---|
 | 153 |               _molecule,
 | 
|---|
 | 154 |               moleculeSubjectKilled);
 | 
|---|
| [68418e] | 155 |           QtObservedMolecule::ptr observedmolecule(new QtObservedMolecule(ObservedValues, *this));
 | 
|---|
| [15c8a9] | 156 | #ifndef NDEBUG
 | 
|---|
| [41e287] | 157 |           bool status =
 | 
|---|
| [15c8a9] | 158 | #endif
 | 
|---|
| [68418e] | 159 |               moleculeObservedValues.insert(_id, observedmolecule);
 | 
|---|
| [41e287] | 160 |           ASSERT( status,
 | 
|---|
| [68418e] | 161 |               "QtObservedInstanceBoard::recieveNotification() - could not insert ObservedMolecule for"
 | 
|---|
| [15c8a9] | 162 |               +toString(_id)+".");
 | 
|---|
 | 163 |           // we need to check for index changes
 | 
|---|
 | 164 |           LOG(3, "DEBUG: InformationBoard signOn()s to molecule " << _id);
 | 
|---|
 | 165 |           _molecule->signOn(this, molecule::IndexChanged);
 | 
|---|
 | 166 |           MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
 | 
|---|
| [8d5fbf1] | 167 |           _molecule->signOn(this, molecule::AtomInserted);
 | 
|---|
 | 168 |           MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
 | 
|---|
 | 169 |           _molecule->signOn(this, molecule::AtomRemoved);
 | 
|---|
 | 170 |           MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
 | 
|---|
| [15c8a9] | 171 | 
 | 
|---|
 | 172 |           emit moleculeInserted(_id);
 | 
|---|
 | 173 |         } else {
 | 
|---|
| [2f7988] | 174 |           ELOG(1, "QtObservedInstanceBoard got MoleculeInserted for unknown molecule id " << _id);
 | 
|---|
| [15c8a9] | 175 |         }
 | 
|---|
 | 176 |         break;
 | 
|---|
 | 177 |       }
 | 
|---|
 | 178 |       case World::MoleculeRemoved:
 | 
|---|
 | 179 |       {
 | 
|---|
 | 180 |         const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
 | 
|---|
 | 181 |         LOG(3, "DEBUG: InformationBoard got MoleculeRemoved signal for molecule " << _id);
 | 
|---|
 | 182 |         // note down such that ObservedValues are simply dropped
 | 
|---|
 | 183 |         lastremovedmolecule = _id;
 | 
|---|
 | 184 |         break;
 | 
|---|
 | 185 |       }
 | 
|---|
 | 186 |       case World::AtomInserted:
 | 
|---|
 | 187 |       {
 | 
|---|
 | 188 |         const atomId_t _id = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
 | 
|---|
 | 189 |   #ifdef LOG_OBSERVER
 | 
|---|
 | 190 |         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
 | 
|---|
 | 191 |   #endif
 | 
|---|
 | 192 |         LOG(3, "DEBUG: InformationBoard got atomInserted signal for atom " << _id);
 | 
|---|
 | 193 |         const atom * const _atom = const_cast<const World &>(World::getInstance()).
 | 
|---|
 | 194 |             getAtom(AtomById(_id));
 | 
|---|
 | 195 |         if (_atom!= NULL) {
 | 
|---|
| [65c323] | 196 |           ObservedValues_t ObservedValues(QtObservedAtom::MAX_ObservedTypes);
 | 
|---|
| [15c8a9] | 197 |           LOG(3, "DEBUG: InformationBoard initializes ObservedValues for atom " << _id);
 | 
|---|
| [65c323] | 198 |           QtObservedAtom::initObservedValues(
 | 
|---|
| [15c8a9] | 199 |               ObservedValues,
 | 
|---|
 | 200 |               _id,
 | 
|---|
 | 201 |               _atom,
 | 
|---|
 | 202 |               atomSubjectKilled);
 | 
|---|
| [68418e] | 203 |           QtObservedAtom::ptr observedatom(new QtObservedAtom(ObservedValues, *this));
 | 
|---|
| [15c8a9] | 204 | #ifndef NDEBUG
 | 
|---|
| [41e287] | 205 |           bool status  =
 | 
|---|
| [15c8a9] | 206 | #endif
 | 
|---|
| [68418e] | 207 |               atomObservedValues.insert(_id, observedatom);
 | 
|---|
| [41e287] | 208 |           ASSERT( status,
 | 
|---|
| [2f7988] | 209 |               "QtObservedInstanceBoard::recieveNotification() - could not insert ObservedValues for"
 | 
|---|
| [15c8a9] | 210 |               +toString(_id)+".");
 | 
|---|
 | 211 |           // we need to check for index changes
 | 
|---|
 | 212 |           LOG(3, "DEBUG: InformationBoard signOn()s to atom " << _id);
 | 
|---|
 | 213 |           _atom->signOn(this, atom::IndexChanged);
 | 
|---|
 | 214 |           AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
 | 
|---|
 | 215 |         } else {
 | 
|---|
| [2f7988] | 216 |           ELOG(1, "QtObservedInstanceBoard got AtomInserted for unknown atom id " << _id);
 | 
|---|
| [15c8a9] | 217 |         }
 | 
|---|
 | 218 |         break;
 | 
|---|
 | 219 |       }
 | 
|---|
 | 220 |       case World::AtomRemoved:
 | 
|---|
 | 221 |       {
 | 
|---|
 | 222 |         const atomId_t _id = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
 | 
|---|
 | 223 |         LOG(3, "DEBUG: InformationBoard got AtomRemoved signal for atom " << _id);
 | 
|---|
 | 224 |         // note down such that ObservedValues are simply dropped
 | 
|---|
 | 225 |         lastremovedatom = _id;
 | 
|---|
 | 226 |         break;
 | 
|---|
 | 227 |       }
 | 
|---|
 | 228 |       default:
 | 
|---|
| [2f7988] | 229 |         ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for World.");
 | 
|---|
| [15c8a9] | 230 |         break;
 | 
|---|
 | 231 |     }
 | 
|---|
 | 232 |   } else if (dynamic_cast<molecule *>(publisher) != NULL) {
 | 
|---|
 | 233 |     const moleculeId_t molid = const_cast<const World &>(World::getInstance()).lastChangedMolId();
 | 
|---|
 | 234 |     switch (notification->getChannelNo()) {
 | 
|---|
 | 235 |       case molecule::AtomInserted:
 | 
|---|
 | 236 |       {
 | 
|---|
 | 237 |         const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
 | 
|---|
 | 238 |             getMolecule(MoleculeById(molid));
 | 
|---|
 | 239 |         if (_molecule != NULL) {
 | 
|---|
 | 240 |           const atomId_t atomid = const_cast<const molecule *>(_molecule)->lastChangedAtomId();
 | 
|---|
 | 241 |           LOG(3, "DEBUG: InformationBoard got AtomInserted signal for atom "
 | 
|---|
 | 242 |               << atomid << " from molecule " << molid);
 | 
|---|
 | 243 |           // check whether atom's observedvalues are present
 | 
|---|
| [41e287] | 244 |           ASSERT( atomObservedValues.isPresent(atomid),
 | 
|---|
| [2f7988] | 245 |               "QtObservedInstanceBoard::recieveNotification() - ObservedValues for atom "
 | 
|---|
| [15c8a9] | 246 |               +toString(atomid)+" are not present yet.");
 | 
|---|
 | 247 |           // and emit
 | 
|---|
 | 248 |           emit atomInserted(molid, atomid);
 | 
|---|
 | 249 |         } else {
 | 
|---|
| [2f7988] | 250 |           ELOG(2, "QtObservedInstanceBoard::recieveNotification() - molecule "
 | 
|---|
| [15c8a9] | 251 |               << molid << " has disappeared.");
 | 
|---|
 | 252 |         }
 | 
|---|
 | 253 |         break;
 | 
|---|
 | 254 |       }
 | 
|---|
 | 255 |       case molecule::AtomRemoved:
 | 
|---|
 | 256 |       {
 | 
|---|
 | 257 |         const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
 | 
|---|
 | 258 |             getMolecule(MoleculeById(molid));
 | 
|---|
 | 259 |         if (_molecule != NULL) {
 | 
|---|
 | 260 |           const atomId_t atomid = const_cast<const molecule *>(_molecule)->lastChangedAtomId();
 | 
|---|
 | 261 |           LOG(3, "DEBUG: InformationBoard got AtomRemoved signal for atom "
 | 
|---|
 | 262 |               << atomid << " from molecule " << molid);
 | 
|---|
| [8d5fbf1] | 263 |           lastremovedatomsmolecule = std::make_pair(molid, atomid);
 | 
|---|
| [15c8a9] | 264 |         }
 | 
|---|
 | 265 |         break;
 | 
|---|
 | 266 |       }
 | 
|---|
 | 267 |       case molecule::IndexChanged:
 | 
|---|
 | 268 |       {
 | 
|---|
 | 269 |         // molecule has changed its index
 | 
|---|
 | 270 |         const moleculeId_t newmoleculeId = dynamic_cast<molecule *>(publisher)->getId();
 | 
|---|
 | 271 |         LOG(3, "DEBUG: InformationBoard got IndexChanged from molecule " << molid << " to " << newmoleculeId);
 | 
|---|
| [41e287] | 272 | #ifndef NDEBUG
 | 
|---|
 | 273 |         bool status =
 | 
|---|
 | 274 | #endif
 | 
|---|
 | 275 |         moleculeObservedValues.changeIdentifier(molid, newmoleculeId);
 | 
|---|
 | 276 |         ASSERT( status,
 | 
|---|
 | 277 |             "QtObservedInstanceBoard::recieveNotification() - cannot change molecule's id "
 | 
|---|
 | 278 |             +toString(molid)+" "+toString(newmoleculeId)+" in moleculeObservedValues.");
 | 
|---|
| [15c8a9] | 279 |         // no need update SignedOn, ref does not change
 | 
|---|
 | 280 |         emit moleculeIndexChanged(molid, newmoleculeId);
 | 
|---|
 | 281 |         break;
 | 
|---|
 | 282 |       }
 | 
|---|
 | 283 |       default:
 | 
|---|
| [2f7988] | 284 |         ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here.");
 | 
|---|
| [15c8a9] | 285 |         break;
 | 
|---|
 | 286 |     }
 | 
|---|
 | 287 |   } else if (dynamic_cast<atom *>(publisher) != NULL) {
 | 
|---|
 | 288 |     const atomId_t oldatomId = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
 | 
|---|
 | 289 |     switch (notification->getChannelNo()) {
 | 
|---|
 | 290 |       case AtomObservable::IndexChanged:
 | 
|---|
 | 291 |       {
 | 
|---|
 | 292 |         const atomId_t newatomId = dynamic_cast<atom *>(publisher)->getId();
 | 
|---|
 | 293 |         LOG(3, "DEBUG: InformationBoard got IndexChanged from atom " << oldatomId << " to " << newatomId);
 | 
|---|
| [41e287] | 294 |         atomObservedValues.changeIdentifier(oldatomId, newatomId);
 | 
|---|
| [15c8a9] | 295 |         // no need update SignedOn, ref does not change
 | 
|---|
 | 296 |         emit atomIndexChanged(oldatomId, newatomId);
 | 
|---|
 | 297 |         break;
 | 
|---|
 | 298 |       }
 | 
|---|
 | 299 |       default:
 | 
|---|
| [2f7988] | 300 |         ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here.");
 | 
|---|
| [15c8a9] | 301 |         break;
 | 
|---|
 | 302 |     }
 | 
|---|
 | 303 |   } else {
 | 
|---|
| [2f7988] | 304 |     ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - notification from unknown source.");
 | 
|---|
| [15c8a9] | 305 |   }
 | 
|---|
 | 306 | }
 | 
|---|
 | 307 | 
 | 
|---|
| [2f7988] | 308 | void QtObservedInstanceBoard::atomcountsubjectKilled(const atomId_t _atomid)
 | 
|---|
| [15c8a9] | 309 | {
 | 
|---|
| [68418e] | 310 |   if ((_atomid == lastremovedatomsmolecule.second) && (_atomid == lastremovedatom)) {
 | 
|---|
 | 311 |     LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << _atomid);
 | 
|---|
| [90821d] | 312 |     emit atomRemoved(lastremovedatomsmolecule.first, lastremovedatomsmolecule.second);
 | 
|---|
| [68418e] | 313 |   } else
 | 
|---|
| [90821d] | 314 |     ELOG(2, "QtObservedInstanceBoard::atomcountsubjectKilled() - id " << _atomid
 | 
|---|
| [68418e] | 315 |         << " not fitting with " << lastremovedatomsmolecule << " or " << lastremovedatom);
 | 
|---|
| [15c8a9] | 316 | }
 | 
|---|
 | 317 | 
 | 
|---|
| [2f7988] | 318 | void QtObservedInstanceBoard::moleculecountsubjectKilled(const moleculeId_t _molid)
 | 
|---|
| [15c8a9] | 319 | {
 | 
|---|
| [68418e] | 320 |   if (lastremovedmolecule == _molid) {
 | 
|---|
 | 321 |     LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << _molid);
 | 
|---|
 | 322 |     emit moleculeRemoved(_molid);
 | 
|---|
 | 323 |   } else
 | 
|---|
 | 324 |     ELOG(2, "QtObservedInstanceBoard::moleculecountsubjectKilled() - id " << _molid
 | 
|---|
 | 325 |         << " not fitting with " << lastremovedmolecule);
 | 
|---|
| [15c8a9] | 326 | }
 | 
|---|
 | 327 | 
 | 
|---|
| [41e287] | 328 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id)
 | 
|---|
| [15c8a9] | 329 | {
 | 
|---|
| [41e287] | 330 |   return atomObservedValues.get(_id);
 | 
|---|
| [15c8a9] | 331 | }
 | 
|---|
 | 332 | 
 | 
|---|
| [41e287] | 333 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id)
 | 
|---|
| [15c8a9] | 334 | {
 | 
|---|
| [41e287] | 335 |   return moleculeObservedValues.get(_id);
 | 
|---|
| [15c8a9] | 336 | }
 | 
|---|
 | 337 | 
 | 
|---|
| [68418e] | 338 | void QtObservedInstanceBoard::markObservedAtomAsConnected(const atomId_t _id)
 | 
|---|
| [15c8a9] | 339 | {
 | 
|---|
| [68418e] | 340 |   atomObservedValues.markObservedValuesAsConnected(_id);
 | 
|---|
| [15c8a9] | 341 | }
 | 
|---|
 | 342 | 
 | 
|---|
| [68418e] | 343 | void QtObservedInstanceBoard::markObservedAtomAsDisconnected(const atomId_t _id)
 | 
|---|
| [15c8a9] | 344 | {
 | 
|---|
| [68418e] | 345 |   atomObservedValues.markObservedValuesAsDisconnected(_id);
 | 
|---|
| [15c8a9] | 346 | }
 | 
|---|
| [98c35c] | 347 | 
 | 
|---|
| [68418e] | 348 | void QtObservedInstanceBoard::markObservedMoleculeAsConnected(const moleculeId_t _id)
 | 
|---|
| [98c35c] | 349 | {
 | 
|---|
| [68418e] | 350 |   moleculeObservedValues.markObservedValuesAsConnected(_id);
 | 
|---|
| [98c35c] | 351 | }
 | 
|---|
 | 352 | 
 | 
|---|
| [68418e] | 353 | void QtObservedInstanceBoard::markObservedMoleculeAsDisconnected(const moleculeId_t _id)
 | 
|---|
| [98c35c] | 354 | {
 | 
|---|
| [68418e] | 355 |   moleculeObservedValues.markObservedValuesAsDisconnected(_id);
 | 
|---|
| [98c35c] | 356 | }
 | 
|---|