13 #ifndef QmitkColorTransferFunctionCanvas_h
14 #define QmitkColorTransferFunctionCanvas_h
19 #include <vtkColorTransferFunction.h>
52 int GetNearHandle(
int x,
int y,
unsigned int maxSquaredDistance = 100)
override;
66 this->m_ColorTransferFunction = colorTransferFunction;
67 this->
SetMin(colorTransferFunction->GetRange()[0]);
68 this->
SetMax(colorTransferFunction->GetRange()[1]);
82 return m_ColorTransferFunction->AddRGBPoint(x,
83 m_ColorTransferFunction->GetRedValue(x),
84 m_ColorTransferFunction->GetGreenValue(x),
85 m_ColorTransferFunction->GetBlueValue(x));
95 m_ColorTransferFunction->RemovePoint(x);
98 std::cout <<
"old/new size" << old_size <<
"/" <<
GetFunctionSize() << std::endl;
99 std::cout <<
"called with x=" << x << std::endl;
108 double GetFunctionX(
int index)
override {
return m_ColorTransferFunction->GetDataPointer()[index * 4]; }
136 void AddRGB(
double x,
double r,
double g,
double b);
157 if ((m_ColorTransferFunction->GetRange()[0]) == 0)
159 range = m_ColorTransferFunction->GetRange()[1];
164 range = (m_ColorTransferFunction->GetRange()[1]) - (m_ColorTransferFunction->GetRange()[0]);
172 m_ColorTransferFunction->AddRGBSegment(this->GetFunctionMin(), 1, 0, 0, this->GetFunctionMax(), 1, 1, 0);
Canvas widget for editing a vtkColorTransferFunction.
vtkColorTransferFunction * m_ColorTransferFunction
QmitkColorTransferFunctionCanvas(QWidget *parent=nullptr, Qt::WindowFlags f={})
Construct the color transfer function canvas.
int GetFunctionSize() override
Get the number of points in the color transfer function.
int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=100) override
Find a handle near the given canvas position.
void SetTitle(const QString &title)
Set the title text displayed on the canvas.
void DoubleClickOnHandle(int handle) override
Open a QColorDialog to change the color at the given handle.
void RemoveFunctionPoint(double x) override
Remove the color function point at position x.
double GetFunctionY(int) override
Always returns 0.0 since color transfer functions have no y component.
void MoveFunctionPoint(int index, std::pair< double, double > pos) override
Move a function point to a new position, preserving its color.
double GetFunctionX(int index) override
Get the x (scalar) value of a function point by index.
int AddFunctionPoint(double x, double val) override
Add a color function point at position x, preserving the existing color at x.
double GetFunctionMin()
Get the minimum scalar value of the function range.
double GetFunctionRange()
Get the span of the function range (max - min).
void AddRGB(double x, double r, double g, double b)
Add an RGB color point to the transfer function.
void RemoveAllFunctionPoints()
Reset the function to a default red-to-yellow gradient.
double GetFunctionMax()
Get the maximum scalar value of the function range.
void paintEvent(QPaintEvent *e) override
Paint the color gradient, handles, title, and min/max labels.
void SetColorTransferFunction(vtkColorTransferFunction *colorTransferFunction)
Set the vtkColorTransferFunction to edit.
Abstract base class for transfer function editing canvases.
void SetMin(double min)
Set the minimum scalar value and update the lower display bound.
virtual int GetFunctionSize()=0
Get the number of function points.
void SetMax(double max)
Set the maximum scalar value and update the upper display bound.