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

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 25a81d was a39d72, checked in by Frederik Heber <heber@…>, 10 years ago

Fixed formula usage in Qt part of code.

  • formula of a molecule is only access through ObservedValue or directly within the World's O/O system.
  • Molecule may disappear before selection event.
  • Atoms may disappear before selection event.
  • Property mode set to 100644
File size: 19.9 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/Views/Qt4/QtSelectionChangedAgent.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(QObject *parent) :
75 QObject(parent),
76 selectionMode(SelectAtom)
77{
78 int sphereDetails[] = {5, 3, 2, 0};
79 int cylinderDetails[] = {16, 8, 6, 3};
80 for (int i=0;i<GLMoleculeObject::DETAILTYPES_MAX;i++){
81 QGLBuilder emptyBuilder;
82 GLMoleculeObject::meshEmpty[i] = emptyBuilder.finalizedSceneNode();
83 QGLBuilder sphereBuilder;
84 sphereBuilder << QGLSphere(2.0, sphereDetails[i]);
85 GLMoleculeObject::meshSphere[i] = sphereBuilder.finalizedSceneNode();
86 GLMoleculeObject::meshSphere[i]->setOption(QGLSceneNode::CullBoundingBox, true);
87 QGLBuilder cylinderBuilder;
88 cylinderBuilder << QGLCylinder(.25,.25,1.0,cylinderDetails[i]);
89 GLMoleculeObject::meshCylinder[i] = cylinderBuilder.finalizedSceneNode();
90 GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true);
91 }
92
93// connect(this, SIGNAL(updated()), this, SLOT(update()));
94}
95
96GLWorldScene::~GLWorldScene()
97{
98 // remove all elements
99 GLMoleculeObject::cleanMaterialMap();
100}
101
102///** Update the WorldScene with molecules and atomsfrom World.
103// *
104// * This function should be called after e.g. WorldTime::TimeChanged was
105// * received or after another molecule has been loaded.
106// *
107// */
108//void GLWorldScene::update()
109//{
110// const std::vector<const molecule *> &molecules =
111// const_cast<const World &>(World::getInstance()).getAllMolecules();
112//
113// for (std::vector<const molecule*>::const_iterator moliter = molecules.begin();
114// moliter != molecules.end();
115// moliter++) {
116// // check whether molecule already exists
117// const moleculeId_t molid = (*moliter)->getId();
118// const bool mol_present = MoleculesinSceneMap.count(molid);
119// if (!mol_present)
120// moleculeInserted((*moliter)->getId());
121// }
122//
123// MoleculeNodeMap::iterator iter = MoleculesinSceneMap.begin();
124// for (;iter != MoleculesinSceneMap.end();) {
125// const moleculeId_t molid = iter->first;
126// const molecule * const mol = const_cast<const World &>(World::getInstance()).
127// getMolecule(MoleculeById(molid));
128// const bool mol_absent = (mol == NULL);
129// // step on to next molecule before possibly removing entry and invalidating iter
130// ++iter;
131// if (mol_absent)
132// moleculeRemoved(molid);
133// }
134//
135//}
136
137void GLWorldScene::atomClicked(atomId_t no)
138{
139 LOG(3, "INFO: GLMoleculeObject_molecule - atom " << no << " has been clicked.");
140 const atom * const Walker = const_cast<const World &>(World::getInstance()).
141 getAtom(AtomById(no));
142 if (selectionMode == SelectAtom){
143 if (!World::getInstance().isSelected(Walker))
144 SelectionAtomById(std::vector<atomId_t>(1,no));
145 else
146 SelectionNotAtomById(std::vector<atomId_t>(1,no));
147 }else if (selectionMode == SelectMolecule){
148 const molecule *mol = Walker->getMolecule();
149 ASSERT(mol, "Atom without molecule has been clicked.");
150 molids_t ids(1, mol->getId());
151 if (!World::getInstance().isSelected(mol))
152 SelectionMoleculeById(ids);
153 else
154 SelectionNotMoleculeById(ids);
155 }
156 emit clicked(no);
157}
158
159void GLWorldScene::moleculeClicked(moleculeId_t no)
160{
161 LOG(3, "INFO: GLMoleculeObject_molecule - mol " << no << " has been clicked.");
162 const molecule * const mol= const_cast<const World &>(World::getInstance()).
163 getMolecule(MoleculeById(no));
164 ASSERT(mol, "Atom without molecule has been clicked.");
165 molids_t ids(1, mol->getId());
166 if (!World::getInstance().isSelected(mol))
167 SelectionMoleculeById(ids);
168 else
169 SelectionNotMoleculeById(ids);
170 emit clicked(no);
171}
172
173/** Inserts an atom into the scene before molecule is present.
174 *
175 * @param _molid molecule to insert atom for
176 * @param _atomid atom to insert
177 */
178void GLWorldScene::atomInserted(const moleculeId_t _molid, const atomId_t _atomid)
179{
180 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+".");
181
182 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
183
184 // check of molecule is already present
185 if (MoleculesinSceneMap.count(_molid) != 0) {
186 // pass signal through
187 } else {
188 // store signal for when it is instantiated
189 if (MoleculeMissedStateMap.count(_molid) == 0)
190 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) );
191 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomInsertedState) );
192 }
193}
194
195/** Removes an atom into the scene before molecule is present.
196 *
197 * @param _molid molecule to insert atom for
198 * @param _atomid atom to insert
199 */
200void GLWorldScene::atomRemoved(const moleculeId_t _molid, const atomId_t _atomid)
201{
202 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_atomid)+".");
203
204 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
205
206 // check of molecule is already present
207 if (MoleculesinSceneMap.count(_molid) != 0) {
208 // pass signal through
209 } else {
210 // store signal for when it is instantiated
211 if (MoleculeMissedStateMap.count(_molid) == 0)
212 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) );
213 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomRemovedState) );
214 }
215}
216
217/** Inserts a molecule into the scene.
218 *
219 * @param _mol molecule to insert
220 */
221void GLWorldScene::moleculeInserted(const moleculeId_t _id)
222{
223 LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "+toString(_id)+".");
224 MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(_id);
225 ASSERT( iter == MoleculesinSceneMap.end(),
226 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" already present.");
227
228 // check whether molecule is still present
229 if (RemovalMolecules.count(_id) != 0) {
230 RemovalMolecules.erase(_id);
231 return;
232 }
233 if (const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(_id)) == NULL)
234 return;
235
236 // add new object
237 GLMoleculeObject_molecule *molObject =
238 new GLMoleculeObject_molecule(GLMoleculeObject::meshEmpty, this, _id);
239 ASSERT( molObject != NULL,
240 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
241 MoleculesinSceneMap.insert( make_pair(_id, molObject) );
242
243 // now handle all state changes that came up before the instantiation
244 while (MoleculeMissedStateMap.count(_id) != 0) {
245 ASSERT( !MoleculeMissedStateMap[_id].empty(),
246 "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
247 +toString(_id));
248 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
249 for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
250 !MoleculeMissedStateMap[_id].empty();
251 iter = MoleculeMissedStateMap[_id].begin()) {
252 std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter =
253 MoleculeMissedStateMap[_id].equal_range(iter->first);
254 const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second);
255 if (StateCounts > 1) {
256 // more than one state change, have to combine
257 typedef std::map<StateChangeType, size_t> StateChangeAmounts_t;
258 StateChangeAmounts_t StateChangeAmounts;
259 for (StateChangeMap_t::const_iterator stateiter = rangeiter.first;
260 stateiter != rangeiter.second; ++stateiter)
261 ++StateChangeAmounts[stateiter->second];
262 ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState],
263 "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
264 +toString(iter->first));
265 if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
266 LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
267 QMetaObject::invokeMethod(molObject, // pointer to a QObject
268 "atomInserted", // member name (no parameters here)
269 Qt::DirectConnection, // connection type
270 Q_ARG(const atomId_t, iter->first)); // parameters
271 } else {
272 LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
273 }
274 } else {
275 // can only be an insertion
276 switch (rangeiter.first->second) {
277 case atomRemovedState:
278 ASSERT( 0,
279 "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom "
280 +toString(iter->first));
281 break;
282 case atomInsertedState:
283 LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
284 QMetaObject::invokeMethod(molObject, // pointer to a QObject
285 "atomInserted", // member name (no parameters here)
286 Qt::DirectConnection, // connection type
287 Q_ARG(const atomId_t, iter->first)); // parameters
288 break;
289 default:
290 ASSERT( 0,
291 "GLWorldScene::moleculeInserted() - there are unknown change states.");
292 break;
293 }
294 }
295 // removed state changes for this atom
296 MoleculeMissedStateMap[_id].erase(iter);
297 }
298 // remove state change map for the molecule
299 MoleculeMissedStateMap.erase(_id);
300 }
301
302 // now let the molObject sign on to molecule
303 molObject->activateObserver();
304
305 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
306 connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
307 connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
308 connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
309 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
310 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
311 connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
312 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
313 connect (molObject, SIGNAL(indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t)), this, SLOT(changeMoleculeId(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t)));
314
315 emit changed();
316 emit changeOccured();
317}
318
319/** Removes a molecule from the scene.
320 *
321 * @param _id id of molecule to remove
322 */
323void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
324{
325 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_id)+".");
326 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
327 if ( iter == MoleculesinSceneMap.end())
328 RemovalMolecules.insert(_id);
329 else {
330
331 GLMoleculeObject_molecule *molObject = iter->second;
332 molObject->disconnect();
333 MoleculesinSceneMap.erase(iter);
334 delete molObject;
335
336 // remove any possible state changes left
337 {
338 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
339 MoleculeMissedStateMap.erase(_id);
340 }
341
342 emit changed();
343 emit changeOccured();
344 }
345}
346
347void GLWorldScene::moleculesVisibilityChanged(const moleculeId_t _id, bool _visible)
348{
349 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
350 ASSERT( iter != MoleculesinSceneMap.end(),
351 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" is unknown.");
352
353 GLMoleculeObject_molecule *molObject = iter->second;
354 molObject->setVisible(_visible);
355
356 emit changed();
357 emit changeOccured();
358}
359
360/** Adds a shape to the scene.
361 *
362 * uses ShapeRegistry::lastChanged()
363 *
364 */
365void GLWorldScene::addShape()
366{
367 Shape &shape = *ShapeRegistry::getInstance().lastChanged();
368 GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(shape, this);
369 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName());
370 ASSERT(iter == ShapesinSceneMap.end(),
371 "GLWorldScene::addShape() - same shape "+shape.getName()+" added again.");
372 ShapesinSceneMap.insert( make_pair(shape.getName(), shapeObject) );
373}
374
375void GLWorldScene::removeShape()
376{
377 Shape &shape = *ShapeRegistry::getInstance().lastChanged();
378 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName());
379 ASSERT(iter != ShapesinSceneMap.end(),
380 "GLWorldScene::removeShape() - shape "+shape.getName()+" not in scene.");
381 ShapesinSceneMap.erase(iter);
382 delete(iter->second);
383}
384
385void GLWorldScene::updateSelectedShapes()
386{
387 foreach (QObject *obj, children()) {
388 GLMoleculeObject_shape *shapeobj = qobject_cast<GLMoleculeObject_shape *>(obj);
389 if (shapeobj){
390 shapeobj->enable(ShapeRegistry::getInstance().isSelected(shapeobj->getShape()));
391 }
392 }
393}
394
395void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const
396{
397 // Initialize all of the mesh objects that we have as children.
398 foreach (QObject *obj, children()) {
399 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
400 if (meshobj)
401 meshobj->initialize(view, painter);
402 }
403}
404
405void GLWorldScene::draw(QGLPainter *painter, const QVector4D &cameraPlane) const
406{
407 // Draw all of the mesh objects that we have as children.
408 foreach (QObject *obj, children()) {
409 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
410 if (meshobj)
411 meshobj->draw(painter, cameraPlane);
412 }
413}
414
415void GLWorldScene::setSelectionMode(SelectionModeType mode)
416{
417 selectionMode = mode;
418 // TODO send update to toolbar
419}
420
421void GLWorldScene::setSelectionChangedAgent(QtSelectionChangedAgent *agent)
422{
423 connect(agent, SIGNAL(atomSelected(const moleculeId_t, const atomId_t)),
424 this, SLOT(AtomSelected(const moleculeId_t, const atomId_t)));
425 connect(agent, SIGNAL(atomUnselected(const moleculeId_t, const atomId_t)),
426 this, SLOT(AtomUnselected(const moleculeId_t, const atomId_t)));
427
428 connect(agent, SIGNAL(moleculeSelected(const moleculeId_t)),
429 this, SLOT(MoleculeSelected(const moleculeId_t)));
430 connect(agent, SIGNAL(moleculeUnselected(const moleculeId_t)),
431 this, SLOT(MoleculeUnselected(const moleculeId_t)));
432}
433
434void GLWorldScene::setSelectionModeAtom()
435{
436 setSelectionMode(SelectAtom);
437}
438
439void GLWorldScene::setSelectionModeMolecule()
440{
441 setSelectionMode(SelectMolecule);
442}
443
444void GLWorldScene::changeMoleculeId(
445 GLMoleculeObject_molecule *ob,
446 const moleculeId_t oldId,
447 const moleculeId_t newId)
448{
449 LOG(3, "INFO: GLWorldScene - change molecule id " << oldId << " to " << newId << ".");
450
451 {
452 // Remove from map.
453 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(oldId);
454 ASSERT(iter != MoleculesinSceneMap.end(),
455 "GLWorldScene::changeMoleculeId() - molecule with old id "+toString(oldId)+" not on display.");
456 ASSERT(iter->second == ob,
457 "GLWorldScene::changeMoleculeId() - molecule with id "
458 +toString(oldId)+" does not match with object in MoleculesinSceneMap.");
459 MoleculesinSceneMap.erase(iter);
460
461 // Reinsert with new id.
462 {
463 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(newId);
464 ASSERT(iter == MoleculesinSceneMap.end(),
465 "GLWorldScene::changeMoleculeId() - moleculewith new id "+toString(newId)+" already known.");
466 }
467 MoleculesinSceneMap.insert( make_pair(newId, ob) );
468 }
469
470 {
471 // Remove and re-insert from map if present.
472 MoleculeMissedStateMap_t::iterator iter = MoleculeMissedStateMap.find(oldId);
473 if (iter != MoleculeMissedStateMap.end()) {
474 StateChangeMap_t changemap = iter->second;
475 MoleculeMissedStateMap.erase(iter);
476 MoleculeMissedStateMap.insert( std::make_pair(newId, changemap) );
477 }
478 }
479}
480
481void GLWorldScene::AtomSelected(const moleculeId_t _molid, const atomId_t _id)
482{
483 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
484 if (iter != MoleculesinSceneMap.end())
485 QMetaObject::invokeMethod(iter->second, // pointer to a QObject
486 "AtomSelected", // member name (no parameters here)
487 Qt::QueuedConnection, // connection type
488 Q_ARG(const atomId_t, _id)); // parameters
489 else
490 ELOG(2, "DEBUG: GLWorldScene::AtomSelected() - molecule " <<
491 _molid << " unknown to GLWorldScene.");
492}
493
494void GLWorldScene::AtomUnselected(const moleculeId_t _molid, const atomId_t _id)
495{
496 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
497 if (iter != MoleculesinSceneMap.end())
498 QMetaObject::invokeMethod(iter->second, // pointer to a QObject
499 "AtomUnselected", // member name (no parameters here)
500 Qt::QueuedConnection, // connection type
501 Q_ARG(const atomId_t, _id)); // parameters
502 else
503 ELOG(2, "GLWorldScene::AtomUnselected() - molecule "
504 << _molid << " unknown to GLWorldScene.");
505}
506
507void GLWorldScene::MoleculeSelected(const moleculeId_t _molid)
508{
509 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
510 if (iter != MoleculesinSceneMap.end())
511 QMetaObject::invokeMethod(iter->second, // pointer to a QObject
512 "Selected", // member name (no parameters here)
513 Qt::QueuedConnection); // connection type
514 else
515 ELOG(2, "GLWorldScene::MoleculeSelected() - molecule "
516 << _molid << " unknown to GLWorldScene.");
517}
518
519void GLWorldScene::MoleculeUnselected(const moleculeId_t _molid)
520{
521 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
522 if (iter != MoleculesinSceneMap.end())
523 QMetaObject::invokeMethod(iter->second, // pointer to a QObject
524 "Unselected", // member name (no parameters here)
525 Qt::QueuedConnection); // connection type
526 else
527 ELOG(2, "GLWorldScene::MoleculeUnselected() - molecule "
528 << _molid << " unknown to GLWorldScene.");
529}
Note: See TracBrowser for help on using the repository browser.