26 setContentsMargins(1, 1, 1, 1);
36 QPainter painter(
this);
42 painter.setPen(Qt::black);
43 painter.drawText(QPoint(11, 21),
m_Title);
44 painter.setPen(Qt::white);
45 painter.drawText(QPoint(10, 20),
m_Title);
49 QString qs_min = QString::number(
m_Min,
'g', 4);
50 QString qs_max = QString::number(
m_Max,
'g', 4);
52 QRect qr_min = painter.fontMetrics().boundingRect(qs_min);
53 QRect qr_max = painter.fontMetrics().boundingRect(qs_max);
57 y = this->contentsRect().height() - qr_min.height() + 5;
62 painter.setPen(Qt::black);
63 painter.drawText(QPoint(x + 1, y + 1), qs_min);
64 painter.setPen(Qt::white);
65 painter.drawText(QPoint(x, y), qs_min);
67 y = this->contentsRect().height() - qr_max.height() + 5;
68 x = this->contentsRect().width() - qr_max.width() - 6;
70 painter.setPen(Qt::black);
71 painter.drawText(QPoint(x, y + 1), qs_max);
72 painter.setPen(Qt::white);
73 painter.drawText(QPoint(x, y), qs_max);
76 painter.setPen(Qt::gray);
78 QRect contentsRect = this->contentsRect();
79 painter.drawRect(0, 0, contentsRect.width() + 1, contentsRect.height() + 1);
86 painter.setPen(Qt::black);
90 std::pair<int, int> left;
91 std::pair<int, int> right;
101 right = this->
FunctionToCanvas(std::make_pair(dp[(i + 1) * 2], dp[(i + 1) * 2 + 1]));
103 painter.drawLine(left.first, left.second, right.first, right.second);
110 std::pair<int, int> point = this->
FunctionToCanvas(std::make_pair(dp[i * 2], dp[i * 2 + 1]));
114 painter.setBrush(QBrush(Qt::red));
117 int xCursor =
m_XEdit->cursorPosition();
118 int yCursor =
m_YEdit->cursorPosition();
121 m_XEdit->setCursorPosition(xCursor);
122 m_YEdit->setCursorPosition(yCursor);
127 painter.setBrush(QBrush(Qt::green));
129 painter.drawEllipse(point.first - 4, point.second - 4, 8, 8);
132 painter.setBrush(Qt::NoBrush);
141 std::pair<int, int> point = this->
FunctionToCanvas(std::make_pair(dp[i * 2], dp[i * 2 + 1]));
142 if ((
unsigned int)((point.first - x) * (point.first - x) + (point.second - y) * (point.second - y)) <=
double GetFunctionY(int index) override
virtual void paintEvent(QPaintEvent *e) override
double GetFunctionX(int index) override
int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=32) override
QmitkPiecewiseFunctionCanvas(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
void PaintHistogram(QPainter &p)
void MoveFunctionPoint(int index, std::pair< double, double > pos) override
void SetTitle(const QString &title)
void RemoveFunctionPoint(double x) override
vtkPiecewiseFunction * m_PiecewiseFunction
int AddFunctionPoint(double x, double val) override
std::pair< int, int > FunctionToCanvas(std::pair< double, double >)