16 #include <qstyleoption.h> 18 static QBitmap
qwtBorderMask(
const QWidget *canvas,
const QSize &size )
20 const QRect r( 0, 0, size.width(), size.height() );
22 QPainterPath borderPath;
24 ( void )QMetaObject::invokeMethod(
25 const_cast< QWidget *>( canvas ),
"borderPath", Qt::DirectConnection,
26 Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) );
28 if ( borderPath.isEmpty() )
30 if ( canvas->contentsRect() == canvas->rect() )
34 mask.fill( Qt::color0 );
36 QPainter painter( &mask );
37 painter.fillRect( canvas->contentsRect(), Qt::color1 );
42 QImage image( size, QImage::Format_ARGB32_Premultiplied );
43 image.fill( Qt::color0 );
45 QPainter painter( &image );
46 painter.setClipPath( borderPath );
47 painter.fillRect( r, Qt::color1 );
51 painter.setCompositionMode( QPainter::CompositionMode_DestinationOut );
53 if ( canvas->testAttribute(Qt::WA_StyledBackground ) )
55 QStyleOptionFrame opt;
58 canvas->style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, canvas );
62 const QVariant borderRadius = canvas->property(
"borderRadius" );
63 const QVariant frameWidth = canvas->property(
"frameWidth" );
65 if ( borderRadius.type() == QVariant::Double
66 && frameWidth.type() == QVariant::Int )
68 const double br = borderRadius.toDouble();
69 const int fw = frameWidth.toInt();
71 if ( br > 0.0 && fw > 0 )
73 painter.setPen( QPen( Qt::color1, fw ) );
74 painter.setBrush( Qt::NoBrush );
75 painter.setRenderHint( QPainter::Antialiasing,
true );
77 painter.drawPath( borderPath );
84 const QImage mask = image.createMaskFromColor(
85 QColor( Qt::color1 ).rgb(), Qt::MaskOutColor );
87 return QBitmap::fromImage( mask );
116 connect(
this, SIGNAL(
panned(
int,
int ) ),
162 return parentWidget();
168 return parentWidget();
176 w = w->parentWidget();
178 return qobject_cast<
QwtPlot *>( w );
186 w = w->parentWidget();
188 return qobject_cast<
const QwtPlot *>( w );
201 if ( dx == 0 && dy == 0 )
259 const QWidget *cv =
canvas();
260 if ( cv && cv->inherits(
"QGLWidget" ) )
264 QPixmap pm( cv->size() );
267 QPainter painter( &pm );
268 const_cast<QwtPlot *
>(
plot() )->drawCanvas( &painter );
QwtPlotPanner(QWidget *)
A panner for the canvas of a QwtPlot.
static void fillPixmap(const QWidget *, QPixmap &, const QPoint &offset=QPoint())
const QwtScaleDiv & axisScaleDiv(int axisId) const
Return the scale division of a specified axis.
bool isAxisEnabled(int axis) const
virtual QBitmap contentsMask() const
virtual QBitmap contentsMask() const
Calculate a mask for the contents of the panned widget.
virtual ~QwtPlotPanner()
Destructor.
void setAutoReplot(bool=true)
Set or reset the autoReplot option.
QwtPanner provides panning of a widget.
virtual void replot()
Redraw the plot.
void setAxisEnabled(int axis, bool on)
En/Disable an axis.
double upperBound() const
virtual QPixmap grab() const
double lowerBound() const
virtual QwtScaleMap canvasMap(int axisId) const
void panned(int dx, int dy)
QwtPlot * plot()
Return plot widget, containing the observed plot canvas.
static QBitmap qwtBorderMask(const QWidget *canvas, const QSize &size)
double invTransform(double p) const
virtual QPixmap grab() const
QWidget * canvas()
Return observed plot canvas.
virtual void moveCanvas(int dx, int dy)
TFSIMD_FORCE_INLINE const tfScalar & w() const
bool isAxisEnabled[QwtPlot::axisCnt]
double transform(double s) const
void setAxisScale(int axisId, double min, double max, double step=0)
Disable autoscaling and specify a fixed scale for a selected axis.