From ad9180d44b69200020f3b40f9011bd3dbfe1034e Mon Sep 17 00:00:00 2001 From: Peter Spackman Date: Mon, 9 Sep 2024 15:10:37 +0800 Subject: [PATCH] Begin facilitating selection of centroids --- src/graphics/chemicalstructurerenderer.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/graphics/chemicalstructurerenderer.cpp b/src/graphics/chemicalstructurerenderer.cpp index b9f187f..97370ee 100644 --- a/src/graphics/chemicalstructurerenderer.cpp +++ b/src/graphics/chemicalstructurerenderer.cpp @@ -345,17 +345,29 @@ void ChemicalStructureRenderer::addAggregateRepresentations() { if(!(m_drawingStyle == DrawingStyle::Centroid || m_drawingStyle == DrawingStyle::CenterOfMass)) return; m_ellipsoidRenderer->clear(); + if (m_selectionHandler) { + m_selectionHandler->clear(SelectionType::Aggregate); + } + std::vector fragments = m_structure->completedFragments(); const auto &fragmentMap = m_structure->getFragments(); + int i = 0; for(const auto &frag: fragments) { auto fragment = fragmentMap.at(frag); QColor color = m_structure->getFragmentColor(frag); occ::Vec3 p = (m_drawingStyle == DrawingStyle::Centroid) ? fragment.centroid() : fragment.centerOfMass(); QVector3D pos(p.x(), p.y(), p.z()); - bool selected = false; - QVector3D selectionColor(0.0, 0.0, 0.0); - cx::graphics::addSphereToEllipsoidRenderer(m_ellipsoidRenderer, pos, color, 0.4, selectionColor, selected); + bool selected = m_structure->atomsHaveFlags(fragment.atomIndices, AtomFlag::Selected); + quint32 selectionId{0}; + QVector3D selectionIdColor; + if (m_selectionHandler) { + selectionId = m_selectionHandler->add(SelectionType::Aggregate, i); + selectionIdColor = m_selectionHandler->getColorFromId(selectionId); + } + + cx::graphics::addSphereToEllipsoidRenderer(m_ellipsoidRenderer, pos, color, 0.4, selectionIdColor, selected); + i++; } }