[907636] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[5aaa43] | 5 | * Copyright (C) 2013 Frederik Heber. All rights reserved.
|
---|
[94d5ac6] | 6 | *
|
---|
| 7 | *
|
---|
| 8 | * This file is part of MoleCuilder.
|
---|
| 9 | *
|
---|
| 10 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation, either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
[907636] | 22 | */
|
---|
| 23 |
|
---|
| 24 | /*
|
---|
| 25 | * GLWorldScene.cpp
|
---|
| 26 | *
|
---|
| 27 | * This is based on the Qt3D example "teaservice", specifically parts of teaservice.cpp.
|
---|
| 28 | *
|
---|
| 29 | * Created on: Aug 17, 2011
|
---|
| 30 | * Author: heber
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | // include config.h
|
---|
| 34 | #ifdef HAVE_CONFIG_H
|
---|
| 35 | #include <config.h>
|
---|
| 36 | #endif
|
---|
| 37 |
|
---|
| 38 | #include "GLWorldScene.hpp"
|
---|
[d1196d] | 39 | #include <Qt3D/qglview.h>
|
---|
[bca99d] | 40 | #include <Qt3D/qglbuilder.h>
|
---|
| 41 | #include <Qt3D/qglscenenode.h>
|
---|
| 42 | #include <Qt3D/qglsphere.h>
|
---|
| 43 | #include <Qt3D/qglcylinder.h>
|
---|
[907636] | 44 |
|
---|
[015f8c] | 45 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp"
|
---|
| 46 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp"
|
---|
| 47 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp"
|
---|
| 48 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp"
|
---|
| 49 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_shape.hpp"
|
---|
| 50 |
|
---|
[2f7988] | 51 | #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
|
---|
[907636] | 52 |
|
---|
| 53 | #include "CodePatterns/MemDebug.hpp"
|
---|
| 54 |
|
---|
[7188b1] | 55 | #include "CodePatterns/Log.hpp"
|
---|
| 56 |
|
---|
[f1b5ca] | 57 | #include <boost/assign.hpp>
|
---|
| 58 |
|
---|
[0e9ffe] | 59 | #include "Actions/SelectionAction/Atoms/AtomByIdAction.hpp"
|
---|
[89643d] | 60 | #include "Actions/SelectionAction/Atoms/NotAtomByIdAction.hpp"
|
---|
[6966b7] | 61 | #include "Actions/SelectionAction/Molecules/MoleculeByIdAction.hpp"
|
---|
| 62 | #include "Actions/SelectionAction/Molecules/NotMoleculeByIdAction.hpp"
|
---|
[6f0841] | 63 | #include "Atom/atom.hpp"
|
---|
[7188b1] | 64 | #include "Bond/bond.hpp"
|
---|
[89643d] | 65 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
[8c001a] | 66 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
[37b2575] | 67 | #include "Helpers/helpers.hpp"
|
---|
[85c36d] | 68 | #include "Shapes/ShapeRegistry.hpp"
|
---|
[907636] | 69 | #include "molecule.hpp"
|
---|
| 70 | #include "World.hpp"
|
---|
| 71 |
|
---|
[2ad1ec] | 72 | #include <iostream>
|
---|
| 73 |
|
---|
[ce7fdc] | 74 | using namespace MoleCuilder;
|
---|
[907636] | 75 |
|
---|
[15c8a9] | 76 | GLWorldScene::GLWorldScene(
|
---|
[2f7988] | 77 | QtObservedInstanceBoard * _board,
|
---|
[15c8a9] | 78 | QObject *parent) :
|
---|
| 79 | QObject(parent),
|
---|
[a13f2b] | 80 | BondNodeParentMaps(std::vector<BondNodeParentMap_t>(2)),
|
---|
[15c8a9] | 81 | selectionMode(SelectAtom),
|
---|
| 82 | board(_board)
|
---|
[907636] | 83 | {
|
---|
[f1b5ca] | 84 | qRegisterMetaType<atomId_t>("atomId_t");
|
---|
| 85 | qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");
|
---|
| 86 |
|
---|
[72a4c1] | 87 | int sphereDetails[] = {5, 3, 2, 0};
|
---|
| 88 | int cylinderDetails[] = {16, 8, 6, 3};
|
---|
| 89 | for (int i=0;i<GLMoleculeObject::DETAILTYPES_MAX;i++){
|
---|
| 90 | QGLBuilder emptyBuilder;
|
---|
[8c001a] | 91 | GLMoleculeObject::meshEmpty[i] = emptyBuilder.finalizedSceneNode();
|
---|
[72a4c1] | 92 | QGLBuilder sphereBuilder;
|
---|
| 93 | sphereBuilder << QGLSphere(2.0, sphereDetails[i]);
|
---|
[8c001a] | 94 | GLMoleculeObject::meshSphere[i] = sphereBuilder.finalizedSceneNode();
|
---|
| 95 | GLMoleculeObject::meshSphere[i]->setOption(QGLSceneNode::CullBoundingBox, true);
|
---|
[72a4c1] | 96 | QGLBuilder cylinderBuilder;
|
---|
| 97 | cylinderBuilder << QGLCylinder(.25,.25,1.0,cylinderDetails[i]);
|
---|
[8c001a] | 98 | GLMoleculeObject::meshCylinder[i] = cylinderBuilder.finalizedSceneNode();
|
---|
| 99 | GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true);
|
---|
[72a4c1] | 100 | }
|
---|
[1b07b1] | 101 | connect(board, SIGNAL(moleculeInserted(QtObservedMolecule::ptr)),
|
---|
[bd6768] | 102 | this, SLOT(insertMolecule(QtObservedMolecule::ptr)));
|
---|
[f91ef6] | 103 | connect(board, SIGNAL(moleculeRemoved(ObservedValue_Index_t)),
|
---|
[bd6768] | 104 | this, SLOT(removeMolecule(ObservedValue_Index_t)));
|
---|
| 105 |
|
---|
[59f1bc] | 106 | connect(board, SIGNAL(atomInserted(QtObservedAtom::ptr)),
|
---|
[bd6768] | 107 | this, SLOT(connectAtom(QtObservedAtom::ptr)), Qt::DirectConnection);
|
---|
| 108 | connect(this, SIGNAL(atomConnected(QtObservedAtom::ptr)),
|
---|
| 109 | this, SLOT(insertAtom(QtObservedAtom::ptr)));
|
---|
[f91ef6] | 110 | connect(board, SIGNAL(atomRemoved(ObservedValue_Index_t)),
|
---|
[bd6768] | 111 | this, SLOT(removeAtom(ObservedValue_Index_t)));
|
---|
| 112 |
|
---|
[96f14a] | 113 | connect(board, SIGNAL(bondInserted(QtObservedBond::ptr)),
|
---|
[bd6768] | 114 | this, SLOT(connectBond(QtObservedBond::ptr)), Qt::DirectConnection);
|
---|
| 115 | connect(this, SIGNAL(bondConnected(QtObservedBond::ptr)),
|
---|
| 116 | this, SLOT(insertBond(QtObservedBond::ptr)));
|
---|
[96f14a] | 117 | connect(board, SIGNAL(bondRemoved(ObservedValue_Index_t)),
|
---|
[bd6768] | 118 | this, SLOT(removeBond(ObservedValue_Index_t)));
|
---|
[0a6ff9] | 119 |
|
---|
[f714763] | 120 | // connect(this, SIGNAL(updated()), this, SLOT(update()));
|
---|
[907636] | 121 | }
|
---|
| 122 |
|
---|
| 123 | GLWorldScene::~GLWorldScene()
|
---|
[7188b1] | 124 | {
|
---|
| 125 | // remove all elements
|
---|
| 126 | GLMoleculeObject::cleanMaterialMap();
|
---|
| 127 | }
|
---|
[907636] | 128 |
|
---|
[bd6768] | 129 | void GLWorldScene::clickAtom(atomId_t no)
|
---|
[8c001a] | 130 | {
|
---|
[bd6768] | 131 | LOG(3, "INFO: GLWorldScene - atom " << no << " has been clicked.");
|
---|
[f01769] | 132 | const atom * const Walker = const_cast<const World &>(World::getInstance()).
|
---|
| 133 | getAtom(AtomById(no));
|
---|
[369cb1] | 134 | ASSERT( Walker != NULL,
|
---|
[bd6768] | 135 | "GLWorldScene::clickAtom() - clicked atom has disappeared.");
|
---|
[8c001a] | 136 | if (selectionMode == SelectAtom){
|
---|
| 137 | if (!World::getInstance().isSelected(Walker))
|
---|
| 138 | SelectionAtomById(std::vector<atomId_t>(1,no));
|
---|
| 139 | else
|
---|
| 140 | SelectionNotAtomById(std::vector<atomId_t>(1,no));
|
---|
| 141 | }else if (selectionMode == SelectMolecule){
|
---|
| 142 | const molecule *mol = Walker->getMolecule();
|
---|
| 143 | ASSERT(mol, "Atom without molecule has been clicked.");
|
---|
[d7cad1] | 144 | molids_t ids(1, mol->getId());
|
---|
[8c001a] | 145 | if (!World::getInstance().isSelected(mol))
|
---|
[d7cad1] | 146 | SelectionMoleculeById(ids);
|
---|
[8c001a] | 147 | else
|
---|
[d7cad1] | 148 | SelectionNotMoleculeById(ids);
|
---|
[8c001a] | 149 | }
|
---|
| 150 | emit clicked(no);
|
---|
| 151 | }
|
---|
| 152 |
|
---|
[bd6768] | 153 | /** Prepares adding an atom to the scene
|
---|
| 154 | *
|
---|
| 155 | * We need to listen to moleculeChanged() in order to properly re-parent()
|
---|
| 156 | * this QObject
|
---|
| 157 | *
|
---|
| 158 | * @param _atom atom to connect
|
---|
| 159 | */
|
---|
| 160 | void GLWorldScene::connectAtom(QtObservedAtom::ptr _atom)
|
---|
| 161 | {
|
---|
| 162 | connect(_atom.get(), SIGNAL(moleculeChanged()), this, SLOT(reparentAtom()));
|
---|
| 163 |
|
---|
| 164 | {
|
---|
| 165 | const ObservedValue_Index_t atomid = _atom->getIndex();
|
---|
| 166 | boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
|
---|
[a13f2b] | 167 | AtomNodeParentMap.left.insert( std::make_pair(atomid, (ObservedValue_Index_t)NULL) );
|
---|
[bd6768] | 168 | }
|
---|
| 169 |
|
---|
| 170 | emit atomConnected(_atom);
|
---|
| 171 | }
|
---|
| 172 |
|
---|
[f1b5ca] | 173 | /** Adds an atom to the scene.
|
---|
[59f1bc] | 174 | *
|
---|
[f1b5ca] | 175 | * @param _atom atom to add
|
---|
[9c259e] | 176 | */
|
---|
[bd6768] | 177 | void GLWorldScene::insertAtom(QtObservedAtom::ptr _atom)
|
---|
[9c259e] | 178 | {
|
---|
[f1b5ca] | 179 | LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "
|
---|
| 180 | << _atom->getAtomIndex());
|
---|
| 181 |
|
---|
[f91ef6] | 182 | const ObservedValue_Index_t atomid = _atom->getIndex();
|
---|
[bd6768] | 183 | QObject *parent = static_cast<QObject *>(this);
|
---|
| 184 | GLMoleculeObject_atom *atomObject = NULL;
|
---|
| 185 | {
|
---|
| 186 | boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
|
---|
[a13f2b] | 187 | AtomNodeParentMap_t::left_iterator parentiter = AtomNodeParentMap.left.find(atomid);
|
---|
| 188 | ASSERT (parentiter != AtomNodeParentMap.left.end(),
|
---|
[502614] | 189 | "GLWorldScene::insertAtom() - parent to atom id "+toString(atomid)+" unknown?");
|
---|
| 190 | const ObservedValue_Index_t parentindex = parentiter->second;
|
---|
| 191 | if (parentindex != (ObservedValue_Index_t)NULL) {
|
---|
| 192 | const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentindex);
|
---|
| 193 | if (moliter != MoleculesinSceneMap.end())
|
---|
| 194 | parent = moliter->second;
|
---|
| 195 | }
|
---|
[bd6768] | 196 |
|
---|
| 197 | atomObject = new GLMoleculeObject_atom(
|
---|
| 198 | GLMoleculeObject::meshSphere,
|
---|
| 199 | parent,
|
---|
| 200 | _atom);
|
---|
| 201 | ASSERT( atomObject != NULL,
|
---|
| 202 | "GLWorldScene::atomInserted - could not create atom object for "
|
---|
| 203 | +toString(_atom->getAtomIndex()));
|
---|
| 204 | }
|
---|
[f1b5ca] | 205 | AtomNodeMap::iterator iter = AtomsinSceneMap.find(atomid);
|
---|
| 206 | ASSERT(iter == AtomsinSceneMap.end(),
|
---|
[bd6768] | 207 | "GLWorldScene::insertAtom - same atom with id "
|
---|
[f1b5ca] | 208 | +toString(_atom->getAtomIndex())+" added again.");
|
---|
| 209 | AtomsinSceneMap.insert( make_pair(atomid, atomObject) );
|
---|
| 210 |
|
---|
[bd6768] | 211 | connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(clickAtom(atomId_t)));
|
---|
[f1b5ca] | 212 | connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
|
---|
| 213 | connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
|
---|
| 214 | connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
|
---|
| 215 |
|
---|
| 216 | emit changed();
|
---|
| 217 | emit changeOccured();
|
---|
[59f1bc] | 218 | }
|
---|
| 219 |
|
---|
[f1b5ca] | 220 | /** Removes an atom.
|
---|
[59f1bc] | 221 | *
|
---|
[f1b5ca] | 222 | * @param _atomid index of the atom that is removed
|
---|
[59f1bc] | 223 | */
|
---|
[bd6768] | 224 | void GLWorldScene::removeAtom(ObservedValue_Index_t _atomid)
|
---|
[59f1bc] | 225 | {
|
---|
[f1b5ca] | 226 | LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_atomid)+".");
|
---|
| 227 | // bonds are removed by signal coming from ~bond
|
---|
| 228 |
|
---|
| 229 | // remove atoms
|
---|
| 230 | AtomNodeMap::iterator iter = AtomsinSceneMap.find(_atomid);
|
---|
| 231 | ASSERT(iter != AtomsinSceneMap.end(),
|
---|
[bd6768] | 232 | "GLWorldScene::removeAtom() - atom "+toString(_atomid)+" not on display.");
|
---|
[f1b5ca] | 233 | GLMoleculeObject_atom *atomObject = iter->second;
|
---|
| 234 | AtomsinSceneMap.erase(iter);
|
---|
| 235 | delete atomObject;
|
---|
[bd6768] | 236 | {
|
---|
| 237 | boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
|
---|
[a13f2b] | 238 | AtomNodeParentMap.left.erase(_atomid);
|
---|
[bd6768] | 239 | }
|
---|
[f1b5ca] | 240 | emit changed();
|
---|
| 241 | emit changeOccured();
|
---|
[59f1bc] | 242 | }
|
---|
| 243 |
|
---|
[bd6768] | 244 | /** Prepares adding a bond to the scene
|
---|
| 245 | *
|
---|
| 246 | * We need to listen to moleculeChanged() in order to properly re-parent()
|
---|
| 247 | * this QObject
|
---|
| 248 | *
|
---|
| 249 | * @param _bond bond to connect
|
---|
| 250 | */
|
---|
| 251 | void GLWorldScene::connectBond(QtObservedBond::ptr _bond)
|
---|
| 252 | {
|
---|
| 253 | connect(_bond.get(), SIGNAL(leftmoleculeChanged()), this, SLOT(reparentBondLeft()));
|
---|
| 254 | connect(_bond.get(), SIGNAL(rightmoleculeChanged()), this, SLOT(reparentBondRight()));
|
---|
| 255 |
|
---|
| 256 | {
|
---|
| 257 | const ObservedValue_Index_t bondid = _bond->getIndex();
|
---|
| 258 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
[502614] | 259 | if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL))
|
---|
[a13f2b] | 260 | BondNodeParentMaps[0].left.insert(
|
---|
| 261 | std::make_pair(bondid, _bond->getLeftAtom()->getMoleculeRef()->getIndex()) );
|
---|
| 262 | else
|
---|
| 263 | BondNodeParentMaps[0].left.insert(
|
---|
| 264 | std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
|
---|
[502614] | 265 | if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL))
|
---|
[a13f2b] | 266 | BondNodeParentMaps[1].left.insert(
|
---|
| 267 | std::make_pair(bondid, _bond->getRightAtom()->getMoleculeRef()->getIndex()) );
|
---|
| 268 | else
|
---|
| 269 | BondNodeParentMaps[1].left.insert(
|
---|
| 270 | std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
|
---|
[bd6768] | 271 | }
|
---|
| 272 |
|
---|
| 273 | emit bondConnected(_bond);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[f1b5ca] | 276 | /** Adds a bond to the scene.
|
---|
[96f14a] | 277 | *
|
---|
[f1b5ca] | 278 | * @param _bond bond to add
|
---|
[96f14a] | 279 | */
|
---|
[bd6768] | 280 | void GLWorldScene::insertBond(QtObservedBond::ptr _bond)
|
---|
[96f14a] | 281 | {
|
---|
[f1b5ca] | 282 | static const std::vector< GLMoleculeObject_bond::SideOfBond > bondsides =
|
---|
| 283 | boost::assign::list_of<GLMoleculeObject_bond::SideOfBond>
|
---|
| 284 | (GLMoleculeObject_bond::left)
|
---|
| 285 | (GLMoleculeObject_bond::right);
|
---|
[bd6768] | 286 | LOG(3, "INFO: GLWorldScene::insertBond() - Adding bonds " << _bond->getBondIndex());
|
---|
[f1b5ca] | 287 |
|
---|
[96f14a] | 288 | const ObservedValue_Index_t bondid = _bond->getIndex();
|
---|
[a13f2b] | 289 | #ifdef NDEBUG
|
---|
| 290 | BondNodeMap::iterator iter = BondsinSceneMap.find(bondid);
|
---|
| 291 | ASSERT( iter == BondsinSceneMap.end(),
|
---|
| 292 | "GLWorldScene::insertBond() - bond "+toString(bondid)+" is already known.");
|
---|
| 293 | #endif
|
---|
[bd6768] | 294 | {
|
---|
| 295 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
[a13f2b] | 296 | for (size_t i=0;i<2;++i) {
|
---|
| 297 | BondNodeParentMap_t::left_iterator parentiter = BondNodeParentMaps[i].left.find(bondid);
|
---|
| 298 | ASSERT (parentiter != BondNodeParentMaps[i].left.end(),
|
---|
| 299 | "GLWorldScene::insertBond() - parent to bond id "+toString(bondid)+" unknown?");
|
---|
| 300 | QObject *parent = this;
|
---|
| 301 | if (parentiter->second != (ObservedValue_Index_t)NULL) {
|
---|
| 302 | const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentiter->second);
|
---|
[502614] | 303 | if (moliter != MoleculesinSceneMap.end())
|
---|
[a13f2b] | 304 | parent = moliter->second;
|
---|
[502614] | 305 | }
|
---|
[bd6768] | 306 |
|
---|
| 307 | GLMoleculeObject_bond *bondObject = new GLMoleculeObject_bond(
|
---|
| 308 | GLMoleculeObject::meshCylinder,
|
---|
[a13f2b] | 309 | parent,
|
---|
[bd6768] | 310 | _bond,
|
---|
| 311 | bondsides[i]);
|
---|
| 312 | connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));
|
---|
| 313 | BondsinSceneMap.insert( std::make_pair(bondid, bondObject) );
|
---|
| 314 | }
|
---|
[96f14a] | 315 | }
|
---|
| 316 |
|
---|
[f1b5ca] | 317 | emit changed();
|
---|
| 318 | emit changeOccured();
|
---|
[96f14a] | 319 | }
|
---|
| 320 |
|
---|
[f1b5ca] | 321 | /** Removes a bond.
|
---|
[96f14a] | 322 | *
|
---|
[f1b5ca] | 323 | * @param _bondid id of bond to remove
|
---|
[96f14a] | 324 | */
|
---|
[bd6768] | 325 | void GLWorldScene::removeBond(ObservedValue_Index_t _bondid)
|
---|
[96f14a] | 326 | {
|
---|
[bd6768] | 327 | LOG(3, "INFO: GLWorldScene::removedBond() - Removing bond to id " << _bondid);
|
---|
[9c259e] | 328 |
|
---|
[f1b5ca] | 329 | // left bond
|
---|
[bd6768] | 330 | std::pair<BondNodeMap::iterator, BondNodeMap::iterator> iters =
|
---|
| 331 | BondsinSceneMap.equal_range(_bondid);
|
---|
| 332 | ASSERT( iters.first != iters.second,
|
---|
| 333 | "GLWorldScene::removedBond() - could not find bond to id "+toString(_bondid));
|
---|
| 334 | for (BondNodeMap::iterator iter = iters.first; iter != iters.second; ++iter) {
|
---|
| 335 | GLMoleculeObject_bond *bondObject = iter->second;
|
---|
| 336 | delete bondObject; // is done by signal from bond itself
|
---|
| 337 | //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << ".");
|
---|
| 338 | }
|
---|
| 339 | BondsinSceneMap.erase(_bondid);
|
---|
| 340 | {
|
---|
| 341 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
[a13f2b] | 342 | BondNodeParentMaps[0].left.erase(_bondid);
|
---|
| 343 | BondNodeParentMaps[1].left.erase(_bondid);
|
---|
[bd6768] | 344 | }
|
---|
[8281cc] | 345 |
|
---|
[f1b5ca] | 346 | emit changed();
|
---|
| 347 | emit changeOccured();
|
---|
[9c259e] | 348 | }
|
---|
| 349 |
|
---|
[f1b5ca] | 350 | void GLWorldScene::hoverChangedSignalled(GLMoleculeObject *ob)
|
---|
[96f14a] | 351 | {
|
---|
[f1b5ca] | 352 | // Find the atom, ob corresponds to.
|
---|
| 353 | hoverAtomId = -1;
|
---|
| 354 | GLMoleculeObject_atom *atomObject = dynamic_cast<GLMoleculeObject_atom *>(ob);
|
---|
| 355 | if (atomObject){
|
---|
| 356 | for (AtomNodeMap::iterator iter = AtomsinSceneMap.begin();iter != AtomsinSceneMap.end(); ++ iter){
|
---|
| 357 | if (iter->second == atomObject)
|
---|
| 358 | hoverAtomId = iter->second->objectId();
|
---|
[96f14a] | 359 | }
|
---|
| 360 |
|
---|
[f1b5ca] | 361 | // Propagate signal.
|
---|
| 362 | emit hoverChanged(hoverAtomId);
|
---|
[96f14a] | 363 | } else {
|
---|
[f1b5ca] | 364 | // Find the atom, ob corresponds to.
|
---|
| 365 | GLMoleculeObject_molecule *moleculeObject = dynamic_cast<GLMoleculeObject_molecule *>(ob);
|
---|
| 366 | if (moleculeObject){
|
---|
| 367 | // Propagate signal.
|
---|
| 368 | emit hoverChanged(moleculeObject->objectId(), 0);
|
---|
[96f14a] | 369 | }
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[bd6768] | 373 | void GLWorldScene::clickMolecule(moleculeId_t no)
|
---|
[8281cc] | 374 | {
|
---|
[f1b5ca] | 375 | LOG(3, "INFO: GLMoleculeObject_molecule - mol " << no << " has been clicked.");
|
---|
| 376 | const molecule * const mol= const_cast<const World &>(World::getInstance()).
|
---|
| 377 | getMolecule(MoleculeById(no));
|
---|
| 378 | ASSERT(mol, "Atom without molecule has been clicked.");
|
---|
| 379 | molids_t ids(1, mol->getId());
|
---|
| 380 | if (!World::getInstance().isSelected(mol))
|
---|
| 381 | SelectionMoleculeById(ids);
|
---|
| 382 | else
|
---|
| 383 | SelectionNotMoleculeById(ids);
|
---|
| 384 | emit clicked(no);
|
---|
[8281cc] | 385 | }
|
---|
| 386 |
|
---|
[026bef] | 387 | /** Inserts a molecule into the scene.
|
---|
[c67518] | 388 | *
|
---|
[8c001a] | 389 | * @param _mol molecule to insert
|
---|
[c67518] | 390 | */
|
---|
[bd6768] | 391 | void GLWorldScene::insertMolecule(QtObservedMolecule::ptr _mol)
|
---|
[c67518] | 392 | {
|
---|
[f91ef6] | 393 | const ObservedValue_Index_t molid = _mol->getIndex();
|
---|
| 394 | LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "
|
---|
| 395 | << _mol->getMolIndex());
|
---|
[7cf0eb] | 396 |
|
---|
[1b07b1] | 397 | MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(molid);
|
---|
[8c001a] | 398 | ASSERT( iter == MoleculesinSceneMap.end(),
|
---|
[a13f2b] | 399 | "GLWorldScene::insertMolecule() - molecule's id "+toString(molid)
|
---|
[f91ef6] | 400 | +" already present.");
|
---|
[8c001a] | 401 |
|
---|
| 402 | // add new object
|
---|
[a13f2b] | 403 | LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << molid);
|
---|
[1b07b1] | 404 | GLMoleculeObject_molecule *molObject =
|
---|
| 405 | new GLMoleculeObject_molecule(
|
---|
| 406 | GLMoleculeObject::meshEmpty,
|
---|
| 407 | this,
|
---|
| 408 | _mol);
|
---|
| 409 | ASSERT( molObject != NULL,
|
---|
[bd6768] | 410 | "GLWorldScene::insertMolecule - could not create molecule object for "
|
---|
[a13f2b] | 411 | +toString(molid));
|
---|
[6c4b69] | 412 | #ifndef NDEBUG
|
---|
| 413 | foreach (QObject *obj, molObject->children()) {
|
---|
| 414 | GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
|
---|
| 415 | ASSERT( meshobj == NULL,
|
---|
| 416 | "GLWorldScene::insertMolecule() - there are already atoms or bonds attached to a to molecule.");
|
---|
| 417 | }
|
---|
| 418 | #endif
|
---|
[a13f2b] | 419 |
|
---|
| 420 | // check all atoms for not yet assigned parents
|
---|
| 421 | {
|
---|
| 422 | boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
|
---|
| 423 | std::pair<AtomNodeParentMap_t::right_const_iterator, AtomNodeParentMap_t::right_const_iterator> iters =
|
---|
| 424 | AtomNodeParentMap.right.equal_range(molid);
|
---|
| 425 | for (AtomNodeParentMap_t::right_const_iterator iter = iters.first;
|
---|
| 426 | iter != iters.second; ++iter) {
|
---|
| 427 | AtomNodeMap::const_iterator atomiter = AtomsinSceneMap.find(iter->second);
|
---|
| 428 | if (atomiter != AtomsinSceneMap.end())
|
---|
| 429 | resetParent(atomiter->second, molObject);
|
---|
| 430 | }
|
---|
| 431 | }
|
---|
| 432 | // check all bonds for not yet assigned parents
|
---|
| 433 | {
|
---|
| 434 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
| 435 | for (size_t i=0;i<2;++i) {
|
---|
| 436 | std::pair<BondNodeParentMap_t::right_const_iterator, BondNodeParentMap_t::right_const_iterator> iters =
|
---|
| 437 | BondNodeParentMaps[i].right.equal_range(molid);
|
---|
| 438 | for (BondNodeParentMap_t::right_const_iterator iter = iters.first;
|
---|
| 439 | iter != iters.second; ++iter) {
|
---|
| 440 | BondNodeMap::const_iterator bonditer = BondsinSceneMap.find(iter->second);
|
---|
| 441 | if (bonditer != BondsinSceneMap.end())
|
---|
| 442 | resetParent(bonditer->second, molObject);
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 |
|
---|
[1b07b1] | 447 | #ifndef NDEBUG
|
---|
| 448 | std::pair<MoleculeNodeMap::iterator, bool> inserter =
|
---|
| 449 | #endif
|
---|
| 450 | MoleculesinSceneMap.insert( make_pair(molid, molObject) );
|
---|
| 451 | ASSERT(inserter.second,
|
---|
[bd6768] | 452 | "GLWorldScene::insertMolecule() - molecule "+toString(_mol->getMolIndex())
|
---|
[f91ef6] | 453 | +" already present in scene.");
|
---|
[1b07b1] | 454 |
|
---|
| 455 | connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
|
---|
| 456 | connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
|
---|
| 457 |
|
---|
| 458 | emit changed();
|
---|
| 459 | emit changeOccured();
|
---|
[c67518] | 460 | }
|
---|
| 461 |
|
---|
[7cf0eb] | 462 | /** Removes a molecule from the scene.
|
---|
| 463 | *
|
---|
[f1b5ca] | 464 | * @param _molid index of the molecule to remove
|
---|
[7cf0eb] | 465 | */
|
---|
[bd6768] | 466 | void GLWorldScene::removeMolecule(ObservedValue_Index_t _molid)
|
---|
[7cf0eb] | 467 | {
|
---|
[f1b5ca] | 468 | LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_molid)+".");
|
---|
[7c7c4a] | 469 |
|
---|
[f1b5ca] | 470 | MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
|
---|
[4a187d] | 471 | ASSERT ( iter != MoleculesinSceneMap.end(),
|
---|
[bd6768] | 472 | "GLWorldScene::removeMolecule() - to be removed molecule "+toString(_molid)
|
---|
[4a187d] | 473 | +" is already gone.");
|
---|
[f1b5ca] | 474 | GLMoleculeObject_molecule *molObject = iter->second;
|
---|
[6c4b69] | 475 | // check for any atoms and bonds still attached to it
|
---|
| 476 | #ifndef NDEBUG
|
---|
| 477 | foreach (QObject *obj, molObject->children()) {
|
---|
| 478 | GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
|
---|
| 479 | ASSERT( meshobj == NULL,
|
---|
| 480 | "GLWorldScene::removeMolecule() - there are still atoms or bonds attached to a to molecule.");
|
---|
| 481 | }
|
---|
| 482 | #endif
|
---|
| 483 | // finally, remove molecule
|
---|
[f1b5ca] | 484 | delete molObject;
|
---|
[4a187d] | 485 | MoleculesinSceneMap.erase(iter);
|
---|
[bcf9cd] | 486 |
|
---|
[f1b5ca] | 487 | emit changed();
|
---|
| 488 | emit changeOccured();
|
---|
[ce4126] | 489 | }
|
---|
| 490 |
|
---|
[f91ef6] | 491 | void GLWorldScene::moleculesVisibilityChanged(ObservedValue_Index_t _id, bool _visible)
|
---|
[739ee9] | 492 | {
|
---|
| 493 | MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
|
---|
| 494 | ASSERT( iter != MoleculesinSceneMap.end(),
|
---|
[f91ef6] | 495 | "GLWorldScene::moleculeInserted() - molecule's id "
|
---|
| 496 | +toString(board->getMoleculeIdToIndex(_id))+" is unknown.");
|
---|
[739ee9] | 497 |
|
---|
| 498 | GLMoleculeObject_molecule *molObject = iter->second;
|
---|
| 499 | molObject->setVisible(_visible);
|
---|
| 500 |
|
---|
| 501 | emit changed();
|
---|
| 502 | emit changeOccured();
|
---|
| 503 | }
|
---|
| 504 |
|
---|
[a13f2b] | 505 | /** This converts safely index into a GLMoleculeObject_molecule.
|
---|
| 506 | *
|
---|
| 507 | * \param _MoleculesinSceneMap all present molecules
|
---|
| 508 | * \param _molid index to look for
|
---|
| 509 | * \return MolObject or NULL when not found
|
---|
| 510 | */
|
---|
| 511 | GLMoleculeObject_molecule *GLWorldScene::getMoleculeObject(
|
---|
| 512 | const ObservedValue_Index_t _molid) const
|
---|
| 513 | {
|
---|
| 514 | const MoleculeNodeMap::const_iterator moliter = MoleculesinSceneMap.find(_molid);
|
---|
| 515 | if (moliter != MoleculesinSceneMap.end())
|
---|
| 516 | return moliter->second;
|
---|
| 517 | else
|
---|
| 518 | return NULL;
|
---|
| 519 | }
|
---|
| 520 |
|
---|
[bd6768] | 521 | /** Changes the parent of an object in the scene.
|
---|
| 522 | *
|
---|
| 523 | * \param _id index of the object whose parent to change
|
---|
| 524 | * \param _ob new parent
|
---|
| 525 | */
|
---|
| 526 | void GLWorldScene::reparentAtom()
|
---|
| 527 | {
|
---|
| 528 | QtObservedAtom *walker = dynamic_cast<QtObservedAtom *>(sender());
|
---|
| 529 | boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
|
---|
| 530 | const ObservedValue_Index_t walkerid = walker->getIndex();
|
---|
[6c4b69] | 531 | LOG(4, "DEBUG: GLWorldScene: Received signal moleculeChanged for atom "+toString(walkerid)+".");
|
---|
[a13f2b] | 532 | AtomNodeParentMap_t::left_iterator parentiter = AtomNodeParentMap.left.find(walkerid);
|
---|
| 533 | ASSERT( parentiter != AtomNodeParentMap.left.end(),
|
---|
[bd6768] | 534 | "GLWorldScene::reparentAtom() - could not find object to id "+toString(walkerid));
|
---|
[502614] | 535 |
|
---|
| 536 | // change parent entry
|
---|
[a13f2b] | 537 | AtomNodeParentMap.left.erase(parentiter);
|
---|
[502614] | 538 | if (walker->getMoleculeRef() != NULL)
|
---|
[a13f2b] | 539 | AtomNodeParentMap.left.insert( std::make_pair(walkerid, walker->getMoleculeRef()->getIndex()) );
|
---|
[502614] | 540 | else
|
---|
[a13f2b] | 541 | AtomNodeParentMap.left.insert( std::make_pair(walkerid, (ObservedValue_Index_t)NULL) );
|
---|
| 542 | parentiter = AtomNodeParentMap.left.find(walkerid);
|
---|
[502614] | 543 |
|
---|
[a13f2b] | 544 | const AtomNodeMap::iterator atomiter = AtomsinSceneMap.find(walkerid);
|
---|
| 545 | if (atomiter != AtomsinSceneMap.end())
|
---|
| 546 | resetParent(atomiter->second, getMoleculeObject(parentiter->second));
|
---|
| 547 | // else atom does not yet exist
|
---|
[bd6768] | 548 | }
|
---|
| 549 |
|
---|
[502614] | 550 | /** Changes the parent of an left-side bond in the scene.
|
---|
[bd6768] | 551 | *
|
---|
| 552 | */
|
---|
| 553 | void GLWorldScene::reparentBondLeft()
|
---|
| 554 | {
|
---|
[502614] | 555 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
[bd6768] | 556 | QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender());
|
---|
[502614] | 557 | reparentBond(bond, bond->getLeftAtom(), GLMoleculeObject_bond::left);
|
---|
| 558 | }
|
---|
| 559 |
|
---|
| 560 | /** Changes the parent of an right-side bond in the scene.
|
---|
| 561 | *
|
---|
| 562 | */
|
---|
| 563 | void GLWorldScene::reparentBondRight()
|
---|
| 564 | {
|
---|
[bd6768] | 565 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
[502614] | 566 | QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender());
|
---|
| 567 | reparentBond(bond, bond->getRightAtom(), GLMoleculeObject_bond::right);
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 | GLMoleculeObject_bond *GLWorldScene::getBondInScene(
|
---|
| 571 | const ObservedValue_Index_t _bondid,
|
---|
| 572 | GLMoleculeObject_bond::SideOfBond _side) const
|
---|
| 573 | {
|
---|
| 574 | std::pair<GLWorldScene::BondNodeMap::const_iterator, GLWorldScene::BondNodeMap::const_iterator> iters =
|
---|
| 575 | BondsinSceneMap.equal_range(_bondid);
|
---|
| 576 | ASSERT( std::distance(iters.first, iters.second) == 2,
|
---|
| 577 | "GLWorldScene::getBondInScene() - not exactly two bonds of same id "
|
---|
| 578 | +toString(_bondid)+" present in scene.");
|
---|
| 579 | for (GLWorldScene::BondNodeMap::const_iterator bonditer = iters.first;
|
---|
| 580 | bonditer != iters.second; ++bonditer) {
|
---|
| 581 | if (bonditer->second->BondSide == _side)
|
---|
| 582 | return bonditer->second;
|
---|
[bd6768] | 583 | }
|
---|
[502614] | 584 | return NULL;
|
---|
[bd6768] | 585 | }
|
---|
| 586 |
|
---|
| 587 | /** Changes the parent of an object in the scene.
|
---|
| 588 | *
|
---|
[502614] | 589 | * \param _atom atom of bond whose molecule we are associated to
|
---|
| 590 | * \param _side side of bond
|
---|
[bd6768] | 591 | */
|
---|
[502614] | 592 | void GLWorldScene::reparentBond(
|
---|
| 593 | QtObservedBond *_bond,
|
---|
[507f3c] | 594 | const QtObservedAtom::ptr _atom,
|
---|
[502614] | 595 | const GLMoleculeObject_bond::SideOfBond _side)
|
---|
[bd6768] | 596 | {
|
---|
| 597 | boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
|
---|
[a13f2b] | 598 | const size_t dim = (_side == GLMoleculeObject_bond::left) ? 0 : 1;
|
---|
[502614] | 599 | const ObservedValue_Index_t bondid = _bond->getIndex();
|
---|
[6c4b69] | 600 | LOG(4, "DEBUG: GLWorldScene: Received signal moleculeChanged for bond "+toString(bondid)+".");
|
---|
[a13f2b] | 601 | BondNodeParentMap_t::left_iterator parentiter = BondNodeParentMaps[dim].left.find(bondid);
|
---|
| 602 | ASSERT( parentiter != BondNodeParentMaps[dim].left.end(),
|
---|
[502614] | 603 | "GLWorldScene::reparentBond() - could not find object to id "+toString(bondid));
|
---|
| 604 |
|
---|
| 605 | // change parent entry
|
---|
[a13f2b] | 606 | BondNodeParentMaps[dim].left.erase(bondid);
|
---|
[502614] | 607 | if ((_atom != NULL) && (_atom->getMoleculeRef() != NULL))
|
---|
[a13f2b] | 608 | BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, _atom->getMoleculeRef()->getIndex()));
|
---|
[502614] | 609 | else
|
---|
[a13f2b] | 610 | BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, (ObservedValue_Index_t)NULL) );
|
---|
| 611 | parentiter = BondNodeParentMaps[dim].left.find(bondid);
|
---|
[502614] | 612 |
|
---|
| 613 | // reset parent
|
---|
[a13f2b] | 614 | resetParent(getBondInScene(bondid, _side), getMoleculeObject(parentiter->second));
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 | /** Resets the parent of an GLMoleculeObject.
|
---|
| 618 | *
|
---|
| 619 | * \param _obj object to reparent
|
---|
| 620 | * \param _molid index of parent molecule
|
---|
| 621 | */
|
---|
| 622 | void GLWorldScene::resetParent(
|
---|
| 623 | GLMoleculeObject *_obj,
|
---|
| 624 | GLMoleculeObject_molecule *_molobj)
|
---|
| 625 | {
|
---|
| 626 | if (_obj != NULL) {
|
---|
[502614] | 627 | QObject *parent = this;
|
---|
[a13f2b] | 628 | if (_molobj != NULL)
|
---|
| 629 | parent = _molobj;
|
---|
| 630 | // else: molecule does not yet exist: is done when molecule is instantiated
|
---|
[6c4b69] | 631 | LOG(5, "DEBUG: Resetting parent of " << _obj << " to " << parent);
|
---|
[a13f2b] | 632 | _obj->setParent(parent);
|
---|
[6c4b69] | 633 | ASSERT( _obj->parent() == parent,
|
---|
| 634 | "GLWorldScene::resetParent() - new parent "+toString(parent)+" was not set.");
|
---|
| 635 | } else
|
---|
| 636 | ELOG(1, "Object to reparent was NULL.");
|
---|
[a13f2b] | 637 | // else object does not yet exist
|
---|
[bd6768] | 638 | }
|
---|
| 639 |
|
---|
[f75491] | 640 | /** Adds a shape to the scene.
|
---|
[4d6662] | 641 | *
|
---|
[f75491] | 642 | */
|
---|
[07136a] | 643 | void GLWorldScene::addShape(const std::string &_name)
|
---|
[f75491] | 644 | {
|
---|
[07136a] | 645 | Shape * const shape = ShapeRegistry::getInstance().getByName(_name);
|
---|
| 646 | if (shape != NULL) {
|
---|
| 647 | GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(*shape, this);
|
---|
| 648 | ShapeNodeMap::iterator iter = ShapesinSceneMap.find(_name);
|
---|
| 649 | ASSERT(iter == ShapesinSceneMap.end(),
|
---|
| 650 | "GLWorldScene::addShape() - same shape "+_name+" added again.");
|
---|
| 651 | ShapesinSceneMap.insert( make_pair(_name, shapeObject) );
|
---|
| 652 | } else
|
---|
| 653 | ELOG(2, "GLWorldScene::addShape() - shape disappeared before we could draw it.");
|
---|
| 654 |
|
---|
| 655 | emit changed();
|
---|
[284551] | 656 | }
|
---|
| 657 |
|
---|
[07136a] | 658 | void GLWorldScene::removeShape(const std::string &_name)
|
---|
[85c36d] | 659 | {
|
---|
[07136a] | 660 | ShapeNodeMap::iterator iter = ShapesinSceneMap.find(_name);
|
---|
[ba6b5c] | 661 | ASSERT(iter != ShapesinSceneMap.end(),
|
---|
[07136a] | 662 | "GLWorldScene::removeShape() - shape "+_name+" not in scene.");
|
---|
[148dde0] | 663 | ShapesinSceneMap.erase(iter);
|
---|
[85c36d] | 664 | delete(iter->second);
|
---|
[07136a] | 665 |
|
---|
| 666 | emit changed();
|
---|
[85c36d] | 667 | }
|
---|
| 668 |
|
---|
| 669 | void GLWorldScene::updateSelectedShapes()
|
---|
[284551] | 670 | {
|
---|
| 671 | foreach (QObject *obj, children()) {
|
---|
| 672 | GLMoleculeObject_shape *shapeobj = qobject_cast<GLMoleculeObject_shape *>(obj);
|
---|
[85c36d] | 673 | if (shapeobj){
|
---|
| 674 | shapeobj->enable(ShapeRegistry::getInstance().isSelected(shapeobj->getShape()));
|
---|
| 675 | }
|
---|
[284551] | 676 | }
|
---|
[07136a] | 677 |
|
---|
| 678 | emit changed();
|
---|
[f75491] | 679 | }
|
---|
| 680 |
|
---|
[7188b1] | 681 | void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const
|
---|
| 682 | {
|
---|
| 683 | // Initialize all of the mesh objects that we have as children.
|
---|
| 684 | foreach (QObject *obj, children()) {
|
---|
| 685 | GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
|
---|
| 686 | if (meshobj)
|
---|
| 687 | meshobj->initialize(view, painter);
|
---|
| 688 | }
|
---|
| 689 | }
|
---|
| 690 |
|
---|
[72a4c1] | 691 | void GLWorldScene::draw(QGLPainter *painter, const QVector4D &cameraPlane) const
|
---|
[7188b1] | 692 | {
|
---|
| 693 | // Draw all of the mesh objects that we have as children.
|
---|
| 694 | foreach (QObject *obj, children()) {
|
---|
| 695 | GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
|
---|
| 696 | if (meshobj)
|
---|
[72a4c1] | 697 | meshobj->draw(painter, cameraPlane);
|
---|
[7188b1] | 698 | }
|
---|
[907636] | 699 | }
|
---|
[06ebf5] | 700 |
|
---|
[6966b7] | 701 | void GLWorldScene::setSelectionMode(SelectionModeType mode)
|
---|
| 702 | {
|
---|
| 703 | selectionMode = mode;
|
---|
| 704 | // TODO send update to toolbar
|
---|
| 705 | }
|
---|
| 706 |
|
---|
| 707 | void GLWorldScene::setSelectionModeAtom()
|
---|
| 708 | {
|
---|
| 709 | setSelectionMode(SelectAtom);
|
---|
| 710 | }
|
---|
| 711 |
|
---|
| 712 | void GLWorldScene::setSelectionModeMolecule()
|
---|
| 713 | {
|
---|
| 714 | setSelectionMode(SelectMolecule);
|
---|
| 715 | }
|
---|
[20f9b5] | 716 |
|
---|