]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Add shared ptr for foreground objects
authorCHEMIN Sébastien 236498 <sc236498@is245491.intra.cea.fr>
Wed, 29 May 2024 06:27:22 +0000 (08:27 +0200)
committerCHEMIN Sébastien 236498 <sc236498@is245491.intra.cea.fr>
Wed, 29 May 2024 06:27:22 +0000 (08:27 +0200)
src/QtViewer/QtViewer_ViewPort.cxx
src/QtViewer/QtViewer_ViewPort.h

index 040f79516ed148403440c4f8ed06f59d89845cc7..b741c4b2f140823b10ca6121a5853c12d3e66656 100644 (file)
@@ -76,11 +76,19 @@ QtViewer_ViewPort::~QtViewer_ViewPort()
   zoomCursor = nullptr;
 }
 
+void QtViewer_ViewPort::resetForeground()
+{
+  for (std::shared_ptr<QtViewer_PainterObject> obj : foregroundObjects)
+    obj.reset();
+
+  foregroundObjects.clear();
+}
+
 void QtViewer_ViewPort::drawForeground(QPainter *painter, const QRectF &rect)
 {
   Q_UNUSED(rect);
 
-  for (QtViewer_PainterObject* obj : foregroundObjects)
+  for (std::shared_ptr<QtViewer_PainterObject> obj : foregroundObjects)
     obj->draw(painter);
 }
 
index e419c91e357408f8db0b50ef009ce09facc0271d..200ea383deac56d7bde0a181f423350bb72f9790 100644 (file)
@@ -59,7 +59,8 @@ public:
   QImage dumpView(bool theWholeScene = false, QSizeF theSize = QSizeF());
   bool dumpViewToFormat(const QString& fileName, const QString& format);
 
-  void addForegroundObject(QtViewer_PainterObject* obj) { foregroundObjects.append(obj); }
+  void addForegroundObject( std::shared_ptr<QtViewer_PainterObject> obj) { foregroundObjects.append(obj); }
+  void resetForeground();
 
 signals:
   void vpMouseEvent(QMouseEvent*);
@@ -95,7 +96,7 @@ private:
   QPoint previousPos;
   QCursor* zoomCursor;
 
-  QList<QtViewer_PainterObject*> foregroundObjects;
+  QList<std::shared_ptr<QtViewer_PainterObject> > foregroundObjects;
 };
 
 #endif