10 #include "qwt_plot_intervalcurve.h"
11 #include "qwt_interval_symbol.h"
12 #include "qwt_scale_map.h"
13 #include "qwt_clipper.h"
14 #include "qwt_painter.h"
15 #include "qwt_graphic.h"
22 double xMin,
double xMax,
double yMin,
double yMax )
24 const double y = sample.
value;
28 const bool isOffScreen = ( y < yMin ) || ( y > yMax )
29 || ( x1 < xMin && x2 < xMin ) || ( x1 > xMax && x2 > xMax );
35 double xMin,
double xMax,
double yMin,
double yMax )
37 const double x = sample.
value;
41 const bool isOffScreen = ( x < xMin ) || ( x > xMax )
42 || ( y1 < yMin && y2 < yMin ) || ( y1 > yMax && y2 > yMax );
47 class QwtPlotIntervalCurve::PrivateData
59 pen.setCapStyle( Qt::FlatCap );
108 m_data =
new PrivateData;
131 m_data->paintAttributes |= attribute;
133 m_data->paintAttributes &= ~attribute;
143 return ( m_data->paintAttributes & attribute );
180 if (
style != m_data->style )
182 m_data->style =
style;
195 return m_data->style;
206 if (
symbol != m_data->symbol )
208 delete m_data->symbol;
222 return m_data->symbol;
250 if (
pen != m_data->pen )
278 if (
brush != m_data->brush )
280 m_data->brush =
brush;
293 return m_data->brush;
304 rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
324 const QRectF& canvasRect,
int from,
int to )
const
335 switch ( m_data->style )
338 drawTube( painter, xMap, yMap, canvasRect, from, to );
346 if ( m_data->symbol &&
350 xMap, yMap, canvasRect, from, to );
373 const QRectF& canvasRect,
int from,
int to )
const
379 const size_t size = to - from + 1;
380 QPolygonF polygon( 2 * size );
381 QPointF* points = polygon.data();
383 for ( uint i = 0; i < size; i++ )
385 QPointF& minValue = points[i];
386 QPointF& maxValue = points[2 * size - 1 - i];
425 if ( m_data->brush.style() != Qt::NoBrush )
427 painter->setPen( QPen( Qt::NoPen ) );
428 painter->setBrush( m_data->brush );
434 canvasRect.adjusted( -m, -m, m, m ), polygon,
true );
444 if ( m_data->pen.style() != Qt::NoPen )
446 painter->setPen( m_data->pen );
447 painter->setBrush( Qt::NoBrush );
452 const QRectF clipRect = canvasRect.adjusted( -pw, -pw, pw, pw );
456 std::memcpy( p.data(), points, size *
sizeof( QPointF ) );
460 std::memcpy( p.data(), points + size, size *
sizeof( QPointF ) );
490 const QRectF& canvasRect,
int from,
int to )
const
495 pen.setCapStyle( Qt::FlatCap );
497 painter->setPen(
pen );
502 const double xMin = tr.left();
503 const double xMax = tr.right();
504 const double yMin = tr.top();
505 const double yMax = tr.bottom();
507 const bool doClip = m_data->paintAttributes &
ClipSymbol;
509 for (
int i = from; i <= to; i++ )
515 if ( !doClip || qwtIsVSampleInside( s, xMin, xMax, yMin, yMax ) )
522 QPointF( x, y1 ), QPointF( x, y2 ) );
527 if ( !doClip || qwtIsHSampleInside( s, xMin, xMax, yMin, yMax ) )
534 QPointF( x1, y ), QPointF( x2, y ) );
555 int index,
const QSizeF& size )
const
559 if ( size.isEmpty() )
566 QPainter painter( &icon );
567 painter.setRenderHint( QPainter::Antialiasing,
570 if ( m_data->style ==
Tube )
572 QRectF r( 0, 0, size.width(), size.height() );
573 painter.fillRect( r, m_data->brush );
576 if ( m_data->symbol &&
579 QPen
pen = m_data->symbol->pen();
580 pen.setWidthF(
pen.widthF() );
581 pen.setCapStyle( Qt::FlatCap );
583 painter.setPen(
pen );
584 painter.setBrush( m_data->symbol->brush() );
588 const double x = 0.5 * size.width();
591 QPointF( x, 0 ), QPointF( x, size.height() - 1.0 ) );
595 const double y = 0.5 * size.height();
598 QPointF( 0.0, y ), QPointF( size.width() - 1.0, y ) );
A paint device for scalable graphics.
void setRenderHint(RenderHint, bool on=true)
void setDefaultSize(const QSizeF &)
Set a default size.
A sample of the types (x1-x2, y) or (x, y1-y2)
QwtInterval interval
Interval.
Interface for iterating over an array of intervals.
A drawing primitive for displaying an interval like an error bar.
virtual void draw(QPainter *, Qt::Orientation, const QPointF &from, const QPointF &to) const
@ NoSymbol
No Style. The symbol cannot be drawn.
const QBrush & brush() const
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
static void drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
static qreal effectivePenWidth(const QPen &)
static bool roundingAlignment()
QwtPlotIntervalCurve represents a series of samples, where each value is associated with an interval ...
virtual int rtti() const override
virtual ~QwtPlotIntervalCurve()
Destructor.
QFlags< PaintAttribute > PaintAttributes
void setBrush(const QBrush &)
QwtPlotIntervalCurve(const QString &title=QString())
@ ClipSymbol
Check if a symbol is on the plot canvas before painting it.
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
virtual QwtGraphic legendIcon(int index, const QSizeF &) const override
virtual QRectF boundingRect() const override
void setSymbol(const QwtIntervalSymbol *)
void setStyle(CurveStyle style)
void init()
Initialize internal members.
const QBrush & brush() const
virtual void drawSymbols(QPainter *, const QwtIntervalSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
CurveStyle
Curve styles. The default setting is QwtPlotIntervalCurve::Tube.
const QwtIntervalSymbol * symbol() const
void setPaintAttribute(PaintAttribute, bool on=true)
void setSamples(const QVector< QwtIntervalSample > &)
virtual void drawTube(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
bool testPaintAttribute(PaintAttribute) const
virtual void legendChanged()
void setZ(double z)
Set the z value.
void setItemAttribute(ItemAttribute, bool on=true)
@ Rtti_PlotIntervalCurve
For QwtPlotIntervalCurve.
@ RenderAntialiased
Enable antialiasing.
bool testRenderHint(RenderHint) const
virtual void itemChanged()
@ Legend
The item is represented on the legend.
Base class for plot items representing a series of samples.
Qt::Orientation orientation() const
virtual QRectF boundingRect() const override
double transform(double s) const
double invTransform(double p) const
Abstract interface for iterating over samples.
QwtIntervalSample sample(int index) const
virtual size_t dataSize() const override
QwtSeriesData< QwtIntervalSample > * data()
void setData(QwtSeriesData< QwtIntervalSample > *series)
A class representing a text.
QWT_EXPORT QPolygonF clippedPolygonF(const QRectF &, const QPolygonF &, bool closePolygon=false)