8 #include <QFontDatabase> 12 inline bool operator()(
const double x,
const QPointF &pos )
const 14 return ( x < pos.x() );
45 bool changed =
_param != par;
78 int visible_points = 0;
80 while(
_marker.size() > curves.size())
86 for (
int i =
_marker.size() ;
i < curves.size();
i++ )
92 double text_X_offset = 0;
94 std::multimap<double,QString> text_lines;
96 for (
int i = 0;
i < curves.size();
i++ )
105 QColor color = curve->
pen().color();
107 text_X_offset = rect.width() * 0.02;
119 const QLineF line =
curveLineAt( curve, position.x() );
127 double middle_X = (line.p1().x() + line.p2().x()) / 2.0;
129 if( position.x() < middle_X )
136 if( rect.contains( point ) &&
_visible )
140 double val = point.y();
146 line = QString(
"<font color=%1>%2</font>" ).arg( color.name() ).
arg( val );
150 QString
value = QString::number( val,
'f', 3);
151 int whitespaces = 8 - value.length();
152 while(whitespaces-- > 0) value.prepend(
" ");
154 line = QString(
"<font color=%1>%2 : %3</font>" )
155 .arg( color.name() ).
arg( value ).arg(curve->
title().
text() );
158 text_lines.insert( std::make_pair(val, line) );
170 QString text_marker_info;
173 for(
auto it = text_lines.rbegin(); it != text_lines.rend(); it++)
175 text_marker_info += it->second;
176 if( count++ < text_lines.size() -1 )
178 text_marker_info +=
"<br>";
182 QColor col(
"#FFFFFF" );
186 mark_text.
setText( text_marker_info );
188 QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
189 font.setPointSize( 9 );
199 if(visible_points > 0){
203 double canvas_ratio = rect.width() / double(
_plot->width());
204 double text_width = mark_text.
textSize().width() * canvas_ratio;
226 int index = qwtUpperSampleIndex<QPointF>(
231 line.setP1( curve->
sample( index - 1 ) );
232 line.setP2( curve->
sample( index ) );
virtual size_t dataSize() const
A plot item, that represents a series of points.
void setFont(const QFont &)
void setValue(double, double)
Set Value.
void setText(const QString &, QwtText::TextFormat textFormat=AutoText)
void setBorderPen(const QPen &)
QList< QwtPlotItem * > QwtPlotItemList
See QT 4.x assistant documentation for QList.
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
QwtSeriesData< T > * data()
A class for drawing symbols.
Y axis left of the canvas.
void setColor(const QColor &)
void setLinePen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
QSizeF textSize(const QFont &=QFont()) const
void setRenderFlags(int flags)
Change the render flags.
QwtPlotMarker * _line_marker
QLineF curveLineAt(const QwtPlotCurve *, double x) const
void setXValue(double)
Set X Value.
A class representing a text.
virtual QwtScaleMap canvasMap(int axisId) const
virtual QRectF boundingRect() const
void setBackgroundBrush(const QBrush &)
T sample(int index) const
void setEnabled(bool enable)
QwtPlotMarker * _text_marker
void setLabel(const QwtText &)
Set the label.
QPointF _prev_trackerpoint
std::vector< QwtPlotMarker * > _marker
virtual void setVisible(bool)
void attach(QwtPlot *plot)
Attach the item to a plot.
void setLabelAlignment(Qt::Alignment)
Set the alignment of the label.
void setYValue(double)
Set Y Value.
QPointF actualPosition() const
void setPosition(const QPointF &pos)
void setLineStyle(LineStyle st)
Set the line style.
void setParameter(Parameter par)
bool operator()(const double x, const QPointF &pos) const
A class for drawing markers.
const QwtText & title() const