17 #ifndef __QmlMitkPieceWiseFunctionCanvas_h
18 #define __QmlMitkPieceWiseFunctionCanvas_h
23 #include <vtkPiecewiseFunction.h>
31 Q_PROPERTY(
double greyValue READ getGreyValue WRITE setGreyValue)
32 Q_PROPERTY(
double opacity READ getOpacity WRITE setOpacity)
37 void paint(QPainter* painter ) override;
38 void SetTitle(const QString& title);
39 int GetNearHandle(
int x,
int y,
unsigned int maxSquaredDistance = 32) override;
43 void setGreyValue(
double value);
44 double getGreyValue();
46 void setOpacity(
double opacity);
49 void SetPiecewiseFunction(vtkPiecewiseFunction* piecewiseFunction)
51 this->m_PiecewiseFunction = piecewiseFunction;
52 this->
SetMin(m_PiecewiseFunction->GetRange()[0]);
53 this->
SetMax(m_PiecewiseFunction->GetRange()[1]);
61 return m_PiecewiseFunction->AddPoint(x,val);
67 m_PiecewiseFunction->RemovePoint(x);
70 std::cout <<
"old/new size" << old_size <<
"/" <<
GetFunctionSize() << std::endl;
71 std::cout <<
"called with x=" << x << std::endl;
77 return m_PiecewiseFunction->GetDataPointer()[index*2];
82 return m_PiecewiseFunction->GetValue(m_PiecewiseFunction->GetDataPointer()[index*2]);
87 return m_PiecewiseFunction->GetSize();
98 return m_PiecewiseFunction->GetRange()[1];
103 return m_PiecewiseFunction->GetRange()[0];
109 if((m_PiecewiseFunction->GetRange()[0])<0)
111 range = (m_PiecewiseFunction->GetRange()[1])-(m_PiecewiseFunction->GetRange()[0]);
116 range = m_PiecewiseFunction->GetRange()[1];
123 m_PiecewiseFunction->AddSegment(this->GetFunctionMin(),0,this->GetFunctionMax(),1);
124 m_PiecewiseFunction->AddPoint(0.0,0.0);
130 m_PiecewiseFunction->AddSegment(this->GetFunctionMin(),0,0,1);
131 m_PiecewiseFunction->AddSegment(0,1,((this->GetFunctionRange())*0.125),1);
132 m_PiecewiseFunction->AddSegment(((this->GetFunctionRange())*0.125),1,((this->GetFunctionRange())*0.2),1);
133 m_PiecewiseFunction->AddSegment(((this->GetFunctionRange())*0.2),1,((this->GetFunctionRange())*0.25),1);
142 static void create();
int GetFunctionSize() override
vtkPiecewiseFunction * m_PiecewiseFunction
void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override
double GetFunctionY(int index) override
mitk::SimpleHistogramCache histogramCache
#define MITKQMLITEMS_EXPORT
void mouseMoveEvent(QMouseEvent *mouseEvent) override
double GetFunctionRange()
void mousePressEvent(QMouseEvent *mouseEvent) override
virtual int GetFunctionSize()=0
void mouseReleaseEvent(QMouseEvent *mouseEvent) override
void keyPressEvent(QKeyEvent *event) override
void RemoveFunctionPoint(double x) override
virtual void MoveFunctionPoint(int index, std::pair< double, double > pos)=0
void RemoveAllFunctionPoints()
int AddFunctionPoint(double x, double val) override
void DoubleClickOnHandle(int) override
double GetFunctionX(int index) override