From 74db6a6ba251ce2d843bcab2ae2d11e5636d407c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 10 Apr 2018 12:52:58 +0200 Subject: [PATCH] Fix selection blinking display --- .../Scene_facegraph_item_k_ring_selection.h | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h b/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h index 63e915af13c..994c5b19384 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -490,6 +491,7 @@ protected: bool eventFilter(QObject* target, QEvent *event) { + static QImage background; // This filter is both filtering events from 'viewer' and 'main window' // key events @@ -562,7 +564,16 @@ protected: } else { - sample_mouse_path(); + if (event->type() != QEvent::MouseMove) + { + //Create a QImage of the screen and paint the lasso on top of it +#if QGLVIEWER_VERSION >= 0x020700 + background = static_cast(*QGLViewer::QGLViewerPool().begin())->grabFramebuffer(); +#else + background = static_cast(*QGLViewer::QGLViewerPool().begin())->grabFrameBuffer(); +#endif + } + sample_mouse_path(background); } } //if in edit_mode and the mouse is moving without left button pressed : @@ -612,7 +623,7 @@ protected: return true; } - void sample_mouse_path() + void sample_mouse_path(QImage& background) { CGAL::Three::Viewer_interface* viewer = static_cast(*QGLViewer::QGLViewerPool().begin()); viewer->makeCurrent(); @@ -624,13 +635,9 @@ protected: QPen pen; pen.setColor(QColor(Qt::green)); pen.setWidth(3); - //Create a QImage of the screen and paint the lasso on top of it -#if QGLVIEWER_VERSION >= 0x020700 - QImage image = viewer->grabFramebuffer(); -#else - QImage image = viewer->grabFrameBuffer(); -#endif - QPainter *painter = new QPainter(&image); + + QImage temp(background); + QPainter *painter = new QPainter(&temp); //painter->begin(&image); painter->setPen(pen); for(std::size_t i=0; isize(); ++i) @@ -645,7 +652,7 @@ protected: painter->end(); delete painter; viewer->set2DSelectionMode(true); - viewer->setStaticImage(image); + viewer->setStaticImage(temp); viewer->update(); }