Explorar o código

Add default constructors to ctk*TransferFunction*

Benjamin Long %!s(int64=13) %!d(string=hai) anos
pai
achega
ca69fac10b

+ 4 - 1
Libs/Core/ctkTransferFunction.h

@@ -38,7 +38,10 @@ class ctkTransferFunctionRepresentation;
 /// \ingroup Core
 struct CTK_CORE_EXPORT ctkPoint
 {
-  ctkPoint(){}
+  ctkPoint()
+    :X(0),Value(0)
+  {
+  }
   ctkPoint(qreal x, const QVariant& v)
     :X(x),Value(v)
   {  

+ 4 - 0
Libs/Core/ctkTransferFunctionRepresentation.cpp

@@ -60,6 +60,10 @@ ctkTransferFunctionRepresentationPrivate::ctkTransferFunctionRepresentationPriva
 {
   this->TransferFunction = 0;
   this->VerticalGradientColor = QColor::fromRgbF(1., 0., 0., 1. );
+  this->RangeXDiff = 0.;
+  this->RangeXOffSet = 0.;
+  this->RangeYDiff = 0.;
+  this->RangeYOffSet = 0.;
 }
 
 //-----------------------------------------------------------------------------

+ 2 - 0
Libs/Core/ctkTransferFunctionRepresentation.h

@@ -43,7 +43,9 @@ class CTK_CORE_EXPORT ctkTransferFunctionRepresentation: public QObject
   Q_PROPERTY(QColor verticalGradientColor READ verticalGradientColor WRITE setVerticalGradientColor)
 
 public:
+  /// Construct a representation with no transfer function.
   ctkTransferFunctionRepresentation(QObject* parent = 0);
+  /// Construct a representation with transfer function.
   ctkTransferFunctionRepresentation(ctkTransferFunction* transferFunction, QObject* parent = 0);
   virtual ~ctkTransferFunctionRepresentation();
 

+ 11 - 3
Libs/Visualization/VTK/Core/ctkVTKColorTransferFunction.cpp

@@ -24,11 +24,16 @@
 
 /// CTK includes
 #include "ctkVTKColorTransferFunction.h"
+#include "ctkLogger.h"
 
 /// VTK includes
 #include <vtkColorTransferFunction.h>
 #include <vtkSmartPointer.h>
 
+//--------------------------------------------------------------------------
+static ctkLogger logger("org.commontk.libs.visualization.core.ctkVTKColorTransferFunction");
+//--------------------------------------------------------------------------
+
 //-----------------------------------------------------------------------------
 class ctkVTKColorTransferFunctionPrivate
 {
@@ -86,7 +91,8 @@ void ctkVTKColorTransferFunction::range(qreal& minRange, qreal& maxRange)const
   Q_D(const ctkVTKColorTransferFunction);
   if (d->ColorTransferFunction.GetPointer() == 0)
     {
-    Q_ASSERT(d->ColorTransferFunction.GetPointer());
+    //Q_ASSERT(d->ColorTransferFunction.GetPointer());
+    logger.warn("no ColorTransferFunction");
     minRange = 1.;
     maxRange = 0.;
     return;
@@ -103,7 +109,8 @@ QVariant ctkVTKColorTransferFunction::minValue()const
   Q_D(const ctkVTKColorTransferFunction);
   if (d->ColorTransferFunction.GetPointer() == 0)
     {
-    Q_ASSERT(d->ColorTransferFunction.GetPointer());
+    //Q_ASSERT(d->ColorTransferFunction.GetPointer());
+    logger.warn("no ColorTransferFunction");
     return -1;
     }
   double rgb[3];
@@ -130,7 +137,8 @@ QVariant ctkVTKColorTransferFunction::maxValue()const
   Q_D(const ctkVTKColorTransferFunction);
   if (d->ColorTransferFunction.GetPointer() == 0)
     {
-    Q_ASSERT(d->ColorTransferFunction.GetPointer());
+    //Q_ASSERT(d->ColorTransferFunction.GetPointer());
+    logger.warn("no ColorTransferFunction");
     return -1;
     }
   double rgb[3];

+ 4 - 0
Libs/Visualization/VTK/Core/ctkVTKColorTransferFunction.h

@@ -38,11 +38,15 @@ class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKColorTransferFunction: public ctkT
   Q_OBJECT;
   QVTK_OBJECT;
 public:
+  /// Please note that ctkVTKColorTransferFunction methods only work only if
+  /// colorTransferFunction is set.
   ctkVTKColorTransferFunction(QObject* parent = 0);
   ctkVTKColorTransferFunction(vtkColorTransferFunction* colorTransferFunction, 
                               QObject* parent = 0);
   virtual ~ctkVTKColorTransferFunction();
   
+  /// Please note that controlPoint methods only works if you have at least one
+  /// ControlPoint.
   virtual ctkControlPoint* controlPoint(int index)const;
   virtual QVariant value(qreal pos)const;
   virtual int count()const;