13 #ifndef QmitkPiecewiseFunctionCanvas_h
14 #define QmitkPiecewiseFunctionCanvas_h
19 #include <vtkPiecewiseFunction.h>
28 void SetTitle(
const QString &title);
29 int GetNearHandle(
int x,
int y,
unsigned int maxSquaredDistance = 100)
override;
33 this->m_PiecewiseFunction = piecewiseFunction;
34 this->
SetMin(m_PiecewiseFunction->GetRange()[0]);
35 this->
SetMax(m_PiecewiseFunction->GetRange()[1]);
41 int AddFunctionPoint(
double x,
double val)
override {
return m_PiecewiseFunction->AddPoint(x, val); }
45 m_PiecewiseFunction->RemovePoint(x);
48 std::cout <<
"old/new size" << old_size <<
"/" <<
GetFunctionSize() << std::endl;
49 std::cout <<
"called with x=" << x << std::endl;
53 double GetFunctionX(
int index)
override {
return m_PiecewiseFunction->GetDataPointer()[index * 2]; }
56 return m_PiecewiseFunction->GetValue(m_PiecewiseFunction->GetDataPointer()[index * 2]);
68 if ((m_PiecewiseFunction->GetRange()[0]) < 0)
70 range = (m_PiecewiseFunction->GetRange()[1]) - (m_PiecewiseFunction->GetRange()[0]);
75 range = m_PiecewiseFunction->GetRange()[1];
82 m_PiecewiseFunction->AddSegment(this->GetFunctionMin(), 0, this->GetFunctionMax(), 1);
83 m_PiecewiseFunction->AddPoint(0.0, 0.0);
88 m_PiecewiseFunction->AddSegment(this->GetFunctionMin(), 0, 0, 1);
89 m_PiecewiseFunction->AddSegment(0, 1, ((this->GetFunctionRange()) * 0.125), 1);
90 m_PiecewiseFunction->AddSegment(((this->GetFunctionRange()) * 0.125), 1, ((this->GetFunctionRange()) * 0.2), 1);
91 m_PiecewiseFunction->AddSegment(((this->GetFunctionRange()) * 0.2), 1, ((this->GetFunctionRange()) * 0.25), 1);