| [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"
|
|---|
| [f2d5ce] | 53 | #include "UIElements/Qt4/InstanceBoard/ObservedMaximumAtomTrajectorySize.hpp"
|
|---|
| [41e287] | 54 | #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp"
|
|---|
| [15c8a9] | 55 | #include "World.hpp"
|
|---|
| [f2d5ce] | 56 | #include "WorldTime.hpp"
|
|---|
| 57 |
|
|---|
| 58 | // static entities
|
|---|
| 59 | const Observable::channels_t
|
|---|
| 60 | WorldTimeChannels(1, WorldTime::TimeChanged);
|
|---|
| 61 |
|
|---|
| 62 | const Observable::channels_t
|
|---|
| 63 | MaximumTrajectorySizeChannels(1, ObservedMaximumAtomTrajectorySize::MaximumChanged);
|
|---|
| [15c8a9] | 64 |
|
|---|
| [2f7988] | 65 | QtObservedInstanceBoard::QtObservedInstanceBoard(QWidget * _parent) :
|
|---|
| [15c8a9] | 66 | QWidget(_parent),
|
|---|
| [2f7988] | 67 | Observer("QtObservedInstanceBoard"),
|
|---|
| [15c8a9] | 68 | WorldSignedOn(false),
|
|---|
| [f2d5ce] | 69 | WorldTimeSignedOn(false),
|
|---|
| 70 | MaximumAtomTrajectorySizeSignedOn(false),
|
|---|
| [68418e] | 71 | atomObservedValues(
|
|---|
| 72 | "atom",
|
|---|
| 73 | *this,
|
|---|
| 74 | boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)),
|
|---|
| [b4bd0e] | 75 | bondObservedValues(
|
|---|
| 76 | "bond",
|
|---|
| 77 | *this,
|
|---|
| 78 | boost::bind(&QtObservedInstanceBoard::bondcountsubjectKilled, this, _1)),
|
|---|
| [68418e] | 79 | moleculeObservedValues(
|
|---|
| 80 | "molecule",
|
|---|
| 81 | *this,
|
|---|
| [f2d5ce] | 82 | boost::bind(&QtObservedInstanceBoard::moleculecountsubjectKilled, this, _1)),
|
|---|
| 83 | worldTime(
|
|---|
| 84 | WorldTime::getPointer(),
|
|---|
| 85 | WorldTime::getTime,
|
|---|
| 86 | "WorldTime",
|
|---|
| 87 | 0,
|
|---|
| 88 | WorldTimeChannels),
|
|---|
| 89 | maximumAtomTrajectorySize(
|
|---|
| 90 | ObservedMaximumAtomTrajectorySize::getPointer(),
|
|---|
| 91 | boost::bind(
|
|---|
| 92 | &ObservedMaximumAtomTrajectorySize::GetMaximumAtomTrajectorySize,
|
|---|
| 93 | boost::cref(ObservedMaximumAtomTrajectorySize::getConstInstance())
|
|---|
| 94 | ),
|
|---|
| 95 | "MaximumAtomTrajectorySize",
|
|---|
| 96 | 0,
|
|---|
| 97 | MaximumTrajectorySizeChannels)
|
|---|
| [68418e] | 98 | {
|
|---|
| [59eabc] | 99 | qRegisterMetaType<ObservedValue_Index_t>("ObservedValue_Index_t");
|
|---|
| [04c3a3] | 100 | qRegisterMetaType<QtObservedAtom::ptr>("QtObservedAtom::ptr");
|
|---|
| [b4bd0e] | 101 | qRegisterMetaType<QtObservedBond::ptr>("QtObservedBond::ptr");
|
|---|
| [04c3a3] | 102 | qRegisterMetaType<QtObservedMolecule::ptr>("QtObservedMolecule::ptr");
|
|---|
| 103 |
|
|---|
| [15c8a9] | 104 | // be first (besides ObservedValues to know about new insertions)
|
|---|
| 105 | World::getInstance().signOn(this, World::AtomInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
|
|---|
| 106 | World::getInstance().signOn(this, World::MoleculeInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
|
|---|
| 107 | WorldSignedOn = true;
|
|---|
| [f2d5ce] | 108 | WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);
|
|---|
| 109 | WorldTimeSignedOn = true;
|
|---|
| 110 | ObservedMaximumAtomTrajectorySize::getInstance().signOn(this, ObservedMaximumAtomTrajectorySize::MaximumChanged);
|
|---|
| 111 | MaximumAtomTrajectorySizeSignedOn = true;
|
|---|
| [15c8a9] | 112 | }
|
|---|
| 113 |
|
|---|
| [2f7988] | 114 | QtObservedInstanceBoard::~QtObservedInstanceBoard()
|
|---|
| [15c8a9] | 115 | {
|
|---|
| 116 | if (WorldSignedOn) {
|
|---|
| 117 | World::getInstance().signOff(this, World::AtomInserted);
|
|---|
| 118 | World::getInstance().signOff(this, World::MoleculeInserted);
|
|---|
| 119 | }
|
|---|
| [f2d5ce] | 120 | if (WorldTimeSignedOn) {
|
|---|
| 121 | WorldTime::getInstance().signOff(this, WorldTime::TimeChanged);
|
|---|
| 122 | }
|
|---|
| 123 | if (MaximumAtomTrajectorySizeSignedOn) {
|
|---|
| 124 | ObservedMaximumAtomTrajectorySize::getInstance().signOff(this, ObservedMaximumAtomTrajectorySize::MaximumChanged);
|
|---|
| 125 | }
|
|---|
| [b4bd0e] | 126 | // sign off from all remaining molecules, bonds, and atoms
|
|---|
| [15c8a9] | 127 | for (SignedOn_t::iterator iter = AtomSignedOn.begin(); !AtomSignedOn.empty();
|
|---|
| 128 | iter = AtomSignedOn.begin()) {
|
|---|
| 129 | (*iter)->signOff(this, atom::IndexChanged);
|
|---|
| [b4bd0e] | 130 | (*iter)->signOff(this, atom::BondsAdded);
|
|---|
| 131 | AtomSignedOn.erase(*iter);
|
|---|
| [15c8a9] | 132 | }
|
|---|
| 133 |
|
|---|
| 134 | for (SignedOn_t::iterator iter = MoleculeSignedOn.begin(); !MoleculeSignedOn.empty();
|
|---|
| 135 | iter = MoleculeSignedOn.begin()) {
|
|---|
| [5c9604] | 136 | (*iter)->signOff(this, molecule::IndexChanged);
|
|---|
| 137 | MoleculeSignedOn.erase(iter);
|
|---|
| [15c8a9] | 138 | }
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| [2f7988] | 141 | void QtObservedInstanceBoard::update(Observable *publisher)
|
|---|
| [15c8a9] | 142 | {
|
|---|
| 143 | ASSERT(0,
|
|---|
| [2f7988] | 144 | "QtObservedInstanceBoard::update() - we are not signed on to general updates.");
|
|---|
| [15c8a9] | 145 | }
|
|---|
| 146 |
|
|---|
| [2f7988] | 147 | void QtObservedInstanceBoard::subjectKilled(Observable *publisher)
|
|---|
| [15c8a9] | 148 | {
|
|---|
| 149 | SignedOn_t::iterator iter = AtomSignedOn.find(publisher);
|
|---|
| 150 | if ( iter != AtomSignedOn.end()) {
|
|---|
| 151 | LOG(3, "DEBUG: InstanceBoard got subjectKilled() from atom " << publisher);
|
|---|
| [b4bd0e] | 152 | AtomSignedOn.erase(iter); // only remove one
|
|---|
| [15c8a9] | 153 | } else {
|
|---|
| 154 | iter = MoleculeSignedOn.find(publisher);
|
|---|
| 155 | if ( iter != MoleculeSignedOn.end()) {
|
|---|
| 156 | LOG(3, "DEBUG: InstanceBoard got subjectKilled() from molecule " << publisher);
|
|---|
| 157 | MoleculeSignedOn.erase(iter);
|
|---|
| 158 | } else {
|
|---|
| [f2d5ce] | 159 | if (static_cast<World *>(publisher) == World::getPointer()) {
|
|---|
| 160 | WorldSignedOn = false;
|
|---|
| 161 | } else if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {
|
|---|
| 162 | WorldTimeSignedOn = false;
|
|---|
| 163 | } else if (static_cast<ObservedMaximumAtomTrajectorySize *>(publisher) == ObservedMaximumAtomTrajectorySize::getPointer()) {
|
|---|
| 164 | MaximumAtomTrajectorySizeSignedOn = false;
|
|---|
| 165 | } else {
|
|---|
| 166 | ASSERT(0,
|
|---|
| 167 | "QtObservedInstanceBoard::subjectKilled() - could not find signedOn for atom/molecule "+toString(publisher));
|
|---|
| 168 | }
|
|---|
| [15c8a9] | 169 | }
|
|---|
| 170 | }
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| [2f7988] | 173 | void QtObservedInstanceBoard::recieveNotification(Observable *publisher, Notification_ptr notification)
|
|---|
| [15c8a9] | 174 | {
|
|---|
| 175 | if (static_cast<World *>(publisher) == World::getPointer()) {
|
|---|
| 176 | switch (notification->getChannelNo()) {
|
|---|
| 177 | case World::MoleculeInserted:
|
|---|
| 178 | {
|
|---|
| 179 | const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
|---|
| 180 | #ifdef LOG_OBSERVER
|
|---|
| 181 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been inserted.";
|
|---|
| 182 | #endif
|
|---|
| 183 | LOG(3, "DEBUG: InformationBoard got moleculeInserted signal for molecule " << _id);
|
|---|
| 184 | const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
|
|---|
| 185 | getMolecule(MoleculeById(_id));
|
|---|
| 186 | if (_molecule != NULL) {
|
|---|
| [62a0ee] | 187 | LOG(3, "DEBUG: InformationBoard initializes QtObservedMolecule for " << _id);
|
|---|
| 188 | QtObservedMolecule::ptr observedmolecule(
|
|---|
| 189 | new QtObservedMolecule(
|
|---|
| 190 | _id,
|
|---|
| 191 | _molecule,
|
|---|
| 192 | *this));
|
|---|
| [bfd5d5f] | 193 | observedmolecule->setSelfRef(observedmolecule);
|
|---|
| [08a7ecc] | 194 | const ObservedValue_Index_t index = observedmolecule->getIndex();
|
|---|
| [59eabc] | 195 | moleculeObservedValues.insert(index, observedmolecule);
|
|---|
| [1a58ce] | 196 | moleculeids_lookup.left.insert( std::make_pair(_id, index) );
|
|---|
| [15c8a9] | 197 | // we need to check for index changes
|
|---|
| 198 | LOG(3, "DEBUG: InformationBoard signOn()s to molecule " << _id);
|
|---|
| 199 | _molecule->signOn(this, molecule::IndexChanged);
|
|---|
| 200 | MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
|
|---|
| 201 |
|
|---|
| [1b07b1] | 202 | emit moleculeInserted(observedmolecule);
|
|---|
| [15c8a9] | 203 | } else {
|
|---|
| [2f7988] | 204 | ELOG(1, "QtObservedInstanceBoard got MoleculeInserted for unknown molecule id " << _id);
|
|---|
| [15c8a9] | 205 | }
|
|---|
| 206 | break;
|
|---|
| 207 | }
|
|---|
| 208 | case World::AtomInserted:
|
|---|
| 209 | {
|
|---|
| 210 | const atomId_t _id = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
|---|
| 211 | #ifdef LOG_OBSERVER
|
|---|
| 212 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
|---|
| 213 | #endif
|
|---|
| 214 | LOG(3, "DEBUG: InformationBoard got atomInserted signal for atom " << _id);
|
|---|
| 215 | const atom * const _atom = const_cast<const World &>(World::getInstance()).
|
|---|
| 216 | getAtom(AtomById(_id));
|
|---|
| 217 | if (_atom!= NULL) {
|
|---|
| [62a0ee] | 218 | LOG(3, "DEBUG: InformationBoard initializes QtObservedAtom for " << _id);
|
|---|
| 219 | QtObservedAtom::ptr observedatom(
|
|---|
| 220 | new QtObservedAtom(_id, _atom, *this));
|
|---|
| [bfd5d5f] | 221 | observedatom->setSelfRef(observedatom);
|
|---|
| [08a7ecc] | 222 | const ObservedValue_Index_t index = observedatom->getIndex();
|
|---|
| [59eabc] | 223 | atomObservedValues.insert(index, observedatom);
|
|---|
| [1a58ce] | 224 | atomids_lookup.left.insert( std::make_pair(_id, index) );
|
|---|
| [15c8a9] | 225 | // we need to check for index changes
|
|---|
| 226 | LOG(3, "DEBUG: InformationBoard signOn()s to atom " << _id);
|
|---|
| 227 | _atom->signOn(this, atom::IndexChanged);
|
|---|
| [b4bd0e] | 228 | _atom->signOn(this, atom::BondsAdded);
|
|---|
| 229 | AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
|
|---|
| [15c8a9] | 230 | AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
|
|---|
| [1b07b1] | 231 | emit atomInserted(observedatom);
|
|---|
| [15c8a9] | 232 | } else {
|
|---|
| [2f7988] | 233 | ELOG(1, "QtObservedInstanceBoard got AtomInserted for unknown atom id " << _id);
|
|---|
| [15c8a9] | 234 | }
|
|---|
| 235 | break;
|
|---|
| 236 | }
|
|---|
| 237 | default:
|
|---|
| [2f7988] | 238 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for World.");
|
|---|
| [15c8a9] | 239 | break;
|
|---|
| 240 | }
|
|---|
| 241 | } else if (dynamic_cast<molecule *>(publisher) != NULL) {
|
|---|
| 242 | const moleculeId_t molid = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
|---|
| 243 | switch (notification->getChannelNo()) {
|
|---|
| 244 | case molecule::IndexChanged:
|
|---|
| 245 | {
|
|---|
| 246 | // molecule has changed its index
|
|---|
| 247 | const moleculeId_t newmoleculeId = dynamic_cast<molecule *>(publisher)->getId();
|
|---|
| 248 | LOG(3, "DEBUG: InformationBoard got IndexChanged from molecule " << molid << " to " << newmoleculeId);
|
|---|
| [59eabc] | 249 | {
|
|---|
| [1a58ce] | 250 | typename IdtoIndex_t<moleculeId_t>::left_iterator iter = moleculeids_lookup.left.find(molid);
|
|---|
| 251 | ASSERT( iter != moleculeids_lookup.left.end(),
|
|---|
| [59eabc] | 252 | "QtObservedInstanceBoard::recieveNotification() - mol id "
|
|---|
| 253 | +toString(molid)+" unknown to lookup.");
|
|---|
| 254 | const ObservedValue_Index_t index = iter->second;
|
|---|
| [1a58ce] | 255 | moleculeids_lookup.left.erase(iter);
|
|---|
| 256 | moleculeids_lookup.left.insert( std::pair<moleculeId_t, ObservedValue_Index_t>(newmoleculeId, index) );
|
|---|
| [59eabc] | 257 | }
|
|---|
| [15c8a9] | 258 | // no need update SignedOn, ref does not change
|
|---|
| 259 | emit moleculeIndexChanged(molid, newmoleculeId);
|
|---|
| 260 | break;
|
|---|
| 261 | }
|
|---|
| 262 | default:
|
|---|
| [f2d5ce] | 263 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for Molecule.");
|
|---|
| [15c8a9] | 264 | break;
|
|---|
| 265 | }
|
|---|
| 266 | } else if (dynamic_cast<atom *>(publisher) != NULL) {
|
|---|
| 267 | const atomId_t oldatomId = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
|---|
| 268 | switch (notification->getChannelNo()) {
|
|---|
| 269 | case AtomObservable::IndexChanged:
|
|---|
| 270 | {
|
|---|
| 271 | const atomId_t newatomId = dynamic_cast<atom *>(publisher)->getId();
|
|---|
| 272 | LOG(3, "DEBUG: InformationBoard got IndexChanged from atom " << oldatomId << " to " << newatomId);
|
|---|
| [59eabc] | 273 | {
|
|---|
| [1a58ce] | 274 | typename IdtoIndex_t<atomId_t>::left_iterator iter = atomids_lookup.left.find(oldatomId);
|
|---|
| 275 | ASSERT( iter != atomids_lookup.left.end(),
|
|---|
| [59eabc] | 276 | "QtObservedInstanceBoard::recieveNotification() - atom id "
|
|---|
| 277 | +toString(oldatomId)+" unknown to lookup.");
|
|---|
| 278 | const ObservedValue_Index_t index = iter->second;
|
|---|
| [1a58ce] | 279 | atomids_lookup.left.erase(iter);
|
|---|
| 280 | atomids_lookup.left.insert( std::pair<atomId_t, ObservedValue_Index_t>(newatomId, index) );
|
|---|
| [59eabc] | 281 | }
|
|---|
| [15c8a9] | 282 | // no need update SignedOn, ref does not change
|
|---|
| 283 | emit atomIndexChanged(oldatomId, newatomId);
|
|---|
| 284 | break;
|
|---|
| 285 | }
|
|---|
| [b4bd0e] | 286 | case AtomObservable::BondsAdded:
|
|---|
| 287 | {
|
|---|
| 288 | const atom * _atom = dynamic_cast<atom *>(publisher);
|
|---|
| 289 | const atomId_t _id = _atom->getId();
|
|---|
| 290 | #ifdef LOG_OBSERVER
|
|---|
| 291 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
|---|
| 292 | #endif
|
|---|
| 293 | LOG(3, "DEBUG: InformationBoard got bondInserted signal for atom " << _id);
|
|---|
| 294 | if (_atom != NULL) {
|
|---|
| 295 | // find the new bond by simply taking the last added to the list
|
|---|
| 296 | const BondList &ListOfBonds = _atom->getListOfBonds();
|
|---|
| 297 | const bond::ptr bondref = ListOfBonds.back();
|
|---|
| [4112691] | 298 |
|
|---|
| 299 | // check whether bond is already present, cause we get BondsAdded from both atoms
|
|---|
| [08a7ecc] | 300 | const bondId_t bondid =
|
|---|
| 301 | std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId());
|
|---|
| 302 | if (!bondids_lookup.left.count(bondid)) {
|
|---|
| 303 | const QtObservedAtom::ptr leftatom = getObservedAtom(bondref->leftatom->getId());
|
|---|
| [4112691] | 304 | ASSERT( leftatom,
|
|---|
| 305 | "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
|
|---|
| [08a7ecc] | 306 | const QtObservedAtom::ptr rightatom = getObservedAtom(bondref->rightatom->getId());
|
|---|
| [4112691] | 307 | ASSERT( rightatom,
|
|---|
| 308 | "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
|
|---|
| 309 | LOG(3, "DEBUG: InformationBoard initializes QtObservedBond for " << bondid);
|
|---|
| 310 | QtObservedBond::ptr observedbond(
|
|---|
| 311 | new QtObservedBond(bondid, bondref, leftatom, rightatom, *this));
|
|---|
| [08a7ecc] | 312 | const ObservedValue_Index_t index = observedbond->getIndex();
|
|---|
| [4112691] | 313 | bondObservedValues.insert(index, observedbond);
|
|---|
| 314 | bondids_lookup.left.insert( std::make_pair(bondid, index) );
|
|---|
| 315 | emit bondInserted(observedbond);
|
|---|
| 316 | }
|
|---|
| [b4bd0e] | 317 | } else {
|
|---|
| 318 | ELOG(1, "QtObservedInstanceBoard got BondsAdded for unknown atom id " << _id);
|
|---|
| 319 | }
|
|---|
| 320 | break;
|
|---|
| 321 | }
|
|---|
| [15c8a9] | 322 | default:
|
|---|
| [f2d5ce] | 323 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for Atom.");
|
|---|
| [15c8a9] | 324 | break;
|
|---|
| 325 | }
|
|---|
| [f2d5ce] | 326 | } else if (static_cast<ObservedMaximumAtomTrajectorySize *>(publisher) == ObservedMaximumAtomTrajectorySize::getPointer()) {
|
|---|
| 327 | switch (notification->getChannelNo()) {
|
|---|
| 328 | case ObservedMaximumAtomTrajectorySize::MaximumChanged:
|
|---|
| 329 | {
|
|---|
| 330 | #ifdef LOG_OBSERVER
|
|---|
| 331 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that maximum atom tractory size has changed.";
|
|---|
| 332 | #endif
|
|---|
| 333 | LOG(3, "DEBUG: InformationBoard got MaximumChanged signal from ObservedMaximumAtomTrajectorySize.");
|
|---|
| 334 | emit MaximumAtomTrajectoryChanged();
|
|---|
| 335 | break;
|
|---|
| 336 | }
|
|---|
| 337 | default:
|
|---|
| 338 | {
|
|---|
| 339 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for ObservedMaximumAtomTrajectorySize.");
|
|---|
| 340 | break;
|
|---|
| 341 | }
|
|---|
| 342 | }
|
|---|
| 343 | } else if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {
|
|---|
| 344 | switch (notification->getChannelNo()) {
|
|---|
| 345 | case WorldTime::TimeChanged:
|
|---|
| 346 | {
|
|---|
| 347 | #ifdef LOG_OBSERVER
|
|---|
| 348 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that WorldTime has changed.";
|
|---|
| 349 | #endif
|
|---|
| 350 | LOG(3, "DEBUG: InformationBoard got TimeChanged signal from WorldTime.");
|
|---|
| 351 | emit WorldTimeChanged();
|
|---|
| 352 | break;
|
|---|
| 353 | }
|
|---|
| 354 | default:
|
|---|
| 355 | {
|
|---|
| 356 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here for WorldTime.");
|
|---|
| 357 | break;
|
|---|
| 358 | }
|
|---|
| 359 | }
|
|---|
| [15c8a9] | 360 | } else {
|
|---|
| [2f7988] | 361 | ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - notification from unknown source.");
|
|---|
| [15c8a9] | 362 | }
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| [1a58ce] | 365 | const atomId_t QtObservedInstanceBoard::getAtomIdToIndex(ObservedValue_Index_t _id) const
|
|---|
| 366 | {
|
|---|
| 367 | typename IdtoIndex_t<atomId_t>::right_const_iterator iter = atomids_lookup.right.find(_id);
|
|---|
| [006f6a] | 368 | if (iter != atomids_lookup.right.end())
|
|---|
| 369 | return iter->second;
|
|---|
| 370 | else
|
|---|
| 371 | return (atomId_t)-1;
|
|---|
| [1a58ce] | 372 | }
|
|---|
| 373 |
|
|---|
| [b4bd0e] | 374 | const QtObservedInstanceBoard::bondId_t
|
|---|
| 375 | QtObservedInstanceBoard::getBondIdToIndex(ObservedValue_Index_t _id) const
|
|---|
| 376 | {
|
|---|
| 377 | typename IdtoIndex_t<bondId_t>::right_const_iterator iter = bondids_lookup.right.find(_id);
|
|---|
| [006f6a] | 378 | if (iter != bondids_lookup.right.end())
|
|---|
| 379 | return iter->second;
|
|---|
| 380 | else
|
|---|
| 381 | return QtObservedInstanceBoard::bondId_t(std::make_pair( (atomId_t)-1, (atomId_t)-1) );
|
|---|
| [b4bd0e] | 382 | }
|
|---|
| 383 |
|
|---|
| [1a58ce] | 384 | const moleculeId_t QtObservedInstanceBoard::getMoleculeIdToIndex(ObservedValue_Index_t _id) const
|
|---|
| 385 | {
|
|---|
| 386 | typename IdtoIndex_t<moleculeId_t>::right_const_iterator iter = moleculeids_lookup.right.find(_id);
|
|---|
| [006f6a] | 387 | if (iter != moleculeids_lookup.right.end())
|
|---|
| 388 | return iter->second;
|
|---|
| 389 | else
|
|---|
| 390 | return (moleculeId_t)-1;
|
|---|
| [1a58ce] | 391 | }
|
|---|
| 392 |
|
|---|
| [b4bd0e] | 393 | void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id)
|
|---|
| 394 | {
|
|---|
| 395 | LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << getAtomIdToIndex(_id));
|
|---|
| 396 | emit atomRemoved(_id);
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | void QtObservedInstanceBoard::bondcountsubjectKilled(ObservedValue_Index_t _id)
|
|---|
| 400 | {
|
|---|
| 401 | LOG(3, "DEBUG: InstanceBoard emits bondRemoved for " << getBondIdToIndex(_id));
|
|---|
| 402 | emit bondRemoved(_id);
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id)
|
|---|
| 406 | {
|
|---|
| 407 | LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << getMoleculeIdToIndex(_id));
|
|---|
| 408 | emit moleculeRemoved(_id);
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| [41e287] | 411 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id)
|
|---|
| [15c8a9] | 412 | {
|
|---|
| [e4b13a] | 413 | typename IdtoIndex_t<atomId_t>::left_iterator iter = atomids_lookup.left.find(_id);
|
|---|
| 414 | if (iter == atomids_lookup.left.end())
|
|---|
| 415 | return QtObservedAtom::ptr();
|
|---|
| 416 | else
|
|---|
| 417 | return atomObservedValues.get(iter->second);
|
|---|
| [7f1c00] | 418 | }
|
|---|
| 419 |
|
|---|
| [3054f4a] | 420 | QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(ObservedValue_Index_t _id)
|
|---|
| 421 | {
|
|---|
| 422 | return atomObservedValues.get(_id);
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| [b4bd0e] | 425 | QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(const bondId_t _id)
|
|---|
| 426 | {
|
|---|
| [e4b13a] | 427 | typename IdtoIndex_t<bondId_t>::left_iterator iter = bondids_lookup.left.find(_id);
|
|---|
| 428 | if (iter == bondids_lookup.left.end())
|
|---|
| 429 | return QtObservedBond::ptr();
|
|---|
| 430 | else
|
|---|
| 431 | return bondObservedValues.get(iter->second);
|
|---|
| [b4bd0e] | 432 | }
|
|---|
| 433 |
|
|---|
| 434 | QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(ObservedValue_Index_t _id)
|
|---|
| 435 | {
|
|---|
| 436 | return bondObservedValues.get(_id);
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| [41e287] | 439 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id)
|
|---|
| [15c8a9] | 440 | {
|
|---|
| [e4b13a] | 441 | typename IdtoIndex_t<moleculeId_t>::left_iterator iter = moleculeids_lookup.left.find(_id);
|
|---|
| 442 | if (iter == moleculeids_lookup.left.end())
|
|---|
| 443 | return QtObservedMolecule::ptr();
|
|---|
| 444 | else
|
|---|
| 445 | return moleculeObservedValues.get(iter->second);
|
|---|
| [7f1c00] | 446 | }
|
|---|
| 447 |
|
|---|
| [3054f4a] | 448 | QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(ObservedValue_Index_t _id)
|
|---|
| 449 | {
|
|---|
| 450 | return moleculeObservedValues.get(_id);
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| [f2d5ce] | 453 | const ObservedValue<unsigned int>& QtObservedInstanceBoard::getObservedWorldTime()
|
|---|
| 454 | {
|
|---|
| 455 | return worldTime;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | const ObservedValue<int>& QtObservedInstanceBoard::getObservedMaximumAtomTrajectorySize()
|
|---|
| 459 | {
|
|---|
| 460 | return maximumAtomTrajectorySize;
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| [59eabc] | 463 | void QtObservedInstanceBoard::markObservedAtomAsConnected(ObservedValue_Index_t _id)
|
|---|
| [15c8a9] | 464 | {
|
|---|
| [68418e] | 465 | atomObservedValues.markObservedValuesAsConnected(_id);
|
|---|
| [15c8a9] | 466 | }
|
|---|
| 467 |
|
|---|
| [59eabc] | 468 | void QtObservedInstanceBoard::markObservedAtomAsDisconnected(ObservedValue_Index_t _id)
|
|---|
| [15c8a9] | 469 | {
|
|---|
| [68418e] | 470 | atomObservedValues.markObservedValuesAsDisconnected(_id);
|
|---|
| [15c8a9] | 471 | }
|
|---|
| [98c35c] | 472 |
|
|---|
| [59eabc] | 473 | void QtObservedInstanceBoard::markObservedAtomForErase(ObservedValue_Index_t _id)
|
|---|
| [4e6ffe] | 474 | {
|
|---|
| 475 | atomObservedValues.eraseObservedValues(_id);
|
|---|
| [1a58ce] | 476 | atomids_lookup.right.erase(_id);
|
|---|
| [4e6ffe] | 477 | }
|
|---|
| 478 |
|
|---|
| [b4bd0e] | 479 | void QtObservedInstanceBoard::markObservedBondAsConnected(ObservedValue_Index_t _id)
|
|---|
| 480 | {
|
|---|
| 481 | bondObservedValues.markObservedValuesAsConnected(_id);
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | void QtObservedInstanceBoard::markObservedBondAsDisconnected(ObservedValue_Index_t _id)
|
|---|
| 485 | {
|
|---|
| 486 | bondObservedValues.markObservedValuesAsDisconnected(_id);
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | void QtObservedInstanceBoard::markObservedBondForErase(ObservedValue_Index_t _id)
|
|---|
| 490 | {
|
|---|
| 491 | bondObservedValues.eraseObservedValues(_id);
|
|---|
| 492 | bondids_lookup.right.erase(_id);
|
|---|
| 493 | }
|
|---|
| 494 |
|
|---|
| [59eabc] | 495 | void QtObservedInstanceBoard::markObservedMoleculeAsConnected(ObservedValue_Index_t _id)
|
|---|
| [98c35c] | 496 | {
|
|---|
| [68418e] | 497 | moleculeObservedValues.markObservedValuesAsConnected(_id);
|
|---|
| [98c35c] | 498 | }
|
|---|
| 499 |
|
|---|
| [59eabc] | 500 | void QtObservedInstanceBoard::markObservedMoleculeAsDisconnected(ObservedValue_Index_t _id)
|
|---|
| [98c35c] | 501 | {
|
|---|
| [68418e] | 502 | moleculeObservedValues.markObservedValuesAsDisconnected(_id);
|
|---|
| [98c35c] | 503 | }
|
|---|
| [4e6ffe] | 504 |
|
|---|
| [59eabc] | 505 | void QtObservedInstanceBoard::markObservedMoleculeForErase(ObservedValue_Index_t _id)
|
|---|
| [4e6ffe] | 506 | {
|
|---|
| 507 | moleculeObservedValues.eraseObservedValues(_id);
|
|---|
| [1a58ce] | 508 | moleculeids_lookup.right.erase(_id);
|
|---|
| [4e6ffe] | 509 | }
|
|---|