14 #include <vtkColorTransferFunction.h> 20 #include <QMouseEvent> 21 #include <QColorDialog> 37 BaseWidget(parent,
"transfer_function_color_widget",
"Color Transfer Function"),
38 mCurrentClickPos(INT_MIN,INT_MIN),
41 this->setToolTip(
"Set the color part of a transfer function");
42 this->setFocusPolicy(Qt::StrongFocus);
61 this->setMouseTracking(
true);
66 this->setMouseTracking(
false);
87 QWidget::mousePressEvent(event);
90 if(event->button() == Qt::LeftButton)
99 QWidget::mouseReleaseEvent(event);
106 QWidget::mouseMoveEvent(event);
108 if(event->buttons() == Qt::LeftButton)
132 this->setToolTip(tip);
143 if (event->key()==Qt::Key_Left)
145 if (event->key()==Qt::Key_Right)
158 QWidget::keyPressEvent(event);
166 (intensity -
mImage->getMin()) /
167 static_cast<double>(
mImage->getRange()));
183 QWidget::paintEvent(event);
185 QPainter painter(
this);
188 painter.fillRect(this->
mFullArea, QColor(170, 170, 170));
189 painter.fillRect(this->
mPlotArea, QColor(200, 200, 200));
207 double* rgb = trFunc->GetColor(intensity);
208 painter.setPen(QColor::fromRgbF(rgb[0], rgb[1], rgb[2]));
210 if (( imin <= intensity )&&( intensity <= imax ))
217 int halfAreaTop =
mPlotArea.top() + areaHeight / 4;
218 int halfAreaBottom =
mPlotArea.bottom() - areaHeight / 4;
219 painter.drawLine(x, halfAreaTop, x, halfAreaBottom);
229 for (ColorMap::iterator colorPoint = colorMap.begin(); colorPoint != colorMap.end(); ++colorPoint)
249 painter.drawRect(pointRect);
256 QWidget::resizeEvent(evt);
259 this->
mFullArea = QRect(0, 0, width(), height());
266 std::map<int, QRect>::const_iterator it =
mPointRects.begin();
269 if (it->second.contains(pos))
274 if (colorMap.find(retval.
intensity) != colorMap.end())
305 menu.exec(event->globalPos());
323 double* rgb = trFunc->GetColor(point.
intensity);
324 point.
value = QColor::fromRgbF(rgb[0], rgb[1], rgb[2]);
368 ColorMap::iterator pointIterator = colorMap.find(selectedPointIntensity);
370 std::pair<int,int> range(
mImage->getMin(),
mImage->getMax());
371 if (pointIterator!=colorMap.begin())
373 ColorMap::iterator prevPointIterator = pointIterator;
375 range.first = std::max(range.first, prevPointIterator->first + 1);
378 ColorMap::iterator nextPointIterator = pointIterator;
380 if (nextPointIterator!=colorMap.end())
382 range.second = std::min(range.second, nextPointIterator->first - 1);
400 QColor result = QColorDialog::getColor( newPoint.
value,
this);
402 if (result.isValid() && (result!=newPoint.
value))
QString color2string(QColor color)
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
double roundAwayFromZero(double val)
vtkSmartPointer< class vtkColorTransferFunction > vtkColorTransferFunctionPtr
std::map< int, QColor > ColorMap
static ActiveImageProxyPtr New(ActiveDataPtr activeData)
double constrainValue(double val, double min, double max)
boost::shared_ptr< class ImageTFData > ImageTFDataPtr
Namespace for all CustusX production code.