From b623115a0e94ada2db9513f4755f1104b4c6f427 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 8 Jul 2016 12:15:37 +0300 Subject: [PATCH] Fix problem with rubber band in the VTK viewer. --- src/SVTK/SVTK_InteractorStyle.cxx | 43 ++++++++++++++++--------------- src/SVTK/SVTK_InteractorStyle.h | 4 +-- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index bc55113a3..cd5396b42 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -57,9 +57,10 @@ #include #include +#include + #include #include -#include #include #include @@ -1616,17 +1617,28 @@ void SVTK_InteractorStyle::DominantCombinedSwitch() */ void SVTK_InteractorStyle::drawRect() { - if ( !myRectBand ) { - myRectBand = new QRubberBand( QRubberBand::Rectangle, GetRenderWidget() ); - QPalette palette; - palette.setColor(myRectBand->foregroundRole(), Qt::white); - myRectBand->setPalette(palette); - } - myRectBand->hide(); + if ( !myRectBand ) + myRectBand = new QtxRectRubberBand( GetRenderWidget() ); + myRectBand->setUpdatesEnabled ( false ); QRect aRect = SUIT_Tools::makeRect(myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y()); - myRectBand->setGeometry( aRect ); - myRectBand->setVisible( aRect.isValid() ); + myRectBand->initGeometry( aRect ); + + if ( !myRectBand->isVisible() ) + myRectBand->show(); + + myRectBand->setUpdatesEnabled ( true ); +} + +/*! + \brief Delete rubber band on the end on the dragging operation. +*/ +void SVTK_InteractorStyle::endDrawRect() +{ + if ( myRectBand ) { + myRectBand->clearGeometry(); + myRectBand->hide(); + } } bool isIntersect( const QPoint& theStart1, const QPoint& theEnd1, @@ -1754,17 +1766,6 @@ void SVTK_InteractorStyle::drawPolygon() } } -/*! - \brief Delete rubber band on the end on the dragging operation. -*/ -void SVTK_InteractorStyle::endDrawRect() -{ - if ( myRectBand ) myRectBand->hide(); - - delete myRectBand; - myRectBand = 0; -} - /*! \brief Delete rubber band on the end on the dragging operation. */ diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index 08ae6f021..360e0841a 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -134,7 +134,7 @@ class SVTK_Selector; class SVTK_GenericRenderWindowInteractor; class SVTK_Actor; -class QRubberBand; +class QtxRectRubberBand; #define VTK_INTERACTOR_STYLE_CAMERA_NONE 0 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1 @@ -371,7 +371,7 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle double myBBCenter[3]; bool myBBFirstCheck; - QRubberBand* myRectBand; //!< selection rectangle rubber band + QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band QtxPolyRubberBand* myPolygonBand; //!< polygonal selection QVector myPolygonPoints; PolygonState myPoligonState; -- 2.39.2