19 #include <itkObject.h>
21 #include <QColorDialog>
22 #include <QMouseEvent>
33 m_ImmediateUpdate(false),
35 m_LineEditAvailable(false),
40 setFocusPolicy(Qt::ClickFocus);
45 QWidget::paintEvent(ev);
50 return std::make_pair(
51 (
int)((functionPoint.first -
m_Lower) / (
m_Upper -
m_Lower) * contentsRect().width()) + contentsRect().x(),
52 (
int)(contentsRect().height() * (1 - functionPoint.second)) + contentsRect().y());
57 return std::make_pair(
59 1.0 - (
double)(canvasPoint.second - contentsRect().y()) / contentsRect().height());
64 int nearHandle =
GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y());
92 this->
CanvasToFunction(std::make_pair(mouseEvent->x(), mouseEvent->y())).second);
109 std::pair<double, double> newPos = this->
CanvasToFunction(std::make_pair(mouseEvent->x(), mouseEvent->y()));
124 if (newPos.first <
m_Min)
125 newPos.first =
m_Min;
126 else if (newPos.first >
m_Max)
127 newPos.first =
m_Max;
132 if (newPos.second < 0.0)
134 else if (newPos.second > 1.0)
161 int displayWidth = contentsRect().width();
162 int displayHeight = contentsRect().height();
167 double step = (windowRight - windowLeft) /
double(displayWidth);
169 double pos = windowLeft;
171 for (
int x = 0; x < displayWidth; x++)
174 double right = pos + step;
179 p.drawLine(x, displayHeight * (1 - height), x, displayHeight);
virtual void paintEvent(QPaintEvent *e) override
virtual float GetRelativeBin(double start, double end) const =0
TODO: (What should this method do?)
virtual double GetFunctionX(int index)=0
virtual int AddFunctionPoint(double x, double val)=0
void mousePressEvent(QMouseEvent *mouseEvent) override
virtual void MoveFunctionPoint(int index, std::pair< double, double > pos)=0
virtual int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=32)=0
void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override
QmitkTransferFunctionCanvas(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
virtual void DoubleClickOnHandle(int handle)=0
void PaintHistogram(QPainter &p)
virtual void RemoveFunctionPoint(double x)=0
static RenderingManager * GetInstance()
std::pair< double, double > ValidateCoord(std::pair< double, double > x)
mitk::SimpleHistogram * m_Histogram
virtual double GetFunctionY(int index)=0
virtual int GetFunctionSize()=0
void mouseReleaseEvent(QMouseEvent *mouseEvent) override
std::pair< int, int > FunctionToCanvas(std::pair< double, double >)
void keyPressEvent(QKeyEvent *e) override
std::pair< double, double > CanvasToFunction(std::pair< int, int >)
void SetImmediateUpdate(bool state)
void mouseMoveEvent(QMouseEvent *mouseEvent) override
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)