20 #include <QColorDialog>
47 QRectF contentsRect = this->boundingRect();
48 painter->setPen(Qt::gray);
52 for (
int x = contentsRect.x(); x < contentsRect.x() + contentsRect.width(); x++)
54 double xVal =
m_Min + ((float) x) / contentsRect.width() * (
m_Max
60 painter->drawLine(x, 1, x, contentsRect.height());
67 painter->setPen(Qt::black);
68 painter->drawText(QPoint(11,21),
m_Title);
69 painter->setPen(Qt::white);
70 painter->drawText(QPoint(10,20),
m_Title);
74 QString qs_min = QString::number(
m_Min );
75 QString qs_max = QString::number(
m_Max );
77 QRect qr_min = painter->fontMetrics().boundingRect( qs_min );
78 QRect qr_max = painter->fontMetrics().boundingRect( qs_max );
82 y=this->boundingRect().height()-qr_min.height()+10;
85 painter->setPen(Qt::black);
86 painter->drawText(QPoint(x+1,y+1),qs_min);
87 painter->setPen(Qt::white);
88 painter->drawText(QPoint(x ,y ),qs_min);
90 y=this->boundingRect().height()-qr_max.height()+10;
91 x=this->boundingRect().width()-qr_max.width()-6;
93 painter->setPen(Qt::black);
94 painter->drawText(QPoint(x,y+1),qs_max);
95 painter->setPen(Qt::white);
96 painter->drawText(QPoint(x,y ),qs_max);
101 painter->setBrush(Qt::black);
102 painter->setPen(Qt::black);
105 int handleHeight = (i ==
m_GrabbedHandle) ? (
int) (contentsRect.height() / 1.5)
106 : contentsRect.height() / 2;
110 int y = height() / 2;
111 painter->drawRoundRect(point.first - handleWidth / 2,
112 y - handleHeight / 2, handleWidth, handleHeight, 50, 50);
124 unsigned int maxSquaredDistance)
130 if ((
unsigned int) ((point.first - x) * (point.first - x))
131 < maxSquaredDistance)
145 QColor result = QColorDialog::getColor(col);
146 if (result.isValid())
149 result.green() / 255.0, result.blue() / 255.0);
156 std::pair<double,double> pos)
172 qmlRegisterType<QmlMitkColorTransferFunctionCanvas>(
"Mitk.Views", 1, 0,
"ColorItem");
void AddRGB(double x, double r, double g, double b)
QmlMitkColorTransferFunctionCanvas(QQuickPaintedItem *parent=nullptr)
int GetFunctionSize() override
void setGreyValue(double value)
std::pair< int, int > FunctionToCanvas(std::pair< double, double >)
void SetTitle(const QString &title)
double GetFunctionX(int index) override
int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=32) override
static RenderingManager * GetInstance()
void MoveFunctionPoint(int index, std::pair< double, double > pos) override
void RemoveFunctionPoint(double x) override
void DoubleClickOnHandle(int handle) override
vtkColorTransferFunction * m_ColorTransferFunction
virtual void paint(QPainter *painter) override
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)