19 #include <QColorDialog>
27 setContentsMargins(1, 1, 1, 1);
37 QPainter painter(
this);
40 QRect contentsRect = this->contentsRect();
41 painter.setPen(Qt::gray);
42 painter.drawRect(0, 0, contentsRect.width() + 1, contentsRect.height() + 1);
44 if (!this->isEnabled())
49 for (
int x = contentsRect.x(); x < contentsRect.x() + contentsRect.width(); x++)
51 double xVal =
m_Min + ((float)x) / contentsRect.width() * (
m_Max -
m_Min);
56 painter.drawLine(x, 1, x, contentsRect.height());
63 painter.setPen(Qt::black);
64 painter.drawText(QPoint(11, 21),
m_Title);
65 painter.setPen(Qt::white);
66 painter.drawText(QPoint(10, 20),
m_Title);
70 QString qs_min = QString::number(
m_Min);
71 QString qs_max = QString::number(
m_Max);
73 QRect qr_min = painter.fontMetrics().boundingRect(qs_min);
74 QRect qr_max = painter.fontMetrics().boundingRect(qs_max);
78 y = this->contentsRect().height() - qr_min.height() + 5;
81 painter.setPen(Qt::black);
82 painter.drawText(QPoint(x + 1, y + 1), qs_min);
83 painter.setPen(Qt::white);
84 painter.drawText(QPoint(x, y), qs_min);
86 y = this->contentsRect().height() - qr_max.height() + 5;
87 x = this->contentsRect().width() - qr_max.width() - 6;
89 painter.setPen(Qt::black);
90 painter.drawText(QPoint(x, y + 1), qs_max);
91 painter.setPen(Qt::white);
92 painter.drawText(QPoint(x, y), qs_max);
97 painter.setBrush(Qt::black);
98 painter.setPen(Qt::black);
101 int handleHeight = (i ==
m_GrabbedHandle) ? (
int)(contentsRect.height() / 1.5) : contentsRect.height() / 2;
104 int y = height() / 2;
105 painter.drawRoundRect(point.first - handleWidth / 2, y - handleHeight / 2, handleWidth, handleHeight, 50, 50);
109 int xCursor =
m_XEdit->cursorPosition();
111 m_XEdit->setCursorPosition(xCursor);
122 if ((
unsigned int)((point.first - x) * (point.first - x)) < maxSquaredDistance)
136 QColor result = QColorDialog::getColor(col);
137 if (result.isValid())
139 m_ColorTransferFunction->AddRGBPoint(xVal, result.red() / 255.0, result.green() / 255.0, result.blue() / 255.0);
int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=32) override
void RemoveFunctionPoint(double x) override
void SetTitle(const QString &title)
void MoveFunctionPoint(int index, std::pair< double, double > pos) override
double GetFunctionX(int index) override
void AddRGB(double x, double r, double g, double b)
static RenderingManager * GetInstance()
int GetFunctionSize() override
vtkColorTransferFunction * m_ColorTransferFunction
QmitkColorTransferFunctionCanvas(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
void DoubleClickOnHandle(int handle) override
std::pair< int, int > FunctionToCanvas(std::pair< double, double >)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
virtual void paintEvent(QPaintEvent *e) override