10 #include "ViewPointStyle.h" 13 const QColor COLOR_FOR_BRUSH_ENABLED (Qt::white);
14 const QColor COLOR_FOR_BRUSH_DISABLED (Qt::gray);
23 QPixmap ViewPointStyle::pixmapForCurrentSettings ()
const 25 LOG4CPP_INFO_S ((*mainCat)) <<
"ViewPointStyle::pixmapForCurrentSettings";
28 QPolygonF polygonUnscaled = m_pointStyle.
polygon();
31 double xMinGot = polygonUnscaled.boundingRect().left();
32 double xMaxGot = polygonUnscaled.boundingRect().right();
33 double yMinGot = polygonUnscaled.boundingRect().top();
34 double yMaxGot = polygonUnscaled.boundingRect().bottom();
36 QPolygonF polygonScaled;
37 for (
int i = 0; i < polygonUnscaled.length(); i++) {
38 QPointF pOld = polygonUnscaled.at(i);
39 polygonScaled.append (QPointF ((width () - 1) * (pOld.x() - xMinGot) / (xMaxGot - xMinGot),
40 (height () - 1) * (pOld.y() - yMinGot) / (yMaxGot - yMinGot)));
44 QColor color = ColorPaletteToQColor(m_pointStyle.
paletteColor());
46 color = QColor (Qt::black);
52 QImage::Format_RGB32);
53 QPainter painter (&img);
59 QBrush (m_enabled ? COLOR_FOR_BRUSH_ENABLED : COLOR_FOR_BRUSH_DISABLED));
62 painter.setPen (QPen (color, m_pointStyle.
lineWidth()));
63 painter.drawPolygon (polygonScaled);
67 QPixmap pixmap = QPixmap::fromImage (img);
74 LOG4CPP_INFO_S ((*mainCat)) <<
"ViewPointStyle::setEnabled" 75 <<
" enabled=" << (enabled ?
"true" :
"false");
78 setPixmap (pixmapForCurrentSettings ());
83 LOG4CPP_INFO_S ((*mainCat)) <<
"ViewPointStyle::setPointStyle";
85 m_pointStyle = pointStyle;
86 setPixmap (pixmapForCurrentSettings ());
91 LOG4CPP_INFO_S ((*mainCat)) <<
"ViewPointStyle::unsetPointStyle";
93 QPixmap pEmpty (width (),
95 pEmpty.fill (COLOR_FOR_BRUSH_DISABLED);
void unsetPointStyle()
Apply no PointStyle.
ViewPointStyle(QWidget *parent=0)
Single constructor.
QPolygonF polygon() const
Return the polygon for creating a QGraphicsPolygonItem. The size is determined by the radius...
Details for a specific Point.
void setEnabled(bool enabled)
Show the style with semi-transparency or full-transparency to indicate if associated Curve is active ...
void setPointStyle(const PointStyle &pointStyle)
Apply the PointStyle of the currently selected curve.
ColorPalette paletteColor() const
Get method for point color.
int lineWidth() const
Get method for line width.