Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef QMITKCOLORTRANSFERFUNCTIONCANVAS_H_INCLUDED
00019 #define QMITKCOLORTRANSFERFUNCTIONCANVAS_H_INCLUDED
00020
00021 #include "QmitkTransferFunctionCanvas.h"
00022 #include "QmitkExtExports.h"
00023
00024 #include <vtkColorTransferFunction.h>
00025
00026 class QmitkExt_EXPORT QmitkColorTransferFunctionCanvas: public QmitkTransferFunctionCanvas
00027 {
00028 Q_OBJECT
00029
00030 public:
00031
00032 QmitkColorTransferFunctionCanvas( QWidget* parent = 0, Qt::WindowFlags f = 0 ) ;
00033 virtual void paintEvent( QPaintEvent* e );
00034 int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32);
00035 void SetTitle(std::string title);
00036
00037 void SetColorTransferFunction(vtkColorTransferFunction* colorTransferFunction)
00038 {
00039 this->m_ColorTransferFunction = colorTransferFunction;
00040 this->SetMin(colorTransferFunction->GetRange()[0]);
00041 this->SetMax(colorTransferFunction->GetRange()[1]);
00042 setEnabled(true);
00043 update();
00044 };
00045
00046 void AddFunctionPoint(vtkFloatingPointType x,vtkFloatingPointType )
00047 {
00048 m_ColorTransferFunction->AddRGBPoint(x,m_ColorTransferFunction->GetRedValue(x),m_ColorTransferFunction->GetGreenValue(x),m_ColorTransferFunction->GetBlueValue(x));
00049 };
00050
00051 void RemoveFunctionPoint(vtkFloatingPointType x)
00052 {
00053 int old_size = GetFunctionSize();
00054 m_ColorTransferFunction->RemovePoint(x);
00055 if (GetFunctionSize() + 1 != old_size)
00056 {
00057 std::cout << "old/new size" << old_size << "/" << GetFunctionSize() << std::endl;
00058 std::cout << "called with x=" << x << std::endl;
00059 }
00060 };
00061
00062 vtkFloatingPointType GetFunctionX(int index)
00063 {
00064 return m_ColorTransferFunction->GetDataPointer()[index*4];
00065 }
00066
00067 int GetFunctionSize()
00068 {
00069 return m_ColorTransferFunction->GetSize();
00070 }
00071
00072 void DoubleClickOnHandle(int handle);
00073 void MoveFunctionPoint(int index, std::pair<vtkFloatingPointType,vtkFloatingPointType> pos);
00074
00075 void AddRGB(double x, double r, double g, double b);
00076
00077 double GetFunctionMax()
00078 {
00079 return m_ColorTransferFunction->GetRange()[1];
00080 }
00081
00082 double GetFunctionMin()
00083 {
00084 return m_ColorTransferFunction->GetRange()[0];
00085 }
00086
00087 double GetFunctionRange()
00088 {
00089 double range;
00090 if((m_ColorTransferFunction->GetRange()[0])==0)
00091 {
00092 range = m_ColorTransferFunction->GetRange()[1];
00093 return range;
00094 }
00095 else
00096 {
00097 range = (m_ColorTransferFunction->GetRange()[1])-(m_ColorTransferFunction->GetRange()[0]);
00098 return range;
00099 }
00100 }
00101
00102 void RemoveAllFunctionPoints()
00103 {
00104 m_ColorTransferFunction->AddRGBSegment(this->GetFunctionMin(),1,0,0,this->GetFunctionMax(),1,1,0);
00105 }
00106
00107 float GetFunctionY(int)
00108 {
00109 return 0.0;
00110 }
00111
00112 protected:
00113
00114 vtkColorTransferFunction* m_ColorTransferFunction;
00115 std::string m_Title;
00116
00117 };
00118 #endif