Browse Source

BUG: Don't draw any gradient if the transfer function is null

When the mask was ON and the transfer function was empty, a gradient was
still displayed...
Julien Finet 15 years ago
parent
commit
d950e33b86
1 changed files with 7 additions and 2 deletions
  1. 7 2
      Libs/Widgets/ctkTransferFunctionGradientItem.cpp

+ 7 - 2
Libs/Widgets/ctkTransferFunctionGradientItem.cpp

@@ -33,6 +33,7 @@
 #include "ctkTransferFunctionRepresentation.h"
 #include "ctkTransferFunctionScene.h"
 
+//-----------------------------------------------------------------------------
 class ctkTransferFunctionGradientItemPrivate:public ctkPrivate<ctkTransferFunctionGradientItem>
 {
 public:
@@ -40,6 +41,7 @@ public:
   bool Mask;
 };
 
+//-----------------------------------------------------------------------------
 ctkTransferFunctionGradientItemPrivate::ctkTransferFunctionGradientItemPrivate()
 {
   this->Mask = true;
@@ -70,6 +72,10 @@ void ctkTransferFunctionGradientItem::paint(
   Q_UNUSED(option);
   Q_UNUSED(widget);
 
+  if (this->transferFunction()->count() <= 0)
+    {
+    return;
+    }
   //ctkTransferFunctionScene* tfScene = dynamic_cast<ctkTransferFunctionScene*>(this->scene());
   //Q_ASSERT(tfScene);
   ctkTransferFunctionRepresentation* tfRep = this->transferFunction()->representation();
@@ -78,8 +84,7 @@ void ctkTransferFunctionGradientItem::paint(
 
   if ( this->mask() )
     {
-    const QPainterPath& curve = tfScene->curve();
-    QPainterPath closedPath = curve;
+    QPainterPath closedPath = tfRep->curve();
     QRectF position = this->rect();
     // link to last point
     closedPath.lineTo(position.x() + position.width(), position.y() + position.height());