Yes, I moved the code from XRealTimeCurve and now I am saving legendItemName in XRealTimeCurve only.
{
public:
void setLegendItemName( const QString& name );
private:
}
void XTrendViewer::updateCurveTitle( XTrendCurve* curve )
{
int dataSize = curve->dataSize();
if ( dataSize == 0 )
{
curve->setTitle( curve->legendItemName() );
return;
}
QPointF currentPoint
= curve
->sample
( dataSize
- 1 );
QString legendItemValue
= QString().
setNum( currentPoint.
y(),
'f',
2 );
int maxWidth = fontMetrics.width( maxPenName ) + 10;
QString table
= "<table> <tr> <td width="+ QString().
setNum( maxWidth
) + ">" + curve
->legendItemName
() + "</td> <td width=50>" + legendItemValue + "</td> </tr> </table>";
}
class XRealTimeCurve : public QwtPlotCurve
{
public:
void setLegendItemName( const QString& name );
QString legendItemName() const;
private:
QString legendItem;
}
void XTrendViewer::updateCurveTitle( XTrendCurve* curve )
{
int dataSize = curve->dataSize();
if ( dataSize == 0 )
{
curve->setTitle( curve->legendItemName() );
return;
}
QPointF currentPoint = curve->sample( dataSize - 1 );
QString legendItemValue = QString().setNum( currentPoint.y(), 'f', 2 );
QFontMetrics fontMetrics( QwtText().font() );
int maxWidth = fontMetrics.width( maxPenName ) + 10;
QString table = "<table> <tr> <td width="+ QString().setNum( maxWidth ) + ">" + curve->legendItemName() + "</td> <td width=50>" +
legendItemValue + "</td> </tr> </table>";
curve->setTitle( QwtText( table, QwtText::RichText ) );
}
To copy to clipboard, switch view to plain text mode
I set title and legend item's text from external place in class XTrendViewer : public QwtPlot
Bookmarks