9 #include "qwt_polar_canvas.h" 
   10 #include "qwt_polar_plot.h" 
   11 #include "qwt_painter.h" 
   17 #include <qstyleoption.h> 
   19 #include <qx11info_x11.h> 
   22 static inline void qwtDrawStyledBackground(
 
   23     QWidget* widget, QPainter* painter )
 
   26     opt.initFrom( widget );
 
   27     widget->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, widget );
 
   30 static QWidget* qwtBackgroundWidget( QWidget* w )
 
   32     if ( w->parentWidget() == NULL )
 
   35     if ( w->autoFillBackground() )
 
   37         const QBrush brush = w->palette().brush( w->backgroundRole() );
 
   38         if ( brush.color().alpha() > 0 )
 
   42     if ( w->testAttribute( Qt::WA_StyledBackground ) )
 
   44         QImage image( 1, 1, QImage::Format_ARGB32 );
 
   45         image.fill( Qt::transparent );
 
   47         QPainter painter( &image );
 
   48         painter.translate( -w->rect().center() );
 
   49         qwtDrawStyledBackground( w, &painter );
 
   52         if ( qAlpha( image.pixel( 0, 0 ) ) != 0 )
 
   56     return qwtBackgroundWidget( w->parentWidget() );
 
   59 class QwtPolarCanvas::PrivateData
 
   80     m_data = 
new PrivateData;
 
   83     setCursor( Qt::CrossCursor );
 
   85     setFocusPolicy( Qt::WheelFocus );
 
   99     return qobject_cast< QwtPolarPlot* >( parent() );
 
  105     return qobject_cast< QwtPolarPlot* >( parent() );
 
  120     if ( 
bool( m_data->paintAttributes & attribute ) == on )
 
  124         m_data->paintAttributes |= attribute;
 
  126         m_data->paintAttributes &= ~attribute;
 
  134                 if ( m_data->backingStore == NULL )
 
  135                     m_data->backingStore = 
new QPixmap();
 
  139                     const QRect cr = contentsRect();
 
  140 #if QT_VERSION >= 0x050000 
  141                     *m_data->backingStore = grab( cr );
 
  143                     *m_data->backingStore = QPixmap::grabWidget( 
this, cr );
 
  149                 delete m_data->backingStore;
 
  150                 m_data->backingStore = NULL;
 
  166     return ( m_data->paintAttributes & attribute ) != 0;
 
  172     return m_data->backingStore;
 
  178     if ( m_data->backingStore )
 
  179         *m_data->backingStore = QPixmap();
 
  188     QPainter painter( 
this );
 
  189     painter.setClipRegion( event->region() );
 
  192         && m_data->backingStore != NULL )
 
  194         QPixmap& bs = *m_data->backingStore;
 
  195         if ( bs.size() != size() )
 
  197             bs = QPixmap( size() );
 
  199             if ( bs.x11Info().screen() != x11Info().screen() )
 
  200                 bs.x11SetScreen( x11Info().screen() );
 
  205             if ( testAttribute( Qt::WA_StyledBackground ) )
 
  208                 qwtDrawStyledBackground( 
this, &p );
 
  212                 if ( autoFillBackground() )
 
  215                     p.fillRect( rect(), palette().brush( backgroundRole() ) );
 
  219                     QWidget* bgWidget = qwtBackgroundWidget( 
plot() );
 
  222                         mapTo( bgWidget, rect().topLeft() ) );
 
  230             if ( frameWidth() > 0 )
 
  234         painter.drawPixmap( 0, 0, *m_data->backingStore );
 
  238         qwtDrawStyledBackground( 
this, &painter );
 
  242         if ( frameWidth() > 0 )
 
  243             drawFrame( &painter );
 
  253     QFrame::resizeEvent( event );
 
  255     for ( 
int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
 
  274     const QPointF center = pl->
plotRect().center();
 
  276     double dx = pos.x() - center.x();
 
  277     double dy = -( pos.y() - center.y() );
 
  284     double min = azimuthMap.
s1();
 
  285     double max = azimuthMap.
s2();
 
  291         azimuth += max - min;
 
  293     else if ( azimuth > max )
 
  295         azimuth -= max - min;
 
  320     const QPointF pos = qwtPolar2Pos(
 
  321         pl->
plotRect().center(), radius, azimuth );
 
  323     return pos.toPoint();
 
  327 #include "moc_qwt_polar_canvas.cpp" 
static void fillPixmap(const QWidget *, QPixmap &, const QPoint &offset=QPoint())
A point in polar coordinates.
double radius() const
Returns the radius.
double azimuth() const
Returns the azimuth.
QwtPointPolar normalized() const
QFlags< PaintAttribute > PaintAttributes
PaintAttribute
Paint attributes.
void invalidateBackingStore()
Invalidate the internal backing store.
QwtPointPolar invTransform(const QPoint &) const
QPoint transform(const QwtPointPolar &) const
virtual void paintEvent(QPaintEvent *) override
bool testPaintAttribute(PaintAttribute) const
QwtPolarCanvas(QwtPolarPlot *)
Constructor.
virtual ~QwtPolarCanvas()
Destructor.
virtual void resizeEvent(QResizeEvent *) override
const QPixmap * backingStore() const
void setPaintAttribute(PaintAttribute, bool on=true)
Changing the paint attributes.
A plotting widget, displaying a polar coordinate system.
QwtScaleMap scaleMap(int scaleId, double radius) const
virtual void drawCanvas(QPainter *, const QRectF &) const
void updateScale(int scaleId)
double transform(double s) const
double invTransform(double p) const