19 #include <QColorDialog>
23 : QQuickPaintedItem(parent),
30 m_ImmediateUpdate(false),
32 m_LineEditAvailable(false)
34 setAcceptedMouseButtons(Qt::AllButtons);
35 setAcceptHoverEvents(
true);
36 setAntialiasing(
true);
41 std::pair<double,double> functionPoint)
43 return std::make_pair((
int) ((functionPoint.first -
m_Lower) / (
m_Upper
44 -
m_Lower) * boundingRect().width()) + boundingRect().x(), (
int) (boundingRect().height() * (1 - functionPoint.second)) + boundingRect().y());
48 std::pair<int,int> canvasPoint)
50 return std::make_pair((canvasPoint.first - boundingRect().x()) * (
m_Upper -
m_Lower) / boundingRect().width()
51 +
m_Lower, 1.0 - (
double) (canvasPoint.second - boundingRect().y()) / boundingRect().height());
56 int nearHandle =
GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y());
75 if(mouseEvent->button() == Qt::RightButton)
76 mouseEvent->setAccepted(
false);
84 mouseEvent->pos().y())).first,
85 this->
CanvasToFunction(std::make_pair(mouseEvent->x(), mouseEvent->y())).second);
87 mouseEvent->pos().y());
98 std::pair<double,double>
115 if (newPos.first <
m_Min) newPos.first =
m_Min;
116 else if (newPos.first >
m_Max) newPos.first =
m_Max;
121 if (newPos.second < 0.0) newPos.second = 0.0;
122 else if (newPos.second > 1.0) newPos.second = 1.0;
148 int displayWidth = boundingRect().width();
149 int displayHeight = boundingRect().height();
154 double step = (windowRight-windowLeft)/
double(displayWidth);
156 double pos = windowLeft;
158 for (
int x = 0; x < displayWidth; x++)
161 double right = pos + step;
166 p->drawLine(x, displayHeight*(1-height), x, displayHeight);
std::pair< double, double > ValidateCoord(std::pair< double, double > x)
virtual float GetRelativeBin(double start, double end) const =0
TODO: (What should this method do?)
QmlMitkTransferFunctionCanvas(QQuickPaintedItem *parent=nullptr)
void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override
void PaintHistogram(QPainter *painter)
void mouseMoveEvent(QMouseEvent *mouseEvent) override
std::pair< int, int > FunctionToCanvas(std::pair< double, double >)
void mousePressEvent(QMouseEvent *mouseEvent) override
mitk::SimpleHistogram * m_Histogram
virtual int GetFunctionSize()=0
virtual void DoubleClickOnHandle(int handle)=0
virtual double GetFunctionY(int index)=0
void mouseReleaseEvent(QMouseEvent *mouseEvent) override
static RenderingManager * GetInstance()
virtual int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=32)=0
void keyPressEvent(QKeyEvent *event) override
virtual void RemoveFunctionPoint(double x)=0
std::pair< double, double > CanvasToFunction(std::pair< int, int >)
void SetImmediateUpdate(bool state)
virtual void MoveFunctionPoint(int index, std::pair< double, double > pos)=0
virtual int AddFunctionPoint(double x, double val)=0
virtual double GetFunctionX(int index)=0
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)