10#include "qwt_plot_histogram.h" 
   11#include "qwt_painter.h" 
   12#include "qwt_column_symbol.h" 
   13#include "qwt_scale_map.h" 
   14#include "qwt_graphic.h" 
   19static inline bool qwtIsCombinable( 
const QwtInterval& d1,
 
   37class QwtPlotHistogram::PrivateData
 
   87void QwtPlotHistogram::init()
 
   89    m_data = 
new PrivateData();
 
  106    if ( 
style != m_data->style )
 
  108        m_data->style = 
style;
 
 
  121    return m_data->style;
 
 
  150    if ( 
pen != m_data->pen )
 
 
  176    if ( 
brush != m_data->brush )
 
  178        m_data->brush = 
brush;
 
 
  191    return m_data->brush;
 
 
  210    if ( 
symbol != m_data->symbol )
 
  212        delete m_data->symbol;
 
 
  226    return m_data->symbol;
 
 
  242    if ( m_data->baseline != value )
 
  244        m_data->baseline = value;
 
 
  255    return m_data->baseline;
 
 
  265    if ( !rect.isValid() )
 
  270        rect = QRectF( rect.y(), rect.x(),
 
  271            rect.height(), rect.width() );
 
  273        if ( rect.left() > m_data->baseline )
 
  274            rect.setLeft( m_data->baseline );
 
  275        else if ( rect.right() < m_data->baseline )
 
  276            rect.setRight( m_data->baseline );
 
  280        if ( rect.bottom() < m_data->baseline )
 
  281            rect.setBottom( m_data->baseline );
 
  282        else if ( rect.top() > m_data->baseline )
 
  283            rect.setTop( m_data->baseline );
 
 
  336    const QRectF& canvasRect, 
int from, 
int to )
 const 
  338    Q_UNUSED( canvasRect )
 
  346    switch ( m_data->style )
 
  352            drawLines( painter, xMap, yMap, from, to );
 
 
  378    int from, 
int to )
 const 
  390    for ( 
int i = from; i <= to; i++ )
 
  396            flushPolygon( painter, v0, polygon );
 
  404                flushPolygon( painter, v0, polygon );
 
  419            if ( polygon.size() == 0 )
 
  420                polygon += QPointF( x1, v0 );
 
  422            polygon += QPointF( x1, y );
 
  423            polygon += QPointF( x2, y );
 
  437            if ( polygon.size() == 0 )
 
  438                polygon += QPointF( v0, y1 );
 
  440            polygon += QPointF( x, y1 );
 
  441            polygon += QPointF( x, y2 );
 
  446    flushPolygon( painter, v0, polygon );
 
 
  463    int from, 
int to )
 const 
  465    painter->setPen( m_data->pen );
 
  466    painter->setBrush( m_data->brush );
 
  470    for ( 
int i = from; i <= to; i++ )
 
 
  495    int from, 
int to )
 const 
  499    painter->setPen( m_data->pen );
 
  500    painter->setBrush( Qt::NoBrush );
 
  504    for ( 
int i = from; i <= to; i++ )
 
  514                r.setLeft( qRound( r.left() ) );
 
  515                r.setRight( qRound( r.right() ) );
 
  516                r.setTop( qRound( r.top() ) );
 
  517                r.setBottom( qRound( r.bottom() ) );
 
  525                        r.topRight(), r.bottomRight() );
 
  531                        r.topLeft(), r.bottomLeft() );
 
  537                        r.bottomRight(), r.bottomLeft() );
 
  543                        r.topRight(), r.topLeft() );
 
 
  552void QwtPlotHistogram::flushPolygon( QPainter* painter,
 
  553    double baseLine, QPolygonF& polygon )
 const 
  555    if ( polygon.size() == 0 )
 
  559        polygon += QPointF( baseLine, polygon.last().y() );
 
  561        polygon += QPointF( polygon.last().x(), baseLine );
 
  563    if ( m_data->brush.style() != Qt::NoBrush )
 
  565        painter->setPen( Qt::NoPen );
 
  566        painter->setBrush( m_data->brush );
 
  570            polygon += QPointF( polygon.last().x(), baseLine );
 
  571            polygon += QPointF( polygon.first().x(), baseLine );
 
  575            polygon += QPointF( baseLine, polygon.last().y() );
 
  576            polygon += QPointF( baseLine, polygon.first().y() );
 
  584    if ( m_data->pen.style() != Qt::NoPen )
 
  586        painter->setBrush( Qt::NoBrush );
 
  587        painter->setPen( m_data->pen );
 
  658    if ( m_data->symbol &&
 
  661        m_data->symbol->
draw( painter, rect );
 
  668            r.setLeft( qRound( r.left() ) );
 
  669            r.setRight( qRound( r.right() ) );
 
  670            r.setTop( qRound( r.top() ) );
 
  671            r.setBottom( qRound( r.bottom() ) );
 
 
Template class for data, that is organized as QVector.
Directed rectangle representing bounding rectangle and orientation of a column.
QwtInterval vInterval
Interval for the vertical coordinates.
QwtInterval hInterval
Interval for the horizontal coordinates.
@ LeftToRight
From left to right.
@ TopToBottom
From top to bottom.
@ BottomToTop
From bottom to top.
@ RightToLeft
From right to left.
Direction direction
Direction.
A drawing primitive for columns.
virtual void draw(QPainter *, const QwtColumnRect &) const
@ NoStyle
No Style, the symbol draws nothing.
A paint device for scalable graphics.
A class representing an interval.
void setInterval(double minValue, double maxValue, BorderFlags=IncludeBorders)
@ ExcludeMaximum
Max value is not included in the interval.
@ ExcludeMinimum
Min value is not included in the interval.
BorderFlags borderFlags() const
A sample of the types (x1-x2, y) or (x, y1-y2)
QwtInterval interval
Interval.
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
static void drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
static void drawRect(QPainter *, qreal x, qreal y, qreal w, qreal h)
Wrapper for QPainter::drawRect()
static bool roundingAlignment()
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
virtual QwtColumnRect columnRect(const QwtIntervalSample &, const QwtScaleMap &, const QwtScaleMap &) const
void setBrush(const QBrush &)
HistogramStyle style() const
QwtPlotHistogram(const QString &title=QString())
virtual QwtGraphic legendIcon(int index, const QSizeF &) const override
void setStyle(HistogramStyle style)
void setBaseline(double)
Set the value of the baseline.
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
virtual ~QwtPlotHistogram()
Destructor.
void setSamples(const QVector< QwtIntervalSample > &)
void drawLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
void drawOutline(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
virtual int rtti() const override
virtual QRectF boundingRect() const override
void setSymbol(const QwtColumnSymbol *)
Assign a symbol.
const QwtColumnSymbol * symbol() const
void drawColumns(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
const QBrush & brush() const
virtual void drawColumn(QPainter *, const QwtColumnRect &, const QwtIntervalSample &) const
virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
virtual void legendChanged()
void setZ(double z)
Set the z value.
void setItemAttribute(ItemAttribute, bool on=true)
QwtGraphic defaultIcon(const QBrush &, const QSizeF &) const
Return a default icon from a brush.
@ Rtti_PlotHistogram
For QwtPlotHistogram.
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
double transform(double s) const
virtual QRectF boundingRect() const
virtual T sample(size_t i) const =0
QwtIntervalSample sample(int index) const
virtual size_t dataSize() const override
QwtSeriesData< QwtIntervalSample > * data()
void setData(QwtSeriesData< QwtIntervalSample > *series)
A class representing a text.