改进代码
This commit is contained in:
@@ -197,7 +197,7 @@ void QwtAbstractScaleDraw::draw( QPainter *painter,
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QPen pen = painter->pen();
|
||||
pen = painter->pen();
|
||||
pen.setColor( palette.color( QPalette::WindowText ) );
|
||||
pen.setCapStyle( Qt::FlatCap );
|
||||
|
||||
@@ -226,7 +226,7 @@ void QwtAbstractScaleDraw::draw( QPainter *painter,
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QPen pen = painter->pen();
|
||||
pen = painter->pen();
|
||||
pen.setColor( palette.color( QPalette::WindowText ) );
|
||||
pen.setCapStyle( Qt::FlatCap );
|
||||
|
||||
@@ -392,19 +392,18 @@ QwtText QwtAbstractScaleDraw::label( double value ) const
|
||||
const QwtText &QwtAbstractScaleDraw::tickLabel(
|
||||
const QFont &font, double value ) const
|
||||
{
|
||||
QMap<double, QwtText>::const_iterator it = d_data->labelCache.find( value );
|
||||
if ( it == d_data->labelCache.end() )
|
||||
{
|
||||
QMap<double, QwtText>::const_iterator it1 = d_data->labelCache.constFind( value );
|
||||
if ( it1 != d_data->labelCache.constEnd() )
|
||||
return *it1;
|
||||
|
||||
QwtText lbl = label( value );
|
||||
lbl.setRenderFlags( 0 );
|
||||
lbl.setLayoutAttribute( QwtText::MinimumLayout );
|
||||
|
||||
( void )lbl.textSize( font ); // initialize the internal cache
|
||||
|
||||
it = d_data->labelCache.insert( value, lbl );
|
||||
}
|
||||
|
||||
return ( *it );
|
||||
QMap<double, QwtText>::iterator it2 = d_data->labelCache.insert( value, lbl );
|
||||
return *it2;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
QwtAbstractScaleDraw();
|
||||
virtual ~QwtAbstractScaleDraw();
|
||||
|
||||
void setScaleDiv( const QwtScaleDiv &s );
|
||||
void setScaleDiv( const QwtScaleDiv & );
|
||||
const QwtScaleDiv& scaleDiv() const;
|
||||
|
||||
void setTransformation( QwtTransform * );
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
double tickLength( QwtScaleDiv::TickType ) const;
|
||||
double maxTickLength() const;
|
||||
|
||||
void setSpacing( double margin );
|
||||
void setSpacing( double );
|
||||
double spacing() const;
|
||||
|
||||
void setPenWidth( int width );
|
||||
|
||||
@@ -27,7 +27,7 @@ static double qwtAlignToScaleDiv(
|
||||
if ( tValue == slider->transform( sd.lowerBound() ) )
|
||||
return sd.lowerBound();
|
||||
|
||||
if ( tValue == slider->transform( sd.lowerBound() ) )
|
||||
if ( tValue == slider->transform( sd.upperBound() ) )
|
||||
return sd.upperBound();
|
||||
|
||||
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
bool invertedControls() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setValue( double val );
|
||||
void setValue( double value );
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
@@ -146,7 +146,7 @@ protected:
|
||||
*/
|
||||
virtual double scrolledTo( const QPoint &pos ) const = 0;
|
||||
|
||||
void incrementValue( int numSteps );
|
||||
void incrementValue( int stepCount );
|
||||
|
||||
virtual void scaleChange();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent *event );
|
||||
|
||||
virtual void drawButtonLabel( QPainter *p );
|
||||
virtual void drawButtonLabel( QPainter * );
|
||||
virtual void drawArrow( QPainter *,
|
||||
const QRect &, Qt::ArrowType ) const;
|
||||
virtual QRect labelRect() const;
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
};
|
||||
|
||||
QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
|
||||
QwtLinearColorMap( const QColor &from, const QColor &to,
|
||||
QwtLinearColorMap( const QColor &color1, const QColor &color2,
|
||||
QwtColorMap::Format = QwtColorMap::RGB );
|
||||
|
||||
virtual ~QwtLinearColorMap();
|
||||
@@ -184,7 +184,9 @@ inline QColor QwtColorMap::color(
|
||||
else
|
||||
{
|
||||
const unsigned int index = colorIndex( interval, value );
|
||||
return colorTable( interval )[index]; // slow
|
||||
|
||||
const QVector<QRgb> rgbTable = colorTable( interval );
|
||||
return rgbTable[index]; // slow
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ public:
|
||||
PrivateData():
|
||||
style( QwtColumnSymbol::Box ),
|
||||
frameStyle( QwtColumnSymbol::Raised ),
|
||||
palette( Qt::gray ),
|
||||
lineWidth( 2 )
|
||||
{
|
||||
palette = QPalette( Qt::gray );
|
||||
}
|
||||
|
||||
QwtColumnSymbol::Style style;
|
||||
@@ -287,7 +287,7 @@ void QwtColumnSymbol::drawBox( QPainter *painter,
|
||||
}
|
||||
default:
|
||||
{
|
||||
painter->fillRect( r, d_data->palette.window() );
|
||||
painter->fillRect( r.adjusted( 0, 0, 1, 1 ), d_data->palette.window() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
QwtColumnSymbol( Style = NoStyle );
|
||||
virtual ~QwtColumnSymbol();
|
||||
|
||||
void setFrameStyle( FrameStyle style );
|
||||
void setFrameStyle( FrameStyle );
|
||||
FrameStyle frameStyle() const;
|
||||
|
||||
void setLineWidth( int width );
|
||||
|
||||
@@ -95,7 +95,7 @@ QMap<double, QString> QwtCompassScaleDraw::labelMap() const
|
||||
label() looks in the labelMap() for a corresponding label for value
|
||||
or returns an null text.
|
||||
|
||||
\return Label, or QString::null
|
||||
\return Label
|
||||
\sa labelMap(), setLabelMap()
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -10,8 +10,7 @@
|
||||
#include "qwt_compass_rose.h"
|
||||
#include "qwt_point_polar.h"
|
||||
#include "qwt_painter.h"
|
||||
#include "qpainter.h"
|
||||
#include "qpainterpath.h"
|
||||
#include <qpainter.h>
|
||||
|
||||
static QPointF qwtIntersection(
|
||||
QPointF p11, QPointF p12, QPointF p21, QPointF p22 )
|
||||
|
||||
@@ -62,13 +62,13 @@ public:
|
||||
QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 );
|
||||
virtual ~QwtSimpleCompassRose();
|
||||
|
||||
void setWidth( double w );
|
||||
void setWidth( double );
|
||||
double width() const;
|
||||
|
||||
void setNumThorns( int count );
|
||||
void setNumThorns( int );
|
||||
int numThorns() const;
|
||||
|
||||
void setNumThornLevels( int count );
|
||||
void setNumThornLevels( int );
|
||||
int numThornLevels() const;
|
||||
|
||||
void setShrinkFactor( double factor );
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
double north, QPalette::ColorGroup = QPalette::Active ) const;
|
||||
|
||||
static void drawRose( QPainter *, const QPalette &,
|
||||
const QPointF ¢er, double radius, double origin, double width,
|
||||
const QPointF ¢er, double radius, double north, double width,
|
||||
int numThorns, int numThornLevels, double shrinkFactor );
|
||||
|
||||
private:
|
||||
|
||||
@@ -93,8 +93,7 @@ void QwtCounter::initCounter()
|
||||
d_data->valueEdit->setValidator( new QDoubleValidator( d_data->valueEdit ) );
|
||||
layout->addWidget( d_data->valueEdit );
|
||||
|
||||
connect( d_data->valueEdit, SIGNAL( editingFinished() ),
|
||||
SLOT( textChanged() ) );
|
||||
connect( d_data->valueEdit, SIGNAL(editingFinished()), SLOT(textChanged()) );
|
||||
|
||||
layout->setStretchFactor( d_data->valueEdit, 10 );
|
||||
|
||||
@@ -155,7 +154,7 @@ void QwtCounter::setValid( bool on )
|
||||
}
|
||||
else
|
||||
{
|
||||
d_data->valueEdit->setText( QString::null );
|
||||
d_data->valueEdit->setText( QString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,24 +91,24 @@ public:
|
||||
bool isReadOnly() const;
|
||||
void setReadOnly( bool );
|
||||
|
||||
void setNumButtons( int n );
|
||||
void setNumButtons( int );
|
||||
int numButtons() const;
|
||||
|
||||
void setIncSteps( QwtCounter::Button btn, int nSteps );
|
||||
int incSteps( QwtCounter::Button btn ) const;
|
||||
void setIncSteps( QwtCounter::Button, int numSteps );
|
||||
int incSteps( QwtCounter::Button ) const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
double singleStep() const;
|
||||
void setSingleStep( double s );
|
||||
void setSingleStep( double stepSize );
|
||||
|
||||
void setRange( double min, double max );
|
||||
|
||||
double minimum() const;
|
||||
void setMinimum( double min );
|
||||
void setMinimum( double );
|
||||
|
||||
double maximum() const;
|
||||
void setMaximum( double max );
|
||||
void setMaximum( double );
|
||||
|
||||
void setStepButton1( int nSteps );
|
||||
int stepButton1() const;
|
||||
|
||||
@@ -333,7 +333,6 @@ void QwtWeedingCurveFitter::setChunkSize( uint numPoints )
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
\return Maximum for the number of points passed to a run
|
||||
of the algorithm - or 0, when unlimited
|
||||
\sa setChunkSize()
|
||||
@@ -349,8 +348,10 @@ uint QwtWeedingCurveFitter::chunkSize() const
|
||||
*/
|
||||
QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const
|
||||
{
|
||||
QPolygonF fittedPoints;
|
||||
if ( points.isEmpty() )
|
||||
return points;
|
||||
|
||||
QPolygonF fittedPoints;
|
||||
if ( d_data->chunkSize == 0 )
|
||||
{
|
||||
fittedPoints = simplify( points );
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
const QwtSpline &spline() const;
|
||||
QwtSpline &spline();
|
||||
|
||||
void setSplineSize( int size );
|
||||
void setSplineSize( int );
|
||||
int splineSize() const;
|
||||
|
||||
virtual QPolygonF fitCurve( const QPolygonF & ) const;
|
||||
|
||||
@@ -254,6 +254,8 @@ static inline QDateTime qwtToTimeSpec(
|
||||
return dt.toTimeSpec( spec );
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
static inline double qwtToJulianDay( int year, int month, int day )
|
||||
{
|
||||
// code from QDate but using doubles to avoid overflows
|
||||
@@ -283,6 +285,8 @@ static inline qint64 qwtFloorDiv( int a, int b )
|
||||
return a / b;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline QDate qwtToDate( int year, int month = 1, int day = 1 )
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
@@ -157,7 +157,7 @@ QString QwtDateScaleDraw::dateFormat(
|
||||
return d_data->dateFormats[ intervalType ];
|
||||
}
|
||||
|
||||
return QString::null;
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <qdatetime.h>
|
||||
#include <limits.h>
|
||||
|
||||
static inline double qwtMsecsForType( QwtDate::IntervalType type )
|
||||
static inline double qwtMsecsForType( int type )
|
||||
{
|
||||
static const double msecs[] =
|
||||
{
|
||||
|
||||
@@ -237,7 +237,7 @@ QRect QwtDial::boundingRect() const
|
||||
{
|
||||
const QRect cr = contentsRect();
|
||||
|
||||
const double dim = qMin( cr.width(), cr.height() );
|
||||
const int dim = qMin( cr.width(), cr.height() );
|
||||
|
||||
QRect inner( 0, 0, dim, dim );
|
||||
inner.moveCenter( cr.center() );
|
||||
|
||||
@@ -103,12 +103,12 @@ public:
|
||||
void setMode( Mode );
|
||||
Mode mode() const;
|
||||
|
||||
void setScaleArc( double min, double max );
|
||||
void setScaleArc( double minArc, double maxArc );
|
||||
|
||||
void setMinScaleArc( double min );
|
||||
void setMinScaleArc( double );
|
||||
double minScaleArc() const;
|
||||
|
||||
void setMaxScaleArc( double min );
|
||||
void setMaxScaleArc( double );
|
||||
double maxScaleArc() const;
|
||||
|
||||
virtual void setOrigin( double );
|
||||
@@ -136,7 +136,7 @@ protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void changeEvent( QEvent * );
|
||||
|
||||
virtual void drawFrame( QPainter *p );
|
||||
virtual void drawFrame( QPainter * );
|
||||
virtual void drawContents( QPainter * ) const;
|
||||
virtual void drawFocusIndicator( QPainter * ) const;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "qwt_painter.h"
|
||||
#include <qapplication.h>
|
||||
#include <qpainter.h>
|
||||
#include <QPainterPath>
|
||||
|
||||
#if QT_VERSION < 0x040601
|
||||
#define qFastSin(x) qSin(x)
|
||||
#define qFastCos(x) qCos(x)
|
||||
|
||||
@@ -28,14 +28,14 @@ class QWT_EXPORT QwtDynGridLayout : public QLayout
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QwtDynGridLayout( QWidget *, int margin = 0, int space = -1 );
|
||||
explicit QwtDynGridLayout( int space = -1 );
|
||||
explicit QwtDynGridLayout( QWidget *, int margin = 0, int spacing = -1 );
|
||||
explicit QwtDynGridLayout( int spacing = -1 );
|
||||
|
||||
virtual ~QwtDynGridLayout();
|
||||
|
||||
virtual void invalidate();
|
||||
|
||||
void setMaxColumns( uint maxCols );
|
||||
void setMaxColumns( uint maxColumns );
|
||||
uint maxColumns() const;
|
||||
|
||||
uint numRows () const;
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
void setExpandingDirections( Qt::Orientations );
|
||||
virtual Qt::Orientations expandingDirections() const;
|
||||
QList<QRect> layoutItems( const QRect &, uint numCols ) const;
|
||||
QList<QRect> layoutItems( const QRect &, uint numColumns ) const;
|
||||
|
||||
virtual int maxItemWidth() const;
|
||||
|
||||
@@ -67,14 +67,14 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void layoutGrid( uint numCols,
|
||||
void layoutGrid( uint numColumns,
|
||||
QVector<int>& rowHeight, QVector<int>& colWidth ) const;
|
||||
void stretchGrid( const QRect &rect, uint numCols,
|
||||
void stretchGrid( const QRect &rect, uint numColumns,
|
||||
QVector<int>& rowHeight, QVector<int>& colWidth ) const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
int maxRowWidth( int numCols ) const;
|
||||
int maxRowWidth( int numColumns ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
|
||||
@@ -191,8 +191,8 @@ public:
|
||||
void setMousePattern( MousePatternCode, Qt::MouseButton button,
|
||||
Qt::KeyboardModifiers = Qt::NoModifier );
|
||||
|
||||
void setKeyPattern( KeyPatternCode, int keyCode,
|
||||
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier );
|
||||
void setKeyPattern( KeyPatternCode, int key,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier );
|
||||
|
||||
void setMousePattern( const QVector<MousePattern> & );
|
||||
void setKeyPattern( const QVector<KeyPattern> & );
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
// QWT_VERSION is (major << 16) + (minor << 8) + patch.
|
||||
|
||||
#define QWT_VERSION 0x060103
|
||||
#define QWT_VERSION_STR "6.1.3"
|
||||
#define QWT_VERSION 0x060104
|
||||
#define QWT_VERSION_STR "6.1.4"
|
||||
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
/* template-class specialization 'identifier' is already instantiated */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <qpixmap.h>
|
||||
#include <qpainterpath.h>
|
||||
#include <qmath.h>
|
||||
#include <QPainterPath>
|
||||
|
||||
static bool qwtHasScalablePen( const QPainter *painter )
|
||||
{
|
||||
const QPen pen = painter->pen();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <qmetatype.h>
|
||||
#include <qimage.h>
|
||||
#include <qpixmap.h>
|
||||
#include "qpainterpath.h"
|
||||
|
||||
class QwtPainterCommand;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
QwtInterval normalized() const;
|
||||
QwtInterval inverted() const;
|
||||
QwtInterval limited( double minValue, double maxValue ) const;
|
||||
QwtInterval limited( double lowerBound, double upperBound ) const;
|
||||
|
||||
bool operator==( const QwtInterval & ) const;
|
||||
bool operator!=( const QwtInterval & ) const;
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
void setWidth( int );
|
||||
int width() const;
|
||||
|
||||
void setBrush( const QBrush& b );
|
||||
void setBrush( const QBrush & );
|
||||
const QBrush& brush() const;
|
||||
|
||||
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
|
||||
@@ -79,7 +79,6 @@ public:
|
||||
const QPointF& from, const QPointF& to ) const;
|
||||
|
||||
private:
|
||||
|
||||
class PrivateData;
|
||||
PrivateData* d_data;
|
||||
};
|
||||
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
void setKnobStyle( KnobStyle );
|
||||
KnobStyle knobStyle() const;
|
||||
|
||||
void setBorderWidth( int bw );
|
||||
void setBorderWidth( int );
|
||||
int borderWidth() const;
|
||||
|
||||
void setMarkerStyle( MarkerStyle );
|
||||
@@ -165,7 +165,7 @@ protected:
|
||||
virtual void drawFocusIndicator( QPainter * ) const;
|
||||
|
||||
virtual void drawMarker( QPainter *,
|
||||
const QRectF &, double arc ) const;
|
||||
const QRectF &, double angle ) const;
|
||||
|
||||
virtual double scrolledTo( const QPoint & ) const;
|
||||
virtual bool isScrollPosition( const QPoint & ) const;
|
||||
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
class QwtLegend::PrivateData::LegendView: public QScrollArea
|
||||
{
|
||||
public:
|
||||
LegendView( QWidget *parent ):
|
||||
explicit LegendView( QWidget *parent ):
|
||||
QScrollArea( parent )
|
||||
{
|
||||
contentsWidget = new QWidget( this );
|
||||
@@ -295,6 +295,8 @@ void QwtLegend::setMaxColumns( uint numColums )
|
||||
d_data->view->contentsWidget->layout() );
|
||||
if ( tl )
|
||||
tl->setMaxColumns( numColums );
|
||||
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -385,18 +387,18 @@ const QWidget *QwtLegend::contentsWidget() const
|
||||
\brief Update the entries for an item
|
||||
|
||||
\param itemInfo Info for an item
|
||||
\param data List of legend entry attributes for the item
|
||||
\param legendData List of legend entry attributes for the item
|
||||
*/
|
||||
void QwtLegend::updateLegend( const QVariant &itemInfo,
|
||||
const QList<QwtLegendData> &data )
|
||||
const QList<QwtLegendData> &legendData )
|
||||
{
|
||||
QList<QWidget *> widgetList = legendWidgets( itemInfo );
|
||||
|
||||
if ( widgetList.size() != data.size() )
|
||||
if ( widgetList.size() != legendData.size() )
|
||||
{
|
||||
QLayout *contentsLayout = d_data->view->contentsWidget->layout();
|
||||
|
||||
while ( widgetList.size() > data.size() )
|
||||
while ( widgetList.size() > legendData.size() )
|
||||
{
|
||||
QWidget *w = widgetList.takeLast();
|
||||
|
||||
@@ -409,9 +411,13 @@ void QwtLegend::updateLegend( const QVariant &itemInfo,
|
||||
w->deleteLater();
|
||||
}
|
||||
|
||||
for ( int i = widgetList.size(); i < data.size(); i++ )
|
||||
#if QT_VERSION >= 0x040700
|
||||
widgetList.reserve( legendData.size() );
|
||||
#endif
|
||||
|
||||
for ( int i = widgetList.size(); i < legendData.size(); i++ )
|
||||
{
|
||||
QWidget *widget = createWidget( data[i] );
|
||||
QWidget *widget = createWidget( legendData[i] );
|
||||
|
||||
if ( contentsLayout )
|
||||
contentsLayout->addWidget( widget );
|
||||
@@ -441,8 +447,8 @@ void QwtLegend::updateLegend( const QVariant &itemInfo,
|
||||
updateTabOrder();
|
||||
}
|
||||
|
||||
for ( int i = 0; i < data.size(); i++ )
|
||||
updateWidget( widgetList[i], data[i] );
|
||||
for ( int i = 0; i < legendData.size(); i++ )
|
||||
updateWidget( widgetList[i], legendData[i] );
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -450,15 +456,15 @@ void QwtLegend::updateLegend( const QVariant &itemInfo,
|
||||
|
||||
The default implementation returns a QwtLegendLabel.
|
||||
|
||||
\param data Attributes of the legend entry
|
||||
\param legendData Attributes of the legend entry
|
||||
\return Widget representing data on the legend
|
||||
|
||||
\note updateWidget() will called soon after createWidget()
|
||||
with the same attributes.
|
||||
*/
|
||||
QWidget *QwtLegend::createWidget( const QwtLegendData &data ) const
|
||||
QWidget *QwtLegend::createWidget( const QwtLegendData &legendData ) const
|
||||
{
|
||||
Q_UNUSED( data );
|
||||
Q_UNUSED( legendData );
|
||||
|
||||
QwtLegendLabel *label = new QwtLegendLabel();
|
||||
label->setItemMode( defaultItemMode() );
|
||||
@@ -473,18 +479,18 @@ QWidget *QwtLegend::createWidget( const QwtLegendData &data ) const
|
||||
\brief Update the widget
|
||||
|
||||
\param widget Usually a QwtLegendLabel
|
||||
\param data Attributes to be displayed
|
||||
\param legendData Attributes to be displayed
|
||||
|
||||
\sa createWidget()
|
||||
\note When widget is no QwtLegendLabel updateWidget() does nothing.
|
||||
*/
|
||||
void QwtLegend::updateWidget( QWidget *widget, const QwtLegendData &data )
|
||||
void QwtLegend::updateWidget( QWidget *widget, const QwtLegendData &legendData )
|
||||
{
|
||||
QwtLegendLabel *label = qobject_cast<QwtLegendLabel *>( widget );
|
||||
if ( label )
|
||||
{
|
||||
label->setData( data );
|
||||
if ( !data.value( QwtLegendData::ModeRole ).isValid() )
|
||||
label->setData( legendData );
|
||||
if ( !legendData.value( QwtLegendData::ModeRole ).isValid() )
|
||||
{
|
||||
// use the default mode, when there is no specific
|
||||
// hint from the legend data
|
||||
@@ -558,9 +564,15 @@ bool QwtLegend::eventFilter( QObject *object, QEvent *event )
|
||||
{
|
||||
const QChildEvent *ce =
|
||||
static_cast<const QChildEvent *>(event);
|
||||
|
||||
if ( ce->child()->isWidgetType() )
|
||||
{
|
||||
QWidget *w = static_cast< QWidget * >( ce->child() );
|
||||
/*
|
||||
We are called from the ~QObject and ce->child() is
|
||||
no widget anymore. But all we need is the address
|
||||
to remove it from the map.
|
||||
*/
|
||||
QWidget *w = reinterpret_cast< QWidget * >( ce->child() );
|
||||
d_data->itemMap.removeWidget( w );
|
||||
}
|
||||
break;
|
||||
@@ -678,7 +690,7 @@ void QwtLegend::renderLegend( QPainter *painter,
|
||||
layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );
|
||||
|
||||
uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
|
||||
QList<QRect> itemRects =
|
||||
const QList<QRect> itemRects =
|
||||
legendLayout->layoutItems( layoutRect, numCols );
|
||||
|
||||
int index = 0;
|
||||
@@ -742,8 +754,12 @@ void QwtLegend::renderItem( QPainter *painter,
|
||||
QRectF titleRect = rect;
|
||||
titleRect.setX( iconRect.right() + 2 * label->spacing() );
|
||||
|
||||
painter->setFont( label->font() );
|
||||
QFont labelFont = label->font();
|
||||
labelFont.resolve( QFont::AllPropertiesResolved );
|
||||
|
||||
painter->setFont( labelFont );
|
||||
painter->setPen( label->palette().color( QPalette::Text ) );
|
||||
|
||||
const_cast< QwtLegendLabel *>( label )->drawText( painter, titleRect );
|
||||
}
|
||||
}
|
||||
@@ -794,7 +810,7 @@ bool QwtLegend::isEmpty() const
|
||||
/*!
|
||||
Return the extent, that is needed for the scrollbars
|
||||
|
||||
\param orientation Orientation (
|
||||
\param orientation Orientation
|
||||
\return The width of the vertical scrollbar for Qt::Horizontal and v.v.
|
||||
*/
|
||||
int QwtLegend::scrollExtent( Qt::Orientation orientation ) const
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
virtual bool eventFilter( QObject *, QEvent * );
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual int heightForWidth( int w ) const;
|
||||
virtual int heightForWidth( int width ) const;
|
||||
|
||||
QScrollBar *horizontalScrollBar() const;
|
||||
QScrollBar *verticalScrollBar() const;
|
||||
@@ -105,7 +105,7 @@ protected Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual QWidget *createWidget( const QwtLegendData & ) const;
|
||||
virtual void updateWidget( QWidget *widget, const QwtLegendData &data );
|
||||
virtual void updateWidget( QWidget *widget, const QwtLegendData & );
|
||||
|
||||
private:
|
||||
void updateTabOrder();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "qwt_null_paintdevice.h"
|
||||
#include <qpaintengine.h>
|
||||
#include <qpixmap.h>
|
||||
#include <QPainterPath>
|
||||
|
||||
class QwtNullPaintDevice::PrivateData
|
||||
{
|
||||
public:
|
||||
@@ -337,13 +337,13 @@ void QwtNullPaintDevice::PaintEngine::drawImage(
|
||||
}
|
||||
|
||||
void QwtNullPaintDevice::PaintEngine::updateState(
|
||||
const QPaintEngineState &state)
|
||||
const QPaintEngineState &engineState)
|
||||
{
|
||||
QwtNullPaintDevice *device = nullDevice();
|
||||
if ( device == NULL )
|
||||
return;
|
||||
|
||||
device->updateState( state );
|
||||
device->updateState( engineState );
|
||||
}
|
||||
|
||||
inline QwtNullPaintDevice *QwtNullPaintDevice::PaintEngine::nullDevice()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "qwt_global.h"
|
||||
#include <qpaintdevice.h>
|
||||
#include <qpaintengine.h>
|
||||
#include "qpainterpath.h"
|
||||
|
||||
/*!
|
||||
\brief A null paint device doing nothing
|
||||
@@ -77,7 +76,7 @@ public:
|
||||
|
||||
virtual QPaintEngine *paintEngine() const;
|
||||
|
||||
virtual int metric( PaintDeviceMetric metric ) const;
|
||||
virtual int metric( PaintDeviceMetric ) const;
|
||||
|
||||
virtual void drawRects(const QRect *, int );
|
||||
virtual void drawRects(const QRectF *, int );
|
||||
@@ -105,12 +104,12 @@ public:
|
||||
virtual void drawTextItem(const QPointF &, const QTextItem &);
|
||||
|
||||
virtual void drawTiledPixmap(const QRectF &,
|
||||
const QPixmap &, const QPointF &s);
|
||||
const QPixmap &, const QPointF & );
|
||||
|
||||
virtual void drawImage(const QRectF &,
|
||||
const QImage &, const QRectF &, Qt::ImageConversionFlags );
|
||||
|
||||
virtual void updateState( const QPaintEngineState &state );
|
||||
virtual void updateState( const QPaintEngineState & );
|
||||
|
||||
protected:
|
||||
//! \return Size needed to implement metric()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <qpaintengine.h>
|
||||
#include <qapplication.h>
|
||||
#include <qdesktopwidget.h>
|
||||
#include "qpainterpath.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <qwindow.h>
|
||||
@@ -142,6 +141,12 @@ static inline void qwtUnscaleFont( QPainter *painter )
|
||||
*/
|
||||
bool QwtPainter::isX11GraphicsSystem()
|
||||
{
|
||||
/*
|
||||
The X11 paint engine has been removed with Qt 5.0, but
|
||||
reintroduced with Qt 5.10. It can be enabled with
|
||||
"export QT_XCB_NATIVE_PAINTING=1".
|
||||
*/
|
||||
|
||||
static int onX11 = -1;
|
||||
if ( onX11 < 0 )
|
||||
{
|
||||
@@ -181,7 +186,7 @@ bool QwtPainter::isAligning( QPainter *painter )
|
||||
default:;
|
||||
}
|
||||
|
||||
const QTransform tr = painter->transform();
|
||||
const QTransform &tr = painter->transform();
|
||||
if ( tr.isRotating() || tr.isScaling() )
|
||||
{
|
||||
// we might have to check translations too
|
||||
@@ -215,6 +220,10 @@ void QwtPainter::setRoundingAlignment( bool enable )
|
||||
much faster when they are split in smaller chunks: f.e all supported Qt versions
|
||||
>= Qt 5.0 when drawing an antialiased polyline with a pen width >=2.
|
||||
|
||||
Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... )
|
||||
for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked
|
||||
around in this mode.
|
||||
|
||||
The default setting is true.
|
||||
|
||||
\sa polylineSplitting()
|
||||
@@ -452,7 +461,7 @@ void QwtPainter::drawPolygon( QPainter *painter, const QPolygonF &polygon )
|
||||
|
||||
QPolygonF cpa = polygon;
|
||||
if ( deviceClipping )
|
||||
cpa = QwtClipper::clipPolygonF( clipRect, polygon );
|
||||
cpa = QwtClipper::clipPolygonF( clipRect, polygon, true );
|
||||
|
||||
painter->drawPolygon( cpa );
|
||||
}
|
||||
@@ -501,7 +510,7 @@ void QwtPainter::drawPolygon( QPainter *painter, const QPolygon &polygon )
|
||||
|
||||
QPolygon cpa = polygon;
|
||||
if ( deviceClipping )
|
||||
cpa = QwtClipper::clipPolygon( clipRect, polygon );
|
||||
cpa = QwtClipper::clipPolygon( clipRect, polygon, true );
|
||||
|
||||
painter->drawPolygon( cpa );
|
||||
}
|
||||
@@ -537,8 +546,10 @@ void QwtPainter::drawPolyline( QPainter *painter,
|
||||
polygon.constData(), polygon.size(), d_polylineSplitting );
|
||||
}
|
||||
else
|
||||
{
|
||||
qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting );
|
||||
}
|
||||
}
|
||||
|
||||
//! Wrapper for QPainter::drawPoint()
|
||||
void QwtPainter::drawPoint( QPainter *painter, const QPointF &pos )
|
||||
@@ -690,9 +701,10 @@ void QwtPainter::drawFocusRect( QPainter *painter, const QWidget *widget,
|
||||
opt.init( widget );
|
||||
opt.rect = rect;
|
||||
opt.state |= QStyle::State_HasFocus;
|
||||
opt.backgroundColor = widget->palette().color( widget->backgroundRole() );
|
||||
|
||||
widget->style()->drawPrimitive( QStyle::PE_FrameFocusRect,
|
||||
&opt, painter, widget );
|
||||
widget->style()->drawPrimitive(
|
||||
QStyle::PE_FrameFocusRect, &opt, painter, widget );
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -950,10 +962,10 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
|
||||
double lw2 = lineWidth * 0.5;
|
||||
QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 );
|
||||
QRectF innerRect = rect.adjusted( lw2, lw2, -lw2, -lw2 );
|
||||
|
||||
QPainterPath path;
|
||||
path.addRoundedRect( r, xRadius, yRadius );
|
||||
path.addRoundedRect( innerRect, xRadius, yRadius );
|
||||
|
||||
enum Style
|
||||
{
|
||||
@@ -1002,7 +1014,7 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
|
||||
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
{
|
||||
QRectF r = pathList[2 * i].controlPointRect();
|
||||
const QRectF r = pathList[2 * i].controlPointRect();
|
||||
|
||||
QPen arcPen;
|
||||
arcPen.setCapStyle( Qt::FlatCap );
|
||||
@@ -1251,7 +1263,7 @@ void QwtPainter::drawBackgound( QPainter *painter,
|
||||
/*!
|
||||
\return A pixmap that can be used as backing store
|
||||
|
||||
\param widget Widget, for which the backinstore is intended
|
||||
\param widget Widget, for which the backingstore is intended
|
||||
\param size Size of the pixmap
|
||||
*/
|
||||
QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <qpen.h>
|
||||
#include <qline.h>
|
||||
#include <qpalette.h>
|
||||
#include <QPainterPath>
|
||||
|
||||
class QPainter;
|
||||
class QBrush;
|
||||
class QColor;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
static void fillRect( QPainter *, const QRectF &, const QBrush & );
|
||||
|
||||
static void drawEllipse( QPainter *, const QRectF & );
|
||||
static void drawPie( QPainter *, const QRectF & r, int a, int alen );
|
||||
static void drawPie( QPainter *, const QRectF &, int a, int alen );
|
||||
|
||||
static void drawLine( QPainter *, double x1, double y1, double x2, double y2 );
|
||||
static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 );
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
static void drawFrame( QPainter *, const QRectF &rect,
|
||||
const QPalette &palette, QPalette::ColorRole foregroundRole,
|
||||
int lineWidth, int midLineWidth, int frameStyle );
|
||||
int frameWidth, int midLineWidth, int frameStyle );
|
||||
|
||||
static void drawFocusRect( QPainter *, const QWidget * );
|
||||
static void drawFocusRect( QPainter *, const QWidget *, const QRect & );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -8,7 +8,6 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "qwt_painter_command.h"
|
||||
#include "qpainterpath.h"
|
||||
|
||||
//! Construct an invalid command
|
||||
QwtPainterCommand::QwtPainterCommand():
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <qpixmap.h>
|
||||
#include <qimage.h>
|
||||
#include <qpolygon.h>
|
||||
#include <QPainterPath>
|
||||
|
||||
class QPainterPath;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -247,17 +247,21 @@ bool QwtPanner::isEnabled() const
|
||||
Repaint the grabbed pixmap on its current position and
|
||||
fill the empty spaces by the background of the parent widget.
|
||||
|
||||
\param pe Paint event
|
||||
\param event Paint event
|
||||
*/
|
||||
void QwtPanner::paintEvent( QPaintEvent *pe )
|
||||
void QwtPanner::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
int dx = d_data->pos.x() - d_data->initialPos.x();
|
||||
int dy = d_data->pos.y() - d_data->initialPos.y();
|
||||
|
||||
QRect r( 0, 0, d_data->pixmap.width(), d_data->pixmap.height() );
|
||||
r.moveCenter( QPoint( r.center().x() + dx, r.center().y() + dy ) );
|
||||
QRectF r;
|
||||
r.setSize( d_data->pixmap.size() );
|
||||
#if QT_VERSION >= 0x050000
|
||||
r.setSize( r.size() / d_data->pixmap.devicePixelRatio() );
|
||||
#endif
|
||||
r.moveCenter( QPointF( r.center().x() + dx, r.center().y() + dy ) );
|
||||
|
||||
QPixmap pm( size() );
|
||||
QPixmap pm = QwtPainter::backingStore( this, size() );
|
||||
QwtPainter::fillPixmap( parentWidget(), pm );
|
||||
|
||||
QPainter painter( &pm );
|
||||
@@ -266,11 +270,11 @@ void QwtPanner::paintEvent( QPaintEvent *pe )
|
||||
{
|
||||
QPixmap masked = d_data->pixmap;
|
||||
masked.setMask( d_data->contentsMask );
|
||||
painter.drawPixmap( r, masked );
|
||||
painter.drawPixmap( r.toRect(), masked );
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.drawPixmap( r, d_data->pixmap );
|
||||
painter.drawPixmap( r.toRect(), d_data->pixmap );
|
||||
}
|
||||
|
||||
painter.end();
|
||||
@@ -279,7 +283,7 @@ void QwtPanner::paintEvent( QPaintEvent *pe )
|
||||
pm.setMask( d_data->contentsMask );
|
||||
|
||||
painter.begin( this );
|
||||
painter.setClipRegion( pe->region() );
|
||||
painter.setClipRegion( event->region() );
|
||||
painter.drawPixmap( 0, 0, pm );
|
||||
}
|
||||
|
||||
|
||||
@@ -751,14 +751,16 @@ void QwtPicker::drawTracker( QPainter *painter ) const
|
||||
The reason, why a selection() differs from the picked points
|
||||
depends on the application requirements. F.e. :
|
||||
|
||||
- A rectangular selection might need to have a specific aspect ratio only.\n
|
||||
- A selection could accept non intersecting polygons only.\n
|
||||
- ...\n
|
||||
- A rectangular selection might need to have a specific aspect ratio only.
|
||||
- A selection could accept non intersecting polygons only.
|
||||
- ...
|
||||
|
||||
The example below is for a rectangular selection, where the first
|
||||
point is the center of the selected rectangle.
|
||||
|
||||
\par Example
|
||||
\verbatim QPolygon MyPicker::adjustedPoints(const QPolygon &points) const
|
||||
\code
|
||||
QPolygon MyPicker::adjustedPoints( const QPolygon &points ) const
|
||||
{
|
||||
QPolygon adjusted;
|
||||
if ( points.size() == 2 )
|
||||
@@ -773,7 +775,9 @@ void QwtPicker::drawTracker( QPainter *painter ) const
|
||||
adjusted += rect.bottomRight();
|
||||
}
|
||||
return adjusted;
|
||||
}\endverbatim\n
|
||||
}
|
||||
\endcode
|
||||
\endpar
|
||||
|
||||
\param points Selected points
|
||||
\return Selected points unmodified
|
||||
@@ -832,7 +836,7 @@ QRect QwtPicker::trackerRect( const QFont &font ) const
|
||||
&& rubberBand() != NoRubberBand )
|
||||
{
|
||||
const QPoint last =
|
||||
d_data->pickedPoints[int( d_data->pickedPoints.count() ) - 2];
|
||||
d_data->pickedPoints[ d_data->pickedPoints.count() - 2 ];
|
||||
|
||||
alignment |= ( pos.x() >= last.x() ) ? Qt::AlignRight : Qt::AlignLeft;
|
||||
alignment |= ( pos.y() > last.y() ) ? Qt::AlignBottom : Qt::AlignTop;
|
||||
@@ -1234,7 +1238,7 @@ void QwtPicker::begin()
|
||||
if ( d_data->isActive )
|
||||
return;
|
||||
|
||||
d_data->pickedPoints.resize( 0 );
|
||||
d_data->pickedPoints.clear();
|
||||
d_data->isActive = true;
|
||||
Q_EMIT activated( true );
|
||||
|
||||
@@ -1280,7 +1284,7 @@ bool QwtPicker::end( bool ok )
|
||||
if ( ok )
|
||||
Q_EMIT selected( d_data->pickedPoints );
|
||||
else
|
||||
d_data->pickedPoints.resize( 0 );
|
||||
d_data->pickedPoints.clear();
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
@@ -1314,9 +1318,7 @@ void QwtPicker::append( const QPoint &pos )
|
||||
{
|
||||
if ( d_data->isActive )
|
||||
{
|
||||
const int idx = d_data->pickedPoints.count();
|
||||
d_data->pickedPoints.resize( idx + 1 );
|
||||
d_data->pickedPoints[idx] = pos;
|
||||
d_data->pickedPoints += pos;
|
||||
|
||||
updateDisplay();
|
||||
Q_EMIT appended( pos );
|
||||
@@ -1332,21 +1334,18 @@ void QwtPicker::append( const QPoint &pos )
|
||||
*/
|
||||
void QwtPicker::move( const QPoint &pos )
|
||||
{
|
||||
if ( d_data->isActive )
|
||||
if ( d_data->isActive && !d_data->pickedPoints.isEmpty() )
|
||||
{
|
||||
const int idx = d_data->pickedPoints.count() - 1;
|
||||
if ( idx >= 0 )
|
||||
QPoint &point = d_data->pickedPoints.last();
|
||||
if ( point != pos )
|
||||
{
|
||||
if ( d_data->pickedPoints[idx] != pos )
|
||||
{
|
||||
d_data->pickedPoints[idx] = pos;
|
||||
point = pos;
|
||||
|
||||
updateDisplay();
|
||||
Q_EMIT moved( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Remove the last point of the selection
|
||||
@@ -1356,21 +1355,19 @@ void QwtPicker::move( const QPoint &pos )
|
||||
*/
|
||||
void QwtPicker::remove()
|
||||
{
|
||||
if ( d_data->isActive )
|
||||
if ( d_data->isActive && !d_data->pickedPoints.isEmpty() )
|
||||
{
|
||||
const int idx = d_data->pickedPoints.count() - 1;
|
||||
if ( idx > 0 )
|
||||
{
|
||||
const int idx = d_data->pickedPoints.count();
|
||||
|
||||
const QPoint pos = d_data->pickedPoints[idx - 1];
|
||||
d_data->pickedPoints.resize( idx - 1 );
|
||||
#if QT_VERSION >= 0x050100
|
||||
const QPoint pos = d_data->pickedPoints.takeLast();
|
||||
#else
|
||||
const QPoint pos = d_data->pickedPoints.last();
|
||||
d_data->pickedPoints.resize( d_data->pickedPoints.count() - 1 );
|
||||
#endif
|
||||
|
||||
updateDisplay();
|
||||
Q_EMIT removed( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Validate and fix up the selection
|
||||
@@ -1423,12 +1420,10 @@ void QwtPicker::stretchSelection( const QSize &oldSize, const QSize &newSize )
|
||||
return;
|
||||
}
|
||||
|
||||
const double xRatio =
|
||||
double( newSize.width() ) / double( oldSize.width() );
|
||||
const double yRatio =
|
||||
double( newSize.height() ) / double( oldSize.height() );
|
||||
const double xRatio = double( newSize.width() ) / double( oldSize.width() );
|
||||
const double yRatio = double( newSize.height() ) / double( oldSize.height() );
|
||||
|
||||
for ( int i = 0; i < int( d_data->pickedPoints.count() ); i++ )
|
||||
for ( int i = 0; i < d_data->pickedPoints.count(); i++ )
|
||||
{
|
||||
QPoint &p = d_data->pickedPoints[i];
|
||||
p.setX( qRound( p.x() * xRatio ) );
|
||||
|
||||
@@ -58,13 +58,16 @@ class QwtWidgetOverlay;
|
||||
position.
|
||||
|
||||
\par Example
|
||||
\verbatim #include <qwt_picker.h>
|
||||
\code
|
||||
#include <qwt_picker.h>
|
||||
#include <qwt_picker_machine.h>
|
||||
|
||||
QwtPicker *picker = new QwtPicker(widget);
|
||||
picker->setStateMachine(new QwtPickerDragRectMachine);
|
||||
picker->setTrackerMode(QwtPicker::ActiveOnly);
|
||||
picker->setRubberBand(QwtPicker::RectRubberBand); \endverbatim\n
|
||||
picker->setRubberBand(QwtPicker::RectRubberBand);
|
||||
\endcode
|
||||
\endpar
|
||||
|
||||
The state machine triggers the following commands:
|
||||
|
||||
@@ -307,8 +310,8 @@ protected:
|
||||
virtual void widgetEnterEvent( QEvent * );
|
||||
virtual void widgetLeaveEvent( QEvent * );
|
||||
|
||||
virtual void stretchSelection( const QSize &oldSize,
|
||||
const QSize &newSize );
|
||||
virtual void stretchSelection(
|
||||
const QSize &oldSize, const QSize &newSize );
|
||||
|
||||
virtual void updateDisplay();
|
||||
|
||||
|
||||
@@ -28,18 +28,16 @@ static inline void qwtEnableLegendItems( QwtPlot *plot, bool on )
|
||||
if ( on )
|
||||
{
|
||||
QObject::connect(
|
||||
plot, SIGNAL( legendDataChanged(
|
||||
const QVariant &, const QList<QwtLegendData> & ) ),
|
||||
plot, SLOT( updateLegendItems(
|
||||
const QVariant &, const QList<QwtLegendData> & ) ) );
|
||||
plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
|
||||
plot, SLOT(updateLegendItems(QVariant,QList<QwtLegendData>))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
QObject::disconnect(
|
||||
plot, SIGNAL( legendDataChanged(
|
||||
const QVariant &, const QList<QwtLegendData> & ) ),
|
||||
plot, SLOT( updateLegendItems(
|
||||
const QVariant &, const QList<QwtLegendData> & ) ) );
|
||||
plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>) ),
|
||||
plot, SLOT( updateLegendItems(QVariant,QList<QwtLegendData>))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,13 +603,24 @@ void QwtPlot::updateLayout()
|
||||
d_data->footerLabel->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
d_data->footerLabel->hide();
|
||||
}
|
||||
|
||||
for ( int axisId = 0; axisId < axisCnt; axisId++ )
|
||||
{
|
||||
QwtScaleWidget* scaleWidget = axisWidget( axisId );
|
||||
|
||||
if ( axisEnabled( axisId ) )
|
||||
{
|
||||
axisWidget( axisId )->setGeometry( scaleRect[axisId] );
|
||||
if ( scaleRect[axisId] != scaleWidget->geometry() )
|
||||
{
|
||||
scaleWidget->setGeometry( scaleRect[axisId] );
|
||||
|
||||
int startDist, endDist;
|
||||
scaleWidget->getBorderDistHint( startDist, endDist );
|
||||
scaleWidget->setBorderDist( startDist, endDist );
|
||||
}
|
||||
|
||||
#if 1
|
||||
if ( axisId == xBottom || axisId == xTop )
|
||||
@@ -626,14 +635,16 @@ void QwtPlot::updateLayout()
|
||||
r.translate( -scaleRect[ axisId ].x(),
|
||||
-scaleRect[axisId].y() );
|
||||
|
||||
axisWidget( axisId )->setMask( r );
|
||||
scaleWidget->setMask( r );
|
||||
}
|
||||
#endif
|
||||
if ( !axisWidget( axisId )->isVisibleTo( this ) )
|
||||
axisWidget( axisId )->show();
|
||||
if ( !scaleWidget->isVisibleTo( this ) )
|
||||
scaleWidget->show();
|
||||
}
|
||||
else
|
||||
axisWidget( axisId )->hide();
|
||||
{
|
||||
scaleWidget->hide();
|
||||
}
|
||||
}
|
||||
|
||||
if ( d_data->legend )
|
||||
@@ -938,12 +949,9 @@ void QwtPlot::insertLegend( QwtAbstractLegend *legend,
|
||||
|
||||
if ( d_data->legend )
|
||||
{
|
||||
connect( this,
|
||||
SIGNAL( legendDataChanged(
|
||||
const QVariant &, const QList<QwtLegendData> & ) ),
|
||||
d_data->legend,
|
||||
SLOT( updateLegend(
|
||||
const QVariant &, const QList<QwtLegendData> & ) )
|
||||
connect(
|
||||
this, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
|
||||
d_data->legend, SLOT(updateLegend(QVariant,QList<QwtLegendData>) )
|
||||
);
|
||||
|
||||
if ( d_data->legend->parent() != this )
|
||||
|
||||
@@ -49,7 +49,7 @@ class QwtTextLabel;
|
||||
The following example shows (schematically) the most simple
|
||||
way to use QwtPlot. By default, only the left and bottom axes are
|
||||
visible and their scales are computed automatically.
|
||||
\verbatim
|
||||
\code
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
|
||||
@@ -68,7 +68,8 @@ curve2->attach(myPlot);
|
||||
|
||||
// finally, refresh the plot
|
||||
myPlot->replot();
|
||||
\endverbatim
|
||||
\endcode
|
||||
\endpar
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
|
||||
@@ -149,7 +150,7 @@ public:
|
||||
// Title
|
||||
|
||||
void setTitle( const QString & );
|
||||
void setTitle( const QwtText &t );
|
||||
void setTitle( const QwtText & );
|
||||
QwtText title() const;
|
||||
|
||||
QwtTextLabel *titleLabel();
|
||||
@@ -158,7 +159,7 @@ public:
|
||||
// Footer
|
||||
|
||||
void setFooter( const QString & );
|
||||
void setFooter( const QwtText &t );
|
||||
void setFooter( const QwtText & );
|
||||
QwtText footer() const;
|
||||
|
||||
QwtTextLabel *footerLabel();
|
||||
@@ -191,10 +192,10 @@ public:
|
||||
void enableAxis( int axisId, bool tf = true );
|
||||
bool axisEnabled( int axisId ) const;
|
||||
|
||||
void setAxisFont( int axisId, const QFont &f );
|
||||
void setAxisFont( int axisId, const QFont & );
|
||||
QFont axisFont( int axisId ) const;
|
||||
|
||||
void setAxisScale( int axisId, double min, double max, double step = 0 );
|
||||
void setAxisScale( int axisId, double min, double max, double stepSize = 0 );
|
||||
void setAxisScaleDiv( int axisId, const QwtScaleDiv & );
|
||||
void setAxisScaleDraw( int axisId, QwtScaleDraw * );
|
||||
|
||||
@@ -290,7 +291,7 @@ protected:
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateLegendItems( const QVariant &itemInfo,
|
||||
const QList<QwtLegendData> &data );
|
||||
const QList<QwtLegendData> &legendData );
|
||||
|
||||
private:
|
||||
friend class QwtPlotItem;
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
|
||||
protected:
|
||||
double sampleWidth( const QwtScaleMap &map,
|
||||
double canvasSize, double dataSize,
|
||||
double canvasSize, double boundingSize,
|
||||
double value ) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -189,7 +189,6 @@ bool QwtPlot::axisAutoScale( int axisId ) const
|
||||
return d_axisData[axisId]->doAutoScale;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -329,10 +329,10 @@ void QwtPlotBarChart::drawBar( QPainter *painter,
|
||||
else
|
||||
{
|
||||
// we build a temporary default symbol
|
||||
QwtColumnSymbol sym( QwtColumnSymbol::Box );
|
||||
sym.setLineWidth( 1 );
|
||||
sym.setFrameStyle( QwtColumnSymbol::Plain );
|
||||
sym.draw( painter, rect );
|
||||
QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box );
|
||||
columnSymbol.setLineWidth( 1 );
|
||||
columnSymbol.setFrameStyle( QwtColumnSymbol::Plain );
|
||||
columnSymbol.draw( painter, rect );
|
||||
}
|
||||
|
||||
delete specialSym;
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
LegendBarTitles
|
||||
};
|
||||
|
||||
explicit QwtPlotBarChart( const QString &title = QString::null );
|
||||
explicit QwtPlotBarChart( const QString &title = QString() );
|
||||
explicit QwtPlotBarChart( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotBarChart();
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
void setSamples( const QVector<QPointF> & );
|
||||
void setSamples( const QVector<double> & );
|
||||
void setSamples( QwtSeriesData<QPointF> *series );
|
||||
void setSamples( QwtSeriesData<QPointF> * );
|
||||
|
||||
void setSymbol( QwtColumnSymbol * );
|
||||
const QwtColumnSymbol *symbol() const;
|
||||
@@ -102,7 +102,7 @@ protected:
|
||||
int index, const QPointF& sample ) const;
|
||||
|
||||
virtual void drawBar( QPainter *,
|
||||
int sampleIndex, const QPointF& point,
|
||||
int sampleIndex, const QPointF& sample,
|
||||
const QwtColumnRect & ) const;
|
||||
|
||||
QList<QwtLegendData> legendData() const;
|
||||
|
||||
@@ -48,6 +48,12 @@ public:
|
||||
border.rectList += rects[i];
|
||||
}
|
||||
|
||||
virtual void drawRects(const QRect *rects, int count )
|
||||
{
|
||||
// to silence -Woverloaded-virtual
|
||||
QwtNullPaintDevice::drawRects( rects, count );
|
||||
}
|
||||
|
||||
virtual void drawPath( const QPainterPath &path )
|
||||
{
|
||||
const QRectF rect( QPointF( 0.0, 0.0 ), d_size );
|
||||
@@ -728,7 +734,14 @@ void QwtPlotCanvas::paintEvent( QPaintEvent *event )
|
||||
d_data->backingStore != NULL )
|
||||
{
|
||||
QPixmap &bs = *d_data->backingStore;
|
||||
if ( bs.size() != size() )
|
||||
|
||||
qreal pixelRatio = 1.0;
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
pixelRatio = bs.devicePixelRatio();
|
||||
#endif
|
||||
|
||||
if ( bs.size() != size() * pixelRatio )
|
||||
{
|
||||
bs = QwtPainter::backingStore( this, size() );
|
||||
|
||||
|
||||
@@ -556,8 +556,10 @@ void QwtPlotCurve::drawLines( QPainter *painter,
|
||||
*/
|
||||
void QwtPlotCurve::drawSticks( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &, int from, int to ) const
|
||||
const QRectF &canvasRect, int from, int to ) const
|
||||
{
|
||||
Q_UNUSED( canvasRect )
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint( QPainter::Antialiasing, false );
|
||||
|
||||
@@ -758,8 +760,11 @@ void QwtPlotCurve::drawSteps( QPainter *painter,
|
||||
|
||||
if ( d_data->paintAttributes & ClipPolygons )
|
||||
{
|
||||
qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
|
||||
const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
|
||||
|
||||
const QPolygonF clipped = QwtClipper::clipPolygonF(
|
||||
canvasRect, polygon, false );
|
||||
clipRect, polygon, false );
|
||||
|
||||
QwtPainter::drawPolyline( painter, clipped );
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotCurve( const QString &title = QString() );
|
||||
explicit QwtPlotCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotCurve();
|
||||
@@ -270,27 +270,27 @@ protected:
|
||||
|
||||
void init();
|
||||
|
||||
virtual void drawCurve( QPainter *p, int style,
|
||||
virtual void drawCurve( QPainter *, int style,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawSymbols( QPainter *p, const QwtSymbol &,
|
||||
virtual void drawSymbols( QPainter *, const QwtSymbol &,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawLines( QPainter *p,
|
||||
virtual void drawLines( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawSticks( QPainter *p,
|
||||
virtual void drawSticks( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawDots( QPainter *p,
|
||||
virtual void drawDots( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawSteps( QPainter *p,
|
||||
virtual void drawSteps( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
|
||||
@@ -137,8 +137,8 @@ void QwtPlotDict::removeItem( QwtPlotItem *item )
|
||||
void QwtPlotDict::detachItems( int rtti, bool autoDelete )
|
||||
{
|
||||
PrivateData::ItemList list = d_data->itemList;
|
||||
QwtPlotItemIterator it = list.begin();
|
||||
while ( it != list.end() )
|
||||
QwtPlotItemIterator it = list.constBegin();
|
||||
while ( it != list.constEnd() )
|
||||
{
|
||||
QwtPlotItem *item = *it;
|
||||
|
||||
@@ -180,7 +180,7 @@ QwtPlotItemList QwtPlotDict::itemList( int rtti ) const
|
||||
QwtPlotItemList items;
|
||||
|
||||
PrivateData::ItemList list = d_data->itemList;
|
||||
for ( QwtPlotItemIterator it = list.begin(); it != list.end(); ++it )
|
||||
for ( QwtPlotItemIterator it = list.constBegin(); it != list.constEnd(); ++it )
|
||||
{
|
||||
QwtPlotItem *item = *it;
|
||||
if ( item->rtti() == rtti )
|
||||
|
||||
@@ -301,7 +301,7 @@ bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
|
||||
doCopyCache = qwtHasBackingStore( plotCanvas );
|
||||
if ( doCopyCache )
|
||||
{
|
||||
painter.drawPixmap( plotCanvas->contentsRect().topLeft(),
|
||||
painter.drawPixmap( plotCanvas->rect().topLeft(),
|
||||
*plotCanvas->backingStore() );
|
||||
}
|
||||
}
|
||||
|
||||
377
qwtdemo/qwt/qwt_plot_glcanvas.cpp
Normal file
377
qwtdemo/qwt/qwt_plot_glcanvas.cpp
Normal file
@@ -0,0 +1,377 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "qwt_plot_glcanvas.h"
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_painter.h"
|
||||
#include <qevent.h>
|
||||
#include <qpainter.h>
|
||||
#include <qdrawutil.h>
|
||||
#include <qstyle.h>
|
||||
#include <qstyleoption.h>
|
||||
|
||||
#define FIX_GL_TRANSLATION 0
|
||||
|
||||
static QWidget *qwtBGWidget( QWidget *widget )
|
||||
{
|
||||
QWidget *w = widget;
|
||||
|
||||
for ( ; w->parentWidget() != NULL; w = w->parentWidget() )
|
||||
{
|
||||
if ( w->autoFillBackground() ||
|
||||
w->testAttribute( Qt::WA_StyledBackground ) )
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
static void qwtUpdateContentsRect( QwtPlotGLCanvas *canvas )
|
||||
{
|
||||
const int fw = canvas->frameWidth();
|
||||
canvas->setContentsMargins( fw, fw, fw, fw );
|
||||
}
|
||||
|
||||
class QwtPlotGLCanvas::PrivateData
|
||||
{
|
||||
public:
|
||||
PrivateData():
|
||||
frameStyle( QFrame::Panel | QFrame::Sunken),
|
||||
lineWidth( 2 ),
|
||||
midLineWidth( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
int frameStyle;
|
||||
int lineWidth;
|
||||
int midLineWidth;
|
||||
};
|
||||
|
||||
class QwtPlotGLCanvasFormat: public QGLFormat
|
||||
{
|
||||
public:
|
||||
QwtPlotGLCanvasFormat():
|
||||
QGLFormat( QGLFormat::defaultFormat() )
|
||||
{
|
||||
setSampleBuffers( true );
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
|
||||
\param plot Parent plot widget
|
||||
\sa QwtPlot::setCanvas()
|
||||
*/
|
||||
QwtPlotGLCanvas::QwtPlotGLCanvas( QwtPlot *plot ):
|
||||
QGLWidget( QwtPlotGLCanvasFormat(), plot )
|
||||
{
|
||||
d_data = new PrivateData;
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
setCursor( Qt::CrossCursor );
|
||||
#endif
|
||||
|
||||
setAutoFillBackground( true );
|
||||
qwtUpdateContentsRect( this );
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
QwtPlotGLCanvas::~QwtPlotGLCanvas()
|
||||
{
|
||||
delete d_data;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the frame style
|
||||
|
||||
\param style The bitwise OR between a shape and a shadow.
|
||||
|
||||
\sa frameStyle(), QFrame::setFrameStyle(),
|
||||
setFrameShadow(), setFrameShape()
|
||||
*/
|
||||
void QwtPlotGLCanvas::setFrameStyle( int style )
|
||||
{
|
||||
if ( style != d_data->frameStyle )
|
||||
{
|
||||
d_data->frameStyle = style;
|
||||
qwtUpdateContentsRect( this );
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\return The bitwise OR between a frameShape() and a frameShadow()
|
||||
\sa setFrameStyle(), QFrame::frameStyle()
|
||||
*/
|
||||
int QwtPlotGLCanvas::frameStyle() const
|
||||
{
|
||||
return d_data->frameStyle;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the frame shadow
|
||||
|
||||
\param shadow Frame shadow
|
||||
\sa frameShadow(), setFrameShape(), QFrame::setFrameShadow()
|
||||
*/
|
||||
void QwtPlotGLCanvas::setFrameShadow( Shadow shadow )
|
||||
{
|
||||
setFrameStyle(( d_data->frameStyle & QFrame::Shape_Mask ) | shadow );
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Frame shadow
|
||||
\sa setFrameShadow(), QFrame::setFrameShadow()
|
||||
*/
|
||||
QwtPlotGLCanvas::Shadow QwtPlotGLCanvas::frameShadow() const
|
||||
{
|
||||
return (Shadow) ( d_data->frameStyle & QFrame::Shadow_Mask );
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the frame shape
|
||||
|
||||
\param shape Frame shape
|
||||
\sa frameShape(), setFrameShadow(), QFrame::frameShape()
|
||||
*/
|
||||
void QwtPlotGLCanvas::setFrameShape( Shape shape )
|
||||
{
|
||||
setFrameStyle( ( d_data->frameStyle & QFrame::Shadow_Mask ) | shape );
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Frame shape
|
||||
\sa setFrameShape(), QFrame::frameShape()
|
||||
*/
|
||||
QwtPlotGLCanvas::Shape QwtPlotGLCanvas::frameShape() const
|
||||
{
|
||||
return (Shape) ( d_data->frameStyle & QFrame::Shape_Mask );
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the frame line width
|
||||
|
||||
The default line width is 2 pixels.
|
||||
|
||||
\param width Line width of the frame
|
||||
\sa lineWidth(), setMidLineWidth()
|
||||
*/
|
||||
void QwtPlotGLCanvas::setLineWidth( int width )
|
||||
{
|
||||
width = qMax( width, 0 );
|
||||
if ( width != d_data->lineWidth )
|
||||
{
|
||||
d_data->lineWidth = qMax( width, 0 );
|
||||
qwtUpdateContentsRect( this );
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Line width of the frame
|
||||
\sa setLineWidth(), midLineWidth()
|
||||
*/
|
||||
int QwtPlotGLCanvas::lineWidth() const
|
||||
{
|
||||
return d_data->lineWidth;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the frame mid line width
|
||||
|
||||
The default midline width is 0 pixels.
|
||||
|
||||
\param width Midline width of the frame
|
||||
\sa midLineWidth(), setLineWidth()
|
||||
*/
|
||||
void QwtPlotGLCanvas::setMidLineWidth( int width )
|
||||
{
|
||||
width = qMax( width, 0 );
|
||||
if ( width != d_data->midLineWidth )
|
||||
{
|
||||
d_data->midLineWidth = width;
|
||||
qwtUpdateContentsRect( this );
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Midline width of the frame
|
||||
\sa setMidLineWidth(), lineWidth()
|
||||
*/
|
||||
int QwtPlotGLCanvas::midLineWidth() const
|
||||
{
|
||||
return d_data->midLineWidth;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Frame width depending on the style, line width and midline width.
|
||||
*/
|
||||
int QwtPlotGLCanvas::frameWidth() const
|
||||
{
|
||||
return ( frameStyle() != NoFrame ) ? d_data->lineWidth : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Paint event
|
||||
|
||||
\param event Paint event
|
||||
\sa QwtPlot::drawCanvas()
|
||||
*/
|
||||
void QwtPlotGLCanvas::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
Q_UNUSED( event );
|
||||
|
||||
QPainter painter( this );
|
||||
|
||||
#if FIX_GL_TRANSLATION
|
||||
if ( painter.paintEngine()->type() == QPaintEngine::OpenGL2 )
|
||||
{
|
||||
// work around a translation bug of QPaintEngine::OpenGL2
|
||||
painter.translate( 1, 1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
drawBackground( &painter );
|
||||
drawItems( &painter );
|
||||
|
||||
if ( !testAttribute( Qt::WA_StyledBackground ) )
|
||||
{
|
||||
if ( frameWidth() > 0 )
|
||||
drawBorder( &painter );
|
||||
}
|
||||
}
|
||||
/*!
|
||||
Qt event handler for QEvent::PolishRequest and QEvent::StyleChange
|
||||
\param event Qt Event
|
||||
\return See QGLWidget::event()
|
||||
*/
|
||||
bool QwtPlotGLCanvas::event( QEvent *event )
|
||||
{
|
||||
const bool ok = QGLWidget::event( event );
|
||||
|
||||
if ( event->type() == QEvent::PolishRequest ||
|
||||
event->type() == QEvent::StyleChange )
|
||||
{
|
||||
// assuming, that we always have a styled background
|
||||
// when we have a style sheet
|
||||
|
||||
setAttribute( Qt::WA_StyledBackground,
|
||||
testAttribute( Qt::WA_StyleSheet ) );
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*!
|
||||
Draw the plot items
|
||||
\param painter Painter
|
||||
|
||||
\sa QwtPlot::drawCanvas()
|
||||
*/
|
||||
void QwtPlotGLCanvas::drawItems( QPainter *painter )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->setClipRect( contentsRect(), Qt::IntersectClip );
|
||||
|
||||
QwtPlot *plot = qobject_cast< QwtPlot *>( parent() );
|
||||
if ( plot )
|
||||
plot->drawCanvas( painter );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
/*!
|
||||
Draw the background of the canvas
|
||||
\param painter Painter
|
||||
*/
|
||||
void QwtPlotGLCanvas::drawBackground( QPainter *painter )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QWidget *w = qwtBGWidget( this );
|
||||
|
||||
const QPoint off = mapTo( w, QPoint() );
|
||||
painter->translate( -off );
|
||||
|
||||
const QRect fillRect = rect().translated( off );
|
||||
|
||||
if ( w->testAttribute( Qt::WA_StyledBackground ) )
|
||||
{
|
||||
painter->setClipRect( fillRect );
|
||||
|
||||
QStyleOption opt;
|
||||
opt.initFrom( w );
|
||||
w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->fillRect( fillRect,
|
||||
w->palette().brush( w->backgroundRole() ) );
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
/*!
|
||||
Draw the border of the canvas
|
||||
\param painter Painter
|
||||
*/
|
||||
void QwtPlotGLCanvas::drawBorder( QPainter *painter )
|
||||
{
|
||||
const int fw = frameWidth();
|
||||
if ( fw <= 0 )
|
||||
return;
|
||||
|
||||
if ( frameShadow() == QwtPlotGLCanvas::Plain )
|
||||
{
|
||||
qDrawPlainRect( painter, frameRect(),
|
||||
palette().shadow().color(), lineWidth() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( frameShape() == QwtPlotGLCanvas::Box )
|
||||
{
|
||||
qDrawShadeRect( painter, frameRect(), palette(),
|
||||
frameShadow() == Sunken, lineWidth(), midLineWidth() );
|
||||
}
|
||||
else
|
||||
{
|
||||
qDrawShadePanel( painter, frameRect(), palette(),
|
||||
frameShadow() == Sunken, lineWidth() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Calls repaint()
|
||||
void QwtPlotGLCanvas::replot()
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Empty path
|
||||
*/
|
||||
QPainterPath QwtPlotGLCanvas::borderPath( const QRect &rect ) const
|
||||
{
|
||||
Q_UNUSED( rect );
|
||||
return QPainterPath();
|
||||
}
|
||||
|
||||
//! \return The rectangle where the frame is drawn in.
|
||||
QRect QwtPlotGLCanvas::frameRect() const
|
||||
{
|
||||
const int fw = frameWidth();
|
||||
return contentsRect().adjusted( -fw, -fw, fw, fw );
|
||||
}
|
||||
130
qwtdemo/qwt/qwt_plot_glcanvas.h
Normal file
130
qwtdemo/qwt/qwt_plot_glcanvas.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_GLCANVAS_H
|
||||
#define QWT_PLOT_GLCANVAS_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qframe.h>
|
||||
#include <qgl.h>
|
||||
|
||||
class QwtPlot;
|
||||
|
||||
/*!
|
||||
\brief An alternative canvas for a QwtPlot derived from QGLWidget
|
||||
|
||||
QwtPlotGLCanvas implements the very basics to act as canvas
|
||||
inside of a QwtPlot widget. It might be extended to a full
|
||||
featured alternative to QwtPlotCanvas in a future version of Qwt.
|
||||
|
||||
Even if QwtPlotGLCanvas is not derived from QFrame it imitates
|
||||
its API. When using style sheets it supports the box model - beside
|
||||
backgrounds with rounded borders.
|
||||
|
||||
\sa QwtPlot::setCanvas(), QwtPlotCanvas
|
||||
|
||||
\note With Qt4 you might want to use the QPaintEngine::OpenGL paint engine
|
||||
( see QGL::setPreferredPaintEngine() ). On a Linux test system
|
||||
QPaintEngine::OpenGL2 shows very basic problems like translated
|
||||
geometries.
|
||||
*/
|
||||
class QWT_EXPORT QwtPlotGLCanvas: public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS( Shape Shadow )
|
||||
|
||||
Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
|
||||
Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
|
||||
Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
|
||||
Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
|
||||
Q_PROPERTY( int frameWidth READ frameWidth )
|
||||
Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false )
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief Frame shadow
|
||||
|
||||
Unfortunately it is not possible to use QFrame::Shadow
|
||||
as a property of a widget that is not derived from QFrame.
|
||||
The following enum is made for the designer only. It is safe
|
||||
to use QFrame::Shadow instead.
|
||||
*/
|
||||
enum Shadow
|
||||
{
|
||||
//! QFrame::Plain
|
||||
Plain = QFrame::Plain,
|
||||
|
||||
//! QFrame::Raised
|
||||
Raised = QFrame::Raised,
|
||||
|
||||
//! QFrame::Sunken
|
||||
Sunken = QFrame::Sunken
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Frame shape
|
||||
|
||||
Unfortunately it is not possible to use QFrame::Shape
|
||||
as a property of a widget that is not derived from QFrame.
|
||||
The following enum is made for the designer only. It is safe
|
||||
to use QFrame::Shadow instead.
|
||||
|
||||
\note QFrame::StyledPanel and QFrame::WinPanel are unsupported
|
||||
and will be displayed as QFrame::Panel.
|
||||
*/
|
||||
enum Shape
|
||||
{
|
||||
NoFrame = QFrame::NoFrame,
|
||||
|
||||
Box = QFrame::Box,
|
||||
Panel = QFrame::Panel
|
||||
};
|
||||
|
||||
explicit QwtPlotGLCanvas( QwtPlot * = NULL );
|
||||
virtual ~QwtPlotGLCanvas();
|
||||
|
||||
void setFrameStyle( int style );
|
||||
int frameStyle() const;
|
||||
|
||||
void setFrameShadow( Shadow );
|
||||
Shadow frameShadow() const;
|
||||
|
||||
void setFrameShape( Shape );
|
||||
Shape frameShape() const;
|
||||
|
||||
void setLineWidth( int );
|
||||
int lineWidth() const;
|
||||
|
||||
void setMidLineWidth( int );
|
||||
int midLineWidth() const;
|
||||
|
||||
int frameWidth() const;
|
||||
QRect frameRect() const;
|
||||
|
||||
Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
|
||||
|
||||
virtual bool event( QEvent * );
|
||||
|
||||
public Q_SLOTS:
|
||||
void replot();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
|
||||
virtual void drawBackground( QPainter * );
|
||||
virtual void drawBorder( QPainter * );
|
||||
virtual void drawItems( QPainter * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -39,22 +39,22 @@ public:
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
void enableX( bool tf );
|
||||
void enableX( bool );
|
||||
bool xEnabled() const;
|
||||
|
||||
void enableY( bool tf );
|
||||
void enableY( bool );
|
||||
bool yEnabled() const;
|
||||
|
||||
void enableXMin( bool tf );
|
||||
void enableXMin( bool );
|
||||
bool xMinEnabled() const;
|
||||
|
||||
void enableYMin( bool tf );
|
||||
void enableYMin( bool );
|
||||
bool yMinEnabled() const;
|
||||
|
||||
void setXDiv( const QwtScaleDiv &sx );
|
||||
void setXDiv( const QwtScaleDiv & );
|
||||
const QwtScaleDiv &xScaleDiv() const;
|
||||
|
||||
void setYDiv( const QwtScaleDiv &sy );
|
||||
void setYDiv( const QwtScaleDiv & );
|
||||
const QwtScaleDiv &yScaleDiv() const;
|
||||
|
||||
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
|
||||
@@ -65,19 +65,19 @@ public:
|
||||
const QPen& majorPen() const;
|
||||
|
||||
void setMinorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
|
||||
void setMinorPen( const QPen &p );
|
||||
void setMinorPen( const QPen & );
|
||||
const QPen& minorPen() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
virtual void updateScaleDiv(
|
||||
const QwtScaleDiv &xMap, const QwtScaleDiv &yMap );
|
||||
const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv );
|
||||
|
||||
private:
|
||||
void drawLines( QPainter *painter, const QRectF &,
|
||||
Qt::Orientation orientation, const QwtScaleMap &,
|
||||
void drawLines( QPainter *, const QRectF &,
|
||||
Qt::Orientation, const QwtScaleMap &,
|
||||
const QList<double> & ) const;
|
||||
|
||||
class PrivateData;
|
||||
|
||||
@@ -332,8 +332,10 @@ void QwtPlotHistogram::setSamples(
|
||||
*/
|
||||
void QwtPlotHistogram::drawSeries( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &, int from, int to ) const
|
||||
const QRectF &canvasRect, int from, int to ) const
|
||||
{
|
||||
Q_UNUSED( canvasRect )
|
||||
|
||||
if ( !painter || dataSize() <= 0 )
|
||||
return;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
UserStyle = 100
|
||||
};
|
||||
|
||||
explicit QwtPlotHistogram( const QString &title = QString::null );
|
||||
explicit QwtPlotHistogram( const QString &title = QString() );
|
||||
explicit QwtPlotHistogram( const QwtText &title );
|
||||
virtual ~QwtPlotHistogram();
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
void setSamples( const QVector<QwtIntervalSample> & );
|
||||
void setSamples( QwtSeriesData<QwtIntervalSample> * );
|
||||
|
||||
void setBaseline( double reference );
|
||||
void setBaseline( double );
|
||||
double baseline() const;
|
||||
|
||||
void setStyle( HistogramStyle style );
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
void setSymbol( const QwtColumnSymbol * );
|
||||
const QwtColumnSymbol *symbol() const;
|
||||
|
||||
virtual void drawSeries( QPainter *p,
|
||||
virtual void drawSeries( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ const QBrush& QwtPlotIntervalCurve::brush() const
|
||||
QRectF QwtPlotIntervalCurve::boundingRect() const
|
||||
{
|
||||
QRectF rect = QwtPlotSeriesItem::boundingRect();
|
||||
if ( rect.isValid() && orientation() == Qt::Vertical )
|
||||
if ( orientation() == Qt::Vertical )
|
||||
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
|
||||
|
||||
return rect;
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotIntervalCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotIntervalCurve( const QString &title = QString() );
|
||||
explicit QwtPlotIntervalCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotIntervalCurve();
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
void setSymbol( const QwtIntervalSymbol * );
|
||||
const QwtIntervalSymbol *symbol() const;
|
||||
|
||||
virtual void drawSeries( QPainter *p,
|
||||
virtual void drawSeries( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ QRectF QwtPlotItem::boundingRect() const
|
||||
\param right Returns the right margin
|
||||
\param bottom Returns the bottom margin
|
||||
|
||||
\return The default implementation returns 0 for all margins
|
||||
The default implementation returns 0 for all margins
|
||||
|
||||
\sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
|
||||
*/
|
||||
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
|
||||
virtual void getCanvasMarginHint(
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasSize,
|
||||
const QRectF &canvasRect,
|
||||
double &left, double &top, double &right, double &bottom) const;
|
||||
|
||||
virtual void updateScaleDiv(
|
||||
|
||||
@@ -844,16 +844,16 @@ QRectF QwtPlotLayout::alignLegend( const QRectF &canvasRect,
|
||||
\param rect Bounding rectangle for title, footer, axes and canvas.
|
||||
\param dimTitle Expanded height of the title widget
|
||||
\param dimFooter Expanded height of the footer widget
|
||||
\param dimAxis Expanded heights of the axis in axis orientation.
|
||||
\param dimAxes Expanded heights of the axis in axis orientation.
|
||||
|
||||
\sa Options
|
||||
*/
|
||||
void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
|
||||
int &dimTitle, int &dimFooter, int dimAxis[QwtPlot::axisCnt] ) const
|
||||
int &dimTitle, int &dimFooter, int dimAxes[QwtPlot::axisCnt] ) const
|
||||
{
|
||||
dimTitle = dimFooter = 0;
|
||||
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
|
||||
dimAxis[axis] = 0;
|
||||
dimAxes[axis] = 0;
|
||||
|
||||
int backboneOffset[QwtPlot::axisCnt];
|
||||
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
|
||||
@@ -888,7 +888,7 @@ void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
|
||||
!= d_data->layoutData.scale[QwtPlot::yRight].isEnabled )
|
||||
{
|
||||
// center to the canvas
|
||||
w -= dimAxis[QwtPlot::yLeft] + dimAxis[QwtPlot::yRight];
|
||||
w -= dimAxes[QwtPlot::yLeft] + dimAxes[QwtPlot::yRight];
|
||||
}
|
||||
|
||||
int d = qCeil( d_data->layoutData.title.text.heightForWidth( w ) );
|
||||
@@ -911,7 +911,7 @@ void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
|
||||
!= d_data->layoutData.scale[QwtPlot::yRight].isEnabled )
|
||||
{
|
||||
// center to the canvas
|
||||
w -= dimAxis[QwtPlot::yLeft] + dimAxis[QwtPlot::yRight];
|
||||
w -= dimAxes[QwtPlot::yLeft] + dimAxes[QwtPlot::yRight];
|
||||
}
|
||||
|
||||
int d = qCeil( d_data->layoutData.footer.text.heightForWidth( w ) );
|
||||
@@ -935,37 +935,37 @@ void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
|
||||
double length;
|
||||
if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom )
|
||||
{
|
||||
length = rect.width() - dimAxis[QwtPlot::yLeft]
|
||||
- dimAxis[QwtPlot::yRight];
|
||||
length = rect.width() - dimAxes[QwtPlot::yLeft]
|
||||
- dimAxes[QwtPlot::yRight];
|
||||
length -= scaleData.start + scaleData.end;
|
||||
|
||||
if ( dimAxis[QwtPlot::yRight] > 0 )
|
||||
if ( dimAxes[QwtPlot::yRight] > 0 )
|
||||
length -= 1;
|
||||
|
||||
length += qMin( dimAxis[QwtPlot::yLeft],
|
||||
length += qMin( dimAxes[QwtPlot::yLeft],
|
||||
scaleData.start - backboneOffset[QwtPlot::yLeft] );
|
||||
length += qMin( dimAxis[QwtPlot::yRight],
|
||||
length += qMin( dimAxes[QwtPlot::yRight],
|
||||
scaleData.end - backboneOffset[QwtPlot::yRight] );
|
||||
}
|
||||
else // QwtPlot::yLeft, QwtPlot::yRight
|
||||
{
|
||||
length = rect.height() - dimAxis[QwtPlot::xTop]
|
||||
- dimAxis[QwtPlot::xBottom];
|
||||
length = rect.height() - dimAxes[QwtPlot::xTop]
|
||||
- dimAxes[QwtPlot::xBottom];
|
||||
length -= scaleData.start + scaleData.end;
|
||||
length -= 1;
|
||||
|
||||
if ( dimAxis[QwtPlot::xBottom] <= 0 )
|
||||
if ( dimAxes[QwtPlot::xBottom] <= 0 )
|
||||
length -= 1;
|
||||
if ( dimAxis[QwtPlot::xTop] <= 0 )
|
||||
if ( dimAxes[QwtPlot::xTop] <= 0 )
|
||||
length -= 1;
|
||||
|
||||
if ( dimAxis[QwtPlot::xBottom] > 0 )
|
||||
if ( dimAxes[QwtPlot::xBottom] > 0 )
|
||||
{
|
||||
length += qMin(
|
||||
d_data->layoutData.scale[QwtPlot::xBottom].tickOffset,
|
||||
double( scaleData.start - backboneOffset[QwtPlot::xBottom] ) );
|
||||
}
|
||||
if ( dimAxis[QwtPlot::xTop] > 0 )
|
||||
if ( dimAxes[QwtPlot::xTop] > 0 )
|
||||
{
|
||||
length += qMin(
|
||||
d_data->layoutData.scale[QwtPlot::xTop].tickOffset,
|
||||
@@ -983,9 +983,9 @@ void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
|
||||
}
|
||||
|
||||
|
||||
if ( d > dimAxis[axis] )
|
||||
if ( d > dimAxes[axis] )
|
||||
{
|
||||
dimAxis[axis] = d;
|
||||
dimAxes[axis] = d;
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
virtual ~QwtPlotLayout();
|
||||
|
||||
void setCanvasMargin( int margin, int axis = -1 );
|
||||
int canvasMargin( int axis ) const;
|
||||
int canvasMargin( int axisId ) const;
|
||||
|
||||
void setAlignCanvasToScales( bool );
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
virtual QSize minimumSizeHint( const QwtPlot * ) const;
|
||||
|
||||
virtual void activate( const QwtPlot *,
|
||||
const QRectF &rect, Options options = 0x00 );
|
||||
const QRectF &plotRect, Options options = 0x00 );
|
||||
|
||||
virtual void invalidate();
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
void setFont( const QFont& );
|
||||
QFont font() const;
|
||||
|
||||
void setBorderDistance( int numPixels );
|
||||
void setBorderDistance( int );
|
||||
int borderDistance() const;
|
||||
|
||||
void setBorderRadius( double );
|
||||
@@ -105,9 +105,9 @@ public:
|
||||
void setTextPen( const QPen & );
|
||||
QPen textPen() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
void clearLegend();
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
virtual QRect geometry( const QRectF &canvasRect ) const;
|
||||
|
||||
virtual QSize minimumSize( const QwtLegendData & ) const;
|
||||
virtual int heightForWidth( const QwtLegendData &, int w ) const;
|
||||
virtual int heightForWidth( const QwtLegendData &, int width ) const;
|
||||
|
||||
QList< const QwtPlotItem * > plotItems() const;
|
||||
QList< QRect > legendGeometries( const QwtPlotItem * ) const;
|
||||
|
||||
@@ -548,8 +548,20 @@ const QPen &QwtPlotMarker::linePen() const
|
||||
|
||||
QRectF QwtPlotMarker::boundingRect() const
|
||||
{
|
||||
// width/height of -1 does not affect the autoscale calculation
|
||||
|
||||
switch (d_data->style)
|
||||
{
|
||||
case QwtPlotMarker::HLine:
|
||||
return QRectF( d_data->xValue, d_data->yValue, -1.0, 0.0 );
|
||||
|
||||
case QwtPlotMarker::VLine:
|
||||
return QRectF( d_data->xValue, d_data->yValue, 0.0, -1.0 );
|
||||
|
||||
default :
|
||||
return QRectF( d_data->xValue, d_data->yValue, 0.0, 0.0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Icon representing the marker on the legend
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
Cross
|
||||
};
|
||||
|
||||
explicit QwtPlotMarker( const QString &title = QString::null );
|
||||
explicit QwtPlotMarker( const QString &title = QString() );
|
||||
explicit QwtPlotMarker( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotMarker();
|
||||
@@ -84,11 +84,11 @@ public:
|
||||
void setValue( double, double );
|
||||
void setValue( const QPointF & );
|
||||
|
||||
void setLineStyle( LineStyle st );
|
||||
void setLineStyle( LineStyle );
|
||||
LineStyle lineStyle() const;
|
||||
|
||||
void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
|
||||
void setLinePen( const QPen &p );
|
||||
void setLinePen( const QPen & );
|
||||
const QPen &linePen() const;
|
||||
|
||||
void setSymbol( const QwtSymbol * );
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
void setSpacing( int );
|
||||
int spacing() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF & ) const;
|
||||
|
||||
|
||||
@@ -206,9 +206,9 @@ void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol *symbol )
|
||||
const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const
|
||||
{
|
||||
QMap<int, QwtColumnSymbol *>::const_iterator it =
|
||||
d_data->symbolMap.find( valueIndex );
|
||||
d_data->symbolMap.constFind( valueIndex );
|
||||
|
||||
return ( it == d_data->symbolMap.end() ) ? NULL : it.value();
|
||||
return ( it == d_data->symbolMap.constEnd() ) ? NULL : it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -221,10 +221,10 @@ const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const
|
||||
*/
|
||||
QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex )
|
||||
{
|
||||
QMap<int, QwtColumnSymbol *>::iterator it =
|
||||
d_data->symbolMap.find( valueIndex );
|
||||
QMap<int, QwtColumnSymbol *>::const_iterator it =
|
||||
d_data->symbolMap.constFind( valueIndex );
|
||||
|
||||
return ( it == d_data->symbolMap.end() ) ? NULL : it.value();
|
||||
return ( it == d_data->symbolMap.constEnd() ) ? NULL : it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -232,12 +232,7 @@ QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex )
|
||||
*/
|
||||
void QwtPlotMultiBarChart::resetSymbolMap()
|
||||
{
|
||||
for ( QMap<int, QwtColumnSymbol *>::iterator it
|
||||
= d_data->symbolMap.begin(); it != d_data->symbolMap.end(); ++it )
|
||||
{
|
||||
delete it.value();
|
||||
}
|
||||
|
||||
qDeleteAll( d_data->symbolMap );
|
||||
d_data->symbolMap.clear();
|
||||
}
|
||||
|
||||
@@ -567,7 +562,6 @@ void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter,
|
||||
|
||||
double sum = baseline();
|
||||
|
||||
const int numBars = sample.set.size();
|
||||
for ( int i = 0; i < numBars; i++ )
|
||||
{
|
||||
const double si = sample.set[ i ];
|
||||
@@ -669,10 +663,10 @@ void QwtPlotMultiBarChart::drawBar( QPainter *painter,
|
||||
else
|
||||
{
|
||||
// we build a temporary default symbol
|
||||
QwtColumnSymbol sym( QwtColumnSymbol::Box );
|
||||
sym.setLineWidth( 1 );
|
||||
sym.setFrameStyle( QwtColumnSymbol::Plain );
|
||||
sym.draw( painter, rect );
|
||||
QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box );
|
||||
columnSymbol.setLineWidth( 1 );
|
||||
columnSymbol.setFrameStyle( QwtColumnSymbol::Plain );
|
||||
columnSymbol.draw( painter, rect );
|
||||
}
|
||||
|
||||
delete specialSym;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
Stacked
|
||||
};
|
||||
|
||||
explicit QwtPlotMultiBarChart( const QString &title = QString::null );
|
||||
explicit QwtPlotMultiBarChart( const QString &title = QString() );
|
||||
explicit QwtPlotMultiBarChart( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotMultiBarChart();
|
||||
@@ -78,8 +78,8 @@ public:
|
||||
void setStyle( ChartStyle style );
|
||||
ChartStyle style() const;
|
||||
|
||||
void setSymbol( int barIndex, QwtColumnSymbol *symbol );
|
||||
const QwtColumnSymbol *symbol( int barIndex ) const;
|
||||
void setSymbol( int valueIndex, QwtColumnSymbol * );
|
||||
const QwtColumnSymbol *symbol( int valueIndex ) const;
|
||||
|
||||
void resetSymbolMap();
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
protected:
|
||||
QwtColumnSymbol *symbol( int barIndex );
|
||||
QwtColumnSymbol *symbol( int valueIndex );
|
||||
|
||||
virtual QwtColumnSymbol *specialSymbol(
|
||||
int sampleIndex, int valueIndex ) const;
|
||||
@@ -105,7 +105,7 @@ protected:
|
||||
int index, const QwtSetSample& sample ) const;
|
||||
|
||||
virtual void drawBar( QPainter *, int sampleIndex,
|
||||
int barIndex, const QwtColumnRect & ) const;
|
||||
int valueIndex, const QwtColumnRect & ) const;
|
||||
|
||||
void drawStackedBars( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -14,10 +14,29 @@
|
||||
#include <qbitmap.h>
|
||||
#include <qstyle.h>
|
||||
#include <qstyleoption.h>
|
||||
#include "qpainterpath.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#if QT_VERSION < 0x050100
|
||||
#define QWT_USE_WINDOW_HANDLE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef QWT_USE_WINDOW_HANDLE
|
||||
#include <qwindow.h>
|
||||
#endif
|
||||
|
||||
static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
qreal pixelRatio = 1.0;
|
||||
|
||||
#ifdef QWT_USE_WINDOW_HANDLE
|
||||
pixelRatio = canvas->windowHandle()->devicePixelRatio();
|
||||
#else
|
||||
pixelRatio = canvas->devicePixelRatio();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const QRect r( 0, 0, size.width(), size.height() );
|
||||
|
||||
QPainterPath borderPath;
|
||||
@@ -31,7 +50,12 @@ static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
|
||||
if ( canvas->contentsRect() == canvas->rect() )
|
||||
return QBitmap();
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
QBitmap mask( size * pixelRatio );
|
||||
mask.setDevicePixelRatio( pixelRatio );
|
||||
#else
|
||||
QBitmap mask( size );
|
||||
#endif
|
||||
mask.fill( Qt::color0 );
|
||||
|
||||
QPainter painter( &mask );
|
||||
@@ -40,7 +64,12 @@ static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
|
||||
return mask;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
QImage image( size * pixelRatio, QImage::Format_ARGB32_Premultiplied );
|
||||
image.setDevicePixelRatio( pixelRatio );
|
||||
#else
|
||||
QImage image( size, QImage::Format_ARGB32_Premultiplied );
|
||||
#endif
|
||||
image.fill( Qt::color0 );
|
||||
|
||||
QPainter painter( &image );
|
||||
|
||||
@@ -192,6 +192,9 @@ int QwtPlotPicker::yAxis() const
|
||||
*/
|
||||
QwtText QwtPlotPicker::trackerText( const QPoint &pos ) const
|
||||
{
|
||||
if ( plot() == NULL )
|
||||
return QwtText();
|
||||
|
||||
return trackerTextF( invTransform( pos ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotRasterItem( const QString& title = QString::null );
|
||||
explicit QwtPlotRasterItem( const QString& title = QString() );
|
||||
explicit QwtPlotRasterItem( const QwtText& title );
|
||||
virtual ~QwtPlotRasterItem();
|
||||
|
||||
@@ -98,9 +98,9 @@ public:
|
||||
|
||||
void invalidateCache();
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
virtual QRectF pixelHint( const QRectF & ) const;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -14,24 +14,61 @@
|
||||
#include "qwt_abstract_legend.h"
|
||||
#include "qwt_scale_widget.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
#include "qwt_scale_map.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_text_label.h"
|
||||
#include "qwt_math.h"
|
||||
|
||||
#include <qpainter.h>
|
||||
#include "qpainterpath.h"
|
||||
#include <qpaintengine.h>
|
||||
#include <qtransform.h>
|
||||
#include <qprinter.h>
|
||||
#include <qprintdialog.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qstyle.h>
|
||||
#include <qstyleoption.h>
|
||||
#include <qimagewriter.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
#ifndef QWT_NO_SVG
|
||||
#ifdef QT_SVG_LIB
|
||||
#if QT_VERSION >= 0x040500
|
||||
#define QWT_FORMAT_SVG 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#define QWT_FORMAT_PDF 1
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_PDF
|
||||
|
||||
// QPdfWriter::setResolution() has been introduced with
|
||||
// Qt 5.3. Guess it is o.k. to stay with QPrinter for older
|
||||
// versions.
|
||||
|
||||
#if QT_VERSION >= 0x050300
|
||||
|
||||
#ifndef QWT_FORMAT_PDF
|
||||
#define QWT_FORMAT_PDF 1
|
||||
#endif
|
||||
|
||||
#define QWT_PDF_WRITER 1
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
// postscript support has been dropped in Qt5
|
||||
#if QT_VERSION < 0x050000
|
||||
#define QWT_FORMAT_POSTSCRIPT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if QWT_FORMAT_SVG
|
||||
#include <qsvggenerator.h>
|
||||
#endif
|
||||
|
||||
#if QWT_PDF_WRITER
|
||||
#include <qpdfwriter.h>
|
||||
#endif
|
||||
|
||||
static QPainterPath qwtCanvasClip(
|
||||
@@ -58,6 +95,14 @@ static QPainterPath qwtCanvasClip(
|
||||
return clipPath;
|
||||
}
|
||||
|
||||
static inline QFont qwtResolvedFont( const QWidget *widget )
|
||||
{
|
||||
QFont font = widget->font();
|
||||
font.resolve( QFont::AllPropertiesResolved );
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
class QwtPlotRenderer::PrivateData
|
||||
{
|
||||
public:
|
||||
@@ -239,9 +284,20 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot,
|
||||
const QRectF documentRect( 0.0, 0.0, size.width(), size.height() );
|
||||
|
||||
const QString fmt = format.toLower();
|
||||
if ( fmt == "pdf" )
|
||||
if ( fmt == QLatin1String( "pdf" ) )
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if QWT_FORMAT_PDF
|
||||
|
||||
#if QWT_PDF_WRITER
|
||||
QPdfWriter pdfWriter( fileName );
|
||||
pdfWriter.setPageSizeMM( sizeMM );
|
||||
pdfWriter.setTitle( title );
|
||||
pdfWriter.setPageMargins( QMarginsF() );
|
||||
pdfWriter.setResolution( resolution );
|
||||
|
||||
QPainter painter( &pdfWriter );
|
||||
render( plot, &painter, documentRect );
|
||||
#else
|
||||
QPrinter printer;
|
||||
printer.setOutputFormat( QPrinter::PdfFormat );
|
||||
printer.setColorMode( QPrinter::Color );
|
||||
@@ -253,12 +309,12 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot,
|
||||
|
||||
QPainter painter( &printer );
|
||||
render( plot, &painter, documentRect );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if ( fmt == "ps" )
|
||||
else if ( fmt == QLatin1String( "ps" ) )
|
||||
{
|
||||
#if QT_VERSION < 0x050000
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if QWT_FORMAT_POSTSCRIPT
|
||||
QPrinter printer;
|
||||
printer.setOutputFormat( QPrinter::PostScriptFormat );
|
||||
printer.setColorMode( QPrinter::Color );
|
||||
@@ -270,14 +326,11 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot,
|
||||
|
||||
QPainter painter( &printer );
|
||||
render( plot, &painter, documentRect );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if ( fmt == "svg" )
|
||||
else if ( fmt == QLatin1String( "svg" ) )
|
||||
{
|
||||
#ifndef QWT_NO_SVG
|
||||
#ifdef QT_SVG_LIB
|
||||
#if QT_VERSION >= 0x040500
|
||||
#if QWT_FORMAT_SVG
|
||||
QSvgGenerator generator;
|
||||
generator.setTitle( title );
|
||||
generator.setFileName( fileName );
|
||||
@@ -286,8 +339,6 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot,
|
||||
|
||||
QPainter painter( &generator );
|
||||
render( plot, &painter, documentRect );
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -367,9 +418,7 @@ void QwtPlotRenderer::renderTo(
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef QWT_NO_SVG
|
||||
#ifdef QT_SVG_LIB
|
||||
#if QT_VERSION >= 0x040500
|
||||
#if QWT_FORMAT_SVG
|
||||
|
||||
/*!
|
||||
\brief Render the plot to a QSvgGenerator
|
||||
@@ -395,8 +444,7 @@ void QwtPlotRenderer::renderTo(
|
||||
QPainter p( &generator );
|
||||
render( plot, &p, rect );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@@ -461,11 +509,6 @@ void QwtPlotRenderer::render( QwtPlot *plot,
|
||||
|
||||
if ( !plot->axisEnabled( axisId ) )
|
||||
{
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int top = 0;
|
||||
int bottom = 0;
|
||||
|
||||
// When we have a scale the frame is painted on
|
||||
// the position of the backbone - otherwise we
|
||||
// need to introduce a margin around the canvas
|
||||
@@ -487,7 +530,6 @@ void QwtPlotRenderer::render( QwtPlot *plot,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
layoutRect.adjust( left, top, right, bottom );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -502,7 +544,6 @@ void QwtPlotRenderer::render( QwtPlot *plot,
|
||||
layoutOptions |= QwtPlotLayout::IgnoreFrames;
|
||||
}
|
||||
|
||||
|
||||
if ( d_data->discardFlags & DiscardLegend )
|
||||
layoutOptions |= QwtPlotLayout::IgnoreLegend;
|
||||
|
||||
@@ -591,18 +632,18 @@ void QwtPlotRenderer::render( QwtPlot *plot,
|
||||
|
||||
\param plot Plot widget
|
||||
\param painter Painter
|
||||
\param rect Bounding rectangle
|
||||
\param titleRect Bounding rectangle for the title
|
||||
*/
|
||||
void QwtPlotRenderer::renderTitle( const QwtPlot *plot,
|
||||
QPainter *painter, const QRectF &rect ) const
|
||||
QPainter *painter, const QRectF &titleRect ) const
|
||||
{
|
||||
painter->setFont( plot->titleLabel()->font() );
|
||||
painter->setFont( qwtResolvedFont( plot->titleLabel() ) );
|
||||
|
||||
const QColor color = plot->titleLabel()->palette().color(
|
||||
QPalette::Active, QPalette::Text );
|
||||
|
||||
painter->setPen( color );
|
||||
plot->titleLabel()->text().draw( painter, rect );
|
||||
plot->titleLabel()->text().draw( painter, titleRect );
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -610,35 +651,34 @@ void QwtPlotRenderer::renderTitle( const QwtPlot *plot,
|
||||
|
||||
\param plot Plot widget
|
||||
\param painter Painter
|
||||
\param rect Bounding rectangle
|
||||
\param footerRect Bounding rectangle for the footer
|
||||
*/
|
||||
void QwtPlotRenderer::renderFooter( const QwtPlot *plot,
|
||||
QPainter *painter, const QRectF &rect ) const
|
||||
QPainter *painter, const QRectF &footerRect ) const
|
||||
{
|
||||
painter->setFont( plot->footerLabel()->font() );
|
||||
painter->setFont( qwtResolvedFont( plot->footerLabel() ) );
|
||||
|
||||
const QColor color = plot->footerLabel()->palette().color(
|
||||
QPalette::Active, QPalette::Text );
|
||||
|
||||
painter->setPen( color );
|
||||
plot->footerLabel()->text().draw( painter, rect );
|
||||
plot->footerLabel()->text().draw( painter, footerRect );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Render the legend into a given rectangle.
|
||||
|
||||
\param plot Plot widget
|
||||
\param painter Painter
|
||||
\param rect Bounding rectangle
|
||||
\param legendRect Bounding rectangle for the legend
|
||||
*/
|
||||
void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
|
||||
QPainter *painter, const QRectF &rect ) const
|
||||
QPainter *painter, const QRectF &legendRect ) const
|
||||
{
|
||||
if ( plot->legend() )
|
||||
{
|
||||
bool fillBackground = !( d_data->discardFlags & DiscardBackground );
|
||||
plot->legend()->renderLegend( painter, rect, fillBackground );
|
||||
plot->legend()->renderLegend( painter, legendRect, fillBackground );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,12 +692,12 @@ void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
|
||||
\param startDist Start border distance
|
||||
\param endDist End border distance
|
||||
\param baseDist Base distance
|
||||
\param rect Bounding rectangle
|
||||
\param scaleRect Bounding rectangle for the scale
|
||||
*/
|
||||
void QwtPlotRenderer::renderScale( const QwtPlot *plot,
|
||||
QPainter *painter,
|
||||
int axisId, int startDist, int endDist, int baseDist,
|
||||
const QRectF &rect ) const
|
||||
const QRectF &scaleRect ) const
|
||||
{
|
||||
if ( !plot->axisEnabled( axisId ) )
|
||||
return;
|
||||
@@ -666,7 +706,7 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot,
|
||||
if ( scaleWidget->isColorBarEnabled()
|
||||
&& scaleWidget->colorBarWidth() > 0 )
|
||||
{
|
||||
scaleWidget->drawColorBar( painter, scaleWidget->colorBarRect( rect ) );
|
||||
scaleWidget->drawColorBar( painter, scaleWidget->colorBarRect( scaleRect ) );
|
||||
baseDist += scaleWidget->colorBarWidth() + scaleWidget->spacing();
|
||||
}
|
||||
|
||||
@@ -679,33 +719,33 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot,
|
||||
{
|
||||
case QwtPlot::yLeft:
|
||||
{
|
||||
x = rect.right() - 1.0 - baseDist;
|
||||
y = rect.y() + startDist;
|
||||
w = rect.height() - startDist - endDist;
|
||||
x = scaleRect.right() - 1.0 - baseDist;
|
||||
y = scaleRect.y() + startDist;
|
||||
w = scaleRect.height() - startDist - endDist;
|
||||
align = QwtScaleDraw::LeftScale;
|
||||
break;
|
||||
}
|
||||
case QwtPlot::yRight:
|
||||
{
|
||||
x = rect.left() + baseDist;
|
||||
y = rect.y() + startDist;
|
||||
w = rect.height() - startDist - endDist;
|
||||
x = scaleRect.left() + baseDist;
|
||||
y = scaleRect.y() + startDist;
|
||||
w = scaleRect.height() - startDist - endDist;
|
||||
align = QwtScaleDraw::RightScale;
|
||||
break;
|
||||
}
|
||||
case QwtPlot::xTop:
|
||||
{
|
||||
x = rect.left() + startDist;
|
||||
y = rect.bottom() - 1.0 - baseDist;
|
||||
w = rect.width() - startDist - endDist;
|
||||
x = scaleRect.left() + startDist;
|
||||
y = scaleRect.bottom() - 1.0 - baseDist;
|
||||
w = scaleRect.width() - startDist - endDist;
|
||||
align = QwtScaleDraw::TopScale;
|
||||
break;
|
||||
}
|
||||
case QwtPlot::xBottom:
|
||||
{
|
||||
x = rect.left() + startDist;
|
||||
y = rect.top() + baseDist;
|
||||
w = rect.width() - startDist - endDist;
|
||||
x = scaleRect.left() + startDist;
|
||||
y = scaleRect.top() + baseDist;
|
||||
w = scaleRect.width() - startDist - endDist;
|
||||
align = QwtScaleDraw::BottomScale;
|
||||
break;
|
||||
}
|
||||
@@ -713,9 +753,9 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot,
|
||||
return;
|
||||
}
|
||||
|
||||
scaleWidget->drawTitle( painter, align, rect );
|
||||
scaleWidget->drawTitle( painter, align, scaleRect );
|
||||
|
||||
painter->setFont( scaleWidget->font() );
|
||||
painter->setFont( qwtResolvedFont( scaleWidget ) );
|
||||
|
||||
QwtScaleDraw *sd = const_cast<QwtScaleDraw *>( scaleWidget->scaleDraw() );
|
||||
const QPointF sdPos = sd->pos();
|
||||
@@ -740,12 +780,12 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot,
|
||||
|
||||
\param plot Plot widget
|
||||
\param painter Painter
|
||||
\param map Maps mapping between plot and paint device coordinates
|
||||
\param maps Maps mapping between plot and paint device coordinates
|
||||
\param canvasRect Canvas rectangle
|
||||
*/
|
||||
void QwtPlotRenderer::renderCanvas( const QwtPlot *plot,
|
||||
QPainter *painter, const QRectF &canvasRect,
|
||||
const QwtScaleMap *map ) const
|
||||
const QwtScaleMap *maps ) const
|
||||
{
|
||||
const QWidget *canvas = plot->canvas();
|
||||
|
||||
@@ -771,7 +811,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot,
|
||||
painter->save();
|
||||
|
||||
painter->setClipRect( canvasRect );
|
||||
plot->drawItems( painter, canvasRect, map );
|
||||
plot->drawItems( painter, canvasRect, maps );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
@@ -795,7 +835,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot,
|
||||
else
|
||||
painter->setClipPath( clipPath );
|
||||
|
||||
plot->drawItems( painter, canvasRect, map );
|
||||
plot->drawItems( painter, canvasRect, maps );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
@@ -833,7 +873,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot,
|
||||
QwtPainter::drawBackgound( painter, innerRect, canvas );
|
||||
}
|
||||
|
||||
plot->drawItems( painter, innerRect, map );
|
||||
plot->drawItems( painter, innerRect, maps );
|
||||
|
||||
painter->restore();
|
||||
|
||||
@@ -845,17 +885,14 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot,
|
||||
canvas->property( "frameShadow" ).toInt() |
|
||||
canvas->property( "frameShape" ).toInt();
|
||||
|
||||
const int frameWidth = canvas->property( "frameWidth" ).toInt();
|
||||
|
||||
|
||||
const QVariant borderRadius = canvas->property( "borderRadius" );
|
||||
if ( borderRadius.type() == QVariant::Double
|
||||
&& borderRadius.toDouble() > 0.0 )
|
||||
{
|
||||
const double r = borderRadius.toDouble();
|
||||
const double radius = borderRadius.toDouble();
|
||||
|
||||
QwtPainter::drawRoundedFrame( painter, canvasRect,
|
||||
r, r, canvas->palette(), frameWidth, frameStyle );
|
||||
radius, radius, canvas->palette(), frameWidth, frameStyle );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -976,13 +1013,13 @@ bool QwtPlotRenderer::exportTo( QwtPlot *plot, const QString &documentName,
|
||||
QImageWriter::supportedImageFormats();
|
||||
|
||||
QStringList filter;
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if QWT_FORMAT_PDF
|
||||
filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)";
|
||||
#endif
|
||||
#ifndef QWT_NO_SVG
|
||||
#if QWT_FORMAT_SVG
|
||||
filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)";
|
||||
#endif
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if QWT_FORMAT_POSTSCRIPT
|
||||
filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)";
|
||||
#endif
|
||||
|
||||
|
||||
@@ -127,27 +127,27 @@ public:
|
||||
void renderTo( QwtPlot *, QPrinter & ) const;
|
||||
#endif
|
||||
|
||||
void renderTo( QwtPlot *, QPaintDevice &p ) const;
|
||||
void renderTo( QwtPlot *, QPaintDevice & ) const;
|
||||
|
||||
virtual void render( QwtPlot *,
|
||||
QPainter *, const QRectF &rect ) const;
|
||||
QPainter *, const QRectF &plotRect ) const;
|
||||
|
||||
virtual void renderTitle( const QwtPlot *,
|
||||
QPainter *, const QRectF & ) const;
|
||||
QPainter *, const QRectF &titleRect ) const;
|
||||
|
||||
virtual void renderFooter( const QwtPlot *,
|
||||
QPainter *, const QRectF & ) const;
|
||||
QPainter *, const QRectF &footerRect ) const;
|
||||
|
||||
virtual void renderScale( const QwtPlot *, QPainter *,
|
||||
int axisId, int startDist, int endDist,
|
||||
int baseDist, const QRectF & ) const;
|
||||
int baseDist, const QRectF &scaleRect ) const;
|
||||
|
||||
virtual void renderCanvas( const QwtPlot *,
|
||||
QPainter *, const QRectF &canvasRect,
|
||||
const QwtScaleMap* maps ) const;
|
||||
|
||||
virtual void renderLegend(
|
||||
const QwtPlot *, QPainter *, const QRectF & ) const;
|
||||
const QwtPlot *, QPainter *, const QRectF &legendRect ) const;
|
||||
|
||||
bool exportTo( QwtPlot *, const QString &documentName,
|
||||
const QSizeF &sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
|
||||
|
||||
@@ -34,14 +34,14 @@ class QPalette;
|
||||
\par Example
|
||||
The following example shows how to replace the left axis, by a scale item
|
||||
at the x position 0.0.
|
||||
\verbatim
|
||||
QwtPlotScaleItem *scaleItem =
|
||||
new QwtPlotScaleItem(QwtScaleDraw::RightScale, 0.0);
|
||||
\code
|
||||
QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem( QwtScaleDraw::RightScale, 0.0 );
|
||||
scaleItem->setFont( plot->axisWidget( QwtPlot::yLeft )->font() );
|
||||
scaleItem->attach(plot);
|
||||
|
||||
plot->enableAxis( QwtPlot::yLeft, false );
|
||||
\endverbatim
|
||||
\endcode
|
||||
\endpar
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtPlotScaleItem: public QwtPlotItem
|
||||
@@ -75,14 +75,14 @@ public:
|
||||
void setPosition( double pos );
|
||||
double position() const;
|
||||
|
||||
void setBorderDistance( int numPixels );
|
||||
void setBorderDistance( int );
|
||||
int borderDistance() const;
|
||||
|
||||
void setAlignment( QwtScaleDraw::Alignment );
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
virtual void updateScaleDiv( const QwtScaleDiv &, const QwtScaleDiv & );
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ QwtPlotSeriesItem::QwtPlotSeriesItem( const QString &title ):
|
||||
QwtPlotItem( QwtText( title ) )
|
||||
{
|
||||
d_data = new PrivateData();
|
||||
setItemInterest( QwtPlotItem::ScaleInterest, true );
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
|
||||
@@ -23,7 +23,7 @@ class QWT_EXPORT QwtPlotSeriesItem: public QwtPlotItem,
|
||||
public virtual QwtAbstractSeriesStore
|
||||
{
|
||||
public:
|
||||
explicit QwtPlotSeriesItem( const QString &title = QString::null );
|
||||
explicit QwtPlotSeriesItem( const QString &title = QString() );
|
||||
explicit QwtPlotSeriesItem( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotSeriesItem();
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
void setOrientation( Qt::Orientation );
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF & ) const;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
LegendColor
|
||||
};
|
||||
|
||||
explicit QwtPlotShapeItem( const QString &title = QString::null );
|
||||
explicit QwtPlotShapeItem( const QString &title = QString() );
|
||||
explicit QwtPlotShapeItem( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotShapeItem();
|
||||
@@ -93,9 +93,9 @@ public:
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotSpectroCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotSpectroCurve( const QString &title = QString() );
|
||||
explicit QwtPlotSpectroCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotSpectroCurve();
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
void setPenWidth(double width);
|
||||
void setPenWidth( double );
|
||||
double penWidth() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
//! Display modes
|
||||
typedef QFlags<DisplayMode> DisplayModes;
|
||||
|
||||
explicit QwtPlotSpectrogram( const QString &title = QString::null );
|
||||
explicit QwtPlotSpectrogram( const QString &title = QString() );
|
||||
virtual ~QwtPlotSpectrogram();
|
||||
|
||||
void setDisplayMode( DisplayMode, bool on = true );
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
protected:
|
||||
virtual QImage renderImage(
|
||||
@@ -101,12 +101,12 @@ protected:
|
||||
virtual QwtRasterData::ContourLines renderContourLines(
|
||||
const QRectF &rect, const QSize &raster ) const;
|
||||
|
||||
virtual void drawContourLines( QPainter *p,
|
||||
virtual void drawContourLines( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QwtRasterData::ContourLines& lines ) const;
|
||||
const QwtRasterData::ContourLines& ) const;
|
||||
|
||||
void renderTile( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRect &imageRect, QImage *image ) const;
|
||||
const QRect &tile, QImage * ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
|
||||
219
qwtdemo/qwt/qwt_plot_svgitem.cpp
Normal file
219
qwtdemo/qwt/qwt_plot_svgitem.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "qwt_plot_svgitem.h"
|
||||
#include "qwt_scale_map.h"
|
||||
#include "qwt_painter.h"
|
||||
#include <qpainter.h>
|
||||
#include <qsvgrenderer.h>
|
||||
|
||||
class QwtPlotSvgItem::PrivateData
|
||||
{
|
||||
public:
|
||||
PrivateData()
|
||||
{
|
||||
}
|
||||
|
||||
QRectF boundingRect;
|
||||
QSvgRenderer renderer;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
|
||||
Sets the following item attributes:
|
||||
- QwtPlotItem::AutoScale: true
|
||||
- QwtPlotItem::Legend: false
|
||||
|
||||
\param title Title
|
||||
*/
|
||||
QwtPlotSvgItem::QwtPlotSvgItem( const QString& title ):
|
||||
QwtPlotItem( QwtText( title ) )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
|
||||
Sets the following item attributes:
|
||||
- QwtPlotItem::AutoScale: true
|
||||
- QwtPlotItem::Legend: false
|
||||
|
||||
\param title Title
|
||||
*/
|
||||
QwtPlotSvgItem::QwtPlotSvgItem( const QwtText& title ):
|
||||
QwtPlotItem( title )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
QwtPlotSvgItem::~QwtPlotSvgItem()
|
||||
{
|
||||
delete d_data;
|
||||
}
|
||||
|
||||
void QwtPlotSvgItem::init()
|
||||
{
|
||||
d_data = new PrivateData();
|
||||
d_data->boundingRect = QwtPlotItem::boundingRect();
|
||||
|
||||
setItemAttribute( QwtPlotItem::AutoScale, true );
|
||||
setItemAttribute( QwtPlotItem::Legend, false );
|
||||
|
||||
setZ( 8.0 );
|
||||
}
|
||||
|
||||
//! \return QwtPlotItem::Rtti_PlotSVG
|
||||
int QwtPlotSvgItem::rtti() const
|
||||
{
|
||||
return QwtPlotItem::Rtti_PlotSVG;
|
||||
}
|
||||
|
||||
/*!
|
||||
Load a SVG file
|
||||
|
||||
\param rect Bounding rectangle
|
||||
\param fileName SVG file name
|
||||
|
||||
\return true, if the SVG file could be loaded
|
||||
*/
|
||||
bool QwtPlotSvgItem::loadFile( const QRectF &rect,
|
||||
const QString &fileName )
|
||||
{
|
||||
d_data->boundingRect = rect;
|
||||
const bool ok = d_data->renderer.load( fileName );
|
||||
|
||||
legendChanged();
|
||||
itemChanged();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*!
|
||||
Load SVG data
|
||||
|
||||
\param rect Bounding rectangle
|
||||
\param data in SVG format
|
||||
|
||||
\return true, if the SVG data could be loaded
|
||||
*/
|
||||
bool QwtPlotSvgItem::loadData( const QRectF &rect,
|
||||
const QByteArray &data )
|
||||
{
|
||||
d_data->boundingRect = rect;
|
||||
const bool ok = d_data->renderer.load( data );
|
||||
|
||||
legendChanged();
|
||||
itemChanged();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
//! Bounding rectangle of the item
|
||||
QRectF QwtPlotSvgItem::boundingRect() const
|
||||
{
|
||||
return d_data->boundingRect;
|
||||
}
|
||||
|
||||
//! \return Renderer used to render the SVG data
|
||||
const QSvgRenderer &QwtPlotSvgItem::renderer() const
|
||||
{
|
||||
return d_data->renderer;
|
||||
}
|
||||
|
||||
//! \return Renderer used to render the SVG data
|
||||
QSvgRenderer &QwtPlotSvgItem::renderer()
|
||||
{
|
||||
return d_data->renderer;
|
||||
}
|
||||
|
||||
/*!
|
||||
Draw the SVG item
|
||||
|
||||
\param painter Painter
|
||||
\param xMap X-Scale Map
|
||||
\param yMap Y-Scale Map
|
||||
\param canvasRect Contents rect of the plot canvas
|
||||
*/
|
||||
void QwtPlotSvgItem::draw( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect ) const
|
||||
{
|
||||
const QRectF cRect = QwtScaleMap::invTransform(
|
||||
xMap, yMap, canvasRect.toRect() );
|
||||
const QRectF bRect = boundingRect();
|
||||
if ( bRect.isValid() && cRect.isValid() )
|
||||
{
|
||||
QRectF rect = bRect;
|
||||
if ( bRect.contains( cRect ) )
|
||||
rect = cRect;
|
||||
|
||||
const QRectF r = QwtScaleMap::transform( xMap, yMap, rect );
|
||||
render( painter, viewBox( rect ), r );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Render the SVG data
|
||||
|
||||
\param painter Painter
|
||||
\param viewBox View Box, see QSvgRenderer::viewBox()
|
||||
\param rect Target rectangle on the paint device
|
||||
*/
|
||||
void QwtPlotSvgItem::render( QPainter *painter,
|
||||
const QRectF &viewBox, const QRectF &rect ) const
|
||||
{
|
||||
if ( !viewBox.isValid() )
|
||||
return;
|
||||
|
||||
QRectF r = rect;
|
||||
|
||||
if ( QwtPainter::roundingAlignment( painter ) )
|
||||
{
|
||||
r.setLeft ( qRound( r.left() ) );
|
||||
r.setRight ( qRound( r.right() ) );
|
||||
r.setTop ( qRound( r.top() ) );
|
||||
r.setBottom ( qRound( r.bottom() ) );
|
||||
}
|
||||
|
||||
d_data->renderer.setViewBox( viewBox );
|
||||
d_data->renderer.render( painter, r );
|
||||
}
|
||||
|
||||
/*!
|
||||
Calculate the view box from rect and boundingRect().
|
||||
|
||||
\param rect Rectangle in scale coordinates
|
||||
\return View box, see QSvgRenderer::viewBox()
|
||||
*/
|
||||
QRectF QwtPlotSvgItem::viewBox( const QRectF &rect ) const
|
||||
{
|
||||
const QSize sz = d_data->renderer.defaultSize();
|
||||
const QRectF br = boundingRect();
|
||||
|
||||
if ( !rect.isValid() || !br.isValid() || sz.isNull() )
|
||||
return QRectF();
|
||||
|
||||
QwtScaleMap xMap;
|
||||
xMap.setScaleInterval( br.left(), br.right() );
|
||||
xMap.setPaintInterval( 0, sz.width() );
|
||||
|
||||
QwtScaleMap yMap;
|
||||
yMap.setScaleInterval( br.top(), br.bottom() );
|
||||
yMap.setPaintInterval( sz.height(), 0 );
|
||||
|
||||
const double x1 = xMap.transform( rect.left() );
|
||||
const double x2 = xMap.transform( rect.right() );
|
||||
const double y1 = yMap.transform( rect.bottom() );
|
||||
const double y2 = yMap.transform( rect.top() );
|
||||
|
||||
return QRectF( x1, y1, x2 - x1, y2 - y1 );
|
||||
}
|
||||
61
qwtdemo/qwt/qwt_plot_svgitem.h
Normal file
61
qwtdemo/qwt/qwt_plot_svgitem.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_SVGITEM_H
|
||||
#define QWT_PLOT_SVGITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include <qstring.h>
|
||||
|
||||
class QSvgRenderer;
|
||||
class QByteArray;
|
||||
|
||||
/*!
|
||||
\brief A plot item, which displays
|
||||
data in Scalable Vector Graphics (SVG) format.
|
||||
|
||||
SVG images are often used to display maps
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtPlotSvgItem: public QwtPlotItem
|
||||
{
|
||||
public:
|
||||
explicit QwtPlotSvgItem( const QString& title = QString() );
|
||||
explicit QwtPlotSvgItem( const QwtText& title );
|
||||
virtual ~QwtPlotSvgItem();
|
||||
|
||||
bool loadFile( const QRectF&, const QString &fileName );
|
||||
bool loadData( const QRectF&, const QByteArray & );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual void draw( QPainter *,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect ) const;
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
protected:
|
||||
const QSvgRenderer &renderer() const;
|
||||
QSvgRenderer &renderer();
|
||||
|
||||
void render( QPainter *,
|
||||
const QRectF &viewBox, const QRectF &rect ) const;
|
||||
|
||||
QRectF viewBox( const QRectF &rect ) const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -27,8 +27,7 @@
|
||||
|
||||
\par Example
|
||||
The following code shows how to add a title.
|
||||
|
||||
\verbatim
|
||||
\code
|
||||
QwtText title( "Plot Title" );
|
||||
title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
|
||||
|
||||
@@ -38,8 +37,9 @@
|
||||
|
||||
QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
|
||||
titleItem->setText( title );
|
||||
titleItem->attach( this );
|
||||
\endverbatim
|
||||
titleItem->attach( plot );
|
||||
\endcode
|
||||
\endpar
|
||||
|
||||
\sa QwtPlotMarker
|
||||
*/
|
||||
|
||||
@@ -235,12 +235,14 @@ QPen QwtPlotTradingCurve::symbolPen() const
|
||||
void QwtPlotTradingCurve::setSymbolBrush(
|
||||
Direction direction, const QBrush &brush )
|
||||
{
|
||||
if ( direction < 0 || direction >= 2 )
|
||||
// silencing -Wtautological-constant-out-of-range-compare
|
||||
const int index = static_cast< int >( direction );
|
||||
if ( index < 0 || index >= 2 )
|
||||
return;
|
||||
|
||||
if ( brush != d_data->symbolBrush[ direction ] )
|
||||
if ( brush != d_data->symbolBrush[ index ] )
|
||||
{
|
||||
d_data->symbolBrush[ direction ] = brush;
|
||||
d_data->symbolBrush[ index ] = brush;
|
||||
|
||||
legendChanged();
|
||||
itemChanged();
|
||||
@@ -256,10 +258,11 @@ void QwtPlotTradingCurve::setSymbolBrush(
|
||||
*/
|
||||
QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const
|
||||
{
|
||||
if ( direction < 0 || direction >= 2 )
|
||||
const int index = static_cast< int >( direction );
|
||||
if ( index < 0 || index >= 2 )
|
||||
return QBrush();
|
||||
|
||||
return d_data->symbolBrush[ direction ];
|
||||
return d_data->symbolBrush[ index ];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -359,7 +362,7 @@ double QwtPlotTradingCurve::maxSymbolWidth() const
|
||||
QRectF QwtPlotTradingCurve::boundingRect() const
|
||||
{
|
||||
QRectF rect = QwtPlotSeriesItem::boundingRect();
|
||||
if ( rect.isValid() && orientation() == Qt::Vertical )
|
||||
if ( orientation() == Qt::Vertical )
|
||||
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
|
||||
|
||||
return rect;
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotTradingCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotTradingCurve( const QString &title = QString() );
|
||||
explicit QwtPlotTradingCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotTradingCurve();
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
void setSymbolBrush( Direction, const QBrush & );
|
||||
QBrush symbolBrush( Direction ) const;
|
||||
|
||||
void setSymbolExtent( double width );
|
||||
void setSymbolExtent( double );
|
||||
double symbolExtent() const;
|
||||
|
||||
void setMinSymbolWidth( double );
|
||||
@@ -152,7 +152,7 @@ protected:
|
||||
|
||||
virtual void drawUserSymbol( QPainter *,
|
||||
SymbolStyle, const QwtOHLCSample &,
|
||||
Qt::Orientation, bool inverted, double width ) const;
|
||||
Qt::Orientation, bool inverted, double symbolWidth ) const;
|
||||
|
||||
void drawBar( QPainter *painter, const QwtOHLCSample &,
|
||||
Qt::Orientation, bool inverted, double width ) const;
|
||||
|
||||
@@ -28,7 +28,7 @@ void QwtPlot::applyProperties( const QString & /* xmlDocument */ )
|
||||
This method is intended for manipulating the plot widget
|
||||
from a specific editor in the Qwt designer plugin.
|
||||
|
||||
\return QString::null
|
||||
\return QString()
|
||||
\warning The plot editor has never been implemented.
|
||||
*/
|
||||
QString QwtPlot::grabProperties() const
|
||||
@@ -37,6 +37,6 @@ QString QwtPlot::grabProperties() const
|
||||
// Temporary dummy code, for designer tests
|
||||
return title().text();
|
||||
#else
|
||||
return QString::null;
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ public:
|
||||
uint zoomRectIndex() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void moveBy( double x, double y );
|
||||
void moveBy( double dx, double dy );
|
||||
virtual void moveTo( const QPointF & );
|
||||
|
||||
virtual void zoom( const QRectF & );
|
||||
virtual void zoom( int up );
|
||||
virtual void zoom( int offset );
|
||||
|
||||
Q_SIGNALS:
|
||||
/*!
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual size_t size() const;
|
||||
virtual QPointF sample( size_t i ) const;
|
||||
virtual QPointF sample( size_t index ) const;
|
||||
|
||||
const QVector<double> &xData() const;
|
||||
const QVector<double> &yData() const;
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual size_t size() const;
|
||||
virtual QPointF sample( size_t i ) const;
|
||||
virtual QPointF sample( size_t index ) const;
|
||||
|
||||
const double *xData() const;
|
||||
const double *yData() const;
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
QwtInterval interval() const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual QPointF sample( size_t i ) const;
|
||||
virtual QPointF sample( size_t index ) const;
|
||||
|
||||
/*!
|
||||
Calculate a y value for a x value
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <qtconcurrentrun.h>
|
||||
|
||||
#if !defined(QT_NO_QFUTURE)
|
||||
#define QWT_USE_THREADS 0
|
||||
#define QWT_USE_THREADS 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual double extent( const QFont & ) const;
|
||||
|
||||
protected:
|
||||
virtual void drawTick( QPainter *, double val, double len ) const;
|
||||
virtual void drawTick( QPainter *, double value, double len ) const;
|
||||
virtual void drawBackbone( QPainter * ) const;
|
||||
virtual void drawLabel( QPainter *, double val ) const;
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _QWT_SAMPLING_THREAD_H_
|
||||
#define _QWT_SAMPLING_THREAD_H_
|
||||
|
||||
|
||||
@@ -80,19 +80,19 @@ public:
|
||||
int maxLabelHeight( const QFont & ) const;
|
||||
int maxLabelWidth( const QFont & ) const;
|
||||
|
||||
QPointF labelPosition( double val ) const;
|
||||
QPointF labelPosition( double value ) const;
|
||||
|
||||
QRectF labelRect( const QFont &, double val ) const;
|
||||
QSizeF labelSize( const QFont &, double val ) const;
|
||||
QRectF labelRect( const QFont &, double value ) const;
|
||||
QSizeF labelSize( const QFont &, double value ) const;
|
||||
|
||||
QRect boundingLabelRect( const QFont &, double val ) const;
|
||||
QRect boundingLabelRect( const QFont &, double value ) const;
|
||||
|
||||
protected:
|
||||
QTransform labelTransformation( const QPointF &, const QSizeF & ) const;
|
||||
|
||||
virtual void drawTick( QPainter *, double val, double len ) const;
|
||||
virtual void drawTick( QPainter *, double value, double len ) const;
|
||||
virtual void drawBackbone( QPainter * ) const;
|
||||
virtual void drawLabel( QPainter *, double val ) const;
|
||||
virtual void drawLabel( QPainter *, double value ) const;
|
||||
|
||||
private:
|
||||
QwtScaleDraw( const QwtScaleDraw & );
|
||||
|
||||
@@ -467,16 +467,16 @@ QwtScaleEngine::Attributes QwtScaleEngine::attributes() const
|
||||
|
||||
/*!
|
||||
\brief Specify a reference point
|
||||
\param r new reference value
|
||||
\param reference New reference value
|
||||
|
||||
The reference point is needed if options IncludeReference or
|
||||
Symmetric are active. Its default value is 0.0.
|
||||
|
||||
\sa Attribute
|
||||
*/
|
||||
void QwtScaleEngine::setReference( double r )
|
||||
void QwtScaleEngine::setReference( double reference )
|
||||
{
|
||||
d_data->referenceValue = r;
|
||||
d_data->referenceValue = reference;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
static double ceilEps( double value, double intervalSize );
|
||||
static double floorEps( double value, double intervalSize );
|
||||
|
||||
static double divideEps( double interval, double steps );
|
||||
static double divideEps( double intervalSize, double numSteps );
|
||||
|
||||
static double divideInterval( double interval,
|
||||
static double divideInterval( double intervalSize,
|
||||
int numSteps, uint base );
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
void setAttributes( Attributes );
|
||||
Attributes attributes() const;
|
||||
|
||||
void setReference( double reference );
|
||||
void setReference( double );
|
||||
double reference() const;
|
||||
|
||||
void setMargins( double lower, double upper );
|
||||
@@ -128,12 +128,12 @@ public:
|
||||
QwtTransform *transformation() const;
|
||||
|
||||
protected:
|
||||
bool contains( const QwtInterval &, double val ) const;
|
||||
bool contains( const QwtInterval &, double value ) const;
|
||||
QList<double> strip( const QList<double>&, const QwtInterval & ) const;
|
||||
|
||||
double divideInterval( double interval, int numSteps ) const;
|
||||
double divideInterval( double intervalSize, int numSteps ) const;
|
||||
|
||||
QwtInterval buildInterval( double v ) const;
|
||||
QwtInterval buildInterval( double value ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
@@ -153,11 +153,11 @@ public:
|
||||
QwtLinearScaleEngine( uint base = 10 );
|
||||
virtual ~QwtLinearScaleEngine();
|
||||
|
||||
virtual void autoScale( int maxSteps,
|
||||
virtual void autoScale( int maxNumSteps,
|
||||
double &x1, double &x2, double &stepSize ) const;
|
||||
|
||||
virtual QwtScaleDiv divideScale( double x1, double x2,
|
||||
int numMajorSteps, int numMinorSteps,
|
||||
int maxMajorSteps, int maxMinorSteps,
|
||||
double stepSize = 0.0 ) const;
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ protected:
|
||||
QwtInterval align( const QwtInterval&, double stepSize ) const;
|
||||
|
||||
void buildTicks(
|
||||
const QwtInterval &, double stepSize, int maxMinSteps,
|
||||
const QwtInterval &, double stepSize, int maxMinorSteps,
|
||||
QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
|
||||
|
||||
QList<double> buildMajorTicks(
|
||||
@@ -193,18 +193,18 @@ public:
|
||||
QwtLogScaleEngine( uint base = 10 );
|
||||
virtual ~QwtLogScaleEngine();
|
||||
|
||||
virtual void autoScale( int maxSteps,
|
||||
virtual void autoScale( int maxNumSteps,
|
||||
double &x1, double &x2, double &stepSize ) const;
|
||||
|
||||
virtual QwtScaleDiv divideScale( double x1, double x2,
|
||||
int numMajorSteps, int numMinorSteps,
|
||||
int maxMajorSteps, int maxMinorSteps,
|
||||
double stepSize = 0.0 ) const;
|
||||
|
||||
protected:
|
||||
QwtInterval align( const QwtInterval&, double stepSize ) const;
|
||||
|
||||
void buildTicks(
|
||||
const QwtInterval &, double stepSize, int maxMinSteps,
|
||||
const QwtInterval &, double stepSize, int maxMinorSteps,
|
||||
QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
|
||||
|
||||
QList<double> buildMajorTicks(
|
||||
|
||||
@@ -145,6 +145,8 @@ void QwtScaleWidget::setLayoutFlag( LayoutFlag flag, bool on )
|
||||
d_data->layoutFlags |= flag;
|
||||
else
|
||||
d_data->layoutFlags &= ~flag;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
void setLayoutFlag( LayoutFlag, bool on );
|
||||
bool testLayoutFlag( LayoutFlag ) const;
|
||||
|
||||
void setBorderDist( int start, int end );
|
||||
void setBorderDist( int dist1, int dist2 );
|
||||
int startBorderDist() const;
|
||||
int endBorderDist() const;
|
||||
|
||||
@@ -76,10 +76,10 @@ public:
|
||||
void setMargin( int );
|
||||
int margin() const;
|
||||
|
||||
void setSpacing( int td );
|
||||
void setSpacing( int );
|
||||
int spacing() const;
|
||||
|
||||
void setScaleDiv( const QwtScaleDiv &sd );
|
||||
void setScaleDiv( const QwtScaleDiv & );
|
||||
void setTransformation( QwtTransform * );
|
||||
|
||||
void setScaleDraw( QwtScaleDraw * );
|
||||
@@ -119,10 +119,10 @@ protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
void draw( QPainter *p ) const;
|
||||
void draw( QPainter * ) const;
|
||||
|
||||
void scaleChange();
|
||||
void layoutScale( bool update = true );
|
||||
void layoutScale( bool update_geometry = true );
|
||||
|
||||
private:
|
||||
void initScale( QwtScaleDraw::Alignment );
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
//! Destructor
|
||||
virtual ~QwtSeriesData();
|
||||
|
||||
#ifndef QWT_PYTHON_WRAPPER
|
||||
|
||||
//! \return Number of samples
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
@@ -77,6 +79,13 @@ public:
|
||||
*/
|
||||
virtual QRectF boundingRect() const = 0;
|
||||
|
||||
#else
|
||||
// Needed for generating the python bindings, but not for using them !
|
||||
virtual size_t size() const { return 0; }
|
||||
virtual T sample( size_t i ) const { return T(); }
|
||||
virtual QRectF boundingRect() const { return d_boundingRect; }
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Set a the "rect of interest"
|
||||
|
||||
@@ -274,8 +283,7 @@ QWT_EXPORT QRectF qwtBoundingRect(
|
||||
\par Example
|
||||
The following example shows finds a point of curve from an x
|
||||
coordinate
|
||||
|
||||
\verbatim
|
||||
\code
|
||||
#include <qwt_series_data.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
|
||||
@@ -309,8 +317,8 @@ QLineF curveLineAt( const QwtPlotCurve *curve, double x )
|
||||
return line;
|
||||
}
|
||||
|
||||
\endverbatim
|
||||
|
||||
\endcode
|
||||
\endpar
|
||||
|
||||
\param series Series of samples
|
||||
\param value Value
|
||||
@@ -318,8 +326,6 @@ QLineF curveLineAt( const QwtPlotCurve *curve, double x )
|
||||
|
||||
\note The samples must be sorted according to the order specified
|
||||
by the lessThan object
|
||||
|
||||
of the range [begin, end) and returns the position of the one-past-the-last occurrence of value. If no such item is found, returns the position where the item should be inserted.
|
||||
*/
|
||||
template <typename T, typename LessThan>
|
||||
inline int qwtUpperSampleIndex( const QwtSeriesData<T> &series,
|
||||
|
||||
@@ -27,6 +27,7 @@ protected:
|
||||
//! Destructor
|
||||
virtual ~QwtAbstractSeriesStore() {}
|
||||
|
||||
#ifndef QWT_PYTHON_WRAPPER
|
||||
//! dataChanged() indicates, that the series has been changed.
|
||||
virtual void dataChanged() = 0;
|
||||
|
||||
@@ -41,6 +42,13 @@ protected:
|
||||
|
||||
//! \return Number of samples
|
||||
virtual size_t dataSize() const = 0;
|
||||
#else
|
||||
// Needed for generating the python bindings, but not for using them !
|
||||
virtual void dataChanged() {}
|
||||
virtual void setRectOfInterest( const QRectF & ) {}
|
||||
virtual QRectF dataRect() const { return QRectF( 0.0, 0.0, -1.0, -1.0 ); }
|
||||
virtual size_t dataSize() const { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void setHandleSize( const QSize & );
|
||||
QSize handleSize() const;
|
||||
|
||||
void setBorderWidth( int bw );
|
||||
void setBorderWidth( int );
|
||||
int borderWidth() const;
|
||||
|
||||
void setSpacing( int );
|
||||
|
||||
@@ -926,9 +926,10 @@ QwtSymbol::CachePolicy QwtSymbol::cachePolicy() const
|
||||
to fit into the size. Otherwise the symbol size depends on
|
||||
the bounding rectangle of the path.
|
||||
|
||||
\par Example
|
||||
The following code defines a symbol drawing an arrow:
|
||||
|
||||
\verbatim
|
||||
\code
|
||||
#include <qwt_symbol.h>
|
||||
|
||||
QwtSymbol *symbol = new QwtSymbol();
|
||||
@@ -955,7 +956,8 @@ symbol->setPath( path );
|
||||
symbol->setPinPoint( QPointF( 0.0, 0.0 ) );
|
||||
|
||||
setSize( 10, 14 );
|
||||
\endverbatim
|
||||
\endcode
|
||||
\endpar
|
||||
|
||||
\param path Painter path
|
||||
|
||||
@@ -1357,8 +1359,6 @@ void QwtSymbol::drawSymbols( QPainter *painter,
|
||||
{
|
||||
const QRect br = boundingRect();
|
||||
|
||||
const QRect rect( 0, 0, br.width(), br.height() );
|
||||
|
||||
if ( d_data->cache.pixmap.isNull() )
|
||||
{
|
||||
d_data->cache.pixmap = QwtPainter::backingStore( NULL, br.size() );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpolygon.h>
|
||||
#include "qpainterpath.h"
|
||||
|
||||
class QPainter;
|
||||
class QRect;
|
||||
@@ -22,6 +21,7 @@ class QPen;
|
||||
class QColor;
|
||||
class QPointF;
|
||||
class QPolygonF;
|
||||
class QPainterPath;
|
||||
class QPixmap;
|
||||
class QByteArray;
|
||||
class QwtGraphic;
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
|
||||
virtual void setColor( const QColor & );
|
||||
|
||||
void setBrush( const QBrush& b );
|
||||
void setBrush( const QBrush & );
|
||||
const QBrush &brush() const;
|
||||
|
||||
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
|
||||
Precision and time intervals are multiples of milliseconds (ms).
|
||||
|
||||
( QwtSystemClock is obsolete since Qt 4.8 as QElapsedTimer offers the same
|
||||
precision )
|
||||
|
||||
\note The implementation uses high-resolution performance counter on Windows,
|
||||
mach_absolute_time() on the Mac or POSIX timers on other systems.
|
||||
If none is available it falls back on QTimer.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user