source: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp@ b43585

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since b43585 was 5cd3a33, checked in by Frederik Heber <heber@…>, 9 years ago

Removed QtSelectionUsage in GLWorldView and related.

  • instead GLMoleculeObject_.. directly use observedvalue to get notified when they have been (un)selected.
  • Property mode set to 100644
File size: 18.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Copyright (C) 2013 Frederik Heber. All rights reserved.
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/>.
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"
39#include <Qt3D/qglview.h>
40#include <Qt3D/qglbuilder.h>
41#include <Qt3D/qglscenenode.h>
42#include <Qt3D/qglsphere.h>
43#include <Qt3D/qglcylinder.h>
44
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
51#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
52
53#include "CodePatterns/MemDebug.hpp"
54
55#include "CodePatterns/Log.hpp"
56
57#include "Actions/SelectionAction/Atoms/AtomByIdAction.hpp"
58#include "Actions/SelectionAction/Atoms/NotAtomByIdAction.hpp"
59#include "Actions/SelectionAction/Molecules/MoleculeByIdAction.hpp"
60#include "Actions/SelectionAction/Molecules/NotMoleculeByIdAction.hpp"
61#include "Atom/atom.hpp"
62#include "Bond/bond.hpp"
63#include "Descriptors/AtomIdDescriptor.hpp"
64#include "Descriptors/MoleculeIdDescriptor.hpp"
65#include "Helpers/helpers.hpp"
66#include "Shapes/ShapeRegistry.hpp"
67#include "molecule.hpp"
68#include "World.hpp"
69
70#include <iostream>
71
72using namespace MoleCuilder;
73
74GLWorldScene::GLWorldScene(
75 QtObservedInstanceBoard * _board,
76 QObject *parent) :
77 QObject(parent),
78 selectionMode(SelectAtom),
79 board(_board)
80{
81 int sphereDetails[] = {5, 3, 2, 0};
82 int cylinderDetails[] = {16, 8, 6, 3};
83 for (int i=0;i<GLMoleculeObject::DETAILTYPES_MAX;i++){
84 QGLBuilder emptyBuilder;
85 GLMoleculeObject::meshEmpty[i] = emptyBuilder.finalizedSceneNode();
86 QGLBuilder sphereBuilder;
87 sphereBuilder << QGLSphere(2.0, sphereDetails[i]);
88 GLMoleculeObject::meshSphere[i] = sphereBuilder.finalizedSceneNode();
89 GLMoleculeObject::meshSphere[i]->setOption(QGLSceneNode::CullBoundingBox, true);
90 QGLBuilder cylinderBuilder;
91 cylinderBuilder << QGLCylinder(.25,.25,1.0,cylinderDetails[i]);
92 GLMoleculeObject::meshCylinder[i] = cylinderBuilder.finalizedSceneNode();
93 GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true);
94 }
95 connect(board, SIGNAL(moleculeInserted(const moleculeId_t)),
96 this, SLOT(moleculeInserted(const moleculeId_t)));
97 connect(board, SIGNAL(moleculeRemoved(const moleculeId_t)),
98 this, SLOT(moleculeRemoved(const moleculeId_t)));
99 connect(board, SIGNAL(moleculeIndexChanged(const moleculeId_t, const moleculeId_t)),
100 this, SLOT(moleculeIndexChanged(const moleculeId_t, const moleculeId_t)));
101 connect(board, SIGNAL(atomInserted(const moleculeId_t, const atomId_t)),
102 this, SLOT(atomInserted(const moleculeId_t, const atomId_t)), Qt::DirectConnection);
103 connect(board, SIGNAL(atomRemoved(const moleculeId_t, const atomId_t)),
104 this, SLOT(atomRemoved(const moleculeId_t, const atomId_t)), Qt::DirectConnection);
105
106// connect(this, SIGNAL(updated()), this, SLOT(update()));
107}
108
109GLWorldScene::~GLWorldScene()
110{
111 // remove all elements
112 GLMoleculeObject::cleanMaterialMap();
113}
114
115void GLWorldScene::atomClicked(atomId_t no)
116{
117 LOG(3, "INFO: GLMoleculeObject_molecule - atom " << no << " has been clicked.");
118 const atom * const Walker = const_cast<const World &>(World::getInstance()).
119 getAtom(AtomById(no));
120 ASSERT( Walker != NULL,
121 "GLWorldScene::atomClicked() - clicked atom has disappeared.");
122 if (selectionMode == SelectAtom){
123 if (!World::getInstance().isSelected(Walker))
124 SelectionAtomById(std::vector<atomId_t>(1,no));
125 else
126 SelectionNotAtomById(std::vector<atomId_t>(1,no));
127 }else if (selectionMode == SelectMolecule){
128 const molecule *mol = Walker->getMolecule();
129 ASSERT(mol, "Atom without molecule has been clicked.");
130 molids_t ids(1, mol->getId());
131 if (!World::getInstance().isSelected(mol))
132 SelectionMoleculeById(ids);
133 else
134 SelectionNotMoleculeById(ids);
135 }
136 emit clicked(no);
137}
138
139void GLWorldScene::moleculeClicked(moleculeId_t no)
140{
141 LOG(3, "INFO: GLMoleculeObject_molecule - mol " << no << " has been clicked.");
142 const molecule * const mol= const_cast<const World &>(World::getInstance()).
143 getMolecule(MoleculeById(no));
144 ASSERT(mol, "Atom without molecule has been clicked.");
145 molids_t ids(1, mol->getId());
146 if (!World::getInstance().isSelected(mol))
147 SelectionMoleculeById(ids);
148 else
149 SelectionNotMoleculeById(ids);
150 emit clicked(no);
151}
152
153/** Inserts an atom into the scene before molecule is present.
154 *
155 * @param _molid molecule to insert atom for
156 * @param _atomid atom to insert
157 */
158void GLWorldScene::atomInserted(const moleculeId_t _molid, const atomId_t _atomid)
159{
160 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
161
162 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+".");
163
164 // check of molecule is already present
165 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(_molid);
166 if (moliter != MoleculesinSceneMap.end()) {
167 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule
168 } else {
169 // store signal for when it is instantiated
170 if (MoleculeMissedStateMap.count(_molid) == 0)
171 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) );
172 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomInsertedState) );
173 }
174}
175
176/** Removes an atom into the scene before molecule is present.
177 *
178 * @param _molid molecule to insert atom for
179 * @param _atomid atom to insert
180 */
181void GLWorldScene::atomRemoved(const moleculeId_t _molid, const atomId_t _atomid)
182{
183 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_atomid)+".");
184
185 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
186
187 // check of molecule is already present
188 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(_molid);
189 if (moliter != MoleculesinSceneMap.end()) {
190 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule
191 } else {
192 // store signal for when it is instantiated
193 if (MoleculeMissedStateMap.count(_molid) == 0)
194 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) );
195 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomRemovedState) );
196 }
197}
198
199/** Inserts a molecule into the scene.
200 *
201 * @param _mol molecule to insert
202 */
203void GLWorldScene::moleculeInserted(const moleculeId_t _id)
204{
205 LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "+toString(_id)+".");
206
207 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
208
209 MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(_id);
210 ASSERT( iter == MoleculesinSceneMap.end(),
211 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" already present.");
212
213 // check whether molecule is still present
214 if (RemovalMolecules.count(_id) != 0) {
215 RemovalMolecules.erase(_id);
216 return;
217 }
218 if (const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(_id)) == NULL) {
219 ELOG(2, "Molecule with id " << _id << " has disappeared.");
220 return;
221 }
222
223 // add new object
224 LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id);
225 GLMoleculeObject_molecule *molObject =
226 new GLMoleculeObject_molecule(
227 GLMoleculeObject::meshEmpty,
228 this,
229 *board,
230 board->getObservedMolecule(_id));
231 ASSERT( molObject != NULL,
232 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
233 MoleculesinSceneMap.insert( make_pair(_id, molObject) );
234
235 // now handle all state changes that came up before the instantiation
236 while (MoleculeMissedStateMap.count(_id) != 0) {
237 ASSERT( !MoleculeMissedStateMap[_id].empty(),
238 "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
239 +toString(_id));
240 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
241 for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
242 !MoleculeMissedStateMap[_id].empty();
243 iter = MoleculeMissedStateMap[_id].begin()) {
244 std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter =
245 MoleculeMissedStateMap[_id].equal_range(iter->first);
246 const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second);
247 if (StateCounts > 1) {
248 // more than one state change, have to combine
249 typedef std::map<StateChangeType, size_t> StateChangeAmounts_t;
250 StateChangeAmounts_t StateChangeAmounts;
251 for (StateChangeMap_t::const_iterator stateiter = rangeiter.first;
252 stateiter != rangeiter.second; ++stateiter)
253 ++StateChangeAmounts[stateiter->second];
254 ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState],
255 "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
256 +toString(iter->first));
257 if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
258 LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
259 QMetaObject::invokeMethod(molObject, // pointer to a QObject
260 "atomInserted", // member name (no parameters here)
261 Qt::QueuedConnection, // connection type
262 Q_ARG(const atomId_t, iter->first)); // parameters
263 } else {
264 LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
265 }
266 } else {
267 // can only be an insertion
268 switch (rangeiter.first->second) {
269 case atomRemovedState:
270 ASSERT( 0,
271 "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom "
272 +toString(iter->first));
273 break;
274 case atomInsertedState:
275 LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
276 QMetaObject::invokeMethod(molObject, // pointer to a QObject
277 "atomInserted", // member name (no parameters here)
278 Qt::QueuedConnection, // connection type
279 Q_ARG(const atomId_t, iter->first)); // parameters
280 break;
281 default:
282 ASSERT( 0,
283 "GLWorldScene::moleculeInserted() - there are unknown change states.");
284 break;
285 }
286 }
287 // removed state changes for this atom
288 MoleculeMissedStateMap[_id].erase(iter);
289 }
290 // remove state change map for the molecule
291 MoleculeMissedStateMap.erase(_id);
292 }
293
294 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
295 connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
296 connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
297 connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
298 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
299 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
300 connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
301 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
302 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
303
304 emit changed();
305 emit changeOccured();
306}
307
308/** Removes a molecule from the scene.
309 *
310 * @param _id id of molecule to remove
311 */
312void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
313{
314 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_id)+".");
315
316 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
317
318 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
319 if ( iter == MoleculesinSceneMap.end()) {
320 RemovalMolecules.insert(_id);
321 } else {
322 LOG(1, "DEBUG: Removing GLMoleculeObject_molecule to id " << _id);
323 GLMoleculeObject_molecule *molObject = iter->second;
324 molObject->disconnect();
325 MoleculesinSceneMap.erase(iter);
326 delete molObject;
327 }
328
329 // remove any possible state changes left
330 {
331 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
332 MoleculeMissedStateMap.erase(_id);
333 }
334
335 emit changed();
336 emit changeOccured();
337}
338
339void GLWorldScene::moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid)
340{
341 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_oldid);
342 if ( iter == MoleculesinSceneMap.end()) {
343 RemovalMolecule_t::iterator removeiter =
344 RemovalMolecules.find(_oldid);
345 ASSERT( removeiter != RemovalMolecules.end(),
346 "GLWorldScene::moleculeIndexChanged() - cannot find id "+toString(_oldid)+" in any map.");
347 RemovalMolecules.erase(removeiter);
348 RemovalMolecules.insert(_newid);
349 } else {
350 LOG(1, "DEBUG: Changing GLMoleculeObject_molecule from " << _oldid << " to id " << _newid);
351 GLMoleculeObject_molecule* molObject = iter->second;
352 MoleculesinSceneMap.erase(iter);
353 MoleculesinSceneMap.insert(
354 std::make_pair( _newid, molObject) );
355 }
356}
357
358void GLWorldScene::moleculesVisibilityChanged(const moleculeId_t _id, bool _visible)
359{
360 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
361 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
362 ASSERT( iter != MoleculesinSceneMap.end(),
363 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" is unknown.");
364
365 GLMoleculeObject_molecule *molObject = iter->second;
366 molObject->setVisible(_visible);
367
368 emit changed();
369 emit changeOccured();
370}
371
372/** Adds a shape to the scene.
373 *
374 */
375void GLWorldScene::addShape(const std::string &_name)
376{
377 Shape * const shape = ShapeRegistry::getInstance().getByName(_name);
378 if (shape != NULL) {
379 GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(*shape, this);
380 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(_name);
381 ASSERT(iter == ShapesinSceneMap.end(),
382 "GLWorldScene::addShape() - same shape "+_name+" added again.");
383 ShapesinSceneMap.insert( make_pair(_name, shapeObject) );
384 } else
385 ELOG(2, "GLWorldScene::addShape() - shape disappeared before we could draw it.");
386
387 emit changed();
388}
389
390void GLWorldScene::removeShape(const std::string &_name)
391{
392 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(_name);
393 ASSERT(iter != ShapesinSceneMap.end(),
394 "GLWorldScene::removeShape() - shape "+_name+" not in scene.");
395 ShapesinSceneMap.erase(iter);
396 delete(iter->second);
397
398 emit changed();
399}
400
401void GLWorldScene::updateSelectedShapes()
402{
403 foreach (QObject *obj, children()) {
404 GLMoleculeObject_shape *shapeobj = qobject_cast<GLMoleculeObject_shape *>(obj);
405 if (shapeobj){
406 shapeobj->enable(ShapeRegistry::getInstance().isSelected(shapeobj->getShape()));
407 }
408 }
409
410 emit changed();
411}
412
413void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const
414{
415 // Initialize all of the mesh objects that we have as children.
416 foreach (QObject *obj, children()) {
417 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
418 if (meshobj)
419 meshobj->initialize(view, painter);
420 }
421}
422
423void GLWorldScene::draw(QGLPainter *painter, const QVector4D &cameraPlane) const
424{
425 // Draw all of the mesh objects that we have as children.
426 foreach (QObject *obj, children()) {
427 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
428 if (meshobj)
429 meshobj->draw(painter, cameraPlane);
430 }
431}
432
433void GLWorldScene::setSelectionMode(SelectionModeType mode)
434{
435 selectionMode = mode;
436 // TODO send update to toolbar
437}
438
439void GLWorldScene::setSelectionModeAtom()
440{
441 setSelectionMode(SelectAtom);
442}
443
444void GLWorldScene::setSelectionModeMolecule()
445{
446 setSelectionMode(SelectMolecule);
447}
448
449void GLWorldScene::changeMoleculeId(
450 GLMoleculeObject_molecule *ob,
451 const moleculeId_t oldId,
452 const moleculeId_t newId)
453{
454 LOG(3, "INFO: GLWorldScene - change molecule id " << oldId << " to " << newId << ".");
455
456 {
457 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
458 // Remove from map.
459 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(oldId);
460 ASSERT(iter != MoleculesinSceneMap.end(),
461 "GLWorldScene::changeMoleculeId() - molecule with old id "+toString(oldId)+" not on display.");
462 ASSERT(iter->second == ob,
463 "GLWorldScene::changeMoleculeId() - molecule with id "
464 +toString(oldId)+" does not match with object in MoleculesinSceneMap.");
465 MoleculesinSceneMap.erase(iter);
466
467 // Reinsert with new id.
468 {
469 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(newId);
470 ASSERT(iter == MoleculesinSceneMap.end(),
471 "GLWorldScene::changeMoleculeId() - moleculewith new id "+toString(newId)+" already known.");
472 }
473 MoleculesinSceneMap.insert( make_pair(newId, ob) );
474 }
475
476 {
477 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
478 // Remove and re-insert from map if present.
479 MoleculeMissedStateMap_t::iterator iter = MoleculeMissedStateMap.find(oldId);
480 if (iter != MoleculeMissedStateMap.end()) {
481 StateChangeMap_t changemap = iter->second;
482 MoleculeMissedStateMap.erase(iter);
483 MoleculeMissedStateMap.insert( std::make_pair(newId, changemap) );
484 }
485 }
486}
487
Note: See TracBrowser for help on using the repository browser.