1 Attachment(s)
Re: qwt-6.0.2 subclassing QwtPlotCurve and reimpl. drawSymbols for rotated markers
Hello you all,
I'm using qwt 6.0.2 and I'm trying to draw rotated markers by a custom angle, tipically 30° counterclockwise.
Surfing the group, I found this thread in which is described how to plot custom markers/symbols: unfortunately doesn't work for me, because the signature of the method QwtPlotCurve::drawSymbols doesn't match with my version.
How do I solve this?
Added after 57 minutes:
Actually I solved quick and dirty modifying directly QwtPlotMarker sources.
Addedo to .h:
Code:
void setLabelRotationAngle(double angle = 0.0);
...
private:
double _rotationAngle;
Added to .cpp:
Code:
_rotationAngle(0.0)
{
d_data = new PrivateData;
setZ( 30.0 );
}
.....
{
_rotationAngle = angle;
}
and into drawlabel method:
Code:
{
.....
if (_rotationAngle != 0.0){
painter
->setRenderHint
(QPainter::Antialiasing);
painter->rotate(_rotationAngle);
}
const QRectF textRect
( 0,
0, textSize.
width(), textSize.
height() );
d_data->label.draw( painter, textRect );
}
the client side:
Code:
marker
->setLabel
(QString::fromLatin1(QDateTime::fromTime_t(ge
->timestamp
).
toString("hh:mm").
toAscii()));
marker->setLabelOrientation(Qt::Horizontal);
marker
->setLinePen
(QPen(Qt
::darkGray,
0, Qt
::DotLine));
marker->setXValue(ge->timestamp);
marker->setYValue(d);
marker->setLabelAlignment(Qt::AlignCenter | Qt::AlignLeft);
// the tip:
marker->setLabelRotationAngle(-30.0);
curve->add_marker(marker);
marker->attach(this);
the results: