17 #ifndef QMITKPIECEWISEFUNCTIONCANVAS_H_INCLUDED
18 #define QMITKPIECEWISEFUNCTIONCANVAS_H_INCLUDED
23 #include <vtkPiecewiseFunction.h>
31 virtual void paintEvent(QPaintEvent *e)
override;
32 void SetTitle(
const QString &title);
33 int GetNearHandle(
int x,
int y,
unsigned int maxSquaredDistance = 32)
override;
37 this->m_PiecewiseFunction = piecewiseFunction;
38 this->
SetMin(m_PiecewiseFunction->GetRange()[0]);
39 this->
SetMax(m_PiecewiseFunction->GetRange()[1]);
45 int AddFunctionPoint(
double x,
double val)
override {
return m_PiecewiseFunction->AddPoint(x, val); }
49 m_PiecewiseFunction->RemovePoint(x);
52 std::cout <<
"old/new size" << old_size <<
"/" <<
GetFunctionSize() << std::endl;
53 std::cout <<
"called with x=" << x << std::endl;
57 double GetFunctionX(
int index)
override {
return m_PiecewiseFunction->GetDataPointer()[index * 2]; }
60 return m_PiecewiseFunction->GetValue(m_PiecewiseFunction->GetDataPointer()[index * 2]);
72 if ((m_PiecewiseFunction->GetRange()[0]) < 0)
74 range = (m_PiecewiseFunction->GetRange()[1]) - (m_PiecewiseFunction->GetRange()[0]);
79 range = m_PiecewiseFunction->GetRange()[1];
86 m_PiecewiseFunction->AddSegment(this->GetFunctionMin(), 0, this->GetFunctionMax(), 1);
87 m_PiecewiseFunction->AddPoint(0.0, 0.0);
92 m_PiecewiseFunction->AddSegment(this->GetFunctionMin(), 0, 0, 1);
93 m_PiecewiseFunction->AddSegment(0, 1, ((this->GetFunctionRange()) * 0.125), 1);
94 m_PiecewiseFunction->AddSegment(((this->GetFunctionRange()) * 0.125), 1, ((this->GetFunctionRange()) * 0.2), 1);
95 m_PiecewiseFunction->AddSegment(((this->GetFunctionRange()) * 0.2), 1, ((this->GetFunctionRange()) * 0.25), 1);
void DoubleClickOnHandle(int) override
virtual void paintEvent(QPaintEvent *e) override
virtual void MoveFunctionPoint(int index, std::pair< double, double > pos)=0
double GetFunctionY(int index) override
double GetFunctionRange()
virtual int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=32)=0
double GetFunctionX(int index) override
void RemoveAllFunctionPoints()
void SetPiecewiseFunction(vtkPiecewiseFunction *piecewiseFunction)
void RemoveFunctionPoint(double x) override
vtkPiecewiseFunction * m_PiecewiseFunction
int GetFunctionSize() override
virtual int GetFunctionSize()=0
int AddFunctionPoint(double x, double val) override