source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp@ b4bd0e

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 b4bd0e was 6af6a62, checked in by Frederik Heber <heber@…>, 9 years ago

FIX: Removed GLMoleculeObject_molecule's molref.

  • Property mode set to 100644
File size: 18.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 * GLMoleculeObject_molecule.cpp
26 *
27 * Created on: Mar 30, 2012
28 * Author: ankele
29 */
30
31
32// include config.h
33#ifdef HAVE_CONFIG_H
34#include <config.h>
35#endif
36
37#include "GLMoleculeObject_molecule.hpp"
38
39#include <Qt3D/qglscenenode.h>
40#include <Qt3D/qglbuilder.h>
41
42#include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp"
43
44#include "CodePatterns/MemDebug.hpp"
45
46#include <boost/assign.hpp>
47
48#include "CodePatterns/Assert.hpp"
49#include "CodePatterns/IteratorAdaptors.hpp"
50#include "CodePatterns/Log.hpp"
51
52#include "LinearAlgebra/Vector.hpp"
53#include "LinkedCell/PointCloudAdaptor.hpp"
54#include "LinkedCell/linkedcell.hpp"
55#include "Tesselation/tesselation.hpp"
56#include "Tesselation/BoundaryLineSet.hpp"
57#include "Tesselation/BoundaryTriangleSet.hpp"
58#include "Tesselation/CandidateForTesselation.hpp"
59#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
60#include "Atom/TesselPoint.hpp"
61#include "World.hpp"
62
63using namespace boost::assign;
64
65static Observable::channels_t getAllAtomicChangesChannels()
66{
67 Observable::channels_t channels;
68 channels += molecule::AtomInserted, molecule::AtomRemoved, molecule::AtomMoved;
69 return channels;
70}
71
72const Observable::channels_t GLMoleculeObject_molecule::HullChannels(getAllAtomicChangesChannels());
73
74static QGLSceneNode *createMoleculeMesh(const QGeometryData &_geo)
75{
76 // Build a mesh from the geometry.
77 QGLBuilder builder;
78 builder.addTriangles(_geo);
79 QGLSceneNode *mesh = builder.finalizedSceneNode();
80 return mesh;
81}
82
83GLMoleculeObject_molecule::GLMoleculeObject_molecule(
84 QObject *parent,
85 QtObservedInstanceBoard &_board,
86 QtObservedMolecule::ptr &_ObservedMolecule) :
87 GLMoleculeObject((QGLSceneNode *)NULL, parent),
88 owner(NULL),
89 hoverAtomId(-1),
90 board(_board),
91 ObservedMolecule(_ObservedMolecule)
92{
93 init(ObservedMolecule->getMolIndex());
94}
95
96GLMoleculeObject_molecule::GLMoleculeObject_molecule(
97 QGLSceneNode *mesh[],
98 QObject *parent,
99 QtObservedInstanceBoard &_board,
100 QtObservedMolecule::ptr &_ObservedMolecule) :
101 GLMoleculeObject(mesh, parent),
102 owner(NULL),
103 hoverAtomId(-1),
104 board(_board),
105 ObservedMolecule(_ObservedMolecule)
106{
107 init(ObservedMolecule->getMolIndex());
108}
109
110void GLMoleculeObject_molecule::init(const moleculeId_t _molid)
111{
112 setObjectId(_molid);
113 setMaterial(getMaterial(1));
114
115 m_selected = const_cast<const World &>(World::getInstance()).isMoleculeSelected(_molid);
116
117 // initially, atoms and bonds should be visible
118 m_visible = false;
119
120 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
121 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
122 connect (ObservedMolecule.get(), SIGNAL(tesselationhullChanged()), this, SLOT(resetTesselationHull()));
123 connect (ObservedMolecule.get(), SIGNAL(boundingboxChanged()), this, SLOT(resetBoundingBox()));
124 connect (ObservedMolecule.get(), SIGNAL(indexChanged(const moleculeId_t, const moleculeId_t)),
125 this, SLOT(resetIndex(const moleculeId_t, const moleculeId_t)));
126 /// these are channeled through GLWorldScene instead to ensure synchronicity
127// connect (ObservedMolecule.get(), SIGNAL(atomInserted(QtObservedAtom::ptr)),
128// this, SLOT(atomInserted(QtObservedAtom::ptr)) );
129// connect (ObservedMolecule.get(), SIGNAL(atomRemoved(const atomId_t)),
130// this, SLOT(atomRemoved(const atomId_t)) );
131 connect (ObservedMolecule.get(), SIGNAL(selectedChanged()), this, SLOT(resetSelected()));
132
133 connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
134}
135
136GLMoleculeObject_molecule::~GLMoleculeObject_molecule()
137{}
138
139void GLMoleculeObject_molecule::addAtomBonds(
140 const bond::ptr &_bond,
141 const GLMoleculeObject_bond::SideOfBond _side
142 )
143{
144 bool bond_present = false;
145 const BondIds ids = getBondIds(_bond, _side);
146 // check whether bond is not present already
147 bond_present = BondsinSceneMap.count(ids);
148 if (!bond_present)
149 bondInserted(ids.first, ids.second, _side);
150 else {
151 BondsinSceneMap[ids]->resetPosition();
152 BondsinSceneMap[ids]->resetWidth();
153 }
154}
155
156QGeometryData GLMoleculeObject_molecule::updateTesselationHull() const
157{
158 QGeometryData geo;
159
160 const molecule * const molref =
161 QtObservedMolecule::getMolecule(ObservedMolecule->getMolIndex());
162 if (molref == NULL) {
163 ELOG(1, "Could not createMoleculeMesh, molecule with id "
164 << ObservedMolecule->getMolIndex() << " already gone.");
165 return geo;
166 }
167 double minradius = 2.; // TODO: set to maximum bond length value
168 LOG(3, "DEBUG: Molecule fits into sphere of radius " << minradius);
169 // check minimum bond radius in molecule
170 double minlength = std::numeric_limits<double>::max();
171 for (molecule::const_iterator iter = molref->begin();
172 iter != molref->end(); ++iter) {
173 const BondList &ListOfBonds = (*iter)->getListOfBonds();
174 for (BondList::const_iterator bonditer = ListOfBonds.begin();
175 bonditer != ListOfBonds.end(); ++bonditer) {
176 const double bond_distance = (*bonditer)->GetDistance();
177 minlength = std::min(bond_distance, minlength);
178 }
179 }
180 minradius = std::max( std::max(minradius, minlength), 1.);
181
182 // we need at least three points for tesselation
183 if (AtomsinSceneMap.size() >= 3) {
184 // Tesselate the points.
185 Tesselation T;
186 PointCloudAdaptor<molecule> cloud(
187 const_cast<molecule *>(molref),
188 ObservedMolecule->getMolName());
189 T(cloud, minradius);
190
191 // Fill the points into a Qt geometry.
192 LinkedCell_deprecated LinkedList(cloud, minradius);
193 std::map<int, int> indices;
194 std::map<int, Vector> normals;
195 int index = 0;
196 for (PointMap::const_iterator piter = T.PointsOnBoundary.begin();
197 piter != T.PointsOnBoundary.end(); ++piter) {
198 const Vector &point = piter->second->getPosition();
199 // add data to the primitive
200 geo.appendVertex(QVector3D(point[0], point[1], point[2]));
201 Vector normalvector;
202 for (LineMap::const_iterator lineiter = piter->second->lines.begin();
203 lineiter != piter->second->lines.end(); ++lineiter)
204 for (TriangleMap::const_iterator triangleiter = lineiter->second->triangles.begin();
205 triangleiter != lineiter->second->triangles.end(); ++triangleiter)
206 normalvector +=
207 triangleiter->second->NormalVector;
208 normalvector.Normalize();
209 geo.appendNormal(QVector3D(normalvector[0], normalvector[1], normalvector[2]));
210 geo.appendColor(QColor(1, 1, 1, 1));
211 geo.appendTexCoord(QVector2D(0, 0));
212 indices.insert( std::make_pair( piter->second->getNr(), index++));
213 }
214
215 // Fill the tesselated triangles into the geometry.
216 for (TriangleMap::const_iterator runner = T.TrianglesOnBoundary.begin();
217 runner != T.TrianglesOnBoundary.end(); runner++) {
218 int v[3];
219 for (size_t i=0; i<3; ++i)
220 v[i] = runner->second->endpoints[i]->getNr();
221
222 // Sort the vertices so the triangle is clockwise (relative to the normal vector).
223 Vector cross = T.PointsOnBoundary[v[1]]->getPosition() - T.PointsOnBoundary[v[0]]->getPosition();
224 cross.VectorProduct(T.PointsOnBoundary[v[2]]->getPosition() - T.PointsOnBoundary[v[0]]->getPosition());
225 if (cross.ScalarProduct(runner->second->NormalVector) > 0)
226 geo.appendIndices(indices[v[0]], indices[v[1]], indices[v[2]]);
227 else
228 geo.appendIndices(indices[v[0]], indices[v[2]], indices[v[1]]);
229 }
230 }
231
232 return geo;
233}
234
235void GLMoleculeObject_molecule::resetTesselationHull()
236{
237 if (owner != NULL) {
238 TesselationHull = updateTesselationHull();
239 updateMesh(createMoleculeMesh(TesselationHull));
240 }
241}
242
243void GLMoleculeObject_molecule::resetBoundingBox()
244{
245 molecule::BoundingBoxInfo info = ObservedMolecule->getBoundingBox();
246 setPosition(QVector3D(info.position[0], info.position[1], info.position[2]));
247 setScale(info.radius + 0.3); // getBoundingSphere() only sees atoms as points, so make the box a bit bigger
248}
249
250void GLMoleculeObject_molecule::resetIndex(const moleculeId_t, const moleculeId_t)
251{
252 const atomId_t newId = ObservedMolecule->getMolIndex();
253 const size_t oldId = objectId();
254 ASSERT( newId != oldId,
255 "GLMoleculeObject_molecule::resetIndex() - index "+toString(newId)+" did not change.");
256 LOG(4, "INFO: GLMoleculeObject_molecule: new index is "+toString(newId)+".");
257 setObjectId(newId);
258}
259
260void GLMoleculeObject_molecule::resetSelected()
261{
262 const bool new_selected = ObservedMolecule->getMolSelected();
263 m_selected = new_selected;
264
265 emit changed();
266}
267
268void GLMoleculeObject_molecule::initialize(QGLView *view, QGLPainter *painter)
269{
270 // Initialize all of the mesh objects that we have as children.
271 if (m_visible) {
272 GLMoleculeObject::initialize(view, painter);
273 } else {
274 foreach (QObject *obj, children()) {
275 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
276 if (meshobj)
277 meshobj->initialize(view, painter);
278 }
279 }
280}
281
282void GLMoleculeObject_molecule::draw(QGLPainter *painter, const QVector4D &cameraPlane)
283{
284 // draw either molecule's mesh or all atoms and bonds
285 if (m_visible) {
286 resetTesselationHull();
287
288 painter->modelViewMatrix().push();
289
290 // Apply the material and effect to the painter.
291 QGLMaterial *material;
292 if (m_hovering)
293 material = m_hoverMaterial;
294 else if (m_selected)
295 material = m_selectionMaterial;
296 else
297 material = m_material;
298
299 ASSERT(material, "GLMoleculeObject::draw: chosen material is NULL");
300
301 painter->setColor(material->diffuseColor());
302 painter->setFaceMaterial(QGL::AllFaces, material);
303 if (m_effect)
304 painter->setUserEffect(m_effect);
305 else
306 painter->setStandardEffect(QGL::LitMaterial);
307
308 // Mark the object for object picking purposes.
309 int prevObjectId = painter->objectPickId();
310 if (m_objectId != -1)
311 painter->setObjectPickId(m_objectId);
312
313 m_mesh[0]->draw(painter);
314
315 // Turn off the user effect, if present.
316 if (m_effect)
317 painter->setStandardEffect(QGL::LitMaterial);
318
319 // Revert to the previous object identifier.
320 painter->setObjectPickId(prevObjectId);
321
322 // Restore the modelview matrix.
323 painter->modelViewMatrix().pop();
324
325 // GLMoleculeObject::draw(painter, cameraPlane);
326 } else {
327 // Draw all of the mesh objects that we have as children.
328 foreach (QObject *obj, children()) {
329 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
330 if (meshobj)
331 meshobj->draw(painter, cameraPlane);
332 }
333
334 // update bounding box prior to selection
335 resetBoundingBox();
336
337 painter->modelViewMatrix().push();
338 painter->modelViewMatrix().translate(m_position);
339 if (m_rotationAngle != 0.0f)
340 painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);
341 if ((m_scaleX != 1.0f) || (m_scaleY != 1.0f) || (m_scaleZ != 1.0f))
342 painter->modelViewMatrix().scale(m_scaleX, m_scaleY, m_scaleZ);
343
344 // Draw a box around the mesh, if selected.
345 if (m_selected)
346 drawSelectionBox(painter);
347
348 // Restore the modelview matrix.
349 painter->modelViewMatrix().pop();
350 }
351}
352
353/** Adds an atom of this molecule to the scene.
354 *
355 * @param _atom atom to add
356 */
357void GLMoleculeObject_molecule::atomInserted(QtObservedAtom::ptr _atom)
358{
359 const ObservedValue_Index_t atomid = _atom->getIndex();
360 LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomInserted for atom "
361 << _atom->getAtomIndex());
362
363 if (_atom) {
364 GLMoleculeObject_atom *atomObject =
365 new GLMoleculeObject_atom(
366 GLMoleculeObject::meshSphere,
367 this,
368 _atom);
369 ASSERT( atomObject != NULL,
370 "GLMoleculeObject_molecule::atomInserted - could not create atom object for "
371 +toString(_atom->getAtomIndex()));
372 AtomNodeMap::iterator iter = AtomsinSceneMap.find(atomid);
373 ASSERT(iter == AtomsinSceneMap.end(),
374 "GLMoleculeObject_molecule::atomInserted - same atom with id "
375 +toString(_atom->getAtomIndex())+" added again.");
376 AtomsinSceneMap.insert( make_pair(atomid, atomObject) );
377
378 qRegisterMetaType<atomId_t>("atomId_t");
379 qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");
380 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t)));
381 connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
382 connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
383 connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
384 // connect (atomObject, SIGNAL(bondsChanged()), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
385 connect (atomObject, SIGNAL(BondsAdded(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
386 connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
387 connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t)));
388
389 if (m_objectId == -1)
390 setObjectId(_atom->getAtomIndex());
391
392 // first reset bonds when signals connections have been made
393 atomObject->resetBonds();
394
395 emit changed();
396 emit changeOccured();
397 }
398}
399
400/** Removes an atom of this molecule from the scene.
401 *
402 * We just the id as the atom might have already been destroyed.
403 *
404 * @param _id id of atom to remove
405 */
406void GLMoleculeObject_molecule::atomRemoved(ObservedValue_Index_t _id)
407{
408 LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomRemoved for atom "+toString(_id)+".");
409 // bonds are removed by signal coming from ~bond
410
411 // remove atoms
412 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
413 ASSERT(iter != AtomsinSceneMap.end(),
414 "GLMoleculeObject_molecule::atomRemoved() - atom "+toString(_id)+" not on display.");
415 GLMoleculeObject_atom *atomObject = iter->second;
416 AtomsinSceneMap.erase(iter);
417 atomObject->disconnect();
418 delete atomObject;
419
420 emit changed();
421 emit changeOccured();
422
423 if (AtomsinSceneMap.empty())
424 emit moleculeEmptied(ObservedMolecule);
425}
426
427void GLMoleculeObject_molecule::hoverChangedSignalled(GLMoleculeObject *ob)
428{
429 // Find the atom, ob corresponds to.
430 hoverAtomId = -1;
431 GLMoleculeObject_atom *atomObject = dynamic_cast<GLMoleculeObject_atom *>(ob);
432 if (atomObject){
433 for (AtomNodeMap::iterator iter = AtomsinSceneMap.begin();iter != AtomsinSceneMap.end(); ++ iter){
434 if (iter->second == atomObject)
435 hoverAtomId = iter->second->objectId();
436 }
437
438 // Propagate signal.
439 emit hoverChanged(hoverAtomId);
440 } else {
441 // Find the atom, ob corresponds to.
442 GLMoleculeObject_molecule *moleculeObject = dynamic_cast<GLMoleculeObject_molecule *>(ob);
443 if (moleculeObject == this){
444 // Propagate signal.
445 emit hoverChanged(ObservedMolecule->getMolIndex(), 0);
446 }
447 }
448}
449
450
451/** Helper function to get bond ids in the correct order for BondNodeMap.
452 *
453 * \return pair of ids in correct order.
454 */
455GLMoleculeObject_molecule::BondIds GLMoleculeObject_molecule::getBondIds(
456 const bond::ptr _bond,
457 const enum GLMoleculeObject_bond::SideOfBond _side)
458{
459 BondIds ids;
460 switch (_side) {
461 case GLMoleculeObject_bond::left:
462 ids = std::make_pair(_bond->leftatom->getId(), _bond->rightatom->getId());
463 break;
464 case GLMoleculeObject_bond::right:
465 ids = std::make_pair(_bond->rightatom->getId(), _bond->leftatom->getId());
466 break;
467 }
468 return ids;
469}
470
471/** Adds a bond to the scene.
472 *
473 * @param _bond bond to add
474 * @param side which side of the bond (left or right)
475 */
476void GLMoleculeObject_molecule::bondInserted(
477 const atomId_t _left, const atomId_t _right,
478 const enum GLMoleculeObject_bond::SideOfBond _side)
479{
480 LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(_left)
481 +toString(_right)+".");
482 //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");
483
484 const BondIds ids( std::make_pair(_left, _right) );
485 BondNodeMap::iterator iter = BondsinSceneMap.find(ids);
486 if (iter == BondsinSceneMap.end()) {
487 GLMoleculeObject_bond * bondObject =
488 new GLMoleculeObject_bond(GLMoleculeObject::meshCylinder, this, ids, _side);
489 connect (
490 bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)),
491 this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
492 connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));
493 BondsinSceneMap.insert( make_pair(ids, bondObject) );
494 // BondIdsinSceneMap.insert( Leftids );
495 } else {
496 iter->second->resetPosition();
497 iter->second->resetWidth();
498 }
499 emit changed();
500 emit changeOccured();
501}
502
503/** Removes a bond from the scene.
504 *
505 * @param _bond bond to remove
506 */
507void GLMoleculeObject_molecule::bondRemoved(const atomId_t leftnr, const atomId_t rightnr)
508{
509 LOG(3, "INFO: GLWorldScene::bondRemoved() - Removing bond between "+toString(leftnr)+" and "+toString(rightnr)+".");
510 {
511 // left bond
512 const BondIds Leftids( make_pair(leftnr, rightnr) );
513 BondNodeMap::iterator leftiter = BondsinSceneMap.find( Leftids );
514 ASSERT(leftiter != BondsinSceneMap.end(),
515 "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-"
516 +toString(rightnr)+" not on display.");
517 GLMoleculeObject_bond *bondObject = leftiter->second;
518 bondObject->disconnect();
519 BondsinSceneMap.erase(leftiter);
520 delete bondObject; // is done by signal from bond itself
521 //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << ".");
522 }
523
524 emit changed();
525 emit changeOccured();
526}
527
528void GLMoleculeObject_molecule::setVisible(bool value)
529{
530 // first update the mesh if we are going to be visible now
531 if (value)
532 updateTesselationHull();
533 // then emit onward
534 GLMoleculeObject::setVisible(value);
535
536 emit changed();
537 emit changeOccured();
538}
539
540std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t)
541{
542 ost << t.first << "," << t.second;
543 return ost;
544}
545
546void GLMoleculeObject_molecule::wasClicked()
547{
548 LOG(4, "INFO: GLMoleculeObject_molecule: atom "
549 << ObservedMolecule->getMolIndex() << " has been clicked");
550 emit moleculeClicked(ObservedMolecule->getMolIndex());
551}
Note: See TracBrowser for help on using the repository browser.