改进代码

This commit is contained in:
feiyangqingyun
2021-10-08 10:52:05 +08:00
parent f6923b97a2
commit 200b7eeafb
171 changed files with 2894 additions and 1940 deletions

View File

@@ -21,7 +21,7 @@ class QVariant;
\brief Abstract base class for legend widgets \brief Abstract base class for legend widgets
Legends, that need to be under control of the QwtPlot layout system Legends, that need to be under control of the QwtPlot layout system
need to be derived from QwtAbstractLegend. need to be derived from QwtAbstractLegend.
\note Other type of legends can be implemented by connecting to \note Other type of legends can be implemented by connecting to
the QwtPlot::legendDataChanged() signal. But as these legends the QwtPlot::legendDataChanged() signal. But as these legends
@@ -44,11 +44,11 @@ public:
\param painter Painter \param painter Painter
\param rect Bounding rectangle \param rect Bounding rectangle
\param fillBackground When true, fill rect with the widget background \param fillBackground When true, fill rect with the widget background
\sa renderLegend() is used by QwtPlotRenderer \sa renderLegend() is used by QwtPlotRenderer
*/ */
virtual void renderLegend( QPainter *painter, virtual void renderLegend( QPainter *painter,
const QRectF &rect, bool fillBackground ) const = 0; const QRectF &rect, bool fillBackground ) const = 0;
//! \return True, when no plot item is inserted //! \return True, when no plot item is inserted
@@ -64,8 +64,8 @@ public Q_SLOTS:
\param itemInfo Info about an item \param itemInfo Info about an item
\param data List of legend entry attributes for the item \param data List of legend entry attributes for the item
*/ */
virtual void updateLegend( const QVariant &itemInfo, virtual void updateLegend( const QVariant &itemInfo,
const QList<QwtLegendData> &data ) = 0; const QList<QwtLegendData> &data ) = 0;
}; };
#endif #endif

View File

@@ -71,7 +71,7 @@ QwtAbstractScale::~QwtAbstractScale()
\param value Lower bound \param value Lower bound
\sa lowerBound(), setScale(), setUpperBound() \sa lowerBound(), setScale(), setUpperBound()
\note For inverted scales the lower bound \note For inverted scales the lower bound
is greater than the upper bound is greater than the upper bound
*/ */
void QwtAbstractScale::setLowerBound( double value ) void QwtAbstractScale::setLowerBound( double value )
@@ -94,7 +94,7 @@ double QwtAbstractScale::lowerBound() const
\param value Upper bound \param value Upper bound
\sa upperBound(), setScale(), setLowerBound() \sa upperBound(), setScale(), setLowerBound()
\note For inverted scales the lower bound \note For inverted scales the lower bound
is greater than the upper bound is greater than the upper bound
*/ */
void QwtAbstractScale::setUpperBound( double value ) void QwtAbstractScale::setUpperBound( double value )
@@ -114,15 +114,15 @@ double QwtAbstractScale::upperBound() const
/*! /*!
\brief Specify a scale. \brief Specify a scale.
Define a scale by an interval Define a scale by an interval
The ticks are calculated using scaleMaxMinor(), The ticks are calculated using scaleMaxMinor(),
scaleMaxMajor() and scaleStepSize(). scaleMaxMajor() and scaleStepSize().
\param lowerBound lower limit of the scale interval \param lowerBound lower limit of the scale interval
\param upperBound upper limit of the scale interval \param upperBound upper limit of the scale interval
\note For inverted scales the lower bound \note For inverted scales the lower bound
is greater than the upper bound is greater than the upper bound
*/ */
void QwtAbstractScale::setScale( double lowerBound, double upperBound ) void QwtAbstractScale::setScale( double lowerBound, double upperBound )
@@ -135,7 +135,7 @@ void QwtAbstractScale::setScale( double lowerBound, double upperBound )
Define a scale by an interval Define a scale by an interval
The ticks are calculated using scaleMaxMinor(), The ticks are calculated using scaleMaxMinor(),
scaleMaxMajor() and scaleStepSize(). scaleMaxMajor() and scaleStepSize().
\param interval Interval \param interval Interval
@@ -342,7 +342,7 @@ QwtScaleEngine *QwtAbstractScale::scaleEngine()
\return Scale boundaries and positions of the ticks \return Scale boundaries and positions of the ticks
The scale division might have been assigned explicitly The scale division might have been assigned explicitly
or calculated implicitly by rescale(). or calculated implicitly by rescale().
*/ */
const QwtScaleDiv &QwtAbstractScale::scaleDiv() const const QwtScaleDiv &QwtAbstractScale::scaleDiv() const
{ {
@@ -360,7 +360,7 @@ const QwtScaleMap &QwtAbstractScale::scaleMap() const
/*! /*!
Translate a scale value into a widget coordinate Translate a scale value into a widget coordinate
\param value Scale value \param value Scale value
\return Corresponding widget coordinate for value \return Corresponding widget coordinate for value
\sa scaleMap(), invTransform() \sa scaleMap(), invTransform()
*/ */
@@ -424,7 +424,7 @@ void QwtAbstractScale::scaleChange()
\sa scaleChange() \sa scaleChange()
*/ */
void QwtAbstractScale::rescale( void QwtAbstractScale::rescale(
double lowerBound, double upperBound, double stepSize ) double lowerBound, double upperBound, double stepSize )
{ {
const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale( const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale(

View File

@@ -27,9 +27,9 @@ class QwtInterval;
The scale is painted using a QwtScaleDraw object. The scale is painted using a QwtScaleDraw object.
The scale division might be assigned explicitly - but usually The scale division might be assigned explicitly - but usually
it is calculated from the boundaries using a QwtScaleEngine. it is calculated from the boundaries using a QwtScaleEngine.
The scale engine also decides the type of transformation of the scale The scale engine also decides the type of transformation of the scale
( linear, logarithmic ... ). ( linear, logarithmic ... ).
*/ */
@@ -85,7 +85,7 @@ public:
const QwtScaleMap &scaleMap() const; const QwtScaleMap &scaleMap() const;
protected: protected:
void rescale( double lowerBound, void rescale( double lowerBound,
double upperBound, double stepSize ); double upperBound, double stepSize );
void setAbstractScaleDraw( QwtAbstractScaleDraw * ); void setAbstractScaleDraw( QwtAbstractScaleDraw * );

View File

@@ -25,8 +25,8 @@ public:
penWidth( 0 ), penWidth( 0 ),
minExtent( 0.0 ) minExtent( 0.0 )
{ {
components = QwtAbstractScaleDraw::Backbone components = QwtAbstractScaleDraw::Backbone
| QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Ticks
| QwtAbstractScaleDraw::Labels; | QwtAbstractScaleDraw::Labels;
tickLength[QwtScaleDiv::MinorTick] = 4.0; tickLength[QwtScaleDiv::MinorTick] = 4.0;
@@ -197,7 +197,7 @@ void QwtAbstractScaleDraw::draw( QPainter *painter,
{ {
painter->save(); painter->save();
QPen pen = painter->pen(); pen = painter->pen();
pen.setColor( palette.color( QPalette::WindowText ) ); pen.setColor( palette.color( QPalette::WindowText ) );
pen.setCapStyle( Qt::FlatCap ); pen.setCapStyle( Qt::FlatCap );
@@ -226,7 +226,7 @@ void QwtAbstractScaleDraw::draw( QPainter *painter,
{ {
painter->save(); painter->save();
QPen pen = painter->pen(); pen = painter->pen();
pen.setColor( palette.color( QPalette::WindowText ) ); pen.setColor( palette.color( QPalette::WindowText ) );
pen.setCapStyle( Qt::FlatCap ); pen.setCapStyle( Qt::FlatCap );
@@ -392,19 +392,18 @@ QwtText QwtAbstractScaleDraw::label( double value ) const
const QwtText &QwtAbstractScaleDraw::tickLabel( const QwtText &QwtAbstractScaleDraw::tickLabel(
const QFont &font, double value ) const const QFont &font, double value ) const
{ {
QMap<double, QwtText>::const_iterator it = d_data->labelCache.find( value ); QMap<double, QwtText>::const_iterator it1 = d_data->labelCache.constFind( value );
if ( it == d_data->labelCache.end() ) 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 QwtText lbl = label( value );
lbl.setRenderFlags( 0 );
lbl.setLayoutAttribute( QwtText::MinimumLayout );
it = d_data->labelCache.insert( value, lbl ); ( void )lbl.textSize( font ); // initialize the internal cache
}
return ( *it ); QMap<double, QwtText>::iterator it2 = d_data->labelCache.insert( value, lbl );
return *it2;
} }
/*! /*!

View File

@@ -54,7 +54,7 @@ public:
QwtAbstractScaleDraw(); QwtAbstractScaleDraw();
virtual ~QwtAbstractScaleDraw(); virtual ~QwtAbstractScaleDraw();
void setScaleDiv( const QwtScaleDiv &s ); void setScaleDiv( const QwtScaleDiv & );
const QwtScaleDiv& scaleDiv() const; const QwtScaleDiv& scaleDiv() const;
void setTransformation( QwtTransform * ); void setTransformation( QwtTransform * );
@@ -68,7 +68,7 @@ public:
double tickLength( QwtScaleDiv::TickType ) const; double tickLength( QwtScaleDiv::TickType ) const;
double maxTickLength() const; double maxTickLength() const;
void setSpacing( double margin ); void setSpacing( double );
double spacing() const; double spacing() const;
void setPenWidth( int width ); void setPenWidth( int width );

View File

@@ -17,7 +17,7 @@
#define qFabs(x) ::fabs(x) #define qFabs(x) ::fabs(x)
#endif #endif
static double qwtAlignToScaleDiv( static double qwtAlignToScaleDiv(
const QwtAbstractSlider *slider, double value ) const QwtAbstractSlider *slider, double value )
{ {
const QwtScaleDiv &sd = slider->scaleDiv(); const QwtScaleDiv &sd = slider->scaleDiv();
@@ -27,7 +27,7 @@ static double qwtAlignToScaleDiv(
if ( tValue == slider->transform( sd.lowerBound() ) ) if ( tValue == slider->transform( sd.lowerBound() ) )
return sd.lowerBound(); return sd.lowerBound();
if ( tValue == slider->transform( sd.lowerBound() ) ) if ( tValue == slider->transform( sd.upperBound() ) )
return sd.upperBound(); return sd.upperBound();
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
@@ -106,7 +106,7 @@ QwtAbstractSlider::~QwtAbstractSlider()
delete d_data; delete d_data;
} }
/*! /*!
Set the value to be valid/invalid Set the value to be valid/invalid
\param on When true, the value is invalidated \param on When true, the value is invalidated
@@ -121,14 +121,14 @@ void QwtAbstractSlider::setValid( bool on )
sliderChange(); sliderChange();
Q_EMIT valueChanged( d_data->value ); Q_EMIT valueChanged( d_data->value );
} }
} }
//! \return True, when the value is invalid //! \return True, when the value is invalid
bool QwtAbstractSlider::isValid() const bool QwtAbstractSlider::isValid() const
{ {
return d_data->isValid; return d_data->isValid;
} }
/*! /*!
En/Disable read only mode En/Disable read only mode
@@ -167,9 +167,9 @@ bool QwtAbstractSlider::isReadOnly() const
/*! /*!
\brief Enables or disables tracking. \brief Enables or disables tracking.
If tracking is enabled, the slider emits the valueChanged() If tracking is enabled, the slider emits the valueChanged()
signal while the movable part of the slider is being dragged. signal while the movable part of the slider is being dragged.
If tracking is disabled, the slider emits the valueChanged() signal If tracking is disabled, the slider emits the valueChanged() signal
only when the user releases the slider. only when the user releases the slider.
Tracking is enabled by default. Tracking is enabled by default.
@@ -287,7 +287,7 @@ void QwtAbstractSlider::mouseReleaseEvent( QMouseEvent *event )
/*! /*!
Wheel Event handler Wheel Event handler
In/decreases the value by s number of steps. The direction In/decreases the value by s number of steps. The direction
depends on the invertedControls() property. depends on the invertedControls() property.
When the control or shift modifier is pressed the wheel delta When the control or shift modifier is pressed the wheel delta
@@ -458,7 +458,7 @@ void QwtAbstractSlider::keyPressEvent( QKeyEvent *event )
\brief Set the number of steps \brief Set the number of steps
The range of the slider is divided into a number of steps from The range of the slider is divided into a number of steps from
which the value increments according to user inputs depend. which the value increments according to user inputs depend.
The default setting is 100. The default setting is 100.
@@ -484,7 +484,7 @@ uint QwtAbstractSlider::totalSteps() const
\brief Set the number of steps for a single increment \brief Set the number of steps for a single increment
The range of the slider is divided into a number of steps from The range of the slider is divided into a number of steps from
which the value increments according to user inputs depend. which the value increments according to user inputs depend.
\param stepCount Number of steps \param stepCount Number of steps
@@ -494,7 +494,7 @@ uint QwtAbstractSlider::totalSteps() const
void QwtAbstractSlider::setSingleSteps( uint stepCount ) void QwtAbstractSlider::setSingleSteps( uint stepCount )
{ {
d_data->singleSteps = stepCount; d_data->singleSteps = stepCount;
} }
/*! /*!
\return Number of steps \return Number of steps
@@ -503,13 +503,13 @@ void QwtAbstractSlider::setSingleSteps( uint stepCount )
uint QwtAbstractSlider::singleSteps() const uint QwtAbstractSlider::singleSteps() const
{ {
return d_data->singleSteps; return d_data->singleSteps;
} }
/*! /*!
\brief Set the number of steps for a page increment \brief Set the number of steps for a page increment
The range of the slider is divided into a number of steps from The range of the slider is divided into a number of steps from
which the value increments according to user inputs depend. which the value increments according to user inputs depend.
\param stepCount Number of steps \param stepCount Number of steps
@@ -540,13 +540,13 @@ uint QwtAbstractSlider::pageSteps() const
\sa stepAlignment() \sa stepAlignment()
*/ */
void QwtAbstractSlider::setStepAlignment( bool on ) void QwtAbstractSlider::setStepAlignment( bool on )
{ {
if ( on != d_data->stepAlignment ) if ( on != d_data->stepAlignment )
{ {
d_data->stepAlignment = on; d_data->stepAlignment = on;
} }
} }
/*! /*!
\return True, when step alignment is enabled \return True, when step alignment is enabled
\sa setStepAlignment() \sa setStepAlignment()
@@ -585,8 +585,8 @@ double QwtAbstractSlider::value() const
} }
/*! /*!
If wrapping is true stepping up from upperBound() value will If wrapping is true stepping up from upperBound() value will
take you to the minimum() value and vice versa. take you to the minimum() value and vice versa.
\param on En/Disable wrapping \param on En/Disable wrapping
\sa wrapping() \sa wrapping()
@@ -594,12 +594,12 @@ double QwtAbstractSlider::value() const
void QwtAbstractSlider::setWrapping( bool on ) void QwtAbstractSlider::setWrapping( bool on )
{ {
d_data->wrapping = on; d_data->wrapping = on;
} }
/*! /*!
\return True, when wrapping is set \return True, when wrapping is set
\sa setWrapping() \sa setWrapping()
*/ */
bool QwtAbstractSlider::wrapping() const bool QwtAbstractSlider::wrapping() const
{ {
return d_data->wrapping; return d_data->wrapping;
@@ -608,8 +608,8 @@ bool QwtAbstractSlider::wrapping() const
/*! /*!
Invert wheel and key events Invert wheel and key events
Usually scrolling the mouse wheel "up" and using keys like page Usually scrolling the mouse wheel "up" and using keys like page
up will increase the slider's value towards its maximum. up will increase the slider's value towards its maximum.
When invertedControls() is enabled the value is scrolled When invertedControls() is enabled the value is scrolled
towards its minimum. towards its minimum.
@@ -644,7 +644,7 @@ bool QwtAbstractSlider::invertedControls() const
*/ */
void QwtAbstractSlider::incrementValue( int stepCount ) void QwtAbstractSlider::incrementValue( int stepCount )
{ {
const double value = incrementedValue( const double value = incrementedValue(
d_data->value, stepCount ); d_data->value, stepCount );
if ( value != d_data->value ) if ( value != d_data->value )
@@ -655,14 +655,14 @@ void QwtAbstractSlider::incrementValue( int stepCount )
} }
/*! /*!
Increment a value Increment a value
\param value Value \param value Value
\param stepCount Number of steps \param stepCount Number of steps
\return Incremented value \return Incremented value
*/ */
double QwtAbstractSlider::incrementedValue( double QwtAbstractSlider::incrementedValue(
double value, int stepCount ) const double value, int stepCount ) const
{ {
if ( d_data->totalSteps == 0 ) if ( d_data->totalSteps == 0 )
@@ -683,14 +683,14 @@ double QwtAbstractSlider::incrementedValue(
// we need equidant steps according to // we need equidant steps according to
// paint device coordinates // paint device coordinates
const double range = transformation->transform( maximum() ) const double range = transformation->transform( maximum() )
- transformation->transform( minimum() ); - transformation->transform( minimum() );
const double stepSize = range / d_data->totalSteps; const double stepSize = range / d_data->totalSteps;
double v = transformation->transform( value ); double v = transformation->transform( value );
v = qRound( v / stepSize ) * stepSize; v = qRound( v / stepSize ) * stepSize;
v += stepCount * range / d_data->totalSteps; v += stepCount * range / d_data->totalSteps;
value = transformation->invTransform( v ); value = transformation->invTransform( v );
@@ -756,7 +756,7 @@ double QwtAbstractSlider::alignedValue( double value ) const
stepSize = ( maximum() - minimum() ) / d_data->totalSteps; stepSize = ( maximum() - minimum() ) / d_data->totalSteps;
if ( stepSize > 0.0 ) if ( stepSize > 0.0 )
{ {
value = lowerBound() + value = lowerBound() +
qRound( ( value - lowerBound() ) / stepSize ) * stepSize; qRound( ( value - lowerBound() ) / stepSize ) * stepSize;
} }
} }

View File

@@ -17,14 +17,14 @@
\brief An abstract base class for slider widgets with a scale \brief An abstract base class for slider widgets with a scale
A slider widget displays a value according to a scale. A slider widget displays a value according to a scale.
The class is designed as a common super class for widgets like The class is designed as a common super class for widgets like
QwtKnob, QwtDial and QwtSlider. QwtKnob, QwtDial and QwtSlider.
When the slider is nor readOnly() its value can be modified When the slider is nor readOnly() its value can be modified
by keyboard, mouse and wheel inputs. by keyboard, mouse and wheel inputs.
The range of the slider is divided into a number of steps from The range of the slider is divided into a number of steps from
which the value increments according to user inputs depend. which the value increments according to user inputs depend.
Only for linear scales the number of steps correspond with Only for linear scales the number of steps correspond with
a fixed step size. a fixed step size.
*/ */
@@ -67,7 +67,7 @@ public:
void setPageSteps( uint ); void setPageSteps( uint );
uint pageSteps() const; uint pageSteps() const;
void setStepAlignment( bool ); void setStepAlignment( bool );
bool stepAlignment() const; bool stepAlignment() const;
void setTracking( bool ); void setTracking( bool );
@@ -80,15 +80,15 @@ public:
bool invertedControls() const; bool invertedControls() const;
public Q_SLOTS: public Q_SLOTS:
void setValue( double val ); void setValue( double value );
Q_SIGNALS: Q_SIGNALS:
/*! /*!
\brief Notify a change of value. \brief Notify a change of value.
When tracking is enabled (default setting), When tracking is enabled (default setting),
this signal will be emitted every time the value changes. this signal will be emitted every time the value changes.
\param value New value \param value New value
@@ -146,14 +146,14 @@ protected:
*/ */
virtual double scrolledTo( const QPoint &pos ) const = 0; virtual double scrolledTo( const QPoint &pos ) const = 0;
void incrementValue( int numSteps ); void incrementValue( int stepCount );
virtual void scaleChange(); virtual void scaleChange();
protected: protected:
virtual void sliderChange(); virtual void sliderChange();
double incrementedValue( double incrementedValue(
double value, int stepCount ) const; double value, int stepCount ) const;
private: private:

View File

@@ -52,7 +52,7 @@ QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
setTotalSteps( 60 ); setTotalSteps( 60 );
const int secondsPerHour = 60.0 * 60.0; const int secondsPerHour = 60.0 * 60.0;
QList<double> majorTicks; QList<double> majorTicks;
QList<double> minorTicks; QList<double> minorTicks;
@@ -200,7 +200,7 @@ void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF &center,
if ( isValid() ) if ( isValid() )
{ {
const double hours = value() / ( 60.0 * 60.0 ); const double hours = value() / ( 60.0 * 60.0 );
const double minutes = const double minutes =
( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0; ( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0;
const double seconds = value() - qFloor(hours) * 60.0 * 60.0 const double seconds = value() - qFloor(hours) * 60.0 * 60.0
- qFloor(minutes) * 60.0; - qFloor(minutes) * 60.0;
@@ -213,7 +213,7 @@ void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF &center,
for ( int hand = 0; hand < NHands; hand++ ) for ( int hand = 0; hand < NHands; hand++ )
{ {
const double d = 360.0 - angle[hand] - origin(); const double d = 360.0 - angle[hand] - origin();
drawHand( painter, static_cast<Hand>( hand ), drawHand( painter, static_cast<Hand>( hand ),
center, radius, d, colorGroup ); center, radius, d, colorGroup );
} }
} }

View File

@@ -21,7 +21,7 @@
\image html analogclock.png \image html analogclock.png
\par Example \par Example
\code \code
#include <qwt_analog_clock.h> #include <qwt_analog_clock.h>
QwtAnalogClock *clock = new QwtAnalogClock(...); QwtAnalogClock *clock = new QwtAnalogClock(...);

View File

@@ -35,7 +35,7 @@ public:
protected: protected:
virtual void paintEvent( QPaintEvent *event ); virtual void paintEvent( QPaintEvent *event );
virtual void drawButtonLabel( QPainter *p ); virtual void drawButtonLabel( QPainter * );
virtual void drawArrow( QPainter *, virtual void drawArrow( QPainter *,
const QRect &, Qt::ArrowType ) const; const QRect &, Qt::ArrowType ) const;
virtual QRect labelRect() const; virtual QRect labelRect() const;

View File

@@ -150,29 +150,29 @@ public:
::memcpy( m_buffer, points, m_size * sizeof( Point ) ); ::memcpy( m_buffer, points, m_size * sizeof( Point ) );
} }
inline void reset() inline void reset()
{ {
m_size = 0; m_size = 0;
} }
inline int size() const inline int size() const
{ {
return m_size; return m_size;
} }
inline Point *data() const inline Point *data() const
{ {
return m_buffer; return m_buffer;
} }
inline Point &operator[]( int i ) inline Point &operator[]( int i )
{ {
return m_buffer[i]; return m_buffer[i];
} }
inline const Point &operator[]( int i ) const inline const Point &operator[]( int i ) const
{ {
return m_buffer[i]; return m_buffer[i];
} }
inline void add( const Point &point ) inline void add( const Point &point )
@@ -192,7 +192,7 @@ private:
while ( m_capacity < size ) while ( m_capacity < size )
m_capacity *= 2; m_capacity *= 2;
m_buffer = static_cast<Point *>( m_buffer = static_cast<Point *>(
::realloc( m_buffer, m_capacity * sizeof( Point ) ) ); ::realloc( m_buffer, m_capacity * sizeof( Point ) ) );
} }

View File

@@ -25,12 +25,12 @@ class QRectF;
class QWT_EXPORT QwtClipper class QWT_EXPORT QwtClipper
{ {
public: public:
static QPolygon clipPolygon( const QRect &, static QPolygon clipPolygon( const QRect &,
const QPolygon &, bool closePolygon = false ); const QPolygon &, bool closePolygon = false );
static QPolygon clipPolygon( const QRectF &, static QPolygon clipPolygon( const QRectF &,
const QPolygon &, bool closePolygon = false ); const QPolygon &, bool closePolygon = false );
static QPolygonF clipPolygonF( const QRectF &, static QPolygonF clipPolygonF( const QRectF &,
const QPolygonF &, bool closePolygon = false ); const QPolygonF &, bool closePolygon = false );
static QVector<QwtInterval> clipCircle( static QVector<QwtInterval> clipCircle(

View File

@@ -46,8 +46,8 @@ private:
b = qBlue( rgb ); b = qBlue( rgb );
a = qAlpha( rgb ); a = qAlpha( rgb );
/* /*
when mapping a value to rgb we will have to calcualate: when mapping a value to rgb we will have to calcualate:
- const int v = int( ( s1.v0 + ratio * s1.vStep ) + 0.5 ); - const int v = int( ( s1.v0 + ratio * s1.vStep ) + 0.5 );
Thus adding 0.5 ( for rounding ) can be done in advance Thus adding 0.5 ( for rounding ) can be done in advance

View File

@@ -106,7 +106,7 @@ public:
}; };
QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB ); QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
QwtLinearColorMap( const QColor &from, const QColor &to, QwtLinearColorMap( const QColor &color1, const QColor &color2,
QwtColorMap::Format = QwtColorMap::RGB ); QwtColorMap::Format = QwtColorMap::RGB );
virtual ~QwtLinearColorMap(); virtual ~QwtLinearColorMap();
@@ -184,7 +184,9 @@ inline QColor QwtColorMap::color(
else else
{ {
const unsigned int index = colorIndex( interval, value ); const unsigned int index = colorIndex( interval, value );
return colorTable( interval )[index]; // slow
const QVector<QRgb> rgbTable = colorTable( interval );
return rgbTable[index]; // slow
} }
} }

View File

@@ -114,9 +114,9 @@ public:
PrivateData(): PrivateData():
style( QwtColumnSymbol::Box ), style( QwtColumnSymbol::Box ),
frameStyle( QwtColumnSymbol::Raised ), frameStyle( QwtColumnSymbol::Raised ),
palette( Qt::gray ),
lineWidth( 2 ) lineWidth( 2 )
{ {
palette = QPalette( Qt::gray );
} }
QwtColumnSymbol::Style style; QwtColumnSymbol::Style style;
@@ -287,7 +287,7 @@ void QwtColumnSymbol::drawBox( QPainter *painter,
} }
default: default:
{ {
painter->fillRect( r, d_data->palette.window() ); painter->fillRect( r.adjusted( 0, 0, 1, 1 ), d_data->palette.window() );
} }
} }
} }

View File

@@ -136,7 +136,7 @@ public:
QwtColumnSymbol( Style = NoStyle ); QwtColumnSymbol( Style = NoStyle );
virtual ~QwtColumnSymbol(); virtual ~QwtColumnSymbol();
void setFrameStyle( FrameStyle style ); void setFrameStyle( FrameStyle );
FrameStyle frameStyle() const; FrameStyle frameStyle() const;
void setLineWidth( int width ); void setLineWidth( int width );

View File

@@ -17,7 +17,7 @@
#include <qpixmap.h> #include <qpixmap.h>
#include <qevent.h> #include <qevent.h>
/*! /*!
\brief Constructor \brief Constructor
Initializes a label map for multiples of 45 degrees Initializes a label map for multiples of 45 degrees
@@ -48,7 +48,7 @@ QwtCompassScaleDraw::QwtCompassScaleDraw()
#endif #endif
} }
/*! /*!
\brief Constructor \brief Constructor
\param map Value to label map \param map Value to label map
@@ -95,7 +95,7 @@ QMap<double, QString> QwtCompassScaleDraw::labelMap() const
label() looks in the labelMap() for a corresponding label for value label() looks in the labelMap() for a corresponding label for value
or returns an null text. or returns an null text.
\return Label, or QString::null \return Label
\sa labelMap(), setLabelMap() \sa labelMap(), setLabelMap()
*/ */

View File

@@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library * Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen * Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann * Copyright (C) 2002 Uwe Rathmann
@@ -10,10 +10,9 @@
#include "qwt_compass_rose.h" #include "qwt_compass_rose.h"
#include "qwt_point_polar.h" #include "qwt_point_polar.h"
#include "qwt_painter.h" #include "qwt_painter.h"
#include "qpainter.h" #include <qpainter.h>
#include "qpainterpath.h"
static QPointF qwtIntersection( static QPointF qwtIntersection(
QPointF p11, QPointF p12, QPointF p21, QPointF p22 ) QPointF p11, QPointF p12, QPointF p21, QPointF p22 )
{ {
const QLineF line1( p11, p12 ); const QLineF line1( p11, p12 );
@@ -213,7 +212,7 @@ void QwtSimpleCompassRose::setWidth( double width )
d_data->width = 0.4; d_data->width = 0.4;
} }
/*! /*!
\return Width of the rose \return Width of the rose
\sa setWidth() \sa setWidth()
*/ */

View File

@@ -45,7 +45,7 @@ public:
\param north Position \param north Position
\param colorGroup Color group \param colorGroup Color group
*/ */
virtual void draw( QPainter *painter, virtual void draw( QPainter *painter,
const QPointF &center, double radius, double north, const QPointF &center, double radius, double north,
QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0; QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0;
@@ -62,13 +62,13 @@ public:
QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 ); QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 );
virtual ~QwtSimpleCompassRose(); virtual ~QwtSimpleCompassRose();
void setWidth( double w ); void setWidth( double );
double width() const; double width() const;
void setNumThorns( int count ); void setNumThorns( int );
int numThorns() const; int numThorns() const;
void setNumThornLevels( int count ); void setNumThornLevels( int );
int numThornLevels() const; int numThornLevels() const;
void setShrinkFactor( double factor ); void setShrinkFactor( double factor );
@@ -78,7 +78,7 @@ public:
double north, QPalette::ColorGroup = QPalette::Active ) const; double north, QPalette::ColorGroup = QPalette::Active ) const;
static void drawRose( QPainter *, const QPalette &, static void drawRose( QPainter *, const QPalette &,
const QPointF &center, double radius, double origin, double width, const QPointF &center, double radius, double north, double width,
int numThorns, int numThornLevels, double shrinkFactor ); int numThorns, int numThornLevels, double shrinkFactor );
private: private:
@@ -86,4 +86,4 @@ private:
PrivateData *d_data; PrivateData *d_data;
}; };
#endif #endif

View File

@@ -50,7 +50,7 @@ public:
}; };
/*! /*!
The counter is initialized with a range is set to [0.0, 1.0] with The counter is initialized with a range is set to [0.0, 1.0] with
0.01 as single step size. The value is invalid. 0.01 as single step size. The value is invalid.
The default number of buttons is set to 2. The default increments are: The default number of buttons is set to 2. The default increments are:
@@ -82,8 +82,8 @@ void QwtCounter::initCounter()
btn->installEventFilter( this ); btn->installEventFilter( this );
layout->addWidget( btn ); layout->addWidget( btn );
connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) ); connect( btn, SIGNAL(released()), SLOT(btnReleased()) );
connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) ); connect( btn, SIGNAL(clicked()), SLOT(btnClicked()) );
d_data->buttonDown[i] = btn; d_data->buttonDown[i] = btn;
} }
@@ -93,8 +93,7 @@ void QwtCounter::initCounter()
d_data->valueEdit->setValidator( new QDoubleValidator( d_data->valueEdit ) ); d_data->valueEdit->setValidator( new QDoubleValidator( d_data->valueEdit ) );
layout->addWidget( d_data->valueEdit ); layout->addWidget( d_data->valueEdit );
connect( d_data->valueEdit, SIGNAL( editingFinished() ), connect( d_data->valueEdit, SIGNAL(editingFinished()), SLOT(textChanged()) );
SLOT( textChanged() ) );
layout->setStretchFactor( d_data->valueEdit, 10 ); layout->setStretchFactor( d_data->valueEdit, 10 );
@@ -106,8 +105,8 @@ void QwtCounter::initCounter()
btn->installEventFilter( this ); btn->installEventFilter( this );
layout->addWidget( btn ); layout->addWidget( btn );
connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) ); connect( btn, SIGNAL(released()), SLOT(btnReleased()) );
connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) ); connect( btn, SIGNAL(clicked()), SLOT(btnClicked()) );
d_data->buttonUp[i] = btn; d_data->buttonUp[i] = btn;
} }
@@ -130,13 +129,13 @@ QwtCounter::~QwtCounter()
delete d_data; delete d_data;
} }
/*! /*!
Set the counter to be in valid/invalid state Set the counter to be in valid/invalid state
When the counter is set to invalid, no numbers are displayed and When the counter is set to invalid, no numbers are displayed and
the buttons are disabled. the buttons are disabled.
\param on If true the counter will be set as valid \param on If true the counter will be set as valid
\sa setValue(), isValid() \sa setValue(), isValid()
*/ */
@@ -155,19 +154,19 @@ void QwtCounter::setValid( bool on )
} }
else else
{ {
d_data->valueEdit->setText( QString::null ); d_data->valueEdit->setText( QString() );
} }
} }
} }
/*! /*!
\return True, if the value is valid \return True, if the value is valid
\sa setValid(), setValue() \sa setValid(), setValue()
*/ */
bool QwtCounter::isValid() const bool QwtCounter::isValid() const
{ {
return d_data->isValid; return d_data->isValid;
} }
/*! /*!
\brief Allow/disallow the user to manually edit the value \brief Allow/disallow the user to manually edit the value
@@ -180,7 +179,7 @@ void QwtCounter::setReadOnly( bool on )
d_data->valueEdit->setReadOnly( on ); d_data->valueEdit->setReadOnly( on );
} }
/*! /*!
\return True, when the line line edit is read only. (default is no) \return True, when the line line edit is read only. (default is no)
\sa setReadOnly() \sa setReadOnly()
*/ */
@@ -334,8 +333,8 @@ double QwtCounter::singleStep() const
/*! /*!
\brief En/Disable wrapping \brief En/Disable wrapping
If wrapping is true stepping up from maximum() value will take If wrapping is true stepping up from maximum() value will take
you to the minimum() value and vice versa. you to the minimum() value and vice versa.
\param on En/Disable wrapping \param on En/Disable wrapping
\sa wrapping() \sa wrapping()

View File

@@ -24,9 +24,9 @@
A counter has a range from a minimum value to a maximum value A counter has a range from a minimum value to a maximum value
and a step size. When the wrapping property is set and a step size. When the wrapping property is set
the counter is circular. the counter is circular.
The number of steps by which a button increments or decrements the value The number of steps by which a button increments or decrements the value
can be specified using setIncSteps(). The number of buttons can be can be specified using setIncSteps(). The number of buttons can be
changed with setNumButtons(). changed with setNumButtons().
Example: Example:
@@ -91,24 +91,24 @@ public:
bool isReadOnly() const; bool isReadOnly() const;
void setReadOnly( bool ); void setReadOnly( bool );
void setNumButtons( int n ); void setNumButtons( int );
int numButtons() const; int numButtons() const;
void setIncSteps( QwtCounter::Button btn, int nSteps ); void setIncSteps( QwtCounter::Button, int numSteps );
int incSteps( QwtCounter::Button btn ) const; int incSteps( QwtCounter::Button ) const;
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
double singleStep() const; double singleStep() const;
void setSingleStep( double s ); void setSingleStep( double stepSize );
void setRange( double min, double max ); void setRange( double min, double max );
double minimum() const; double minimum() const;
void setMinimum( double min ); void setMinimum( double );
double maximum() const; double maximum() const;
void setMaximum( double max ); void setMaximum( double );
void setStepButton1( int nSteps ); void setStepButton1( int nSteps );
int stepButton1() const; int stepButton1() const;

View File

@@ -333,8 +333,7 @@ void QwtWeedingCurveFitter::setChunkSize( uint numPoints )
} }
/*! /*!
\return Maximum for the number of points passed to a run
\return Maximum for the number of points passed to a run
of the algorithm - or 0, when unlimited of the algorithm - or 0, when unlimited
\sa setChunkSize() \sa setChunkSize()
*/ */
@@ -349,8 +348,10 @@ uint QwtWeedingCurveFitter::chunkSize() const
*/ */
QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const
{ {
QPolygonF fittedPoints; if ( points.isEmpty() )
return points;
QPolygonF fittedPoints;
if ( d_data->chunkSize == 0 ) if ( d_data->chunkSize == 0 )
{ {
fittedPoints = simplify( points ); fittedPoints = simplify( points );

View File

@@ -77,7 +77,7 @@ public:
const QwtSpline &spline() const; const QwtSpline &spline() const;
QwtSpline &spline(); QwtSpline &spline();
void setSplineSize( int size ); void setSplineSize( int );
int splineSize() const; int splineSize() const;
virtual QPolygonF fitCurve( const QPolygonF & ) const; virtual QPolygonF fitCurve( const QPolygonF & ) const;

View File

@@ -31,7 +31,7 @@ static const QwtJulianDay maxJulianDayD = std::numeric_limits<int>::max();
#endif #endif
static QString qwtExpandedFormat( const QString & format, static QString qwtExpandedFormat( const QString & format,
const QDateTime &dateTime, QwtDate::Week0Type week0Type ) const QDateTime &dateTime, QwtDate::Week0Type week0Type )
{ {
const int week = QwtDate::weekNumber( dateTime.date(), week0Type ); const int week = QwtDate::weekNumber( dateTime.date(), week0Type );
@@ -194,7 +194,7 @@ static inline Qt::DayOfWeek qwtFirstDayOfWeek()
#endif #endif
} }
static inline void qwtFloorTime( static inline void qwtFloorTime(
QwtDate::IntervalType intervalType, QDateTime &dt ) QwtDate::IntervalType intervalType, QDateTime &dt )
{ {
// when dt is inside the special hour where DST is ending // when dt is inside the special hour where DST is ending
@@ -223,7 +223,7 @@ static inline void qwtFloorTime(
{ {
dt.setTime( QTime( t.hour(), 0, 0 ) ); dt.setTime( QTime( t.hour(), 0, 0 ) );
break; break;
} }
default: default:
break; break;
} }
@@ -232,7 +232,7 @@ static inline void qwtFloorTime(
dt = dt.toTimeSpec( Qt::LocalTime ); dt = dt.toTimeSpec( Qt::LocalTime );
} }
static inline QDateTime qwtToTimeSpec( static inline QDateTime qwtToTimeSpec(
const QDateTime &dt, Qt::TimeSpec spec ) const QDateTime &dt, Qt::TimeSpec spec )
{ {
if ( dt.timeSpec() == spec ) if ( dt.timeSpec() == spec )
@@ -254,6 +254,8 @@ static inline QDateTime qwtToTimeSpec(
return dt.toTimeSpec( spec ); return dt.toTimeSpec( spec );
} }
#if 0
static inline double qwtToJulianDay( int year, int month, int day ) static inline double qwtToJulianDay( int year, int month, int day )
{ {
// code from QDate but using doubles to avoid overflows // code from QDate but using doubles to avoid overflows
@@ -279,9 +281,11 @@ static inline qint64 qwtFloorDiv( int a, int b )
{ {
if ( a < 0 ) if ( a < 0 )
a -= b - 1; a -= b - 1;
return a / b; return a / b;
} }
#endif
static inline QDate qwtToDate( int year, int month = 1, int day = 1 ) static inline QDate qwtToDate( int year, int month = 1, int day = 1 )
{ {
@@ -318,7 +322,7 @@ static inline QDate qwtToDate( int year, int month = 1, int day = 1 )
/*! /*!
Translate from double to QDateTime Translate from double to QDateTime
\param value Number of milliseconds since the epoch, \param value Number of milliseconds since the epoch,
1970-01-01T00:00:00 UTC 1970-01-01T00:00:00 UTC
\param timeSpec Time specification \param timeSpec Time specification
\return Datetime value \return Datetime value
@@ -372,7 +376,7 @@ double QwtDate::toDouble( const QDateTime &dateTime )
const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch; const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch;
const QTime time = dt.time(); const QTime time = dt.time();
const double secs = 3600.0 * time.hour() + const double secs = 3600.0 * time.hour() +
60.0 * time.minute() + time.second(); 60.0 * time.minute() + time.second();
return days * msecsPerDay + time.msec() + 1000.0 * secs; return days * msecsPerDay + time.msec() + 1000.0 * secs;
@@ -382,7 +386,7 @@ double QwtDate::toDouble( const QDateTime &dateTime )
Ceil a datetime according the interval type Ceil a datetime according the interval type
\param dateTime Datetime value \param dateTime Datetime value
\param intervalType Interval type, how to ceil. \param intervalType Interval type, how to ceil.
F.e. when intervalType = QwtDate::Months, the result F.e. when intervalType = QwtDate::Months, the result
will be ceiled to the next beginning of a month will be ceiled to the next beginning of a month
\return Ceiled datetime \return Ceiled datetime
@@ -450,7 +454,7 @@ QDateTime QwtDate::ceil( const QDateTime &dateTime, IntervalType intervalType )
case QwtDate::Month: case QwtDate::Month:
{ {
dt.setTime( QTime( 0, 0 ) ); dt.setTime( QTime( 0, 0 ) );
dt.setDate( qwtToDate( dateTime.date().year(), dt.setDate( qwtToDate( dateTime.date().year(),
dateTime.date().month() ) ); dateTime.date().month() ) );
if ( dt < dateTime ) if ( dt < dateTime )
@@ -483,14 +487,14 @@ QDateTime QwtDate::ceil( const QDateTime &dateTime, IntervalType intervalType )
Floor a datetime according the interval type Floor a datetime according the interval type
\param dateTime Datetime value \param dateTime Datetime value
\param intervalType Interval type, how to ceil. \param intervalType Interval type, how to ceil.
F.e. when intervalType = QwtDate::Months, F.e. when intervalType = QwtDate::Months,
the result will be ceiled to the next the result will be ceiled to the next
beginning of a month beginning of a month
\return Floored datetime \return Floored datetime
\sa floor() \sa floor()
*/ */
QDateTime QwtDate::floor( const QDateTime &dateTime, QDateTime QwtDate::floor( const QDateTime &dateTime,
IntervalType intervalType ) IntervalType intervalType )
{ {
if ( dateTime.date() <= QwtDate::minDate() ) if ( dateTime.date() <= QwtDate::minDate() )
@@ -532,7 +536,7 @@ QDateTime QwtDate::floor( const QDateTime &dateTime,
{ {
dt.setTime( QTime( 0, 0 ) ); dt.setTime( QTime( 0, 0 ) );
const QDate date = qwtToDate( dt.date().year(), const QDate date = qwtToDate( dt.date().year(),
dt.date().month() ); dt.date().month() );
dt.setDate( date ); dt.setDate( date );
@@ -555,7 +559,7 @@ QDateTime QwtDate::floor( const QDateTime &dateTime,
/*! /*!
Minimum for the supported date range Minimum for the supported date range
The range of valid dates depends on how QDate stores the The range of valid dates depends on how QDate stores the
Julian day internally. Julian day internally.
- For Qt4 it is "Tue Jan 2 -4713" - For Qt4 it is "Tue Jan 2 -4713"
@@ -576,7 +580,7 @@ QDate QwtDate::minDate()
/*! /*!
Maximum for the supported date range Maximum for the supported date range
The range of valid dates depends on how QDate stores the The range of valid dates depends on how QDate stores the
Julian day internally. Julian day internally.
- For Qt4 it is "Tue Jun 3 5874898" - For Qt4 it is "Tue Jun 3 5874898"
@@ -599,14 +603,14 @@ QDate QwtDate::maxDate()
\brief Date of the first day of the first week for a year \brief Date of the first day of the first week for a year
The first day of a week depends on the current locale The first day of a week depends on the current locale
( QLocale::firstDayOfWeek() ). ( QLocale::firstDayOfWeek() ).
\param year Year \param year Year
\param type Option how to identify the first week \param type Option how to identify the first week
\return First day of week 0 \return First day of week 0
\sa QLocale::firstDayOfWeek(), weekNumber() \sa QLocale::firstDayOfWeek(), weekNumber()
*/ */
QDate QwtDate::dateOfWeek0( int year, Week0Type type ) QDate QwtDate::dateOfWeek0( int year, Week0Type type )
{ {
const Qt::DayOfWeek firstDayOfWeek = qwtFirstDayOfWeek(); const Qt::DayOfWeek firstDayOfWeek = qwtFirstDayOfWeek();
@@ -623,7 +627,7 @@ QDate QwtDate::dateOfWeek0( int year, Week0Type type )
if ( type == QwtDate::FirstThursday ) if ( type == QwtDate::FirstThursday )
{ {
// according to ISO 8601 the first week is defined // according to ISO 8601 the first week is defined
// by the first thursday. // by the first thursday.
int d = Qt::Thursday - firstDayOfWeek; int d = Qt::Thursday - firstDayOfWeek;
if ( d < 0 ) if ( d < 0 )
@@ -640,7 +644,7 @@ QDate QwtDate::dateOfWeek0( int year, Week0Type type )
Find the week number of a date Find the week number of a date
- QwtDate::FirstThursday\n - QwtDate::FirstThursday\n
Corresponding to ISO 8601 ( see QDate::weekNumber() ). Corresponding to ISO 8601 ( see QDate::weekNumber() ).
- QwtDate::FirstDay\n - QwtDate::FirstDay\n
Number of weeks that have begun since dateOfWeek0(). Number of weeks that have begun since dateOfWeek0().
@@ -736,7 +740,7 @@ int QwtDate::utcOffset( const QDateTime &dateTime )
- ww\n - ww\n
week number with a leading zero ( 01 - 53 ) week number with a leading zero ( 01 - 53 )
As week 1 usually starts in the previous year a special rule As week 1 usually starts in the previous year a special rule
is applied for formats, where the year is expected to match the is applied for formats, where the year is expected to match the
week number - even if the date belongs to the previous year. week number - even if the date belongs to the previous year.

View File

@@ -22,15 +22,15 @@
A double is interpreted as the number of milliseconds since A double is interpreted as the number of milliseconds since
1970-01-01T00:00:00 Universal Coordinated Time - also known 1970-01-01T00:00:00 Universal Coordinated Time - also known
as "The Epoch". as "The Epoch".
While the range of the Julian day in Qt4 is limited to [0, MAX_INT], While the range of the Julian day in Qt4 is limited to [0, MAX_INT],
Qt5 stores it as qint64 offering a huge range of valid dates. Qt5 stores it as qint64 offering a huge range of valid dates.
As the significance of a double is below this ( assuming a As the significance of a double is below this ( assuming a
fraction of 52 bits ) the translation is not fraction of 52 bits ) the translation is not
bijective with rounding errors for dates very far from Epoch. bijective with rounding errors for dates very far from Epoch.
For a resolution of 1 ms those start to happen for dates above the For a resolution of 1 ms those start to happen for dates above the
year 144683. year 144683.
An axis for a date/time interval is expected to be aligned An axis for a date/time interval is expected to be aligned
and divided in time/date units like seconds, minutes, ... and divided in time/date units like seconds, minutes, ...
@@ -42,9 +42,9 @@
class QWT_EXPORT QwtDate class QWT_EXPORT QwtDate
{ {
public: public:
/*! /*!
How to identify the first week of year differs between How to identify the first week of year differs between
countries. countries.
*/ */
enum Week0Type enum Week0Type
{ {
@@ -59,14 +59,14 @@ public:
/*! /*!
"The week with January 1.1 in it." "The week with January 1.1 in it."
In the U.S. this definition is more common than In the U.S. this definition is more common than
FirstThursday. FirstThursday.
*/ */
FirstDay FirstDay
}; };
/*! /*!
Classification of an time interval Classification of an time interval
Time intervals needs to be classified to decide how to Time intervals needs to be classified to decide how to
@@ -108,7 +108,7 @@ public:
static QDate minDate(); static QDate minDate();
static QDate maxDate(); static QDate maxDate();
static QDateTime toDateTime( double value, static QDateTime toDateTime( double value,
Qt::TimeSpec = Qt::UTC ); Qt::TimeSpec = Qt::UTC );
static double toDouble( const QDateTime & ); static double toDouble( const QDateTime & );
@@ -121,7 +121,7 @@ public:
static int utcOffset( const QDateTime & ); static int utcOffset( const QDateTime & );
static QString toString( const QDateTime &, static QString toString( const QDateTime &,
const QString & format, Week0Type ); const QString & format, Week0Type );
}; };

View File

@@ -36,7 +36,7 @@ public:
/*! /*!
\brief Constructor \brief Constructor
The default setting is to display tick labels for the The default setting is to display tick labels for the
given time specification. The first week of a year is defined like given time specification. The first week of a year is defined like
for QwtDate::FirstThursday. for QwtDate::FirstThursday.
@@ -109,7 +109,7 @@ int QwtDateScaleDraw::utcOffset() const
\sa week0Type(). \sa week0Type().
\note week0Type has no effect beside for intervals classified as \note week0Type has no effect beside for intervals classified as
QwtDate::Week. QwtDate::Week.
*/ */
void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type ) void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type )
{ {
@@ -117,7 +117,7 @@ void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type )
} }
/*! /*!
\return Setting how to identify the first week of a year. \return Setting how to identify the first week of a year.
\sa setWeek0Type() \sa setWeek0Type()
*/ */
QwtDate::Week0Type QwtDateScaleDraw::week0Type() const QwtDate::Week0Type QwtDateScaleDraw::week0Type() const
@@ -133,10 +133,10 @@ QwtDate::Week0Type QwtDateScaleDraw::week0Type() const
\sa dateFormat(), dateFormatOfDate(), QwtDate::toString() \sa dateFormat(), dateFormatOfDate(), QwtDate::toString()
*/ */
void QwtDateScaleDraw::setDateFormat( void QwtDateScaleDraw::setDateFormat(
QwtDate::IntervalType intervalType, const QString &format ) QwtDate::IntervalType intervalType, const QString &format )
{ {
if ( intervalType >= QwtDate::Millisecond && if ( intervalType >= QwtDate::Millisecond &&
intervalType <= QwtDate::Year ) intervalType <= QwtDate::Year )
{ {
d_data->dateFormats[ intervalType ] = format; d_data->dateFormats[ intervalType ] = format;
@@ -148,16 +148,16 @@ void QwtDateScaleDraw::setDateFormat(
\return Default format string for an datetime interval type \return Default format string for an datetime interval type
\sa setDateFormat(), dateFormatOfDate() \sa setDateFormat(), dateFormatOfDate()
*/ */
QString QwtDateScaleDraw::dateFormat( QString QwtDateScaleDraw::dateFormat(
QwtDate::IntervalType intervalType ) const QwtDate::IntervalType intervalType ) const
{ {
if ( intervalType >= QwtDate::Millisecond && if ( intervalType >= QwtDate::Millisecond &&
intervalType <= QwtDate::Year ) intervalType <= QwtDate::Year )
{ {
return d_data->dateFormats[ intervalType ]; return d_data->dateFormats[ intervalType ];
} }
return QString::null; return QString();
} }
/*! /*!
@@ -181,7 +181,7 @@ QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime &dateTime,
{ {
Q_UNUSED( dateTime ) Q_UNUSED( dateTime )
if ( intervalType >= QwtDate::Millisecond && if ( intervalType >= QwtDate::Millisecond &&
intervalType <= QwtDate::Year ) intervalType <= QwtDate::Year )
{ {
return d_data->dateFormats[ intervalType ]; return d_data->dateFormats[ intervalType ];
@@ -204,7 +204,7 @@ QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime &dateTime,
QwtText QwtDateScaleDraw::label( double value ) const QwtText QwtDateScaleDraw::label( double value ) const
{ {
const QDateTime dt = toDateTime( value ); const QDateTime dt = toDateTime( value );
const QString fmt = dateFormatOfDate( const QString fmt = dateFormatOfDate(
dt, intervalType( scaleDiv() ) ); dt, intervalType( scaleDiv() ) );
return QwtDate::toString( dt, fmt, d_data->week0Type ); return QwtDate::toString( dt, fmt, d_data->week0Type );
@@ -219,7 +219,7 @@ QwtText QwtDateScaleDraw::label( double value ) const
\sa dateFormatOfDate() \sa dateFormatOfDate()
*/ */
QwtDate::IntervalType QwtDateScaleDraw::intervalType( QwtDate::IntervalType QwtDateScaleDraw::intervalType(
const QwtScaleDiv &scaleDiv ) const const QwtScaleDiv &scaleDiv ) const
{ {
int intvType = QwtDate::Year; int intvType = QwtDate::Year;
@@ -232,7 +232,7 @@ QwtDate::IntervalType QwtDateScaleDraw::intervalType(
const QDateTime dt = toDateTime( ticks[i] ); const QDateTime dt = toDateTime( ticks[i] );
for ( int j = QwtDate::Second; j <= intvType; j++ ) for ( int j = QwtDate::Second; j <= intvType; j++ )
{ {
const QDateTime dt0 = QwtDate::floor( dt, const QDateTime dt0 = QwtDate::floor( dt,
static_cast<QwtDate::IntervalType>( j ) ); static_cast<QwtDate::IntervalType>( j ) );
if ( dt0 != dt ) if ( dt0 != dt )

View File

@@ -72,7 +72,7 @@ public:
QDateTime toDateTime( double ) const; QDateTime toDateTime( double ) const;
protected: protected:
virtual QwtDate::IntervalType virtual QwtDate::IntervalType
intervalType( const QwtScaleDiv & ) const; intervalType( const QwtScaleDiv & ) const;
virtual QString dateFormatOfDate( const QDateTime &, virtual QString dateFormatOfDate( const QDateTime &,

View File

@@ -13,7 +13,7 @@
#include <qdatetime.h> #include <qdatetime.h>
#include <limits.h> #include <limits.h>
static inline double qwtMsecsForType( QwtDate::IntervalType type ) static inline double qwtMsecsForType( int type )
{ {
static const double msecs[] = static const double msecs[] =
{ {
@@ -43,7 +43,7 @@ static inline int qwtAlignValue(
} }
static double qwtIntervalWidth( const QDateTime &minDate, static double qwtIntervalWidth( const QDateTime &minDate,
const QDateTime &maxDate, QwtDate::IntervalType intervalType ) const QDateTime &maxDate, QwtDate::IntervalType intervalType )
{ {
switch( intervalType ) switch( intervalType )
{ {
@@ -79,7 +79,7 @@ static double qwtIntervalWidth( const QDateTime &minDate,
} }
case QwtDate::Month: case QwtDate::Month:
{ {
const double years = const double years =
double( maxDate.date().year() ) - minDate.date().year(); double( maxDate.date().year() ) - minDate.date().year();
int months = maxDate.date().month() - minDate.date().month(); int months = maxDate.date().month() - minDate.date().month();
@@ -90,7 +90,7 @@ static double qwtIntervalWidth( const QDateTime &minDate,
} }
case QwtDate::Year: case QwtDate::Year:
{ {
double years = double years =
double( maxDate.date().year() ) - minDate.date().year(); double( maxDate.date().year() ) - minDate.date().year();
if ( maxDate.date().month() < minDate.date().month() ) if ( maxDate.date().month() < minDate.date().month() )
@@ -103,9 +103,9 @@ static double qwtIntervalWidth( const QDateTime &minDate,
return 0.0; return 0.0;
} }
static double qwtRoundedIntervalWidth( static double qwtRoundedIntervalWidth(
const QDateTime &minDate, const QDateTime &maxDate, const QDateTime &minDate, const QDateTime &maxDate,
QwtDate::IntervalType intervalType ) QwtDate::IntervalType intervalType )
{ {
const QDateTime minD = QwtDate::floor( minDate, intervalType ); const QDateTime minD = QwtDate::floor( minDate, intervalType );
const QDateTime maxD = QwtDate::ceil( maxDate, intervalType ); const QDateTime maxD = QwtDate::ceil( maxDate, intervalType );
@@ -130,7 +130,7 @@ static inline int qwtStepCount( int intervalSize, int maxSteps,
return 0; return 0;
} }
static int qwtStepSize( int intervalSize, int maxSteps, uint base ) static int qwtStepSize( int intervalSize, int maxSteps, uint base )
{ {
if ( maxSteps <= 0 ) if ( maxSteps <= 0 )
return 0; return 0;
@@ -161,7 +161,7 @@ static int qwtStepSize( int intervalSize, int maxSteps, uint base )
return 0; return 0;
} }
static int qwtDivideInterval( double intervalSize, int numSteps, static int qwtDivideInterval( double intervalSize, int numSteps,
const int limits[], size_t numLimits ) const int limits[], size_t numLimits )
{ {
const int v = qCeil( intervalSize / double( numSteps ) ); const int v = qCeil( intervalSize / double( numSteps ) );
@@ -180,7 +180,7 @@ static double qwtDivideScale( double intervalSize, int numSteps,
{ {
if ( intervalType != QwtDate::Day ) if ( intervalType != QwtDate::Day )
{ {
if ( ( intervalSize > numSteps ) && if ( ( intervalSize > numSteps ) &&
( intervalSize <= 2 * numSteps ) ) ( intervalSize <= 2 * numSteps ) )
{ {
return 2.0; return 2.0;
@@ -195,7 +195,7 @@ static double qwtDivideScale( double intervalSize, int numSteps,
case QwtDate::Minute: case QwtDate::Minute:
{ {
static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 }; static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 };
stepSize = qwtDivideInterval( intervalSize, numSteps, stepSize = qwtDivideInterval( intervalSize, numSteps,
limits, sizeof( limits ) / sizeof( int ) ); limits, sizeof( limits ) / sizeof( int ) );
@@ -204,7 +204,7 @@ static double qwtDivideScale( double intervalSize, int numSteps,
case QwtDate::Hour: case QwtDate::Hour:
{ {
static int limits[] = { 1, 2, 3, 4, 6, 12, 24 }; static int limits[] = { 1, 2, 3, 4, 6, 12, 24 };
stepSize = qwtDivideInterval( intervalSize, numSteps, stepSize = qwtDivideInterval( intervalSize, numSteps,
limits, sizeof( limits ) / sizeof( int ) ); limits, sizeof( limits ) / sizeof( int ) );
@@ -273,13 +273,13 @@ static double qwtDivideMajorStep( double stepSize, int maxMinSteps,
if ( stepSize > maxMinSteps ) if ( stepSize > maxMinSteps )
{ {
numSteps = qwtStepCount( stepSize, maxMinSteps, numSteps = qwtStepCount( stepSize, maxMinSteps,
limits, sizeof( limits ) / sizeof( int ) ); limits, sizeof( limits ) / sizeof( int ) );
} }
else else
{ {
numSteps = qwtStepCount( stepSize * 60, maxMinSteps, numSteps = qwtStepCount( stepSize * 60, maxMinSteps,
limits, sizeof( limits ) / sizeof( int ) ); limits, sizeof( limits ) / sizeof( int ) );
} }
@@ -358,7 +358,7 @@ static double qwtDivideMajorStep( double stepSize, int maxMinSteps,
} }
else else
{ {
minStepSize = QwtScaleArithmetic::divideInterval( minStepSize = QwtScaleArithmetic::divideInterval(
stepSizeInWeeks, maxMinSteps, 10 ); stepSizeInWeeks, maxMinSteps, 10 );
} }
} }
@@ -400,7 +400,7 @@ static double qwtDivideMajorStep( double stepSize, int maxMinSteps,
if ( numSteps > 0 ) if ( numSteps > 0 )
minStepSize = double( stepSize ) / numSteps; minStepSize = double( stepSize ) / numSteps;
} }
break; break;
} }
default: default:
@@ -444,17 +444,17 @@ static QList<double> qwtDstTicks( const QDateTime &dateTime,
return ticks; return ticks;
} }
static QwtScaleDiv qwtDivideToSeconds( static QwtScaleDiv qwtDivideToSeconds(
const QDateTime &minDate, const QDateTime &maxDate, const QDateTime &minDate, const QDateTime &maxDate,
double stepSize, int maxMinSteps, double stepSize, int maxMinSteps,
QwtDate::IntervalType intervalType ) QwtDate::IntervalType intervalType )
{ {
// calculate the min step size // calculate the min step size
double minStepSize = 0; double minStepSize = 0;
if ( maxMinSteps > 1 ) if ( maxMinSteps > 1 )
{ {
minStepSize = qwtDivideMajorStep( stepSize, minStepSize = qwtDivideMajorStep( stepSize,
maxMinSteps, intervalType ); maxMinSteps, intervalType );
} }
@@ -471,7 +471,7 @@ static QwtScaleDiv qwtDivideToSeconds(
const double s = qwtMsecsForType( intervalType ) / 1000; const double s = qwtMsecsForType( intervalType ) / 1000;
const int secondsMajor = static_cast<int>( stepSize * s ); const int secondsMajor = static_cast<int>( stepSize * s );
const double secondsMinor = minStepSize * s; const double secondsMinor = minStepSize * s;
// UTC excludes daylight savings. So from the difference // UTC excludes daylight savings. So from the difference
// of a date and its UTC counterpart we can find out // of a date and its UTC counterpart we can find out
// the daylight saving hours // the daylight saving hours
@@ -483,7 +483,7 @@ static QwtScaleDiv qwtDivideToSeconds(
QList<double> mediumTicks; QList<double> mediumTicks;
QList<double> minorTicks; QList<double> minorTicks;
for ( QDateTime dt = minDate; dt <= maxDate; for ( QDateTime dt = minDate; dt <= maxDate;
dt = dt.addSecs( secondsMajor ) ) dt = dt.addSecs( secondsMajor ) )
{ {
if ( !dt.isValid() ) if ( !dt.isValid() )
@@ -500,7 +500,7 @@ static QwtScaleDiv qwtDivideToSeconds(
{ {
// we add some minor ticks for the DST hour, // we add some minor ticks for the DST hour,
// otherwise the ticks will be unaligned: 0, 2, 3, 5 ... // otherwise the ticks will be unaligned: 0, 2, 3, 5 ...
minorTicks += qwtDstTicks( minorTicks += qwtDstTicks(
dt, secondsMajor, qRound( secondsMinor ) ); dt, secondsMajor, qRound( secondsMinor ) );
} }
@@ -516,7 +516,7 @@ static QwtScaleDiv qwtDivideToSeconds(
for ( int i = 1; i < numMinorSteps; i++ ) for ( int i = 1; i < numMinorSteps; i++ )
{ {
const QDateTime mt = dt.addMSecs( const QDateTime mt = dt.addMSecs(
qRound64( i * secondsMinor * 1000 ) ); qRound64( i * secondsMinor * 1000 ) );
double minorValue = QwtDate::toDouble( mt ); double minorValue = QwtDate::toDouble( mt );
@@ -528,7 +528,7 @@ static QwtScaleDiv qwtDivideToSeconds(
if ( minorTicks.isEmpty() || minorTicks.last() != minorValue ) if ( minorTicks.isEmpty() || minorTicks.last() != minorValue )
{ {
const bool isMedium = ( numMinorSteps % 2 == 0 ) const bool isMedium = ( numMinorSteps % 2 == 0 )
&& ( i != 1 ) && ( i == numMinorSteps / 2 ); && ( i != 1 ) && ( i == numMinorSteps / 2 );
if ( isMedium ) if ( isMedium )
@@ -552,16 +552,16 @@ static QwtScaleDiv qwtDivideToSeconds(
return scaleDiv; return scaleDiv;
} }
static QwtScaleDiv qwtDivideToMonths( static QwtScaleDiv qwtDivideToMonths(
QDateTime &minDate, const QDateTime &maxDate, QDateTime &minDate, const QDateTime &maxDate,
double stepSize, int maxMinSteps ) double stepSize, int maxMinSteps )
{ {
// months are intervals with non // months are intervals with non
// equidistant ( in ms ) steps: we have to build the // equidistant ( in ms ) steps: we have to build the
// scale division manually // scale division manually
int minStepDays = 0; int minStepDays = 0;
int minStepSize = 0.0; int minStepSize = 0.0;
if ( maxMinSteps > 1 ) if ( maxMinSteps > 1 )
{ {
@@ -578,7 +578,7 @@ static QwtScaleDiv qwtDivideToMonths(
} }
else else
{ {
minStepSize = qwtDivideMajorStep( minStepSize = qwtDivideMajorStep(
stepSize, maxMinSteps, QwtDate::Month ); stepSize, maxMinSteps, QwtDate::Month );
} }
} }
@@ -587,7 +587,7 @@ static QwtScaleDiv qwtDivideToMonths(
QList<double> mediumTicks; QList<double> mediumTicks;
QList<double> minorTicks; QList<double> minorTicks;
for ( QDateTime dt = minDate; for ( QDateTime dt = minDate;
dt <= maxDate; dt = dt.addMonths( stepSize ) ) dt <= maxDate; dt = dt.addMonths( stepSize ) )
{ {
if ( !dt.isValid() ) if ( !dt.isValid() )
@@ -597,7 +597,7 @@ static QwtScaleDiv qwtDivideToMonths(
if ( minStepDays > 0 ) if ( minStepDays > 0 )
{ {
for ( int days = minStepDays; for ( int days = minStepDays;
days < 30; days += minStepDays ) days < 30; days += minStepDays )
{ {
const double tick = QwtDate::toDouble( dt.addDays( days ) ); const double tick = QwtDate::toDouble( dt.addDays( days ) );
@@ -636,9 +636,9 @@ static QwtScaleDiv qwtDivideToMonths(
return scaleDiv; return scaleDiv;
} }
static QwtScaleDiv qwtDivideToYears( static QwtScaleDiv qwtDivideToYears(
const QDateTime &minDate, const QDateTime &maxDate, const QDateTime &minDate, const QDateTime &maxDate,
double stepSize, int maxMinSteps ) double stepSize, int maxMinSteps )
{ {
QList<double> majorTicks; QList<double> majorTicks;
QList<double> mediumTicks; QList<double> mediumTicks;
@@ -648,7 +648,7 @@ static QwtScaleDiv qwtDivideToYears(
if ( maxMinSteps > 1 ) if ( maxMinSteps > 1 )
{ {
minStepSize = qwtDivideMajorStep( minStepSize = qwtDivideMajorStep(
stepSize, maxMinSteps, QwtDate::Year ); stepSize, maxMinSteps, QwtDate::Year );
} }
@@ -701,7 +701,7 @@ static QwtScaleDiv qwtDivideToYears(
{ {
break; break;
} }
} }
QwtScaleDiv scaleDiv; QwtScaleDiv scaleDiv;
scaleDiv.setInterval( QwtDate::toDouble( minDate ), scaleDiv.setInterval( QwtDate::toDouble( minDate ),
@@ -729,13 +729,13 @@ public:
int utcOffset; int utcOffset;
QwtDate::Week0Type week0Type; QwtDate::Week0Type week0Type;
int maxWeeks; int maxWeeks;
}; };
/*! /*!
\brief Constructor \brief Constructor
The engine is initialized to build scales for the The engine is initialized to build scales for the
given time specification. It classifies intervals > 4 weeks given time specification. It classifies intervals > 4 weeks
as >= Qt::Month. The first week of a year is defined like as >= Qt::Month. The first week of a year is defined like
for QwtDate::FirstThursday. for QwtDate::FirstThursday.
@@ -810,7 +810,7 @@ int QwtDateScaleEngine::utcOffset() const
\sa week0Type(), setMaxWeeks() \sa week0Type(), setMaxWeeks()
\note week0Type has no effect beside for intervals classified as \note week0Type has no effect beside for intervals classified as
QwtDate::Week. QwtDate::Week.
*/ */
void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type ) void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type )
{ {
@@ -818,7 +818,7 @@ void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type )
} }
/*! /*!
\return Setting how to identify the first week of a year. \return Setting how to identify the first week of a year.
\sa setWeek0Type(), maxWeeks() \sa setWeek0Type(), maxWeeks()
*/ */
QwtDate::Week0Type QwtDateScaleEngine::week0Type() const QwtDate::Week0Type QwtDateScaleEngine::week0Type() const
@@ -836,7 +836,7 @@ QwtDate::Week0Type QwtDateScaleEngine::week0Type() const
\note In business charts a year is often devided \note In business charts a year is often devided
into weeks [1-52] into weeks [1-52]
\sa maxWeeks(), setWeek0Type() \sa maxWeeks(), setWeek0Type()
*/ */
void QwtDateScaleEngine::setMaxWeeks( int weeks ) void QwtDateScaleEngine::setMaxWeeks( int weeks )
{ {
@@ -862,8 +862,8 @@ int QwtDateScaleEngine::maxWeeks() const
\return Interval classification \return Interval classification
*/ */
QwtDate::IntervalType QwtDateScaleEngine::intervalType( QwtDate::IntervalType QwtDateScaleEngine::intervalType(
const QDateTime &minDate, const QDateTime &maxDate, const QDateTime &minDate, const QDateTime &maxDate,
int maxSteps ) const int maxSteps ) const
{ {
const double jdMin = minDate.date().toJulianDay(); const double jdMin = minDate.date().toJulianDay();
@@ -909,11 +909,11 @@ QwtDate::IntervalType QwtDateScaleEngine::intervalType(
/*! /*!
Align and divide an interval Align and divide an interval
The algorithm aligns and divides the interval into steps. The algorithm aligns and divides the interval into steps.
Datetime interval divisions are usually not equidistant and the Datetime interval divisions are usually not equidistant and the
calculated stepSize can only be used as an approximation calculated stepSize can only be used as an approximation
for the steps calculated by divideScale(). for the steps calculated by divideScale().
\param maxNumSteps Max. number of steps \param maxNumSteps Max. number of steps
\param x1 First limit of the interval (In/Out) \param x1 First limit of the interval (In/Out)
@@ -950,7 +950,7 @@ void QwtDateScaleEngine::autoScale( int maxNumSteps,
if ( maxNumSteps < 1 ) if ( maxNumSteps < 1 )
maxNumSteps = 1; maxNumSteps = 1;
const QwtDate::IntervalType intvType = const QwtDate::IntervalType intvType =
intervalType( from, to, maxNumSteps ); intervalType( from, to, maxNumSteps );
const double width = qwtIntervalWidth( from, to, intvType ); const double width = qwtIntervalWidth( from, to, intvType );
@@ -1014,7 +1014,7 @@ QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2,
maxMajorSteps = qCeil( ( max - min ) / stepSize ); maxMajorSteps = qCeil( ( max - min ) / stepSize );
} }
const QwtDate::IntervalType intvType = const QwtDate::IntervalType intvType =
intervalType( from, to, maxMajorSteps ); intervalType( from, to, maxMajorSteps );
QwtScaleDiv scaleDiv; QwtScaleDiv scaleDiv;
@@ -1030,7 +1030,7 @@ QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2,
const QDateTime minDate = QwtDate::floor( from, intvType ); const QDateTime minDate = QwtDate::floor( from, intvType );
const QDateTime maxDate = QwtDate::ceil( to, intvType ); const QDateTime maxDate = QwtDate::ceil( to, intvType );
scaleDiv = buildScaleDiv( minDate, maxDate, scaleDiv = buildScaleDiv( minDate, maxDate,
maxMajorSteps, maxMinorSteps, intvType ); maxMajorSteps, maxMinorSteps, intvType );
// scaleDiv has been calculated from an extended interval // scaleDiv has been calculated from an extended interval
@@ -1045,21 +1045,21 @@ QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2,
return scaleDiv; return scaleDiv;
} }
QwtScaleDiv QwtDateScaleEngine::buildScaleDiv( QwtScaleDiv QwtDateScaleEngine::buildScaleDiv(
const QDateTime &minDate, const QDateTime &maxDate, const QDateTime &minDate, const QDateTime &maxDate,
int maxMajorSteps, int maxMinorSteps, int maxMajorSteps, int maxMinorSteps,
QwtDate::IntervalType intervalType ) const QwtDate::IntervalType intervalType ) const
{ {
// calculate the step size // calculate the step size
const double stepSize = qwtDivideScale( const double stepSize = qwtDivideScale(
qwtIntervalWidth( minDate, maxDate, intervalType ), qwtIntervalWidth( minDate, maxDate, intervalType ),
maxMajorSteps, intervalType ); maxMajorSteps, intervalType );
// align minDate to the step size // align minDate to the step size
QDateTime dt0 = alignDate( minDate, stepSize, intervalType, false ); QDateTime dt0 = alignDate( minDate, stepSize, intervalType, false );
if ( !dt0.isValid() ) if ( !dt0.isValid() )
{ {
// the floored date is out of the range of a // the floored date is out of the range of a
// QDateTime - we ceil instead. // QDateTime - we ceil instead.
dt0 = alignDate( minDate, stepSize, intervalType, true ); dt0 = alignDate( minDate, stepSize, intervalType, true );
} }
@@ -1068,7 +1068,7 @@ QwtScaleDiv QwtDateScaleEngine::buildScaleDiv(
if ( intervalType <= QwtDate::Week ) if ( intervalType <= QwtDate::Week )
{ {
scaleDiv = qwtDivideToSeconds( dt0, maxDate, scaleDiv = qwtDivideToSeconds( dt0, maxDate,
stepSize, maxMinorSteps, intervalType ); stepSize, maxMinorSteps, intervalType );
} }
else else
@@ -1093,7 +1093,7 @@ QwtScaleDiv QwtDateScaleEngine::buildScaleDiv(
Align a date/time value for a step size Align a date/time value for a step size
For Qt::Day alignments there is no "natural day 0" - For Qt::Day alignments there is no "natural day 0" -
instead the first day of the year is used to avoid jumping instead the first day of the year is used to avoid jumping
major ticks positions when panning a scale. For other alignments major ticks positions when panning a scale. For other alignments
( f.e according to the first day of the month ) alignDate() ( f.e according to the first day of the month ) alignDate()
has to be overloaded. has to be overloaded.
@@ -1105,8 +1105,8 @@ QwtScaleDiv QwtDateScaleEngine::buildScaleDiv(
\return Aligned date/time value \return Aligned date/time value
*/ */
QDateTime QwtDateScaleEngine::alignDate( QDateTime QwtDateScaleEngine::alignDate(
const QDateTime &dateTime, double stepSize, const QDateTime &dateTime, double stepSize,
QwtDate::IntervalType intervalType, bool up ) const QwtDate::IntervalType intervalType, bool up ) const
{ {
// what about: (year == 1582 && month == 10 && day > 4 && day < 15) ?? // what about: (year == 1582 && month == 10 && day > 4 && day < 15) ??
@@ -1122,7 +1122,7 @@ QDateTime QwtDateScaleEngine::alignDate(
{ {
case QwtDate::Millisecond: case QwtDate::Millisecond:
{ {
const int ms = qwtAlignValue( const int ms = qwtAlignValue(
dt.time().msec(), stepSize, up ) ; dt.time().msec(), stepSize, up ) ;
dt = QwtDate::floor( dateTime, QwtDate::Second ); dt = QwtDate::floor( dateTime, QwtDate::Second );
@@ -1292,7 +1292,7 @@ QDateTime QwtDateScaleEngine::toDateTime( double value ) const
QDateTime dt = QwtDate::toDateTime( value, d_data->timeSpec ); QDateTime dt = QwtDate::toDateTime( value, d_data->timeSpec );
if ( !dt.isValid() ) if ( !dt.isValid() )
{ {
const QDate date = ( value <= 0.0 ) const QDate date = ( value <= 0.0 )
? QwtDate::minDate() : QwtDate::maxDate(); ? QwtDate::minDate() : QwtDate::maxDate();
dt = QDateTime( date, QTime( 0, 0 ), d_data->timeSpec ); dt = QDateTime( date, QTime( 0, 0 ), d_data->timeSpec );

View File

@@ -27,12 +27,12 @@
QwtDateScaleEngine supports representations depending QwtDateScaleEngine supports representations depending
on Qt::TimeSpec specifications. The valid range for scales on Qt::TimeSpec specifications. The valid range for scales
is limited by the range of QDateTime, that differs is limited by the range of QDateTime, that differs
between Qt4 and Qt5. between Qt4 and Qt5.
Datetime values are expected as the number of milliseconds since Datetime values are expected as the number of milliseconds since
1970-01-01T00:00:00 Universal Coordinated Time - also known 1970-01-01T00:00:00 Universal Coordinated Time - also known
as "The Epoch", that can be converted to QDateTime using as "The Epoch", that can be converted to QDateTime using
QwtDate::toDateTime(). QwtDate::toDateTime().
\sa QwtDate, QwtPlot::setAxisScaleEngine(), \sa QwtDate, QwtPlot::setAxisScaleEngine(),
@@ -52,19 +52,19 @@ public:
void setWeek0Type( QwtDate::Week0Type ); void setWeek0Type( QwtDate::Week0Type );
QwtDate::Week0Type week0Type() const; QwtDate::Week0Type week0Type() const;
void setMaxWeeks( int ); void setMaxWeeks( int );
int maxWeeks() const; int maxWeeks() const;
virtual void autoScale( int maxNumSteps, virtual void autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const; double &x1, double &x2, double &stepSize ) const;
virtual QwtScaleDiv divideScale( virtual QwtScaleDiv divideScale(
double x1, double x2, double x1, double x2,
int maxMajorSteps, int maxMinorSteps, int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const; double stepSize = 0.0 ) const;
virtual QwtDate::IntervalType intervalType( virtual QwtDate::IntervalType intervalType(
const QDateTime &, const QDateTime &, int maxSteps ) const; const QDateTime &, const QDateTime &, int maxSteps ) const;
QDateTime toDateTime( double ) const; QDateTime toDateTime( double ) const;
@@ -75,7 +75,7 @@ protected:
private: private:
QwtScaleDiv buildScaleDiv( const QDateTime &, const QDateTime &, QwtScaleDiv buildScaleDiv( const QDateTime &, const QDateTime &,
int maxMajorSteps, int maxMinorSteps, int maxMajorSteps, int maxMinorSteps,
QwtDate::IntervalType ) const; QwtDate::IntervalType ) const;
private: private:

View File

@@ -237,7 +237,7 @@ QRect QwtDial::boundingRect() const
{ {
const QRect cr = contentsRect(); 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 ); QRect inner( 0, 0, dim, dim );
inner.moveCenter( cr.center() ); inner.moveCenter( cr.center() );
@@ -337,7 +337,7 @@ void QwtDial::paintEvent( QPaintEvent *event )
QPainter p( &d_data->pixmapCache ); QPainter p( &d_data->pixmapCache );
p.setRenderHint( QPainter::Antialiasing, true ); p.setRenderHint( QPainter::Antialiasing, true );
p.translate( -r.topLeft() ); p.translate( -r.topLeft() );
if ( d_data->mode != QwtDial::RotateScale ) if ( d_data->mode != QwtDial::RotateScale )
drawContents( &p ); drawContents( &p );
@@ -474,7 +474,7 @@ void QwtDial::drawNeedle( QPainter *painter ) const
\param center Center of the dial \param center Center of the dial
\param radius Radius of the scale \param radius Radius of the scale
*/ */
void QwtDial::drawScale( QPainter *painter, void QwtDial::drawScale( QPainter *painter,
const QPointF &center, double radius ) const const QPointF &center, double radius ) const
{ {
QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw *>( scaleDraw() ); QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw *>( scaleDraw() );
@@ -567,9 +567,9 @@ const QwtRoundScaleDraw *QwtDial::scaleDraw() const
Set an individual scale draw Set an individual scale draw
The motivation for setting a scale draw is often The motivation for setting a scale draw is often
to overload QwtRoundScaleDraw::label() to return to overload QwtRoundScaleDraw::label() to return
individual tick labels. individual tick labels.
\param scaleDraw Scale draw \param scaleDraw Scale draw
\warning The previous scale draw is deleted \warning The previous scale draw is deleted
*/ */
@@ -600,7 +600,7 @@ void QwtDial::setScaleArc( double minArc, double maxArc )
if ( maxScaleArc - minScaleArc > 360.0 ) if ( maxScaleArc - minScaleArc > 360.0 )
maxScaleArc = minScaleArc + 360.0; maxScaleArc = minScaleArc + 360.0;
if ( ( minScaleArc != d_data->minScaleArc ) || if ( ( minScaleArc != d_data->minScaleArc ) ||
( maxScaleArc != d_data->maxScaleArc ) ) ( maxScaleArc != d_data->maxScaleArc ) )
{ {
d_data->minScaleArc = minScaleArc; d_data->minScaleArc = minScaleArc;
@@ -611,7 +611,7 @@ void QwtDial::setScaleArc( double minArc, double maxArc )
} }
} }
/*! /*!
Set the lower limit for the scale arc Set the lower limit for the scale arc
\param min Lower limit of the scale arc \param min Lower limit of the scale arc
@@ -622,7 +622,7 @@ void QwtDial::setMinScaleArc( double min )
setScaleArc( min, d_data->maxScaleArc ); setScaleArc( min, d_data->maxScaleArc );
} }
/*! /*!
\return Lower limit of the scale arc \return Lower limit of the scale arc
\sa setScaleArc() \sa setScaleArc()
*/ */
@@ -631,7 +631,7 @@ double QwtDial::minScaleArc() const
return d_data->minScaleArc; return d_data->minScaleArc;
} }
/*! /*!
Set the upper limit for the scale arc Set the upper limit for the scale arc
\param max Upper limit of the scale arc \param max Upper limit of the scale arc
@@ -642,7 +642,7 @@ void QwtDial::setMaxScaleArc( double max )
setScaleArc( d_data->minScaleArc, max ); setScaleArc( d_data->minScaleArc, max );
} }
/*! /*!
\return Upper limit of the scale arc \return Upper limit of the scale arc
\sa setScaleArc() \sa setScaleArc()
*/ */
@@ -690,7 +690,7 @@ QSize QwtDial::sizeHint() const
const int d = 6 * sh + 2 * lineWidth(); const int d = 6 * sh + 2 * lineWidth();
QSize hint( d, d ); QSize hint( d, d );
if ( !isReadOnly() ) if ( !isReadOnly() )
hint = hint.expandedTo( QApplication::globalStrut() ); hint = hint.expandedTo( QApplication::globalStrut() );
@@ -717,7 +717,7 @@ QSize QwtDial::minimumSizeHint() const
\param pos Mouse position \param pos Mouse position
\retval True, when the inner circle contains pos \retval True, when the inner circle contains pos
\sa scrolledTo() \sa scrolledTo()
*/ */
bool QwtDial::isScrollPosition( const QPoint &pos ) const bool QwtDial::isScrollPosition( const QPoint &pos ) const
@@ -729,7 +729,7 @@ bool QwtDial::isScrollPosition( const QPoint &pos ) const
if ( d_data->mode == QwtDial::RotateScale ) if ( d_data->mode == QwtDial::RotateScale )
angle = 360.0 - angle; angle = 360.0 - angle;
double valueAngle = double valueAngle =
qwtNormalizeDegrees( 90.0 - scaleMap().transform( value() ) ); qwtNormalizeDegrees( 90.0 - scaleMap().transform( value() ) );
d_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle ); d_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle );
@@ -774,7 +774,7 @@ double QwtDial::scrolledTo( const QPoint &pos ) const
const double arc = angle - scaleMap().transform( value() ); const double arc = angle - scaleMap().transform( value() );
if ( qAbs( arc ) > 180.0 ) if ( qAbs( arc ) > 180.0 )
{ {
boundedAngle = ( arc > 0 ) boundedAngle = ( arc > 0 )
? scaleMap().p1() : scaleMap().p2(); ? scaleMap().p1() : scaleMap().p2();
} }
@@ -820,7 +820,7 @@ void QwtDial::changeEvent( QEvent *event )
default: default:
break; break;
} }
QwtAbstractSlider::changeEvent( event ); QwtAbstractSlider::changeEvent( event );
} }
@@ -846,7 +846,7 @@ void QwtDial::setAngleRange( double angle, double span )
} }
/*! /*!
Invalidate the internal caches and call Invalidate the internal caches and call
QwtAbstractSlider::scaleChange() QwtAbstractSlider::scaleChange()
*/ */
void QwtDial::scaleChange() void QwtDial::scaleChange()

View File

@@ -103,12 +103,12 @@ public:
void setMode( Mode ); void setMode( Mode );
Mode mode() const; 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; double minScaleArc() const;
void setMaxScaleArc( double min ); void setMaxScaleArc( double );
double maxScaleArc() const; double maxScaleArc() const;
virtual void setOrigin( double ); virtual void setOrigin( double );
@@ -136,16 +136,16 @@ protected:
virtual void paintEvent( QPaintEvent * ); virtual void paintEvent( QPaintEvent * );
virtual void changeEvent( QEvent * ); virtual void changeEvent( QEvent * );
virtual void drawFrame( QPainter *p ); virtual void drawFrame( QPainter * );
virtual void drawContents( QPainter * ) const; virtual void drawContents( QPainter * ) const;
virtual void drawFocusIndicator( QPainter * ) const; virtual void drawFocusIndicator( QPainter * ) const;
void invalidateCache(); void invalidateCache();
virtual void drawScale( QPainter *, virtual void drawScale( QPainter *,
const QPointF &center, double radius ) const; const QPointF &center, double radius ) const;
virtual void drawScaleContents( QPainter *painter, virtual void drawScaleContents( QPainter *painter,
const QPointF &center, double radius ) const; const QPointF &center, double radius ) const;
virtual void drawNeedle( QPainter *, const QPointF &, virtual void drawNeedle( QPainter *, const QPointF &,

View File

@@ -13,7 +13,7 @@
#include "qwt_painter.h" #include "qwt_painter.h"
#include <qapplication.h> #include <qapplication.h>
#include <qpainter.h> #include <qpainter.h>
#include <QPainterPath>
#if QT_VERSION < 0x040601 #if QT_VERSION < 0x040601
#define qFastSin(x) qSin(x) #define qFastSin(x) qSin(x)
#define qFastCos(x) qCos(x) #define qFastCos(x) qCos(x)
@@ -66,7 +66,7 @@ static void qwtDrawStyle2Needle( QPainter *painter,
painter->drawPath( path2 ); painter->drawPath( path2 );
} }
static void qwtDrawShadedPointer( QPainter *painter, static void qwtDrawShadedPointer( QPainter *painter,
const QColor &lightColor, const QColor &darkColor, const QColor &lightColor, const QColor &darkColor,
double length, double width ) double length, double width )
{ {
@@ -222,8 +222,8 @@ const QPalette &QwtDialNeedle::palette() const
\param direction Direction of the needle, in degrees counter clockwise \param direction Direction of the needle, in degrees counter clockwise
\param colorGroup Color group, used for painting \param colorGroup Color group, used for painting
*/ */
void QwtDialNeedle::draw( QPainter *painter, void QwtDialNeedle::draw( QPainter *painter,
const QPointF &center, double length, double direction, const QPointF &center, double length, double direction,
QPalette::ColorGroup colorGroup ) const QPalette::ColorGroup colorGroup ) const
{ {
painter->save(); painter->save();
@@ -315,7 +315,7 @@ double QwtDialSimpleNeedle::width() const
\param length Length of the needle \param length Length of the needle
\param colorGroup Color group, used for painting \param colorGroup Color group, used for painting
*/ */
void QwtDialSimpleNeedle::drawNeedle( QPainter *painter, void QwtDialSimpleNeedle::drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const double length, QPalette::ColorGroup colorGroup ) const
{ {
double knobWidth = 0.0; double knobWidth = 0.0;
@@ -326,7 +326,7 @@ void QwtDialSimpleNeedle::drawNeedle( QPainter *painter,
if ( width <= 0.0 ) if ( width <= 0.0 )
width = qMax(length * 0.06, 6.0); width = qMax(length * 0.06, 6.0);
qwtDrawArrowNeedle( painter, qwtDrawArrowNeedle( painter,
palette(), colorGroup, length, width ); palette(), colorGroup, length, width );
knobWidth = qMin( width * 2.0, 0.2 * length ); knobWidth = qMin( width * 2.0, 0.2 * length );
@@ -335,10 +335,10 @@ void QwtDialSimpleNeedle::drawNeedle( QPainter *painter,
{ {
if ( width <= 0.0 ) if ( width <= 0.0 )
width = 5.0; width = 5.0;
QPen pen ( palette().brush( colorGroup, QPalette::Mid ), width ); QPen pen ( palette().brush( colorGroup, QPalette::Mid ), width );
pen.setCapStyle( Qt::FlatCap ); pen.setCapStyle( Qt::FlatCap );
painter->setPen( pen ); painter->setPen( pen );
painter->drawLine( QPointF( 0.0, 0.0 ), QPointF( length, 0.0 ) ); painter->drawLine( QPointF( 0.0, 0.0 ), QPointF( length, 0.0 ) );
@@ -372,7 +372,7 @@ QwtCompassMagnetNeedle::QwtCompassMagnetNeedle( Style style,
\param length Length of the needle \param length Length of the needle
\param colorGroup Color group, used for painting \param colorGroup Color group, used for painting
*/ */
void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter, void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const double length, QPalette::ColorGroup colorGroup ) const
{ {
if ( d_style == ThinStyle ) if ( d_style == ThinStyle )
@@ -388,14 +388,14 @@ void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter,
dark.light( 100 + colorOffset ), dark.light( 100 + colorOffset ),
dark.dark( 100 + colorOffset ), dark.dark( 100 + colorOffset ),
length, width ); length, width );
painter->rotate( 180.0 ); painter->rotate( 180.0 );
qwtDrawShadedPointer( painter, qwtDrawShadedPointer( painter,
light.light( 100 + colorOffset ), light.light( 100 + colorOffset ),
light.dark( 100 + colorOffset ), light.dark( 100 + colorOffset ),
length, width ); length, width );
const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base ); const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base );
drawKnob( painter, width, baseBrush, true ); drawKnob( painter, width, baseBrush, true );
} }
@@ -430,7 +430,7 @@ QwtCompassWindArrow::QwtCompassWindArrow( Style style,
\param length Length of the needle \param length Length of the needle
\param colorGroup Color group, used for painting \param colorGroup Color group, used for painting
*/ */
void QwtCompassWindArrow::drawNeedle( QPainter *painter, void QwtCompassWindArrow::drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const double length, QPalette::ColorGroup colorGroup ) const
{ {
if ( d_style == Style1 ) if ( d_style == Style1 )

View File

@@ -35,7 +35,7 @@ public:
const QPalette &palette() const; const QPalette &palette() const;
virtual void draw( QPainter *painter, const QPointF &center, virtual void draw( QPainter *painter, const QPointF &center,
double length, double direction, double length, double direction,
QPalette::ColorGroup = QPalette::Active ) const; QPalette::ColorGroup = QPalette::Active ) const;
protected: protected:
@@ -43,9 +43,9 @@ protected:
\brief Draw the needle \brief Draw the needle
The origin of the needle is at position (0.0, 0.0 ) The origin of the needle is at position (0.0, 0.0 )
pointing in direction 0.0 ( = east ). pointing in direction 0.0 ( = east ).
The painter is already initialized with translation and The painter is already initialized with translation and
rotation. rotation.
\param painter Painter \param painter Painter
@@ -54,10 +54,10 @@ protected:
\sa setPalette(), palette() \sa setPalette(), palette()
*/ */
virtual void drawNeedle( QPainter *painter, virtual void drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const = 0; double length, QPalette::ColorGroup colorGroup ) const = 0;
virtual void drawKnob( QPainter *, double width, virtual void drawKnob( QPainter *, double width,
const QBrush &, bool sunken ) const; const QBrush &, bool sunken ) const;
private: private:
@@ -132,7 +132,7 @@ public:
//! A needle with a triangular shape //! A needle with a triangular shape
TriangleStyle, TriangleStyle,
//! A thin needle //! A thin needle
ThinStyle ThinStyle
}; };
@@ -140,7 +140,7 @@ public:
const QColor &light = Qt::white, const QColor &dark = Qt::red ); const QColor &light = Qt::white, const QColor &dark = Qt::red );
protected: protected:
virtual void drawNeedle( QPainter *, virtual void drawNeedle( QPainter *,
double length, QPalette::ColorGroup ) const; double length, QPalette::ColorGroup ) const;
private: private:
@@ -177,11 +177,11 @@ public:
const QColor &dark = Qt::gray ); const QColor &dark = Qt::gray );
protected: protected:
virtual void drawNeedle( QPainter *, virtual void drawNeedle( QPainter *,
double length, QPalette::ColorGroup ) const; double length, QPalette::ColorGroup ) const;
private: private:
Style d_style; Style d_style;
}; };
#endif #endif

View File

@@ -125,7 +125,7 @@ uint QwtDynGridLayout::maxColumns() const
return d_data->maxColumns; return d_data->maxColumns;
} }
/*! /*!
\brief Add an item to the next free position. \brief Add an item to the next free position.
\param item Layout item \param item Layout item
*/ */
@@ -247,9 +247,9 @@ void QwtDynGridLayout::setGeometry( const QRect &rect )
} }
/*! /*!
\brief Calculate the number of columns for a given width. \brief Calculate the number of columns for a given width.
The calculation tries to use as many columns as possible The calculation tries to use as many columns as possible
( limited by maxColumns() ) ( limited by maxColumns() )
\param width Available width for all columns \param width Available width for all columns
@@ -263,7 +263,7 @@ uint QwtDynGridLayout::columnsForWidth( int width ) const
return 0; return 0;
uint maxColumns = itemCount(); uint maxColumns = itemCount();
if ( d_data->maxColumns > 0 ) if ( d_data->maxColumns > 0 )
maxColumns = qMin( d_data->maxColumns, maxColumns ); maxColumns = qMin( d_data->maxColumns, maxColumns );
if ( maxRowWidth( maxColumns ) <= width ) if ( maxRowWidth( maxColumns ) <= width )

View File

@@ -28,14 +28,14 @@ class QWT_EXPORT QwtDynGridLayout : public QLayout
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QwtDynGridLayout( QWidget *, int margin = 0, int space = -1 ); explicit QwtDynGridLayout( QWidget *, int margin = 0, int spacing = -1 );
explicit QwtDynGridLayout( int space = -1 ); explicit QwtDynGridLayout( int spacing = -1 );
virtual ~QwtDynGridLayout(); virtual ~QwtDynGridLayout();
virtual void invalidate(); virtual void invalidate();
void setMaxColumns( uint maxCols ); void setMaxColumns( uint maxColumns );
uint maxColumns() const; uint maxColumns() const;
uint numRows () const; uint numRows () const;
@@ -49,7 +49,7 @@ public:
void setExpandingDirections( Qt::Orientations ); void setExpandingDirections( Qt::Orientations );
virtual Qt::Orientations expandingDirections() const; 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; virtual int maxItemWidth() const;
@@ -67,14 +67,14 @@ public:
protected: protected:
void layoutGrid( uint numCols, void layoutGrid( uint numColumns,
QVector<int>& rowHeight, QVector<int>& colWidth ) const; 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; QVector<int>& rowHeight, QVector<int>& colWidth ) const;
private: private:
void init(); void init();
int maxRowWidth( int numCols ) const; int maxRowWidth( int numColumns ) const;
class PrivateData; class PrivateData;
PrivateData *d_data; PrivateData *d_data;

View File

@@ -105,7 +105,7 @@ void QwtEventPattern::initKeyPattern()
\sa QMouseEvent \sa QMouseEvent
*/ */
void QwtEventPattern::setMousePattern( MousePatternCode pattern, void QwtEventPattern::setMousePattern( MousePatternCode pattern,
Qt::MouseButton button, Qt::KeyboardModifiers modifiers ) Qt::MouseButton button, Qt::KeyboardModifiers modifiers )
{ {
if ( pattern >= 0 && pattern < MousePatternCount ) if ( pattern >= 0 && pattern < MousePatternCount )
@@ -124,7 +124,7 @@ void QwtEventPattern::setMousePattern( MousePatternCode pattern,
\sa QKeyEvent \sa QKeyEvent
*/ */
void QwtEventPattern::setKeyPattern( KeyPatternCode pattern, void QwtEventPattern::setKeyPattern( KeyPatternCode pattern,
int key, Qt::KeyboardModifiers modifiers ) int key, Qt::KeyboardModifiers modifiers )
{ {
if ( pattern >= 0 && pattern < KeyPatternCount ) if ( pattern >= 0 && pattern < KeyPatternCount )
@@ -185,7 +185,7 @@ QVector<QwtEventPattern::KeyPattern> &QwtEventPattern::keyPattern()
\sa keyMatch() \sa keyMatch()
*/ */
bool QwtEventPattern::mouseMatch( MousePatternCode code, bool QwtEventPattern::mouseMatch( MousePatternCode code,
const QMouseEvent *event ) const const QMouseEvent *event ) const
{ {
if ( code >= 0 && code < MousePatternCount ) if ( code >= 0 && code < MousePatternCount )
@@ -231,7 +231,7 @@ bool QwtEventPattern::mouseMatch( const MousePattern &pattern,
\sa mouseMatch() \sa mouseMatch()
*/ */
bool QwtEventPattern::keyMatch( KeyPatternCode code, bool QwtEventPattern::keyMatch( KeyPatternCode code,
const QKeyEvent *event ) const const QKeyEvent *event ) const
{ {
if ( code >= 0 && code < KeyPatternCount ) if ( code >= 0 && code < KeyPatternCount )

View File

@@ -43,12 +43,12 @@ public:
*/ */
enum MousePatternCode enum MousePatternCode
{ {
/*! /*!
The default setting for 1, 2 and 3 button mice is: The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton - Qt::LeftButton
- Qt::LeftButton - Qt::LeftButton
- Qt::LeftButton - Qt::LeftButton
*/ */
MouseSelect1, MouseSelect1,
@@ -149,14 +149,14 @@ public:
{ {
public: public:
//! Constructor //! Constructor
MousePattern( Qt::MouseButton btn = Qt::NoButton, MousePattern( Qt::MouseButton btn = Qt::NoButton,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ): Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
button( btn ), button( btn ),
modifiers( modifierCodes ) modifiers( modifierCodes )
{ {
} }
//! Button //! Button
Qt::MouseButton button; Qt::MouseButton button;
//! Keyboard modifier //! Keyboard modifier
@@ -168,7 +168,7 @@ public:
{ {
public: public:
//! Constructor //! Constructor
KeyPattern( int keyCode = Qt::Key_unknown, KeyPattern( int keyCode = Qt::Key_unknown,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ): Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
key( keyCode ), key( keyCode ),
modifiers( modifierCodes ) modifiers( modifierCodes )
@@ -188,11 +188,11 @@ public:
void initMousePattern( int numButtons ); void initMousePattern( int numButtons );
void initKeyPattern(); void initKeyPattern();
void setMousePattern( MousePatternCode, Qt::MouseButton button, void setMousePattern( MousePatternCode, Qt::MouseButton button,
Qt::KeyboardModifiers = Qt::NoModifier ); Qt::KeyboardModifiers = Qt::NoModifier );
void setKeyPattern( KeyPatternCode, int keyCode, void setKeyPattern( KeyPatternCode, int key,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ); Qt::KeyboardModifiers modifiers = Qt::NoModifier );
void setMousePattern( const QVector<MousePattern> & ); void setMousePattern( const QVector<MousePattern> & );
void setKeyPattern( const QVector<KeyPattern> & ); void setKeyPattern( const QVector<KeyPattern> & );

View File

@@ -14,8 +14,8 @@
// QWT_VERSION is (major << 16) + (minor << 8) + patch. // QWT_VERSION is (major << 16) + (minor << 8) + patch.
#define QWT_VERSION 0x060103 #define QWT_VERSION 0x060104
#define QWT_VERSION_STR "6.1.3" #define QWT_VERSION_STR "6.1.4"
#if defined(_MSC_VER) /* MSVC Compiler */ #if defined(_MSC_VER) /* MSVC Compiler */
/* template-class specialization 'identifier' is already instantiated */ /* template-class specialization 'identifier' is already instantiated */
@@ -26,10 +26,10 @@
#ifdef QWT_DLL #ifdef QWT_DLL
#if defined(QWT_MAKEDLL) // create a Qwt DLL library #if defined(QWT_MAKEDLL) // create a Qwt DLL library
#define QWT_EXPORT Q_DECL_EXPORT #define QWT_EXPORT Q_DECL_EXPORT
#else // use a Qwt DLL library #else // use a Qwt DLL library
#define QWT_EXPORT Q_DECL_IMPORT #define QWT_EXPORT Q_DECL_IMPORT
#endif #endif
#endif // QWT_DLL #endif // QWT_DLL
@@ -38,4 +38,4 @@
#define QWT_EXPORT #define QWT_EXPORT
#endif #endif
#endif #endif

View File

@@ -16,7 +16,7 @@
#include <qpixmap.h> #include <qpixmap.h>
#include <qpainterpath.h> #include <qpainterpath.h>
#include <qmath.h> #include <qmath.h>
#include <QPainterPath>
static bool qwtHasScalablePen( const QPainter *painter ) static bool qwtHasScalablePen( const QPainter *painter )
{ {
const QPen pen = painter->pen(); const QPen pen = painter->pen();
@@ -37,7 +37,7 @@ static bool qwtHasScalablePen( const QPainter *painter )
return scalablePen; return scalablePen;
} }
static QRectF qwtStrokedPathRect( static QRectF qwtStrokedPathRect(
const QPainter *painter, const QPainterPath &path ) const QPainter *painter, const QPainterPath &path )
{ {
QPainterPathStroker stroker; QPainterPathStroker stroker;
@@ -63,8 +63,8 @@ static QRectF qwtStrokedPathRect(
return rect; return rect;
} }
static inline void qwtExecCommand( static inline void qwtExecCommand(
QPainter *painter, const QwtPainterCommand &cmd, QPainter *painter, const QwtPainterCommand &cmd,
QwtGraphic::RenderHints renderHints, QwtGraphic::RenderHints renderHints,
const QTransform &transform, const QTransform &transform,
const QTransform *initialTransform ) const QTransform *initialTransform )
@@ -121,7 +121,7 @@ static inline void qwtExecCommand(
case QwtPainterCommand::Image: case QwtPainterCommand::Image:
{ {
const QwtPainterCommand::ImageData *data = cmd.imageData(); const QwtPainterCommand::ImageData *data = cmd.imageData();
painter->drawImage( data->rect, data->image, painter->drawImage( data->rect, data->image,
data->subRect, data->flags ); data->subRect, data->flags );
break; break;
} }
@@ -129,44 +129,44 @@ static inline void qwtExecCommand(
{ {
const QwtPainterCommand::StateData *data = cmd.stateData(); const QwtPainterCommand::StateData *data = cmd.stateData();
if ( data->flags & QPaintEngine::DirtyPen ) if ( data->flags & QPaintEngine::DirtyPen )
painter->setPen( data->pen ); painter->setPen( data->pen );
if ( data->flags & QPaintEngine::DirtyBrush ) if ( data->flags & QPaintEngine::DirtyBrush )
painter->setBrush( data->brush ); painter->setBrush( data->brush );
if ( data->flags & QPaintEngine::DirtyBrushOrigin ) if ( data->flags & QPaintEngine::DirtyBrushOrigin )
painter->setBrushOrigin( data->brushOrigin ); painter->setBrushOrigin( data->brushOrigin );
if ( data->flags & QPaintEngine::DirtyFont ) if ( data->flags & QPaintEngine::DirtyFont )
painter->setFont( data->font ); painter->setFont( data->font );
if ( data->flags & QPaintEngine::DirtyBackground ) if ( data->flags & QPaintEngine::DirtyBackground )
{ {
painter->setBackgroundMode( data->backgroundMode ); painter->setBackgroundMode( data->backgroundMode );
painter->setBackground( data->backgroundBrush ); painter->setBackground( data->backgroundBrush );
} }
if ( data->flags & QPaintEngine::DirtyTransform ) if ( data->flags & QPaintEngine::DirtyTransform )
{ {
painter->setTransform( data->transform * transform ); painter->setTransform( data->transform * transform );
} }
if ( data->flags & QPaintEngine::DirtyClipEnabled ) if ( data->flags & QPaintEngine::DirtyClipEnabled )
painter->setClipping( data->isClipEnabled ); painter->setClipping( data->isClipEnabled );
if ( data->flags & QPaintEngine::DirtyClipRegion) if ( data->flags & QPaintEngine::DirtyClipRegion)
{ {
painter->setClipRegion( data->clipRegion, painter->setClipRegion( data->clipRegion,
data->clipOperation ); data->clipOperation );
} }
if ( data->flags & QPaintEngine::DirtyClipPath ) if ( data->flags & QPaintEngine::DirtyClipPath )
{ {
painter->setClipPath( data->clipPath, data->clipOperation ); painter->setClipPath( data->clipPath, data->clipOperation );
} }
if ( data->flags & QPaintEngine::DirtyHints) if ( data->flags & QPaintEngine::DirtyHints)
{ {
const QPainter::RenderHints hints = data->renderHints; const QPainter::RenderHints hints = data->renderHints;
@@ -186,10 +186,10 @@ static inline void qwtExecCommand(
hints.testFlag( QPainter::NonCosmeticDefaultPen ) ); hints.testFlag( QPainter::NonCosmeticDefaultPen ) );
} }
if ( data->flags & QPaintEngine::DirtyCompositionMode) if ( data->flags & QPaintEngine::DirtyCompositionMode)
painter->setCompositionMode( data->compositionMode ); painter->setCompositionMode( data->compositionMode );
if ( data->flags & QPaintEngine::DirtyOpacity) if ( data->flags & QPaintEngine::DirtyOpacity)
painter->setOpacity( data->opacity ); painter->setOpacity( data->opacity );
break; break;
@@ -209,7 +209,7 @@ public:
// QVector needs a default constructor // QVector needs a default constructor
} }
PathInfo( const QRectF &pointRect, PathInfo( const QRectF &pointRect,
const QRectF &boundingRect, bool scalablePen ): const QRectF &boundingRect, bool scalablePen ):
d_pointRect( pointRect ), d_pointRect( pointRect ),
d_boundingRect( boundingRect ), d_boundingRect( boundingRect ),
@@ -246,7 +246,7 @@ public:
return rect; return rect;
} }
inline double scaleFactorX( const QRectF& pathRect, inline double scaleFactorX( const QRectF& pathRect,
const QRectF &targetRect, bool scalePens ) const const QRectF &targetRect, bool scalePens ) const
{ {
if ( pathRect.width() <= 0.0 ) if ( pathRect.width() <= 0.0 )
@@ -257,7 +257,7 @@ public:
const double l = qAbs( pathRect.left() - p0.x() ); const double l = qAbs( pathRect.left() - p0.x() );
const double r = qAbs( pathRect.right() - p0.x() ); const double r = qAbs( pathRect.right() - p0.x() );
const double w = 2.0 * qMin( l, r ) const double w = 2.0 * qMin( l, r )
* targetRect.width() / pathRect.width(); * targetRect.width() / pathRect.width();
double sx; double sx;
@@ -267,7 +267,7 @@ public:
} }
else else
{ {
const double pw = qMax( const double pw = qMax(
qAbs( d_boundingRect.left() - d_pointRect.left() ), qAbs( d_boundingRect.left() - d_pointRect.left() ),
qAbs( d_boundingRect.right() - d_pointRect.right() ) ); qAbs( d_boundingRect.right() - d_pointRect.right() ) );
@@ -277,7 +277,7 @@ public:
return sx; return sx;
} }
inline double scaleFactorY( const QRectF& pathRect, inline double scaleFactorY( const QRectF& pathRect,
const QRectF &targetRect, bool scalePens ) const const QRectF &targetRect, bool scalePens ) const
{ {
if ( pathRect.height() <= 0.0 ) if ( pathRect.height() <= 0.0 )
@@ -288,7 +288,7 @@ public:
const double t = qAbs( pathRect.top() - p0.y() ); const double t = qAbs( pathRect.top() - p0.y() );
const double b = qAbs( pathRect.bottom() - p0.y() ); const double b = qAbs( pathRect.bottom() - p0.y() );
const double h = 2.0 * qMin( t, b ) const double h = 2.0 * qMin( t, b )
* targetRect.height() / pathRect.height(); * targetRect.height() / pathRect.height();
double sy; double sy;
@@ -298,7 +298,7 @@ public:
} }
else else
{ {
const double pw = const double pw =
qMax( qAbs( d_boundingRect.top() - d_pointRect.top() ), qMax( qAbs( d_boundingRect.top() - d_pointRect.top() ),
qAbs( d_boundingRect.bottom() - d_pointRect.bottom() ) ); qAbs( d_boundingRect.bottom() - d_pointRect.bottom() ) );
@@ -351,7 +351,7 @@ QwtGraphic::QwtGraphic():
/*! /*!
\brief Copy constructor \brief Copy constructor
\param other Source \param other Source
\sa operator=() \sa operator=()
*/ */
QwtGraphic::QwtGraphic( const QwtGraphic &other ): QwtGraphic::QwtGraphic( const QwtGraphic &other ):
@@ -370,7 +370,7 @@ QwtGraphic::~QwtGraphic()
/*! /*!
\brief Assignment operator \brief Assignment operator
\param other Source \param other Source
\return A reference of this object \return A reference of this object
*/ */
QwtGraphic& QwtGraphic::operator=(const QwtGraphic &other) QwtGraphic& QwtGraphic::operator=(const QwtGraphic &other)
@@ -382,10 +382,10 @@ QwtGraphic& QwtGraphic::operator=(const QwtGraphic &other)
} }
/*! /*!
\brief Clear all stored commands \brief Clear all stored commands
\sa isNull() \sa isNull()
*/ */
void QwtGraphic::reset() void QwtGraphic::reset()
{ {
d_data->commands.clear(); d_data->commands.clear();
d_data->pathInfos.clear(); d_data->pathInfos.clear();
@@ -459,7 +459,7 @@ QRectF QwtGraphic::boundingRect() const
} }
/*! /*!
The control point rectangle is the bounding rectangle The control point rectangle is the bounding rectangle
of all control points of the paths and the target of all control points of the paths and the target
rectangles of the images/pixmaps. rectangles of the images/pixmaps.
@@ -477,10 +477,10 @@ QRectF QwtGraphic::controlPointRect() const
/*! /*!
\brief Calculate the target rectangle for scaling the graphic \brief Calculate the target rectangle for scaling the graphic
\param sx Horizontal scaling factor \param sx Horizontal scaling factor
\param sy Vertical scaling factor \param sy Vertical scaling factor
\note In case of paths that are painted with a cosmetic pen \note In case of paths that are painted with a cosmetic pen
( see QPen::isCosmetic() ) the target rectangle is different to ( see QPen::isCosmetic() ) the target rectangle is different to
multiplying the bounding rectangle. multiplying the bounding rectangle.
@@ -499,7 +499,7 @@ QRectF QwtGraphic::scaledBoundingRect( double sx, double sy ) const
for ( int i = 0; i < d_data->pathInfos.size(); i++ ) for ( int i = 0; i < d_data->pathInfos.size(); i++ )
{ {
rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy, rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy,
!d_data->renderHints.testFlag( RenderPensUnscaled ) ); !d_data->renderHints.testFlag( RenderPensUnscaled ) );
} }
@@ -518,11 +518,11 @@ QSize QwtGraphic::sizeMetrics() const
The default size is used in all methods rendering the graphic, The default size is used in all methods rendering the graphic,
where no size is explicitly specified. Assigning an empty size where no size is explicitly specified. Assigning an empty size
means, that the default size will be calculated from the bounding means, that the default size will be calculated from the bounding
rectangle. rectangle.
The default setting is an empty size. The default setting is an empty size.
\param size Default size \param size Default size
\sa defaultSize(), boundingRect() \sa defaultSize(), boundingRect()
@@ -543,7 +543,7 @@ void QwtGraphic::setDefaultSize( const QSizeF &size )
of the bounding rectangle. of the bounding rectangle.
The default size is used in all methods rendering the graphic, The default size is used in all methods rendering the graphic,
where no size is explicitly specified. where no size is explicitly specified.
\return Default size \return Default size
\sa setDefaultSize(), boundingRect() \sa setDefaultSize(), boundingRect()
@@ -574,7 +574,7 @@ void QwtGraphic::render( QPainter *painter ) const
for ( int i = 0; i < numCommands; i++ ) for ( int i = 0; i < numCommands; i++ )
{ {
qwtExecCommand( painter, commands[i], qwtExecCommand( painter, commands[i],
d_data->renderHints, transform, d_data->initialTransform ); d_data->renderHints, transform, d_data->initialTransform );
} }
@@ -591,7 +591,7 @@ void QwtGraphic::render( QPainter *painter ) const
\param size Size for the scaled graphic \param size Size for the scaled graphic
\param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode
*/ */
void QwtGraphic::render( QPainter *painter, const QSizeF &size, void QwtGraphic::render( QPainter *painter, const QSizeF &size,
Qt::AspectRatioMode aspectRatioMode ) const Qt::AspectRatioMode aspectRatioMode ) const
{ {
const QRectF r( 0.0, 0.0, size.width(), size.height() ); const QRectF r( 0.0, 0.0, size.width(), size.height() );
@@ -607,13 +607,13 @@ void QwtGraphic::render( QPainter *painter, const QSizeF &size,
\param rect Rectangle for the scaled graphic \param rect Rectangle for the scaled graphic
\param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode
*/ */
void QwtGraphic::render( QPainter *painter, const QRectF &rect, void QwtGraphic::render( QPainter *painter, const QRectF &rect,
Qt::AspectRatioMode aspectRatioMode ) const Qt::AspectRatioMode aspectRatioMode ) const
{ {
if ( isEmpty() || rect.isEmpty() ) if ( isEmpty() || rect.isEmpty() )
return; return;
double sx = 1.0; double sx = 1.0;
double sy = 1.0; double sy = 1.0;
if ( d_data->pointRect.width() > 0.0 ) if ( d_data->pointRect.width() > 0.0 )
@@ -622,20 +622,20 @@ void QwtGraphic::render( QPainter *painter, const QRectF &rect,
if ( d_data->pointRect.height() > 0.0 ) if ( d_data->pointRect.height() > 0.0 )
sy = rect.height() / d_data->pointRect.height(); sy = rect.height() / d_data->pointRect.height();
const bool scalePens = const bool scalePens =
!d_data->renderHints.testFlag( RenderPensUnscaled ); !d_data->renderHints.testFlag( RenderPensUnscaled );
for ( int i = 0; i < d_data->pathInfos.size(); i++ ) for ( int i = 0; i < d_data->pathInfos.size(); i++ )
{ {
const PathInfo info = d_data->pathInfos[i]; const PathInfo info = d_data->pathInfos[i];
const double ssx = info.scaleFactorX( const double ssx = info.scaleFactorX(
d_data->pointRect, rect, scalePens ); d_data->pointRect, rect, scalePens );
if ( ssx > 0.0 ) if ( ssx > 0.0 )
sx = qMin( sx, ssx ); sx = qMin( sx, ssx );
const double ssy = info.scaleFactorY( const double ssy = info.scaleFactorY(
d_data->pointRect, rect, scalePens ); d_data->pointRect, rect, scalePens );
if ( ssy > 0.0 ) if ( ssy > 0.0 )
@@ -665,7 +665,7 @@ void QwtGraphic::render( QPainter *painter, const QRectF &rect,
if ( !scalePens && transform.isScaling() ) if ( !scalePens && transform.isScaling() )
{ {
// we don't want to scale pens according to sx/sy, // we don't want to scale pens according to sx/sy,
// but we want to apply the scaling from the // but we want to apply the scaling from the
// painter transformation later // painter transformation later
d_data->initialTransform = new QTransform(); d_data->initialTransform = new QTransform();
@@ -689,10 +689,10 @@ void QwtGraphic::render( QPainter *painter, const QRectF &rect,
\param painter Qt painter \param painter Qt painter
\param pos Reference point, where to render \param pos Reference point, where to render
\param alignment Flags how to align the target rectangle \param alignment Flags how to align the target rectangle
to pos. to pos.
*/ */
void QwtGraphic::render( QPainter *painter, void QwtGraphic::render( QPainter *painter,
const QPointF &pos, Qt::Alignment alignment ) const const QPointF &pos, Qt::Alignment alignment ) const
{ {
QRectF r( pos, defaultSize() ); QRectF r( pos, defaultSize() );
@@ -728,16 +728,16 @@ void QwtGraphic::render( QPainter *painter,
/*! /*!
\brief Convert the graphic to a QPixmap \brief Convert the graphic to a QPixmap
All pixels of the pixmap get initialized by Qt::transparent All pixels of the pixmap get initialized by Qt::transparent
before the graphic is scaled and rendered on it. before the graphic is scaled and rendered on it.
The size of the pixmap is the default size ( ceiled to integers ) The size of the pixmap is the default size ( ceiled to integers )
of the graphic. of the graphic.
\return The graphic as pixmap in default size \return The graphic as pixmap in default size
\sa defaultSize(), toImage(), render() \sa defaultSize(), toImage(), render()
*/ */
QPixmap QwtGraphic::toPixmap() const QPixmap QwtGraphic::toPixmap() const
{ {
if ( isNull() ) if ( isNull() )
@@ -818,7 +818,7 @@ QImage QwtGraphic::toImage( const QSize &size,
/*! /*!
\brief Convert the graphic to a QImage \brief Convert the graphic to a QImage
All pixels of the image get initialized by 0 ( transparent ) All pixels of the image get initialized by 0 ( transparent )
before the graphic is scaled and rendered on it. before the graphic is scaled and rendered on it.
@@ -826,7 +826,7 @@ QImage QwtGraphic::toImage( const QSize &size,
The size of the image is the default size ( ceiled to integers ) The size of the image is the default size ( ceiled to integers )
of the graphic. of the graphic.
\return The graphic as image in default size \return The graphic as image in default size
\sa defaultSize(), toPixmap(), render() \sa defaultSize(), toPixmap(), render()
*/ */
@@ -873,7 +873,7 @@ void QwtGraphic::drawPath( const QPainterPath &path )
QRectF pointRect = scaledPath.boundingRect(); QRectF pointRect = scaledPath.boundingRect();
QRectF boundingRect = pointRect; QRectF boundingRect = pointRect;
if ( painter->pen().style() != Qt::NoPen if ( painter->pen().style() != Qt::NoPen
&& painter->pen().brush().style() != Qt::NoBrush ) && painter->pen().brush().style() != Qt::NoBrush )
{ {
boundingRect = qwtStrokedPathRect( painter, path ); boundingRect = qwtStrokedPathRect( painter, path );
@@ -882,7 +882,7 @@ void QwtGraphic::drawPath( const QPainterPath &path )
updateControlPointRect( pointRect ); updateControlPointRect( pointRect );
updateBoundingRect( boundingRect ); updateBoundingRect( boundingRect );
d_data->pathInfos += PathInfo( pointRect, d_data->pathInfos += PathInfo( pointRect,
boundingRect, qwtHasScalablePen( painter ) ); boundingRect, qwtHasScalablePen( painter ) );
} }
} }
@@ -896,7 +896,7 @@ void QwtGraphic::drawPath( const QPainterPath &path )
\sa QPaintEngine::drawPixmap() \sa QPaintEngine::drawPixmap()
*/ */
void QwtGraphic::drawPixmap( const QRectF &rect, void QwtGraphic::drawPixmap( const QRectF &rect,
const QPixmap &pixmap, const QRectF &subRect ) const QPixmap &pixmap, const QRectF &subRect )
{ {
const QPainter *painter = paintEngine()->painter(); const QPainter *painter = paintEngine()->painter();
@@ -996,8 +996,8 @@ void QwtGraphic::setCommands( QVector< QwtPainterCommand > &commands )
if ( numCommands <= 0 ) if ( numCommands <= 0 )
return; return;
// to calculate a proper bounding rectangle we don't simply copy // to calculate a proper bounding rectangle we don't simply copy
// the commands. // the commands.
const QwtPainterCommand *cmds = commands.constData(); const QwtPainterCommand *cmds = commands.constData();

View File

@@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library * Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen * Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann * Copyright (C) 2002 Uwe Rathmann
@@ -15,7 +15,6 @@
#include <qmetatype.h> #include <qmetatype.h>
#include <qimage.h> #include <qimage.h>
#include <qpixmap.h> #include <qpixmap.h>
#include "qpainterpath.h"
class QwtPainterCommand; class QwtPainterCommand;
@@ -37,37 +36,37 @@ class QwtPainterCommand;
- QSvgRenderer/QSvgGenerator\n - QSvgRenderer/QSvgGenerator\n
Unfortunately QSvgRenderer hides to much information about Unfortunately QSvgRenderer hides to much information about
its nodes in internal APIs, that are necessary for proper its nodes in internal APIs, that are necessary for proper
layout calculations. Also it is derived from QObject and layout calculations. Also it is derived from QObject and
can't be copied like QImage/QPixmap. can't be copied like QImage/QPixmap.
QwtGraphic maps all scalable drawing primitives to a QPainterPath QwtGraphic maps all scalable drawing primitives to a QPainterPath
and stores them together with the painter state changes and stores them together with the painter state changes
( pen, brush, transformation ... ) in a list of QwtPaintCommands. ( pen, brush, transformation ... ) in a list of QwtPaintCommands.
For being a complete QPaintDevice it also stores pixmaps or images, For being a complete QPaintDevice it also stores pixmaps or images,
what is somehow against the idea of the class, because these objects what is somehow against the idea of the class, because these objects
can't be scaled without a loss in quality. can't be scaled without a loss in quality.
The main issue about scaling a QwtGraphic object are the pens used for The main issue about scaling a QwtGraphic object are the pens used for
drawing the outlines of the painter paths. While non cosmetic pens drawing the outlines of the painter paths. While non cosmetic pens
( QPen::isCosmetic() ) are scaled with the same ratio as the path, ( QPen::isCosmetic() ) are scaled with the same ratio as the path,
cosmetic pens have a fixed width. A graphic might have paths with cosmetic pens have a fixed width. A graphic might have paths with
different pens - cosmetic and non-cosmetic. different pens - cosmetic and non-cosmetic.
QwtGraphic caches 2 different rectangles: QwtGraphic caches 2 different rectangles:
- control point rectangle\n - control point rectangle\n
The control point rectangle is the bounding rectangle of all The control point rectangle is the bounding rectangle of all
control point rectangles of the painter paths, or the target control point rectangles of the painter paths, or the target
rectangle of the pixmaps/images. rectangle of the pixmaps/images.
- bounding rectangle\n - bounding rectangle\n
The bounding rectangle extends the control point rectangle by The bounding rectangle extends the control point rectangle by
what is needed for rendering the outline with an unscaled pen. what is needed for rendering the outline with an unscaled pen.
Because the offset for drawing the outline depends on the shape Because the offset for drawing the outline depends on the shape
of the painter path ( the peak of a triangle is different than the flat side ) of the painter path ( the peak of a triangle is different than the flat side )
scaling with a fixed aspect ratio always needs to be calculated from the scaling with a fixed aspect ratio always needs to be calculated from the
control point rectangle. control point rectangle.
\sa QwtPainterCommand \sa QwtPainterCommand
@@ -75,14 +74,14 @@ class QwtPainterCommand;
class QWT_EXPORT QwtGraphic: public QwtNullPaintDevice class QWT_EXPORT QwtGraphic: public QwtNullPaintDevice
{ {
public: public:
/*! /*!
Hint how to render a graphic Hint how to render a graphic
\sa setRenderHint(), testRenderHint() \sa setRenderHint(), testRenderHint()
*/ */
enum RenderHint enum RenderHint
{ {
/*! /*!
When rendering a QwtGraphic a specific scaling between When rendering a QwtGraphic a specific scaling between
the controlPointRect() and the coordinates of the target rectangle the controlPointRect() and the coordinates of the target rectangle
is set up internally in render(). is set up internally in render().
@@ -96,7 +95,7 @@ public:
RenderPensUnscaled = 0x1 RenderPensUnscaled = 0x1
}; };
/*! /*!
\brief Render hints \brief Render hints
The default setting is to disable all hints The default setting is to disable all hints
@@ -117,21 +116,21 @@ public:
void render( QPainter * ) const; void render( QPainter * ) const;
void render( QPainter *, const QSizeF &, void render( QPainter *, const QSizeF &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
void render( QPainter *, const QRectF &, void render( QPainter *, const QRectF &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
void render( QPainter *, const QPointF &, void render( QPainter *, const QPointF &,
Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const; Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
QPixmap toPixmap() const; QPixmap toPixmap() const;
QPixmap toPixmap( const QSize &, QPixmap toPixmap( const QSize &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
QImage toImage() const; QImage toImage() const;
QImage toImage( const QSize &, QImage toImage( const QSize &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
QRectF scaledBoundingRect( double sx, double sy ) const; QRectF scaledBoundingRect( double sx, double sy ) const;
@@ -144,7 +143,7 @@ public:
void setDefaultSize( const QSizeF & ); void setDefaultSize( const QSizeF & );
QSizeF defaultSize() const; QSizeF defaultSize() const;
void setRenderHint( RenderHint, bool on = true ); void setRenderHint( RenderHint, bool on = true );
bool testRenderHint( RenderHint ) const; bool testRenderHint( RenderHint ) const;

View File

@@ -130,9 +130,9 @@ QwtInterval QwtInterval::unite( const QwtInterval &other ) const
return united; return united;
} }
/*! /*!
\brief Intersect 2 intervals \brief Intersect 2 intervals
\param other Interval to be intersect with \param other Interval to be intersect with
\return Intersection \return Intersection
*/ */
@@ -197,7 +197,7 @@ QwtInterval QwtInterval::intersect( const QwtInterval &other ) const
return intersected; return intersected;
} }
/*! /*!
\brief Unite this interval with the given interval. \brief Unite this interval with the given interval.
\param other Interval to be united with \param other Interval to be united with
@@ -209,7 +209,7 @@ QwtInterval& QwtInterval::operator|=( const QwtInterval &other )
return *this; return *this;
} }
/*! /*!
\brief Intersect this interval with the given interval. \brief Intersect this interval with the given interval.
\param other Interval to be intersected with \param other Interval to be intersected with

View File

@@ -27,7 +27,7 @@ class QWT_EXPORT QwtInterval
{ {
public: public:
/*! /*!
Flag indicating if a border is included or excluded Flag indicating if a border is included or excluded
\sa setBorderFlags(), borderFlags() \sa setBorderFlags(), borderFlags()
*/ */
enum BorderFlag enum BorderFlag
@@ -57,7 +57,7 @@ public:
QwtInterval normalized() const; QwtInterval normalized() const;
QwtInterval inverted() 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;
bool operator!=( const QwtInterval & ) const; bool operator!=( const QwtInterval & ) const;
@@ -231,7 +231,7 @@ inline double QwtInterval::width() const
/*! /*!
\brief Intersection of two intervals \brief Intersection of two intervals
\param other Interval to intersect with \param other Interval to intersect with
\return Intersection of this and other \return Intersection of this and other
@@ -257,7 +257,7 @@ inline QwtInterval QwtInterval::operator|(
return unite( other ); return unite( other );
} }
/*! /*!
\brief Compare two intervals \brief Compare two intervals
\param other Interval to compare with \param other Interval to compare with
@@ -269,7 +269,7 @@ inline bool QwtInterval::operator==( const QwtInterval &other ) const
( d_maxValue == other.d_maxValue ) && ( d_maxValue == other.d_maxValue ) &&
( d_borderFlags == other.d_borderFlags ); ( d_borderFlags == other.d_borderFlags );
} }
/*! /*!
\brief Compare two intervals \brief Compare two intervals
\param other Interval to compare with \param other Interval to compare with

View File

@@ -68,7 +68,7 @@ QwtIntervalSymbol::~QwtIntervalSymbol()
} }
//! \brief Assignment operator //! \brief Assignment operator
QwtIntervalSymbol &QwtIntervalSymbol::operator=( QwtIntervalSymbol &QwtIntervalSymbol::operator=(
const QwtIntervalSymbol &other ) const QwtIntervalSymbol &other )
{ {
*d_data = *other.d_data; *d_data = *other.d_data;
@@ -76,14 +76,14 @@ QwtIntervalSymbol &QwtIntervalSymbol::operator=(
} }
//! \brief Compare two symbols //! \brief Compare two symbols
bool QwtIntervalSymbol::operator==( bool QwtIntervalSymbol::operator==(
const QwtIntervalSymbol &other ) const const QwtIntervalSymbol &other ) const
{ {
return *d_data == *other.d_data; return *d_data == *other.d_data;
} }
//! \brief Compare two symbols //! \brief Compare two symbols
bool QwtIntervalSymbol::operator!=( bool QwtIntervalSymbol::operator!=(
const QwtIntervalSymbol &other ) const const QwtIntervalSymbol &other ) const
{ {
return !( *d_data == *other.d_data ); return !( *d_data == *other.d_data );
@@ -152,9 +152,9 @@ const QBrush& QwtIntervalSymbol::brush() const
return d_data->brush; return d_data->brush;
} }
/*! /*!
Build and assign a pen Build and assign a pen
In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
non cosmetic ( see QPen::isCosmetic() ). This method has been introduced non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
to hide this incompatibility. to hide this incompatibility.
@@ -162,12 +162,12 @@ const QBrush& QwtIntervalSymbol::brush() const
\param color Pen color \param color Pen color
\param width Pen width \param width Pen width
\param style Pen style \param style Pen style
\sa pen(), brush() \sa pen(), brush()
*/ */
void QwtIntervalSymbol::setPen( const QColor &color, void QwtIntervalSymbol::setPen( const QColor &color,
qreal width, Qt::PenStyle style ) qreal width, Qt::PenStyle style )
{ {
setPen( QPen( color, width, style ) ); setPen( QPen( color, width, style ) );
} }
@@ -221,7 +221,7 @@ void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,
QwtPainter::drawLine( painter, p1, p2 ); QwtPainter::drawLine( painter, p1, p2 );
if ( d_data->width > pw ) if ( d_data->width > pw )
{ {
if ( ( orientation == Qt::Horizontal ) if ( ( orientation == Qt::Horizontal )
&& ( p1.y() == p2.y() ) ) && ( p1.y() == p2.y() ) )
{ {
const double sw = d_data->width; const double sw = d_data->width;
@@ -232,7 +232,7 @@ void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,
QwtPainter::drawLine( painter, QwtPainter::drawLine( painter,
p2.x(), y, p2.x(), y + sw ); p2.x(), y, p2.x(), y + sw );
} }
else if ( ( orientation == Qt::Vertical ) else if ( ( orientation == Qt::Vertical )
&& ( p1.x() == p2.x() ) ) && ( p1.x() == p2.x() ) )
{ {
const double sw = d_data->width; const double sw = d_data->width;
@@ -273,7 +273,7 @@ void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,
} }
else else
{ {
if ( ( orientation == Qt::Horizontal ) if ( ( orientation == Qt::Horizontal )
&& ( p1.y() == p2.y() ) ) && ( p1.y() == p2.y() ) )
{ {
const double sw = d_data->width; const double sw = d_data->width;

View File

@@ -65,7 +65,7 @@ public:
void setWidth( int ); void setWidth( int );
int width() const; int width() const;
void setBrush( const QBrush& b ); void setBrush( const QBrush & );
const QBrush& brush() const; const QBrush& brush() const;
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
@@ -79,7 +79,6 @@ public:
const QPointF& from, const QPointF& to ) const; const QPointF& from, const QPointF& to ) const;
private: private:
class PrivateData; class PrivateData;
PrivateData* d_data; PrivateData* d_data;
}; };

View File

@@ -119,7 +119,7 @@ QwtKnob::QwtKnob( QWidget* parent ):
setScale( 0.0, 10.0 ); setScale( 0.0, 10.0 );
setValue( 0.0 ); setValue( 0.0 );
setSizePolicy( QSizePolicy::MinimumExpanding, setSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding ); QSizePolicy::MinimumExpanding );
} }
@@ -130,7 +130,7 @@ QwtKnob::~QwtKnob()
} }
/*! /*!
\brief Set the knob type \brief Set the knob type
\param knobStyle Knob type \param knobStyle Knob type
\sa knobStyle(), setBorderWidth() \sa knobStyle(), setBorderWidth()
@@ -185,7 +185,7 @@ QwtKnob::MarkerStyle QwtKnob::markerStyle() const
360 ( so that the knob can be turned several times around its axis ) 360 ( so that the knob can be turned several times around its axis )
have to be set using setNumTurns(). have to be set using setNumTurns().
The default angle is 270 degrees. The default angle is 270 degrees.
\sa totalAngle(), setNumTurns() \sa totalAngle(), setNumTurns()
*/ */
@@ -205,7 +205,7 @@ void QwtKnob::setTotalAngle ( double angle )
} }
} }
/*! /*!
\return the total angle \return the total angle
\sa setTotalAngle(), setNumTurns(), numTurns() \sa setTotalAngle(), setNumTurns(), numTurns()
*/ */
@@ -222,7 +222,7 @@ double QwtKnob::totalAngle() const
\sa numTurns(), totalAngle(), setTotalAngle() \sa numTurns(), totalAngle(), setTotalAngle()
*/ */
void QwtKnob::setNumTurns( int numTurns ) void QwtKnob::setNumTurns( int numTurns )
{ {
numTurns = qMax( numTurns, 1 ); numTurns = qMax( numTurns, 1 );
@@ -244,7 +244,7 @@ void QwtKnob::setNumTurns( int numTurns )
} }
/*! /*!
\return Number of turns. \return Number of turns.
When the total angle is below 360° numTurns() is ceiled to 1. When the total angle is below 360° numTurns() is ceiled to 1.
\sa setNumTurns(), setTotalAngle(), totalAngle() \sa setNumTurns(), setTotalAngle(), totalAngle()
@@ -335,7 +335,7 @@ QRect QwtKnob::knobRect() const
{ {
r.moveBottom( cr.bottom() - d ); r.moveBottom( cr.bottom() - d );
} }
else else
{ {
r.moveCenter( QPoint( r.center().x(), cr.center().y() ) ); r.moveCenter( QPoint( r.center().x(), cr.center().y() ) );
} }
@@ -400,7 +400,7 @@ double QwtKnob::scrolledTo( const QPoint &pos ) const
if ( !wrapping() ) if ( !wrapping() )
{ {
const double boundedAngle = const double boundedAngle =
qBound( scaleMap().p1(), angle, scaleMap().p2() ); qBound( scaleMap().p1(), angle, scaleMap().p2() );
d_data->mouseOffset += ( boundedAngle - angle ); d_data->mouseOffset += ( boundedAngle - angle );
@@ -431,7 +431,7 @@ double QwtKnob::scrolledTo( const QPoint &pos ) const
return scaleMap().invTransform( angle ); return scaleMap().invTransform( angle );
} }
/*! /*!
Handle QEvent::StyleChange and QEvent::FontChange; Handle QEvent::StyleChange and QEvent::FontChange;
\param event Change event \param event Change event
*/ */
@@ -478,7 +478,7 @@ void QwtKnob::paintEvent( QPaintEvent *event )
drawKnob( &painter, knobRect ); drawKnob( &painter, knobRect );
drawMarker( &painter, knobRect, drawMarker( &painter, knobRect,
qwtNormalizeDegrees( scaleMap().transform( value() ) ) ); qwtNormalizeDegrees( scaleMap().transform( value() ) ) );
painter.setRenderHint( QPainter::Antialiasing, false ); painter.setRenderHint( QPainter::Antialiasing, false );
@@ -513,7 +513,7 @@ void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
gradient.setColorAt( 0.7, c2 ); gradient.setColorAt( 0.7, c2 );
gradient.setColorAt( 1.0, c2 ); gradient.setColorAt( 1.0, c2 );
pen = QPen( gradient, d_data->borderWidth ); pen = QPen( gradient, d_data->borderWidth );
} }
QBrush brush; QBrush brush;
@@ -524,7 +524,7 @@ void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
double off = 0.3 * knobRect.width(); double off = 0.3 * knobRect.width();
QRadialGradient gradient( knobRect.center(), QRadialGradient gradient( knobRect.center(),
knobRect.width(), knobRect.topLeft() + QPointF( off, off ) ); knobRect.width(), knobRect.topLeft() + QPointF( off, off ) );
gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) ); gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) );
gradient.setColorAt( 1.0, palette().color( QPalette::Button ) ); gradient.setColorAt( 1.0, palette().color( QPalette::Button ) );
@@ -552,7 +552,7 @@ void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
} }
case QwtKnob::Sunken: case QwtKnob::Sunken:
{ {
QLinearGradient gradient( QLinearGradient gradient(
knobRect.topLeft(), knobRect.bottomRight() ); knobRect.topLeft(), knobRect.bottomRight() );
gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) ); gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) );
gradient.setColorAt( 0.5, palette().color( QPalette::Button ) ); gradient.setColorAt( 0.5, palette().color( QPalette::Button ) );
@@ -577,10 +577,10 @@ void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
\param painter Painter \param painter Painter
\param rect Bounding rectangle of the knob without scale \param rect Bounding rectangle of the knob without scale
\param angle Angle of the marker in degrees \param angle Angle of the marker in degrees
( clockwise, 0 at the 12 o'clock position ) ( clockwise, 0 at the 12 o'clock position )
*/ */
void QwtKnob::drawMarker( QPainter *painter, void QwtKnob::drawMarker( QPainter *painter,
const QRectF &rect, double angle ) const const QRectF &rect, double angle ) const
{ {
if ( d_data->markerStyle == NoMarker || !isValid() ) if ( d_data->markerStyle == NoMarker || !isValid() )
@@ -607,13 +607,13 @@ void QwtKnob::drawMarker( QPainter *painter,
case Notch: case Notch:
case Nub: case Nub:
{ {
const double dotWidth = const double dotWidth =
qMin( double( markerSize ), radius); qMin( double( markerSize ), radius);
const double dotCenterDist = radius - 0.5 * dotWidth; const double dotCenterDist = radius - 0.5 * dotWidth;
if ( dotCenterDist > 0.0 ) if ( dotCenterDist > 0.0 )
{ {
const QPointF center( xm - sinA * dotCenterDist, const QPointF center( xm - sinA * dotCenterDist,
ym - cosA * dotCenterDist ); ym - cosA * dotCenterDist );
QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth ); QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth );
@@ -625,7 +625,7 @@ void QwtKnob::drawMarker( QPainter *painter,
if ( d_data->markerStyle == Notch ) if ( d_data->markerStyle == Notch )
qSwap( c1, c2 ); qSwap( c1, c2 );
QLinearGradient gradient( QLinearGradient gradient(
ellipse.topLeft(), ellipse.bottomRight() ); ellipse.topLeft(), ellipse.bottomRight() );
gradient.setColorAt( 0.0, c1 ); gradient.setColorAt( 0.0, c1 );
gradient.setColorAt( 1.0, c2 ); gradient.setColorAt( 1.0, c2 );
@@ -639,13 +639,13 @@ void QwtKnob::drawMarker( QPainter *painter,
} }
case Dot: case Dot:
{ {
const double dotWidth = const double dotWidth =
qMin( double( markerSize ), radius); qMin( double( markerSize ), radius);
const double dotCenterDist = radius - 0.5 * dotWidth; const double dotCenterDist = radius - 0.5 * dotWidth;
if ( dotCenterDist > 0.0 ) if ( dotCenterDist > 0.0 )
{ {
const QPointF center( xm - sinA * dotCenterDist, const QPointF center( xm - sinA * dotCenterDist,
ym - cosA * dotCenterDist ); ym - cosA * dotCenterDist );
QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth ); QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth );
@@ -680,7 +680,7 @@ void QwtKnob::drawMarker( QPainter *painter,
painter->translate( rect.center() ); painter->translate( rect.center() );
painter->rotate( angle - 90.0 ); painter->rotate( angle - 90.0 );
QPolygonF polygon; QPolygonF polygon;
polygon += QPointF( re, 0.0 ); polygon += QPointF( re, 0.0 );
polygon += QPointF( rb, 0.5 * ( re - rb ) ); polygon += QPointF( rb, 0.5 * ( re - rb ) );
@@ -704,7 +704,7 @@ void QwtKnob::drawMarker( QPainter *painter,
\param painter Painter \param painter Painter
*/ */
void QwtKnob::drawFocusIndicator( QPainter *painter ) const void QwtKnob::drawFocusIndicator( QPainter *painter ) const
{ {
const QRect cr = contentsRect(); const QRect cr = contentsRect();
int w = d_data->knobWidth; int w = d_data->knobWidth;
@@ -722,13 +722,13 @@ void QwtKnob::drawFocusIndicator( QPainter *painter ) const
focusRect.moveCenter( cr.center() ); focusRect.moveCenter( cr.center() );
QwtPainter::drawFocusRect( painter, this, focusRect ); QwtPainter::drawFocusRect( painter, this, focusRect );
} }
/*! /*!
\brief Set the alignment of the knob \brief Set the alignment of the knob
Similar to a QLabel::alignment() the flags decide how Similar to a QLabel::alignment() the flags decide how
to align the knob inside of contentsRect(). to align the knob inside of contentsRect().
The default setting is Qt::AlignCenter The default setting is Qt::AlignCenter
@@ -757,13 +757,13 @@ Qt::Alignment QwtKnob::alignment() const
/*! /*!
\brief Change the knob's width. \brief Change the knob's width.
Setting a fixed value for the diameter of the knob Setting a fixed value for the diameter of the knob
is helpful for aligning several knobs in a row. is helpful for aligning several knobs in a row.
\param width New width \param width New width
\sa knobWidth(), setAlignment() \sa knobWidth(), setAlignment()
\note Modifies the sizePolicy() \note Modifies the sizePolicy()
*/ */
void QwtKnob::setKnobWidth( int width ) void QwtKnob::setKnobWidth( int width )
{ {
@@ -827,7 +827,7 @@ void QwtKnob::setMarkerSize( int size )
} }
} }
/*! /*!
\return Marker size \return Marker size
\sa setMarkerSize() \sa setMarkerSize()
*/ */

View File

@@ -25,9 +25,9 @@ class QwtRoundScaleDraw;
The layout of the knob depends on the knobWidth(). The layout of the knob depends on the knobWidth().
- width > 0 - width > 0
The diameter of the knob is fixed and the knob is aligned The diameter of the knob is fixed and the knob is aligned
according to the alignment() flags inside of the contentsRect(). according to the alignment() flags inside of the contentsRect().
- width <= 0 - width <= 0
The knob is extended to the minimum of width/height of the contentsRect() The knob is extended to the minimum of width/height of the contentsRect()
@@ -35,7 +35,7 @@ class QwtRoundScaleDraw;
Setting a fixed knobWidth() is helpful to align several knobs with different Setting a fixed knobWidth() is helpful to align several knobs with different
scale labels. scale labels.
\image html knob.png \image html knob.png
*/ */
@@ -55,7 +55,7 @@ class QWT_EXPORT QwtKnob: public QwtAbstractSlider
Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
public: public:
/*! /*!
\brief Style of the knob surface \brief Style of the knob surface
Depending on the KnobStyle the surface of the knob is Depending on the KnobStyle the surface of the knob is
@@ -71,13 +71,13 @@ public:
//! Build a gradient from QPalette::Midlight and QPalette::Button //! Build a gradient from QPalette::Midlight and QPalette::Button
Raised, Raised,
/*! /*!
Build a gradient from QPalette::Midlight, QPalette::Button Build a gradient from QPalette::Midlight, QPalette::Button
and QPalette::Midlight and QPalette::Midlight
*/ */
Sunken, Sunken,
/*! /*!
Build a radial gradient from QPalette::Button Build a radial gradient from QPalette::Button
like it is used for QDial in various Qt styles. like it is used for QDial in various Qt styles.
*/ */
@@ -86,37 +86,37 @@ public:
/*! /*!
\brief Marker type \brief Marker type
The marker indicates the current value on the knob The marker indicates the current value on the knob
The default setting is a Notch marker. The default setting is a Notch marker.
\sa setMarkerStyle(), setMarkerSize() \sa setMarkerStyle(), setMarkerSize()
*/ */
enum MarkerStyle enum MarkerStyle
{ {
//! Don't paint any marker //! Don't paint any marker
NoMarker = -1, NoMarker = -1,
//! Paint a single tick in QPalette::ButtonText color //! Paint a single tick in QPalette::ButtonText color
Tick, Tick,
//! Paint a triangle in QPalette::ButtonText color //! Paint a triangle in QPalette::ButtonText color
Triangle, Triangle,
//! Paint a circle in QPalette::ButtonText color //! Paint a circle in QPalette::ButtonText color
Dot, Dot,
/*! /*!
Draw a raised ellipse with a gradient build from Draw a raised ellipse with a gradient build from
QPalette::Light and QPalette::Mid QPalette::Light and QPalette::Mid
*/ */
Nub, Nub,
/*! /*!
Draw a sunken ellipse with a gradient build from Draw a sunken ellipse with a gradient build from
QPalette::Light and QPalette::Mid QPalette::Light and QPalette::Mid
*/ */
Notch Notch
}; };
explicit QwtKnob( QWidget* parent = NULL ); explicit QwtKnob( QWidget* parent = NULL );
@@ -137,7 +137,7 @@ public:
void setKnobStyle( KnobStyle ); void setKnobStyle( KnobStyle );
KnobStyle knobStyle() const; KnobStyle knobStyle() const;
void setBorderWidth( int bw ); void setBorderWidth( int );
int borderWidth() const; int borderWidth() const;
void setMarkerStyle( MarkerStyle ); void setMarkerStyle( MarkerStyle );
@@ -164,8 +164,8 @@ protected:
virtual void drawFocusIndicator( QPainter * ) const; virtual void drawFocusIndicator( QPainter * ) const;
virtual void drawMarker( QPainter *, virtual void drawMarker( QPainter *,
const QRectF &, double arc ) const; const QRectF &, double angle ) const;
virtual double scrolledTo( const QPoint & ) const; virtual double scrolledTo( const QPoint & ) const;
virtual bool isScrollPosition( const QPoint & ) const; virtual bool isScrollPosition( const QPoint & ) const;

View File

@@ -49,7 +49,7 @@ private:
QList< Entry > d_entries; QList< Entry > d_entries;
}; };
void QwtLegendMap::insert( const QVariant &itemInfo, void QwtLegendMap::insert( const QVariant &itemInfo,
const QList<QWidget *> &widgets ) const QList<QWidget *> &widgets )
{ {
for ( int i = 0; i < d_entries.size(); i++ ) for ( int i = 0; i < d_entries.size(); i++ )
@@ -141,7 +141,7 @@ public:
class QwtLegend::PrivateData::LegendView: public QScrollArea class QwtLegend::PrivateData::LegendView: public QScrollArea
{ {
public: public:
LegendView( QWidget *parent ): explicit LegendView( QWidget *parent ):
QScrollArea( parent ) QScrollArea( parent )
{ {
contentsWidget = new QWidget( this ); contentsWidget = new QWidget( this );
@@ -295,6 +295,8 @@ void QwtLegend::setMaxColumns( uint numColums )
d_data->view->contentsWidget->layout() ); d_data->view->contentsWidget->layout() );
if ( tl ) if ( tl )
tl->setMaxColumns( numColums ); tl->setMaxColumns( numColums );
updateGeometry();
} }
/*! /*!
@@ -341,7 +343,7 @@ QwtLegendData::Mode QwtLegend::defaultItemMode() const
} }
/*! /*!
The contents widget is the only child of the viewport of The contents widget is the only child of the viewport of
the internal QScrollArea and the parent widget of all legend items. the internal QScrollArea and the parent widget of all legend items.
\return Container widget of the legend items \return Container widget of the legend items
@@ -370,7 +372,7 @@ QScrollBar *QwtLegend::verticalScrollBar() const
} }
/*! /*!
The contents widget is the only child of the viewport of The contents widget is the only child of the viewport of
the internal QScrollArea and the parent widget of all legend items. the internal QScrollArea and the parent widget of all legend items.
\return Container widget of the legend items \return Container widget of the legend items
@@ -385,18 +387,18 @@ const QWidget *QwtLegend::contentsWidget() const
\brief Update the entries for an item \brief Update the entries for an item
\param itemInfo Info 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, void QwtLegend::updateLegend( const QVariant &itemInfo,
const QList<QwtLegendData> &data ) const QList<QwtLegendData> &legendData )
{ {
QList<QWidget *> widgetList = legendWidgets( itemInfo ); QList<QWidget *> widgetList = legendWidgets( itemInfo );
if ( widgetList.size() != data.size() ) if ( widgetList.size() != legendData.size() )
{ {
QLayout *contentsLayout = d_data->view->contentsWidget->layout(); QLayout *contentsLayout = d_data->view->contentsWidget->layout();
while ( widgetList.size() > data.size() ) while ( widgetList.size() > legendData.size() )
{ {
QWidget *w = widgetList.takeLast(); QWidget *w = widgetList.takeLast();
@@ -409,9 +411,13 @@ void QwtLegend::updateLegend( const QVariant &itemInfo,
w->deleteLater(); 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 ) if ( contentsLayout )
contentsLayout->addWidget( widget ); contentsLayout->addWidget( widget );
@@ -440,9 +446,9 @@ void QwtLegend::updateLegend( const QVariant &itemInfo,
updateTabOrder(); updateTabOrder();
} }
for ( int i = 0; i < data.size(); i++ ) for ( int i = 0; i < legendData.size(); i++ )
updateWidget( widgetList[i], data[i] ); updateWidget( widgetList[i], legendData[i] );
} }
/*! /*!
@@ -450,41 +456,41 @@ void QwtLegend::updateLegend( const QVariant &itemInfo,
The default implementation returns a QwtLegendLabel. 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 \return Widget representing data on the legend
\note updateWidget() will called soon after createWidget() \note updateWidget() will called soon after createWidget()
with the same attributes. 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(); QwtLegendLabel *label = new QwtLegendLabel();
label->setItemMode( defaultItemMode() ); label->setItemMode( defaultItemMode() );
connect( label, SIGNAL( clicked() ), SLOT( itemClicked() ) ); connect( label, SIGNAL(clicked()), SLOT(itemClicked()) );
connect( label, SIGNAL( checked( bool ) ), SLOT( itemChecked( bool ) ) ); connect( label, SIGNAL(checked(bool)), SLOT(itemChecked(bool)) );
return label; return label;
} }
/*! /*!
\brief Update the widget \brief Update the widget
\param widget Usually a QwtLegendLabel \param widget Usually a QwtLegendLabel
\param data Attributes to be displayed \param legendData Attributes to be displayed
\sa createWidget() \sa createWidget()
\note When widget is no QwtLegendLabel updateWidget() does nothing. \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 ); QwtLegendLabel *label = qobject_cast<QwtLegendLabel *>( widget );
if ( label ) if ( label )
{ {
label->setData( data ); label->setData( legendData );
if ( !data.value( QwtLegendData::ModeRole ).isValid() ) if ( !legendData.value( QwtLegendData::ModeRole ).isValid() )
{ {
// use the default mode, when there is no specific // use the default mode, when there is no specific
// hint from the legend data // hint from the legend data
@@ -540,7 +546,7 @@ int QwtLegend::heightForWidth( int width ) const
/*! /*!
Handle QEvent::ChildRemoved andQEvent::LayoutRequest events Handle QEvent::ChildRemoved andQEvent::LayoutRequest events
for the contentsWidget(). for the contentsWidget().
\param object Object to be filtered \param object Object to be filtered
@@ -556,11 +562,17 @@ bool QwtLegend::eventFilter( QObject *object, QEvent *event )
{ {
case QEvent::ChildRemoved: case QEvent::ChildRemoved:
{ {
const QChildEvent *ce = const QChildEvent *ce =
static_cast<const QChildEvent *>(event); static_cast<const QChildEvent *>(event);
if ( ce->child()->isWidgetType() ) 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 ); d_data->itemMap.removeWidget( w );
} }
break; break;
@@ -584,7 +596,7 @@ bool QwtLegend::eventFilter( QObject *object, QEvent *event )
*/ */
QApplication::postEvent( parentWidget(), QApplication::postEvent( parentWidget(),
new QEvent( QEvent::LayoutRequest ) ); new QEvent( QEvent::LayoutRequest ) );
} }
break; break;
} }
default: default:
@@ -644,11 +656,11 @@ void QwtLegend::itemChecked( bool on )
\param painter Painter \param painter Painter
\param rect Bounding rectangle \param rect Bounding rectangle
\param fillBackground When true, fill rect with the widget background \param fillBackground When true, fill rect with the widget background
\sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself \sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself
*/ */
void QwtLegend::renderLegend( QPainter *painter, void QwtLegend::renderLegend( QPainter *painter,
const QRectF &rect, bool fillBackground ) const const QRectF &rect, bool fillBackground ) const
{ {
if ( d_data->itemMap.isEmpty() ) if ( d_data->itemMap.isEmpty() )
@@ -663,7 +675,7 @@ void QwtLegend::renderLegend( QPainter *painter,
} }
} }
const QwtDynGridLayout *legendLayout = const QwtDynGridLayout *legendLayout =
qobject_cast<QwtDynGridLayout *>( contentsWidget()->layout() ); qobject_cast<QwtDynGridLayout *>( contentsWidget()->layout() );
if ( legendLayout == NULL ) if ( legendLayout == NULL )
return; return;
@@ -671,14 +683,14 @@ void QwtLegend::renderLegend( QPainter *painter,
int left, right, top, bottom; int left, right, top, bottom;
getContentsMargins( &left, &top, &right, &bottom ); getContentsMargins( &left, &top, &right, &bottom );
QRect layoutRect; QRect layoutRect;
layoutRect.setLeft( qCeil( rect.left() ) + left ); layoutRect.setLeft( qCeil( rect.left() ) + left );
layoutRect.setTop( qCeil( rect.top() ) + top ); layoutRect.setTop( qCeil( rect.top() ) + top );
layoutRect.setRight( qFloor( rect.right() ) - right ); layoutRect.setRight( qFloor( rect.right() ) - right );
layoutRect.setBottom( qFloor( rect.bottom() ) - bottom ); layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );
uint numCols = legendLayout->columnsForWidth( layoutRect.width() ); uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
QList<QRect> itemRects = const QList<QRect> itemRects =
legendLayout->layoutItems( layoutRect, numCols ); legendLayout->layoutItems( layoutRect, numCols );
int index = 0; int index = 0;
@@ -706,12 +718,12 @@ void QwtLegend::renderLegend( QPainter *painter,
\param painter Painter \param painter Painter
\param widget Widget representing a legend entry \param widget Widget representing a legend entry
\param rect Bounding rectangle \param rect Bounding rectangle
\param fillBackground When true, fill rect with the widget background \param fillBackground When true, fill rect with the widget background
\note When widget is not derived from QwtLegendLabel renderItem \note When widget is not derived from QwtLegendLabel renderItem
does nothing beside the background does nothing beside the background
*/ */
void QwtLegend::renderItem( QPainter *painter, void QwtLegend::renderItem( QPainter *painter,
const QWidget *widget, const QRectF &rect, bool fillBackground ) const const QWidget *widget, const QRectF &rect, bool fillBackground ) const
{ {
if ( fillBackground ) if ( fillBackground )
@@ -732,7 +744,7 @@ void QwtLegend::renderItem( QPainter *painter,
const QSizeF sz = icon.defaultSize(); const QSizeF sz = icon.defaultSize();
const QRectF iconRect( rect.x() + label->margin(), const QRectF iconRect( rect.x() + label->margin(),
rect.center().y() - 0.5 * sz.height(), rect.center().y() - 0.5 * sz.height(),
sz.width(), sz.height() ); sz.width(), sz.height() );
icon.render( painter, iconRect, Qt::KeepAspectRatio ); icon.render( painter, iconRect, Qt::KeepAspectRatio );
@@ -742,8 +754,12 @@ void QwtLegend::renderItem( QPainter *painter,
QRectF titleRect = rect; QRectF titleRect = rect;
titleRect.setX( iconRect.right() + 2 * label->spacing() ); 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 ) ); painter->setPen( label->palette().color( QPalette::Text ) );
const_cast< QwtLegendLabel *>( label )->drawText( painter, titleRect ); const_cast< QwtLegendLabel *>( label )->drawText( painter, titleRect );
} }
} }
@@ -794,7 +810,7 @@ bool QwtLegend::isEmpty() const
/*! /*!
Return the extent, that is needed for the scrollbars 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. \return The width of the vertical scrollbar for Qt::Horizontal and v.v.
*/ */
int QwtLegend::scrollExtent( Qt::Orientation orientation ) const int QwtLegend::scrollExtent( Qt::Orientation orientation ) const

View File

@@ -51,15 +51,15 @@ public:
virtual bool eventFilter( QObject *, QEvent * ); virtual bool eventFilter( QObject *, QEvent * );
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
virtual int heightForWidth( int w ) const; virtual int heightForWidth( int width ) const;
QScrollBar *horizontalScrollBar() const; QScrollBar *horizontalScrollBar() const;
QScrollBar *verticalScrollBar() const; QScrollBar *verticalScrollBar() const;
virtual void renderLegend( QPainter *, virtual void renderLegend( QPainter *,
const QRectF &, bool fillBackground ) const; const QRectF &, bool fillBackground ) const;
virtual void renderItem( QPainter *, virtual void renderItem( QPainter *,
const QWidget *, const QRectF &, bool fillBackground ) const; const QWidget *, const QRectF &, bool fillBackground ) const;
virtual bool isEmpty() const; virtual bool isEmpty() const;
@@ -105,7 +105,7 @@ protected Q_SLOTS:
protected: protected:
virtual QWidget *createWidget( const QwtLegendData & ) const; virtual QWidget *createWidget( const QwtLegendData & ) const;
virtual void updateWidget( QWidget *widget, const QwtLegendData &data ); virtual void updateWidget( QWidget *widget, const QwtLegendData & );
private: private:
void updateTabOrder(); void updateTabOrder();
@@ -114,4 +114,4 @@ private:
PrivateData *d_data; PrivateData *d_data;
}; };
#endif #endif

View File

@@ -123,7 +123,7 @@ QwtLegendData::Mode QwtLegendData::mode() const
const int mode = qvariant_cast<int>( modeValue ); const int mode = qvariant_cast<int>( modeValue );
return static_cast<QwtLegendData::Mode>( mode ); return static_cast<QwtLegendData::Mode>( mode );
} }
return QwtLegendData::ReadOnly; return QwtLegendData::ReadOnly;
} }

View File

@@ -21,11 +21,11 @@
\brief Attributes of an entry on a legend \brief Attributes of an entry on a legend
QwtLegendData is an abstract container ( like QAbstractModel ) QwtLegendData is an abstract container ( like QAbstractModel )
to exchange attributes, that are only known between to to exchange attributes, that are only known between to
the plot item and the legend. the plot item and the legend.
By overloading QwtPlotItem::legendData() any other set of attributes By overloading QwtPlotItem::legendData() any other set of attributes
could be used, that can be handled by a modified ( or completely could be used, that can be handled by a modified ( or completely
different ) implementation of a legend. different ) implementation of a legend.
\sa QwtLegend, QwtPlotLegendItem \sa QwtLegend, QwtPlotLegendItem
@@ -52,13 +52,13 @@ public:
enum Role enum Role
{ {
// The value is a Mode // The value is a Mode
ModeRole, ModeRole,
// The value is a title // The value is a title
TitleRole, TitleRole,
// The value is an icon // The value is an icon
IconRole, IconRole,
// Values < UserRole are reserved for internal use // Values < UserRole are reserved for internal use
UserRole = 32 UserRole = 32

View File

@@ -139,7 +139,7 @@ void QwtLegendLabel::setItemMode( QwtLegendData::Mode mode )
d_data->itemMode = mode; d_data->itemMode = mode;
d_data->isDown = false; d_data->isDown = false;
setFocusPolicy( ( mode != QwtLegendData::ReadOnly ) setFocusPolicy( ( mode != QwtLegendData::ReadOnly )
? Qt::TabFocus : Qt::NoFocus ); ? Qt::TabFocus : Qt::NoFocus );
setMargin( ButtonFrame + Margin ); setMargin( ButtonFrame + Margin );

View File

@@ -77,4 +77,4 @@ private:
PrivateData *d_data; PrivateData *d_data;
}; };
#endif #endif

View File

@@ -190,7 +190,7 @@ double QwtMagnifier::mouseFactor() const
\sa getMouseButton() \sa getMouseButton()
*/ */
void QwtMagnifier::setMouseButton( void QwtMagnifier::setMouseButton(
Qt::MouseButton button, Qt::KeyboardModifiers modifiers ) Qt::MouseButton button, Qt::KeyboardModifiers modifiers )
{ {
d_data->mouseButton = button; d_data->mouseButton = button;
@@ -238,14 +238,14 @@ double QwtMagnifier::keyFactor() const
\param modifiers \param modifiers
\sa getZoomInKey(), setZoomOutKey() \sa getZoomInKey(), setZoomOutKey()
*/ */
void QwtMagnifier::setZoomInKey( int key, void QwtMagnifier::setZoomInKey( int key,
Qt::KeyboardModifiers modifiers ) Qt::KeyboardModifiers modifiers )
{ {
d_data->zoomInKey = key; d_data->zoomInKey = key;
d_data->zoomInKeyModifiers = modifiers; d_data->zoomInKeyModifiers = modifiers;
} }
/*! /*!
\brief Retrieve the settings of the zoom in key \brief Retrieve the settings of the zoom in key
\param key Key code, see Qt::Key \param key Key code, see Qt::Key
@@ -253,7 +253,7 @@ void QwtMagnifier::setZoomInKey( int key,
\sa setZoomInKey() \sa setZoomInKey()
*/ */
void QwtMagnifier::getZoomInKey( int &key, void QwtMagnifier::getZoomInKey( int &key,
Qt::KeyboardModifiers &modifiers ) const Qt::KeyboardModifiers &modifiers ) const
{ {
key = d_data->zoomInKey; key = d_data->zoomInKey;
@@ -268,14 +268,14 @@ void QwtMagnifier::getZoomInKey( int &key,
\param modifiers \param modifiers
\sa getZoomOutKey(), setZoomOutKey() \sa getZoomOutKey(), setZoomOutKey()
*/ */
void QwtMagnifier::setZoomOutKey( int key, void QwtMagnifier::setZoomOutKey( int key,
Qt::KeyboardModifiers modifiers ) Qt::KeyboardModifiers modifiers )
{ {
d_data->zoomOutKey = key; d_data->zoomOutKey = key;
d_data->zoomOutKeyModifiers = modifiers; d_data->zoomOutKeyModifiers = modifiers;
} }
/*! /*!
\brief Retrieve the settings of the zoom out key \brief Retrieve the settings of the zoom out key
\param key Key code, see Qt::Key \param key Key code, see Qt::Key
@@ -283,7 +283,7 @@ void QwtMagnifier::setZoomOutKey( int key,
\sa setZoomOutKey() \sa setZoomOutKey()
*/ */
void QwtMagnifier::getZoomOutKey( int &key, void QwtMagnifier::getZoomOutKey( int &key,
Qt::KeyboardModifiers &modifiers ) const Qt::KeyboardModifiers &modifiers ) const
{ {
key = d_data->zoomOutKey; key = d_data->zoomOutKey;
@@ -437,7 +437,7 @@ void QwtMagnifier::widgetWheelEvent( QWheelEvent *wheelEvent )
in which case the delta value is a multiple in which case the delta value is a multiple
of 120 (== 15 * 8). of 120 (== 15 * 8).
*/ */
double f = qPow( d_data->wheelFactor, double f = qPow( d_data->wheelFactor,
qAbs( wheelEvent->delta() / 120.0 ) ); qAbs( wheelEvent->delta() / 120.0 ) );
if ( wheelEvent->delta() > 0 ) if ( wheelEvent->delta() > 0 )

View File

@@ -27,7 +27,7 @@
#include "qwt_global.h" #include "qwt_global.h"
#ifndef M_PI_2 #ifndef M_PI_2
// For Qt <= 4.8.4 M_PI_2 is not known by MinGW-w64 // For Qt <= 4.8.4 M_PI_2 is not known by MinGW-w64
// when compiling with -std=c++11 // when compiling with -std=c++11
#define M_PI_2 (1.57079632679489661923) #define M_PI_2 (1.57079632679489661923)
#endif #endif

View File

@@ -81,10 +81,10 @@ QwtMatrixRasterData::ResampleMode QwtMatrixRasterData::resampleMode() const
\param axis X, Y or Z axis \param axis X, Y or Z axis
\param interval Interval \param interval Interval
\sa QwtRasterData::interval(), setValueMatrix() \sa QwtRasterData::interval(), setValueMatrix()
*/ */
void QwtMatrixRasterData::setInterval( void QwtMatrixRasterData::setInterval(
Qt::Axis axis, const QwtInterval &interval ) Qt::Axis axis, const QwtInterval &interval )
{ {
QwtRasterData::setInterval( axis, interval ); QwtRasterData::setInterval( axis, interval );
@@ -96,7 +96,7 @@ void QwtMatrixRasterData::setInterval(
The positions of the values are calculated by dividing The positions of the values are calculated by dividing
the bounding rectangle of the X/Y intervals into equidistant the bounding rectangle of the X/Y intervals into equidistant
rectangles ( pixels ). Each value corresponds to the center of rectangles ( pixels ). Each value corresponds to the center of
a pixel. a pixel.
\param values Vector of values \param values Vector of values
@@ -104,7 +104,7 @@ void QwtMatrixRasterData::setInterval(
\sa valueMatrix(), numColumns(), numRows(), setInterval()() \sa valueMatrix(), numColumns(), numRows(), setInterval()()
*/ */
void QwtMatrixRasterData::setValueMatrix( void QwtMatrixRasterData::setValueMatrix(
const QVector<double> &values, int numColumns ) const QVector<double> &values, int numColumns )
{ {
d_data->values = values; d_data->values = values;
@@ -161,17 +161,17 @@ int QwtMatrixRasterData::numRows() const
/*! /*!
\brief Calculate the pixel hint \brief Calculate the pixel hint
pixelHint() returns the geometry of a pixel, that can be used pixelHint() returns the geometry of a pixel, that can be used
to calculate the resolution and alignment of the plot item, that is to calculate the resolution and alignment of the plot item, that is
representing the data. representing the data.
- NearestNeighbour\n - NearestNeighbour\n
pixelHint() returns the surrounding pixel of the top left value pixelHint() returns the surrounding pixel of the top left value
in the matrix. in the matrix.
- BilinearInterpolation\n - BilinearInterpolation\n
Returns an empty rectangle recommending Returns an empty rectangle recommending
to render in target device ( f.e. screen ) resolution. to render in target device ( f.e. screen ) resolution.
\param area Requested area, ignored \param area Requested area, ignored
\return Calculated hint \return Calculated hint
@@ -239,11 +239,11 @@ double QwtMatrixRasterData::value( double x, double y ) const
const double v12 = d_data->value( row2, col1 ); const double v12 = d_data->value( row2, col1 );
const double v22 = d_data->value( row2, col2 ); const double v22 = d_data->value( row2, col2 );
const double x2 = xInterval.minValue() + const double x2 = xInterval.minValue() +
( col2 + 0.5 ) * d_data->dx; ( col2 + 0.5 ) * d_data->dx;
const double y2 = yInterval.minValue() + const double y2 = yInterval.minValue() +
( row2 + 0.5 ) * d_data->dy; ( row2 + 0.5 ) * d_data->dy;
const double rx = ( x2 - x ) / d_data->dx; const double rx = ( x2 - x ) / d_data->dx;
const double ry = ( y2 - y ) / d_data->dy; const double ry = ( y2 - y ) / d_data->dy;

View File

@@ -18,7 +18,7 @@
\brief A class representing a matrix of values as raster data \brief A class representing a matrix of values as raster data
QwtMatrixRasterData implements an interface for a matrix of QwtMatrixRasterData implements an interface for a matrix of
equidistant values, that can be used by a QwtPlotRasterItem. equidistant values, that can be used by a QwtPlotRasterItem.
It implements a couple of resampling algorithms, to provide It implements a couple of resampling algorithms, to provide
values for positions, that or not on the value matrix. values for positions, that or not on the value matrix.
*/ */
@@ -38,7 +38,7 @@ public:
NearestNeighbour, NearestNeighbour,
/*! /*!
Interpolate the value from the distances and values of the Interpolate the value from the distances and values of the
4 surrounding values in the matrix, 4 surrounding values in the matrix,
*/ */
BilinearInterpolation BilinearInterpolation

View File

@@ -10,7 +10,7 @@
#include "qwt_null_paintdevice.h" #include "qwt_null_paintdevice.h"
#include <qpaintengine.h> #include <qpaintengine.h>
#include <qpixmap.h> #include <qpixmap.h>
#include <QPainterPath>
class QwtNullPaintDevice::PrivateData class QwtNullPaintDevice::PrivateData
{ {
public: public:
@@ -50,21 +50,21 @@ public:
virtual void drawPolygon(const QPointF *, int , PolygonDrawMode ); virtual void drawPolygon(const QPointF *, int , PolygonDrawMode );
virtual void drawPolygon(const QPoint *, int , PolygonDrawMode ); virtual void drawPolygon(const QPoint *, int , PolygonDrawMode );
virtual void drawPixmap(const QRectF &, virtual void drawPixmap(const QRectF &,
const QPixmap &, const QRectF &); const QPixmap &, const QRectF &);
virtual void drawTextItem(const QPointF &, const QTextItem &); virtual void drawTextItem(const QPointF &, const QTextItem &);
virtual void drawTiledPixmap(const QRectF &, virtual void drawTiledPixmap(const QRectF &,
const QPixmap &, const QPointF &s); const QPixmap &, const QPointF &s);
virtual void drawImage(const QRectF &, virtual void drawImage(const QRectF &,
const QImage &, const QRectF &, Qt::ImageConversionFlags ); const QImage &, const QRectF &, Qt::ImageConversionFlags );
private: private:
QwtNullPaintDevice *nullDevice(); QwtNullPaintDevice *nullDevice();
}; };
QwtNullPaintDevice::PaintEngine::PaintEngine(): QwtNullPaintDevice::PaintEngine::PaintEngine():
QPaintEngine( QPaintEngine::AllFeatures ) QPaintEngine( QPaintEngine::AllFeatures )
{ {
@@ -282,7 +282,7 @@ void QwtNullPaintDevice::PaintEngine::drawPolygon(
device->drawPolygon( points, pointCount, mode ); device->drawPolygon( points, pointCount, mode );
} }
void QwtNullPaintDevice::PaintEngine::drawPixmap( void QwtNullPaintDevice::PaintEngine::drawPixmap(
const QRectF &rect, const QPixmap &pm, const QRectF &subRect ) const QRectF &rect, const QPixmap &pm, const QRectF &subRect )
{ {
QwtNullPaintDevice *device = nullDevice(); QwtNullPaintDevice *device = nullDevice();
@@ -309,7 +309,7 @@ void QwtNullPaintDevice::PaintEngine::drawTextItem(
} }
void QwtNullPaintDevice::PaintEngine::drawTiledPixmap( void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(
const QRectF &rect, const QPixmap &pixmap, const QRectF &rect, const QPixmap &pixmap,
const QPointF &subRect) const QPointF &subRect)
{ {
QwtNullPaintDevice *device = nullDevice(); QwtNullPaintDevice *device = nullDevice();
@@ -320,13 +320,13 @@ void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(
{ {
QPaintEngine::drawTiledPixmap( rect, pixmap, subRect ); QPaintEngine::drawTiledPixmap( rect, pixmap, subRect );
return; return;
} }
device->drawTiledPixmap( rect, pixmap, subRect ); device->drawTiledPixmap( rect, pixmap, subRect );
} }
void QwtNullPaintDevice::PaintEngine::drawImage( void QwtNullPaintDevice::PaintEngine::drawImage(
const QRectF &rect, const QImage &image, const QRectF &rect, const QImage &image,
const QRectF &subRect, Qt::ImageConversionFlags flags) const QRectF &subRect, Qt::ImageConversionFlags flags)
{ {
QwtNullPaintDevice *device = nullDevice(); QwtNullPaintDevice *device = nullDevice();
@@ -337,13 +337,13 @@ void QwtNullPaintDevice::PaintEngine::drawImage(
} }
void QwtNullPaintDevice::PaintEngine::updateState( void QwtNullPaintDevice::PaintEngine::updateState(
const QPaintEngineState &state) const QPaintEngineState &engineState)
{ {
QwtNullPaintDevice *device = nullDevice(); QwtNullPaintDevice *device = nullDevice();
if ( device == NULL ) if ( device == NULL )
return; return;
device->updateState( state ); device->updateState( engineState );
} }
inline QwtNullPaintDevice *QwtNullPaintDevice::PaintEngine::nullDevice() inline QwtNullPaintDevice *QwtNullPaintDevice::PaintEngine::nullDevice()
@@ -379,7 +379,7 @@ void QwtNullPaintDevice::setMode( Mode mode )
d_data->mode = mode; d_data->mode = mode;
} }
/*! /*!
\return Render mode \return Render mode
\sa setMode() \sa setMode()
*/ */
@@ -393,7 +393,7 @@ QPaintEngine *QwtNullPaintDevice::paintEngine() const
{ {
if ( d_engine == NULL ) if ( d_engine == NULL )
{ {
QwtNullPaintDevice *that = QwtNullPaintDevice *that =
const_cast< QwtNullPaintDevice * >( this ); const_cast< QwtNullPaintDevice * >( this );
that->d_engine = new PaintEngine(); that->d_engine = new PaintEngine();
@@ -402,7 +402,7 @@ QPaintEngine *QwtNullPaintDevice::paintEngine() const
return d_engine; return d_engine;
} }
/*! /*!
See QPaintDevice::metric() See QPaintDevice::metric()
\param deviceMetric Type of metric \param deviceMetric Type of metric
@@ -414,7 +414,7 @@ int QwtNullPaintDevice::metric( PaintDeviceMetric deviceMetric ) const
{ {
int value; int value;
switch ( deviceMetric ) switch ( deviceMetric )
{ {
case PdmWidth: case PdmWidth:
{ {
@@ -529,7 +529,7 @@ void QwtNullPaintDevice::drawPoints(
//! See QPaintEngine::drawPolygon() //! See QPaintEngine::drawPolygon()
void QwtNullPaintDevice::drawPolygon( void QwtNullPaintDevice::drawPolygon(
const QPointF *points, int pointCount, const QPointF *points, int pointCount,
QPaintEngine::PolygonDrawMode mode) QPaintEngine::PolygonDrawMode mode)
{ {
Q_UNUSED(points); Q_UNUSED(points);
@@ -539,7 +539,7 @@ void QwtNullPaintDevice::drawPolygon(
//! See QPaintEngine::drawPolygon() //! See QPaintEngine::drawPolygon()
void QwtNullPaintDevice::drawPolygon( void QwtNullPaintDevice::drawPolygon(
const QPoint *points, int pointCount, const QPoint *points, int pointCount,
QPaintEngine::PolygonDrawMode mode) QPaintEngine::PolygonDrawMode mode)
{ {
Q_UNUSED(points); Q_UNUSED(points);
@@ -548,7 +548,7 @@ void QwtNullPaintDevice::drawPolygon(
} }
//! See QPaintEngine::drawPixmap() //! See QPaintEngine::drawPixmap()
void QwtNullPaintDevice::drawPixmap( const QRectF &rect, void QwtNullPaintDevice::drawPixmap( const QRectF &rect,
const QPixmap &pm, const QRectF &subRect ) const QPixmap &pm, const QRectF &subRect )
{ {
Q_UNUSED(rect); Q_UNUSED(rect);
@@ -566,7 +566,7 @@ void QwtNullPaintDevice::drawTextItem(
//! See QPaintEngine::drawTiledPixmap() //! See QPaintEngine::drawTiledPixmap()
void QwtNullPaintDevice::drawTiledPixmap( void QwtNullPaintDevice::drawTiledPixmap(
const QRectF &rect, const QPixmap &pixmap, const QRectF &rect, const QPixmap &pixmap,
const QPointF &subRect) const QPointF &subRect)
{ {
Q_UNUSED(rect); Q_UNUSED(rect);
@@ -576,7 +576,7 @@ void QwtNullPaintDevice::drawTiledPixmap(
//! See QPaintEngine::drawImage() //! See QPaintEngine::drawImage()
void QwtNullPaintDevice::drawImage( void QwtNullPaintDevice::drawImage(
const QRectF &rect, const QImage &image, const QRectF &rect, const QImage &image,
const QRectF &subRect, Qt::ImageConversionFlags flags) const QRectF &subRect, Qt::ImageConversionFlags flags)
{ {
Q_UNUSED(rect); Q_UNUSED(rect);
@@ -586,7 +586,7 @@ void QwtNullPaintDevice::drawImage(
} }
//! See QPaintEngine::updateState() //! See QPaintEngine::updateState()
void QwtNullPaintDevice::updateState( void QwtNullPaintDevice::updateState(
const QPaintEngineState &state ) const QPaintEngineState &state )
{ {
Q_UNUSED(state); Q_UNUSED(state);

View File

@@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library * Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen * Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann * Copyright (C) 2002 Uwe Rathmann
@@ -13,16 +13,15 @@
#include "qwt_global.h" #include "qwt_global.h"
#include <qpaintdevice.h> #include <qpaintdevice.h>
#include <qpaintengine.h> #include <qpaintengine.h>
#include "qpainterpath.h"
/*! /*!
\brief A null paint device doing nothing \brief A null paint device doing nothing
Sometimes important layout/rendering geometries are not Sometimes important layout/rendering geometries are not
available or changeable from the public Qt class interface. available or changeable from the public Qt class interface.
( f.e hidden in the style implementation ). ( f.e hidden in the style implementation ).
QwtNullPaintDevice can be used to manipulate or filter out QwtNullPaintDevice can be used to manipulate or filter out
this information by analyzing the stream of paint primitives. this information by analyzing the stream of paint primitives.
F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify
@@ -43,7 +42,7 @@ public:
All vector graphic primitives are painted by All vector graphic primitives are painted by
the corresponding draw methods the corresponding draw methods
*/ */
NormalMode, NormalMode,
/*! /*!
Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath
@@ -77,7 +76,7 @@ public:
virtual QPaintEngine *paintEngine() const; 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 QRect *, int );
virtual void drawRects(const QRectF *, int ); virtual void drawRects(const QRectF *, int );
@@ -105,12 +104,12 @@ public:
virtual void drawTextItem(const QPointF &, const QTextItem &); virtual void drawTextItem(const QPointF &, const QTextItem &);
virtual void drawTiledPixmap(const QRectF &, virtual void drawTiledPixmap(const QRectF &,
const QPixmap &, const QPointF &s); const QPixmap &, const QPointF & );
virtual void drawImage(const QRectF &, virtual void drawImage(const QRectF &,
const QImage &, const QRectF &, Qt::ImageConversionFlags ); const QImage &, const QRectF &, Qt::ImageConversionFlags );
virtual void updateState( const QPaintEngineState &state ); virtual void updateState( const QPaintEngineState & );
protected: protected:
//! \return Size needed to implement metric() //! \return Size needed to implement metric()

View File

@@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library * Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen * Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann * Copyright (C) 2002 Uwe Rathmann
@@ -27,13 +27,12 @@
#include <qpaintengine.h> #include <qpaintengine.h>
#include <qapplication.h> #include <qapplication.h>
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#include "qpainterpath.h"
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
#include <qwindow.h> #include <qwindow.h>
#endif #endif
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
#ifdef Q_WS_X11 #ifdef Q_WS_X11
#include <qx11info_x11.h> #include <qx11info_x11.h>
@@ -44,7 +43,7 @@
bool QwtPainter::d_polylineSplitting = true; bool QwtPainter::d_polylineSplitting = true;
bool QwtPainter::d_roundingAlignment = true; bool QwtPainter::d_roundingAlignment = true;
static inline bool qwtIsClippingNeeded( static inline bool qwtIsClippingNeeded(
const QPainter *painter, QRectF &clipRect ) const QPainter *painter, QRectF &clipRect )
{ {
bool doClipping = false; bool doClipping = false;
@@ -142,6 +141,12 @@ static inline void qwtUnscaleFont( QPainter *painter )
*/ */
bool QwtPainter::isX11GraphicsSystem() 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; static int onX11 = -1;
if ( onX11 < 0 ) if ( onX11 < 0 )
{ {
@@ -181,7 +186,7 @@ bool QwtPainter::isAligning( QPainter *painter )
default:; default:;
} }
const QTransform tr = painter->transform(); const QTransform &tr = painter->transform();
if ( tr.isRotating() || tr.isScaling() ) if ( tr.isRotating() || tr.isScaling() )
{ {
// we might have to check translations too // we might have to check translations too
@@ -196,10 +201,10 @@ bool QwtPainter::isAligning( QPainter *painter )
Enable whether coordinates should be rounded, before they are painted Enable whether coordinates should be rounded, before they are painted
to a paint engine that floors to integer values. For other paint engines to a paint engine that floors to integer values. For other paint engines
( PDF, SVG ) this flag has no effect. ( PDF, SVG ) this flag has no effect.
QwtPainter stores this flag only, the rounding itself is done in QwtPainter stores this flag only, the rounding itself is done in
the painting code ( f.e the plot items ). the painting code ( f.e the plot items ).
The default setting is true. The default setting is true.
\sa roundingAlignment(), isAligning() \sa roundingAlignment(), isAligning()
*/ */
@@ -215,6 +220,10 @@ void QwtPainter::setRoundingAlignment( bool enable )
much faster when they are split in smaller chunks: f.e all supported Qt versions 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. >= 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. The default setting is true.
\sa polylineSplitting() \sa polylineSplitting()
@@ -397,7 +406,7 @@ void QwtPainter::drawSimpleRichText( QPainter *painter, const QRectF &rect,
painter->setWorldTransform( transform, true ); painter->setWorldTransform( transform, true );
unscaledRect = transform.inverted().mapRect(rect); unscaledRect = transform.inverted().mapRect(rect);
} }
} }
txt->setDefaultFont( painter->font() ); txt->setDefaultFont( painter->font() );
txt->setPageSize( QSizeF( unscaledRect.width(), QWIDGETSIZE_MAX ) ); txt->setPageSize( QSizeF( unscaledRect.width(), QWIDGETSIZE_MAX ) );
@@ -452,7 +461,7 @@ void QwtPainter::drawPolygon( QPainter *painter, const QPolygonF &polygon )
QPolygonF cpa = polygon; QPolygonF cpa = polygon;
if ( deviceClipping ) if ( deviceClipping )
cpa = QwtClipper::clipPolygonF( clipRect, polygon ); cpa = QwtClipper::clipPolygonF( clipRect, polygon, true );
painter->drawPolygon( cpa ); painter->drawPolygon( cpa );
} }
@@ -501,7 +510,7 @@ void QwtPainter::drawPolygon( QPainter *painter, const QPolygon &polygon )
QPolygon cpa = polygon; QPolygon cpa = polygon;
if ( deviceClipping ) if ( deviceClipping )
cpa = QwtClipper::clipPolygon( clipRect, polygon ); cpa = QwtClipper::clipPolygon( clipRect, polygon, true );
painter->drawPolygon( cpa ); painter->drawPolygon( cpa );
} }
@@ -537,7 +546,9 @@ void QwtPainter::drawPolyline( QPainter *painter,
polygon.constData(), polygon.size(), d_polylineSplitting ); polygon.constData(), polygon.size(), d_polylineSplitting );
} }
else else
{
qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting ); qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting );
}
} }
//! Wrapper for QPainter::drawPoint() //! Wrapper for QPainter::drawPoint()
@@ -565,7 +576,7 @@ void QwtPainter::drawPoint( QPainter *painter, const QPoint &pos )
const int minY = qCeil( clipRect.top() ); const int minY = qCeil( clipRect.top() );
const int maxY = qFloor( clipRect.bottom() ); const int maxY = qFloor( clipRect.bottom() );
if ( pos.x() < minX || pos.x() > maxX if ( pos.x() < minX || pos.x() > maxX
|| pos.y() < minY || pos.y() > maxY ) || pos.y() < minY || pos.y() > maxY )
{ {
return; return;
@@ -576,7 +587,7 @@ void QwtPainter::drawPoint( QPainter *painter, const QPoint &pos )
} }
//! Wrapper for QPainter::drawPoints() //! Wrapper for QPainter::drawPoints()
void QwtPainter::drawPoints( QPainter *painter, void QwtPainter::drawPoints( QPainter *painter,
const QPoint *points, int pointCount ) const QPoint *points, int pointCount )
{ {
QRectF clipRect; QRectF clipRect;
@@ -609,7 +620,7 @@ void QwtPainter::drawPoints( QPainter *painter,
} }
//! Wrapper for QPainter::drawPoints() //! Wrapper for QPainter::drawPoints()
void QwtPainter::drawPoints( QPainter *painter, void QwtPainter::drawPoints( QPainter *painter,
const QPointF *points, int pointCount ) const QPointF *points, int pointCount )
{ {
QRectF clipRect; QRectF clipRect;
@@ -690,13 +701,14 @@ void QwtPainter::drawFocusRect( QPainter *painter, const QWidget *widget,
opt.init( widget ); opt.init( widget );
opt.rect = rect; opt.rect = rect;
opt.state |= QStyle::State_HasFocus; opt.state |= QStyle::State_HasFocus;
opt.backgroundColor = widget->palette().color( widget->backgroundRole() );
widget->style()->drawPrimitive( QStyle::PE_FrameFocusRect, widget->style()->drawPrimitive(
&opt, painter, widget ); QStyle::PE_FrameFocusRect, &opt, painter, widget );
} }
/*! /*!
Draw a round frame Draw a round frame
\param painter Painter \param painter Painter
\param rect Frame rectangle \param rect Frame rectangle
@@ -707,7 +719,7 @@ void QwtPainter::drawFocusRect( QPainter *painter, const QWidget *widget,
\param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow
*/ */
void QwtPainter::drawRoundFrame( QPainter *painter, void QwtPainter::drawRoundFrame( QPainter *painter,
const QRectF &rect, const QPalette &palette, const QRectF &rect, const QPalette &palette,
int lineWidth, int frameStyle ) int lineWidth, int frameStyle )
{ {
enum Style enum Style
@@ -786,7 +798,7 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
if ( shadow == QFrame::Plain ) if ( shadow == QFrame::Plain )
{ {
const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
const QRectF innerRect = outerRect.adjusted( const QRectF innerRect = outerRect.adjusted(
frameWidth, frameWidth, -frameWidth, -frameWidth ); frameWidth, frameWidth, -frameWidth, -frameWidth );
QPainterPath path; QPainterPath path;
@@ -805,12 +817,12 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
if ( shape == QFrame::Box ) if ( shape == QFrame::Box )
{ {
const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
const QRectF midRect1 = outerRect.adjusted( const QRectF midRect1 = outerRect.adjusted(
frameWidth, frameWidth, -frameWidth, -frameWidth ); frameWidth, frameWidth, -frameWidth, -frameWidth );
const QRectF midRect2 = midRect1.adjusted( const QRectF midRect2 = midRect1.adjusted(
midLineWidth, midLineWidth, -midLineWidth, -midLineWidth ); midLineWidth, midLineWidth, -midLineWidth, -midLineWidth );
const QRectF innerRect = midRect2.adjusted( const QRectF innerRect = midRect2.adjusted(
frameWidth, frameWidth, -frameWidth, -frameWidth ); frameWidth, frameWidth, -frameWidth, -frameWidth );
QPainterPath path1; QPainterPath path1;
@@ -886,8 +898,8 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
else else
{ {
const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
const QRectF innerRect = outerRect.adjusted( const QRectF innerRect = outerRect.adjusted(
frameWidth - 1.0, frameWidth - 1.0, frameWidth - 1.0, frameWidth - 1.0,
-( frameWidth - 1.0 ), -( frameWidth - 1.0 ) ); -( frameWidth - 1.0 ), -( frameWidth - 1.0 ) );
QPainterPath path1; QPainterPath path1;
@@ -941,8 +953,8 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
\param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow
*/ */
void QwtPainter::drawRoundedFrame( QPainter *painter, void QwtPainter::drawRoundedFrame( QPainter *painter,
const QRectF &rect, double xRadius, double yRadius, const QRectF &rect, double xRadius, double yRadius,
const QPalette &palette, int lineWidth, int frameStyle ) const QPalette &palette, int lineWidth, int frameStyle )
{ {
painter->save(); painter->save();
@@ -950,10 +962,10 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
painter->setBrush( Qt::NoBrush ); painter->setBrush( Qt::NoBrush );
double lw2 = lineWidth * 0.5; double lw2 = lineWidth * 0.5;
QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 ); QRectF innerRect = rect.adjusted( lw2, lw2, -lw2, -lw2 );
QPainterPath path; QPainterPath path;
path.addRoundedRect( r, xRadius, yRadius ); path.addRoundedRect( innerRect, xRadius, yRadius );
enum Style enum Style
{ {
@@ -972,27 +984,27 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
{ {
// move + 4 * ( cubicTo + lineTo ) // move + 4 * ( cubicTo + lineTo )
QPainterPath pathList[8]; QPainterPath pathList[8];
for ( int i = 0; i < 4; i++ ) for ( int i = 0; i < 4; i++ )
{ {
const int j = i * 4 + 1; const int j = i * 4 + 1;
pathList[ 2 * i ].moveTo( pathList[ 2 * i ].moveTo(
path.elementAt(j - 1).x, path.elementAt( j - 1 ).y path.elementAt(j - 1).x, path.elementAt( j - 1 ).y
); );
pathList[ 2 * i ].cubicTo( pathList[ 2 * i ].cubicTo(
path.elementAt(j + 0).x, path.elementAt(j + 0).y, path.elementAt(j + 0).x, path.elementAt(j + 0).y,
path.elementAt(j + 1).x, path.elementAt(j + 1).y, path.elementAt(j + 1).x, path.elementAt(j + 1).y,
path.elementAt(j + 2).x, path.elementAt(j + 2).y ); path.elementAt(j + 2).x, path.elementAt(j + 2).y );
pathList[ 2 * i + 1 ].moveTo( pathList[ 2 * i + 1 ].moveTo(
path.elementAt(j + 2).x, path.elementAt(j + 2).y path.elementAt(j + 2).x, path.elementAt(j + 2).y
); );
pathList[ 2 * i + 1 ].lineTo( pathList[ 2 * i + 1 ].lineTo(
path.elementAt(j + 3).x, path.elementAt(j + 3).y path.elementAt(j + 3).x, path.elementAt(j + 3).y
); );
} }
QColor c1( palette.color( QPalette::Dark ) ); QColor c1( palette.color( QPalette::Dark ) );
QColor c2( palette.color( QPalette::Light ) ); QColor c2( palette.color( QPalette::Light ) );
@@ -1002,7 +1014,7 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
for ( int i = 0; i < 4; i++ ) for ( int i = 0; i < 4; i++ )
{ {
QRectF r = pathList[2 * i].controlPointRect(); const QRectF r = pathList[2 * i].controlPointRect();
QPen arcPen; QPen arcPen;
arcPen.setCapStyle( Qt::FlatCap ); arcPen.setCapStyle( Qt::FlatCap );
@@ -1146,10 +1158,10 @@ void QwtPainter::drawColorBar( QPainter *painter,
drawPixmap( painter, rect, pixmap ); drawPixmap( painter, rect, pixmap );
} }
static inline void qwtFillRect( const QWidget *widget, QPainter *painter, static inline void qwtFillRect( const QWidget *widget, QPainter *painter,
const QRect &rect, const QBrush &brush) const QRect &rect, const QBrush &brush)
{ {
if ( brush.style() == Qt::TexturePattern ) if ( brush.style() == Qt::TexturePattern )
{ {
painter->save(); painter->save();
@@ -1157,18 +1169,18 @@ static inline void qwtFillRect( const QWidget *widget, QPainter *painter,
painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
painter->restore(); painter->restore();
} }
else if ( brush.gradient() ) else if ( brush.gradient() )
{ {
painter->save(); painter->save();
painter->setClipRect( rect ); painter->setClipRect( rect );
painter->fillRect(0, 0, widget->width(), painter->fillRect(0, 0, widget->width(),
widget->height(), brush); widget->height(), brush);
painter->restore(); painter->restore();
} }
else else
{ {
painter->fillRect(rect, brush); painter->fillRect(rect, brush);
} }
@@ -1178,16 +1190,16 @@ static inline void qwtFillRect( const QWidget *widget, QPainter *painter,
Fill a pixmap with the content of a widget Fill a pixmap with the content of a widget
In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy
for backgrounds with gradients. Thus fillPixmap() offers for backgrounds with gradients. Thus fillPixmap() offers
an alternative implementation. an alternative implementation.
\param widget Widget \param widget Widget
\param pixmap Pixmap to be filled \param pixmap Pixmap to be filled
\param offset Offset \param offset Offset
\sa QPixmap::fill() \sa QPixmap::fill()
*/ */
void QwtPainter::fillPixmap( const QWidget *widget, void QwtPainter::fillPixmap( const QWidget *widget,
QPixmap &pixmap, const QPoint &offset ) QPixmap &pixmap, const QPoint &offset )
{ {
const QRect rect( offset, pixmap.size() ); const QRect rect( offset, pixmap.size() );
@@ -1195,10 +1207,10 @@ void QwtPainter::fillPixmap( const QWidget *widget,
QPainter painter( &pixmap ); QPainter painter( &pixmap );
painter.translate( -offset ); painter.translate( -offset );
const QBrush autoFillBrush = const QBrush autoFillBrush =
widget->palette().brush( widget->backgroundRole() ); widget->palette().brush( widget->backgroundRole() );
if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) ) if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) )
{ {
const QBrush bg = widget->palette().brush( QPalette::Window ); const QBrush bg = widget->palette().brush( QPalette::Window );
qwtFillRect( widget, &painter, rect, bg); qwtFillRect( widget, &painter, rect, bg);
@@ -1207,13 +1219,13 @@ void QwtPainter::fillPixmap( const QWidget *widget,
if ( widget->autoFillBackground() ) if ( widget->autoFillBackground() )
qwtFillRect( widget, &painter, rect, autoFillBrush); qwtFillRect( widget, &painter, rect, autoFillBrush);
if ( widget->testAttribute(Qt::WA_StyledBackground) ) if ( widget->testAttribute(Qt::WA_StyledBackground) )
{ {
painter.setClipRegion( rect ); painter.setClipRegion( rect );
QStyleOption opt; QStyleOption opt;
opt.initFrom( widget ); opt.initFrom( widget );
widget->style()->drawPrimitive( QStyle::PE_Widget, widget->style()->drawPrimitive( QStyle::PE_Widget,
&opt, &painter, widget ); &opt, &painter, widget );
} }
} }
@@ -1251,7 +1263,7 @@ void QwtPainter::drawBackgound( QPainter *painter,
/*! /*!
\return A pixmap that can be used as backing store \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 \param size Size of the pixmap
*/ */
QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size ) QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
@@ -1284,7 +1296,7 @@ QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
pm = QPixmap( size ); pm = QPixmap( size );
#endif #endif
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if ( widget && isX11GraphicsSystem() ) if ( widget && isX11GraphicsSystem() )
{ {

View File

@@ -17,7 +17,7 @@
#include <qpen.h> #include <qpen.h>
#include <qline.h> #include <qline.h>
#include <qpalette.h> #include <qpalette.h>
#include <QPainterPath>
class QPainter; class QPainter;
class QBrush; class QBrush;
class QColor; class QColor;
@@ -50,7 +50,7 @@ public:
static void drawText( QPainter *, const QPointF &, const QString & ); static void drawText( QPainter *, const QPointF &, const QString & );
static void drawText( QPainter *, double x, double y, double w, double h, static void drawText( QPainter *, double x, double y, double w, double h,
int flags, const QString & ); int flags, const QString & );
static void drawText( QPainter *, const QRectF &, static void drawText( QPainter *, const QRectF &,
int flags, const QString & ); int flags, const QString & );
#ifndef QT_NO_RICHTEXT #ifndef QT_NO_RICHTEXT
@@ -63,7 +63,7 @@ public:
static void fillRect( QPainter *, const QRectF &, const QBrush & ); static void fillRect( QPainter *, const QRectF &, const QBrush & );
static void drawEllipse( QPainter *, const QRectF & ); 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 *, double x1, double y1, double x2, double y2 );
static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 ); static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 );
@@ -93,13 +93,13 @@ public:
static void drawRoundFrame( QPainter *, static void drawRoundFrame( QPainter *,
const QRectF &, const QPalette &, int lineWidth, int frameStyle ); const QRectF &, const QPalette &, int lineWidth, int frameStyle );
static void drawRoundedFrame( QPainter *, static void drawRoundedFrame( QPainter *,
const QRectF &, double xRadius, double yRadius, const QRectF &, double xRadius, double yRadius,
const QPalette &, int lineWidth, int frameStyle ); const QPalette &, int lineWidth, int frameStyle );
static void drawFrame( QPainter *, const QRectF &rect, static void drawFrame( QPainter *, const QRectF &rect,
const QPalette &palette, QPalette::ColorRole foregroundRole, 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 * );
static void drawFocusRect( QPainter *, const QWidget *, const QRect & ); static void drawFocusRect( QPainter *, const QWidget *, const QRect & );
@@ -111,7 +111,7 @@ public:
static bool isAligning( QPainter *painter ); static bool isAligning( QPainter *painter );
static bool isX11GraphicsSystem(); static bool isX11GraphicsSystem();
static void fillPixmap( const QWidget *, static void fillPixmap( const QWidget *,
QPixmap &, const QPoint &offset = QPoint() ); QPixmap &, const QPoint &offset = QPoint() );
static void drawBackgound( QPainter *painter, static void drawBackgound( QPainter *painter,

View File

@@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library * Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen * Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann * Copyright (C) 2002 Uwe Rathmann
@@ -8,7 +8,6 @@
*****************************************************************************/ *****************************************************************************/
#include "qwt_painter_command.h" #include "qwt_painter_command.h"
#include "qpainterpath.h"
//! Construct an invalid command //! Construct an invalid command
QwtPainterCommand::QwtPainterCommand(): QwtPainterCommand::QwtPainterCommand():
@@ -64,10 +63,10 @@ QwtPainterCommand::QwtPainterCommand( const QRectF &rect,
d_imageData->flags = flags; d_imageData->flags = flags;
} }
/*! /*!
Constructor for State paint operation Constructor for State paint operation
\param state Paint engine state \param state Paint engine state
*/ */
QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ): QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
d_type( State ) d_type( State )
{ {
@@ -75,56 +74,56 @@ QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
d_stateData->flags = state.state(); d_stateData->flags = state.state();
if ( d_stateData->flags & QPaintEngine::DirtyPen ) if ( d_stateData->flags & QPaintEngine::DirtyPen )
d_stateData->pen = state.pen(); d_stateData->pen = state.pen();
if ( d_stateData->flags & QPaintEngine::DirtyBrush ) if ( d_stateData->flags & QPaintEngine::DirtyBrush )
d_stateData->brush = state.brush(); d_stateData->brush = state.brush();
if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin ) if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin )
d_stateData->brushOrigin = state.brushOrigin(); d_stateData->brushOrigin = state.brushOrigin();
if ( d_stateData->flags & QPaintEngine::DirtyFont ) if ( d_stateData->flags & QPaintEngine::DirtyFont )
d_stateData->font = state.font(); d_stateData->font = state.font();
if ( d_stateData->flags & QPaintEngine::DirtyBackground ) if ( d_stateData->flags & QPaintEngine::DirtyBackground )
{ {
d_stateData->backgroundMode = state.backgroundMode(); d_stateData->backgroundMode = state.backgroundMode();
d_stateData->backgroundBrush = state.backgroundBrush(); d_stateData->backgroundBrush = state.backgroundBrush();
} }
if ( d_stateData->flags & QPaintEngine::DirtyTransform ) if ( d_stateData->flags & QPaintEngine::DirtyTransform )
d_stateData->transform = state.transform(); d_stateData->transform = state.transform();
if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled ) if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled )
d_stateData->isClipEnabled = state.isClipEnabled(); d_stateData->isClipEnabled = state.isClipEnabled();
if ( d_stateData->flags & QPaintEngine::DirtyClipRegion ) if ( d_stateData->flags & QPaintEngine::DirtyClipRegion )
{ {
d_stateData->clipRegion = state.clipRegion(); d_stateData->clipRegion = state.clipRegion();
d_stateData->clipOperation = state.clipOperation(); d_stateData->clipOperation = state.clipOperation();
} }
if ( d_stateData->flags & QPaintEngine::DirtyClipPath ) if ( d_stateData->flags & QPaintEngine::DirtyClipPath )
{ {
d_stateData->clipPath = state.clipPath(); d_stateData->clipPath = state.clipPath();
d_stateData->clipOperation = state.clipOperation(); d_stateData->clipOperation = state.clipOperation();
} }
if ( d_stateData->flags & QPaintEngine::DirtyHints ) if ( d_stateData->flags & QPaintEngine::DirtyHints )
d_stateData->renderHints = state.renderHints(); d_stateData->renderHints = state.renderHints();
if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode ) if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode )
d_stateData->compositionMode = state.compositionMode(); d_stateData->compositionMode = state.compositionMode();
if ( d_stateData->flags & QPaintEngine::DirtyOpacity ) if ( d_stateData->flags & QPaintEngine::DirtyOpacity )
d_stateData->opacity = state.opacity(); d_stateData->opacity = state.opacity();
} }
/*! /*!
Copy constructor Copy constructor
\param other Command to be copied \param other Command to be copied
*/ */
QwtPainterCommand::QwtPainterCommand(const QwtPainterCommand &other) QwtPainterCommand::QwtPainterCommand(const QwtPainterCommand &other)
{ {
@@ -214,25 +213,25 @@ void QwtPainterCommand::reset()
} }
//! \return Painter path to be painted //! \return Painter path to be painted
QPainterPath *QwtPainterCommand::path() QPainterPath *QwtPainterCommand::path()
{ {
return d_path; return d_path;
} }
//! \return Attributes how to paint a QPixmap //! \return Attributes how to paint a QPixmap
QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData() QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData()
{ {
return d_pixmapData; return d_pixmapData;
} }
//! \return Attributes how to paint a QImage //! \return Attributes how to paint a QImage
QwtPainterCommand::ImageData* QwtPainterCommand::imageData() QwtPainterCommand::ImageData* QwtPainterCommand::imageData()
{ {
return d_imageData; return d_imageData;
} }
//! \return Attributes of a state change //! \return Attributes of a state change
QwtPainterCommand::StateData* QwtPainterCommand::stateData() QwtPainterCommand::StateData* QwtPainterCommand::stateData()
{ {
return d_stateData; return d_stateData;
} }

View File

@@ -15,7 +15,7 @@
#include <qpixmap.h> #include <qpixmap.h>
#include <qimage.h> #include <qimage.h>
#include <qpolygon.h> #include <qpolygon.h>
#include <QPainterPath>
class QPainterPath; class QPainterPath;
/*! /*!
@@ -26,7 +26,7 @@ class QPainterPath;
\sa QwtGraphic::commands() \sa QwtGraphic::commands()
*/ */
class QWT_EXPORT QwtPainterCommand class QWT_EXPORT QwtPainterCommand
{ {
public: public:
@@ -49,7 +49,7 @@ public:
State State
}; };
//! Attributes how to paint a QPixmap //! Attributes how to paint a QPixmap
struct PixmapData struct PixmapData
{ {
QRectF rect; QRectF rect;
@@ -57,7 +57,7 @@ public:
QRectF subRect; QRectF subRect;
}; };
//! Attributes how to paint a QImage //! Attributes how to paint a QImage
struct ImageData struct ImageData
{ {
QRectF rect; QRectF rect;
@@ -150,21 +150,21 @@ inline const QPainterPath *QwtPainterCommand::path() const
} }
//! \return Attributes how to paint a QPixmap //! \return Attributes how to paint a QPixmap
inline const QwtPainterCommand::PixmapData* inline const QwtPainterCommand::PixmapData *
QwtPainterCommand::pixmapData() const QwtPainterCommand::pixmapData() const
{ {
return d_pixmapData; return d_pixmapData;
} }
//! \return Attributes how to paint a QImage //! \return Attributes how to paint a QImage
inline const QwtPainterCommand::ImageData * inline const QwtPainterCommand::ImageData *
QwtPainterCommand::imageData() const QwtPainterCommand::imageData() const
{ {
return d_imageData; return d_imageData;
} }
//! \return Attributes of a state change //! \return Attributes of a state change
inline const QwtPainterCommand::StateData * inline const QwtPainterCommand::StateData *
QwtPainterCommand::stateData() const QwtPainterCommand::stateData() const
{ {
return d_stateData; return d_stateData;

View File

@@ -128,7 +128,7 @@ void QwtPanner::getMouseButton( Qt::MouseButton &button,
\param key Key ( See Qt::Keycode ) \param key Key ( See Qt::Keycode )
\param modifiers Keyboard modifiers \param modifiers Keyboard modifiers
*/ */
void QwtPanner::setAbortKey( int key, void QwtPanner::setAbortKey( int key,
Qt::KeyboardModifiers modifiers ) Qt::KeyboardModifiers modifiers )
{ {
d_data->abortKey = key; d_data->abortKey = key;
@@ -136,7 +136,7 @@ void QwtPanner::setAbortKey( int key,
} }
//! Get the abort key and modifiers //! Get the abort key and modifiers
void QwtPanner::getAbortKey( int &key, void QwtPanner::getAbortKey( int &key,
Qt::KeyboardModifiers &modifiers ) const Qt::KeyboardModifiers &modifiers ) const
{ {
key = d_data->abortKey; key = d_data->abortKey;
@@ -247,17 +247,21 @@ bool QwtPanner::isEnabled() const
Repaint the grabbed pixmap on its current position and Repaint the grabbed pixmap on its current position and
fill the empty spaces by the background of the parent widget. 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 dx = d_data->pos.x() - d_data->initialPos.x();
int dy = d_data->pos.y() - d_data->initialPos.y(); int dy = d_data->pos.y() - d_data->initialPos.y();
QRect r( 0, 0, d_data->pixmap.width(), d_data->pixmap.height() ); QRectF r;
r.moveCenter( QPoint( r.center().x() + dx, r.center().y() + dy ) ); 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 ); QwtPainter::fillPixmap( parentWidget(), pm );
QPainter painter( &pm ); QPainter painter( &pm );
@@ -266,11 +270,11 @@ void QwtPanner::paintEvent( QPaintEvent *pe )
{ {
QPixmap masked = d_data->pixmap; QPixmap masked = d_data->pixmap;
masked.setMask( d_data->contentsMask ); masked.setMask( d_data->contentsMask );
painter.drawPixmap( r, masked ); painter.drawPixmap( r.toRect(), masked );
} }
else else
{ {
painter.drawPixmap( r, d_data->pixmap ); painter.drawPixmap( r.toRect(), d_data->pixmap );
} }
painter.end(); painter.end();
@@ -279,7 +283,7 @@ void QwtPanner::paintEvent( QPaintEvent *pe )
pm.setMask( d_data->contentsMask ); pm.setMask( d_data->contentsMask );
painter.begin( this ); painter.begin( this );
painter.setClipRegion( pe->region() ); painter.setClipRegion( event->region() );
painter.drawPixmap( 0, 0, pm ); painter.drawPixmap( 0, 0, pm );
} }

View File

@@ -43,9 +43,9 @@ public:
void setEnabled( bool ); void setEnabled( bool );
bool isEnabled() const; bool isEnabled() const;
void setMouseButton( Qt::MouseButton, void setMouseButton( Qt::MouseButton,
Qt::KeyboardModifiers = Qt::NoModifier ); Qt::KeyboardModifiers = Qt::NoModifier );
void getMouseButton( Qt::MouseButton &button, void getMouseButton( Qt::MouseButton &button,
Qt::KeyboardModifiers & ) const; Qt::KeyboardModifiers & ) const;
void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier ); void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );

View File

@@ -52,12 +52,12 @@ static inline QRegion qwtMaskRegion( const QLine &l, int penWidth )
if ( l.x1() == l.x2() ) if ( l.x1() == l.x2() )
{ {
region += QRect( l.x1() - pw2, l.y1(), region += QRect( l.x1() - pw2, l.y1(),
pw, l.y2() ).normalized(); pw, l.y2() ).normalized();
} }
else if ( l.y1() == l.y2() ) else if ( l.y1() == l.y2() )
{ {
region += QRect( l.x1(), l.y1() - pw2, region += QRect( l.x1(), l.y1() - pw2,
l.x2(), pw ).normalized(); l.x2(), pw ).normalized();
} }
@@ -77,16 +77,16 @@ protected:
}; };
class QwtPickerTracker: public QwtWidgetOverlay class QwtPickerTracker: public QwtWidgetOverlay
{ {
public: public:
QwtPickerTracker( QwtPicker *, QWidget * ); QwtPickerTracker( QwtPicker *, QWidget * );
protected: protected:
virtual void drawOverlay( QPainter * ) const; virtual void drawOverlay( QPainter * ) const;
virtual QRegion maskHint() const; virtual QRegion maskHint() const;
QwtPicker *d_picker; QwtPicker *d_picker;
}; };
class QwtPicker::PrivateData class QwtPicker::PrivateData
@@ -104,7 +104,7 @@ public:
openGL( false ) openGL( false )
{ {
} }
bool enabled; bool enabled;
QwtPickerMachine *stateMachine; QwtPickerMachine *stateMachine;
@@ -557,21 +557,21 @@ QRegion QwtPicker::rubberBandMask() const
{ {
case VLineRubberBand: case VLineRubberBand:
{ {
mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), mask += qwtMaskRegion( QLine( pos.x(), pRect.top(),
pos.x(), pRect.bottom() ), pw ); pos.x(), pRect.bottom() ), pw );
break; break;
} }
case HLineRubberBand: case HLineRubberBand:
{ {
mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), mask += qwtMaskRegion( QLine( pRect.left(), pos.y(),
pRect.right(), pos.y() ), pw ); pRect.right(), pos.y() ), pw );
break; break;
} }
case CrossRubberBand: case CrossRubberBand:
{ {
mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), mask += qwtMaskRegion( QLine( pos.x(), pRect.top(),
pos.x(), pRect.bottom() ), pw ); pos.x(), pRect.bottom() ), pw );
mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), mask += qwtMaskRegion( QLine( pRect.left(), pos.y(),
pRect.right(), pos.y() ), pw ); pRect.right(), pos.y() ), pw );
break; break;
} }
@@ -751,29 +751,33 @@ void QwtPicker::drawTracker( QPainter *painter ) const
The reason, why a selection() differs from the picked points The reason, why a selection() differs from the picked points
depends on the application requirements. F.e. : depends on the application requirements. F.e. :
- A rectangular selection might need to have a specific aspect ratio only.\n - A rectangular selection might need to have a specific aspect ratio only.
- A selection could accept non intersecting polygons only.\n - A selection could accept non intersecting polygons only.
- ...\n - ...
The example below is for a rectangular selection, where the first The example below is for a rectangular selection, where the first
point is the center of the selected rectangle. point is the center of the selected rectangle.
\par Example \par Example
\verbatim QPolygon MyPicker::adjustedPoints(const QPolygon &points) const \code
{ QPolygon MyPicker::adjustedPoints( const QPolygon &points ) const
QPolygon adjusted;
if ( points.size() == 2 )
{ {
const int width = qAbs(points[1].x() - points[0].x()); QPolygon adjusted;
const int height = qAbs(points[1].y() - points[0].y()); if ( points.size() == 2 )
{
const int width = qAbs( points[1].x() - points[0].x() );
const int height = qAbs( points[1].y() - points[0].y() );
QRect rect(0, 0, 2 * width, 2 * height); QRect rect( 0, 0, 2 * width, 2 * height );
rect.moveCenter(points[0]); rect.moveCenter( points[0] );
adjusted += rect.topLeft(); adjusted += rect.topLeft();
adjusted += rect.bottomRight(); adjusted += rect.bottomRight();
}
return adjusted;
} }
return adjusted; \endcode
}\endverbatim\n \endpar
\param points Selected points \param points Selected points
\return Selected points unmodified \return Selected points unmodified
@@ -832,7 +836,7 @@ QRect QwtPicker::trackerRect( const QFont &font ) const
&& rubberBand() != NoRubberBand ) && rubberBand() != NoRubberBand )
{ {
const QPoint last = 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.x() >= last.x() ) ? Qt::AlignRight : Qt::AlignLeft;
alignment |= ( pos.y() > last.y() ) ? Qt::AlignBottom : Qt::AlignTop; alignment |= ( pos.y() > last.y() ) ? Qt::AlignBottom : Qt::AlignTop;
@@ -1182,7 +1186,7 @@ void QwtPicker::transition( const QEvent *event )
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
case QEvent::MouseMove: case QEvent::MouseMove:
{ {
const QMouseEvent *me = const QMouseEvent *me =
static_cast< const QMouseEvent * >( event ); static_cast< const QMouseEvent * >( event );
pos = me->pos(); pos = me->pos();
break; break;
@@ -1234,7 +1238,7 @@ void QwtPicker::begin()
if ( d_data->isActive ) if ( d_data->isActive )
return; return;
d_data->pickedPoints.resize( 0 ); d_data->pickedPoints.clear();
d_data->isActive = true; d_data->isActive = true;
Q_EMIT activated( true ); Q_EMIT activated( true );
@@ -1280,7 +1284,7 @@ bool QwtPicker::end( bool ok )
if ( ok ) if ( ok )
Q_EMIT selected( d_data->pickedPoints ); Q_EMIT selected( d_data->pickedPoints );
else else
d_data->pickedPoints.resize( 0 ); d_data->pickedPoints.clear();
updateDisplay(); updateDisplay();
} }
@@ -1314,9 +1318,7 @@ void QwtPicker::append( const QPoint &pos )
{ {
if ( d_data->isActive ) if ( d_data->isActive )
{ {
const int idx = d_data->pickedPoints.count(); d_data->pickedPoints += pos;
d_data->pickedPoints.resize( idx + 1 );
d_data->pickedPoints[idx] = pos;
updateDisplay(); updateDisplay();
Q_EMIT appended( pos ); Q_EMIT appended( pos );
@@ -1332,18 +1334,15 @@ void QwtPicker::append( const QPoint &pos )
*/ */
void QwtPicker::move( 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; QPoint &point = d_data->pickedPoints.last();
if ( idx >= 0 ) if ( point != pos )
{ {
if ( d_data->pickedPoints[idx] != pos ) point = pos;
{
d_data->pickedPoints[idx] = pos;
updateDisplay(); updateDisplay();
Q_EMIT moved( pos ); Q_EMIT moved( pos );
}
} }
} }
} }
@@ -1356,19 +1355,17 @@ void QwtPicker::move( const QPoint &pos )
*/ */
void QwtPicker::remove() void QwtPicker::remove()
{ {
if ( d_data->isActive ) if ( d_data->isActive && !d_data->pickedPoints.isEmpty() )
{ {
const int idx = d_data->pickedPoints.count() - 1; #if QT_VERSION >= 0x050100
if ( idx > 0 ) const QPoint pos = d_data->pickedPoints.takeLast();
{ #else
const int idx = d_data->pickedPoints.count(); const QPoint pos = d_data->pickedPoints.last();
d_data->pickedPoints.resize( d_data->pickedPoints.count() - 1 );
#endif
const QPoint pos = d_data->pickedPoints[idx - 1]; updateDisplay();
d_data->pickedPoints.resize( idx - 1 ); Q_EMIT removed( pos );
updateDisplay();
Q_EMIT removed( pos );
}
} }
} }
@@ -1423,12 +1420,10 @@ void QwtPicker::stretchSelection( const QSize &oldSize, const QSize &newSize )
return; return;
} }
const double xRatio = const double xRatio = double( newSize.width() ) / double( oldSize.width() );
double( newSize.width() ) / double( oldSize.width() ); const double yRatio = double( newSize.height() ) / double( oldSize.height() );
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]; QPoint &p = d_data->pickedPoints[i];
p.setX( qRound( p.x() * xRatio ) ); p.setX( qRound( p.x() * xRatio ) );
@@ -1471,7 +1466,7 @@ void QwtPicker::setMouseTracking( bool enable )
/*! /*!
Find the area of the observed widget, where selection might happen. Find the area of the observed widget, where selection might happen.
\return parentWidget()->contentsRect() \return parentWidget()->contentsRect()
*/ */
QPainterPath QwtPicker::pickArea() const QPainterPath QwtPicker::pickArea() const
{ {
@@ -1503,7 +1498,7 @@ void QwtPicker::updateDisplay()
if ( trackerMode() == AlwaysOn || if ( trackerMode() == AlwaysOn ||
( trackerMode() == ActiveOnly && isActive() ) ) ( trackerMode() == ActiveOnly && isActive() ) )
{ {
if ( trackerPen() != Qt::NoPen if ( trackerPen() != Qt::NoPen
&& !trackerRect( QFont() ).isEmpty() ) && !trackerRect( QFont() ).isEmpty() )
{ {
showTracker = true; showTracker = true;

View File

@@ -58,13 +58,16 @@ class QwtWidgetOverlay;
position. position.
\par Example \par Example
\verbatim #include <qwt_picker.h> \code
#include <qwt_picker_machine.h> #include <qwt_picker.h>
#include <qwt_picker_machine.h>
QwtPicker *picker = new QwtPicker(widget); QwtPicker *picker = new QwtPicker(widget);
picker->setStateMachine(new QwtPickerDragRectMachine); picker->setStateMachine(new QwtPickerDragRectMachine);
picker->setTrackerMode(QwtPicker::ActiveOnly); picker->setTrackerMode(QwtPicker::ActiveOnly);
picker->setRubberBand(QwtPicker::RectRubberBand); \endverbatim\n picker->setRubberBand(QwtPicker::RectRubberBand);
\endcode
\endpar
The state machine triggers the following commands: The state machine triggers the following commands:
@@ -307,8 +310,8 @@ protected:
virtual void widgetEnterEvent( QEvent * ); virtual void widgetEnterEvent( QEvent * );
virtual void widgetLeaveEvent( QEvent * ); virtual void widgetLeaveEvent( QEvent * );
virtual void stretchSelection( const QSize &oldSize, virtual void stretchSelection(
const QSize &newSize ); const QSize &oldSize, const QSize &newSize );
virtual void updateDisplay(); virtual void updateDisplay();

View File

@@ -105,7 +105,7 @@ QList<QwtPickerMachine::Command> QwtPickerClickPointMachine::transition(
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
cmdList += Begin; cmdList += Begin;
@@ -151,7 +151,7 @@ QList<QwtPickerMachine::Command> QwtPickerDragPointMachine::transition(
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
if ( state() == 0 ) if ( state() == 0 )
@@ -224,7 +224,7 @@ QList<QwtPickerMachine::Command> QwtPickerClickRectMachine::transition(
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
switch ( state() ) switch ( state() )
@@ -259,7 +259,7 @@ QList<QwtPickerMachine::Command> QwtPickerClickRectMachine::transition(
} }
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
{ {
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
if ( state() == 1 ) if ( state() == 1 )
@@ -323,7 +323,7 @@ QList<QwtPickerMachine::Command> QwtPickerDragRectMachine::transition(
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
if ( state() == 0 ) if ( state() == 0 )
@@ -354,7 +354,7 @@ QList<QwtPickerMachine::Command> QwtPickerDragRectMachine::transition(
} }
case QEvent::KeyPress: case QEvent::KeyPress:
{ {
if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1,
static_cast<const QKeyEvent *> ( event ) ) ) static_cast<const QKeyEvent *> ( event ) ) )
{ {
if ( state() == 0 ) if ( state() == 0 )
@@ -395,7 +395,7 @@ QList<QwtPickerMachine::Command> QwtPickerPolygonMachine::transition(
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
if ( state() == 0 ) if ( state() == 0 )
@@ -410,7 +410,7 @@ QList<QwtPickerMachine::Command> QwtPickerPolygonMachine::transition(
cmdList += Append; cmdList += Append;
} }
} }
if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2, if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2,
static_cast<const QMouseEvent *>( event ) ) ) static_cast<const QMouseEvent *>( event ) ) )
{ {
if ( state() == 1 ) if ( state() == 1 )

View File

@@ -169,7 +169,7 @@ public:
/*! /*!
\brief A state machine for line selections \brief A state machine for line selections
Pressing QwtEventPattern::MouseSelect1 selects Pressing QwtEventPattern::MouseSelect1 selects
the first point, releasing it the second point. the first point, releasing it the second point.
Pressing QwtEventPattern::KeySelect1 also selects the Pressing QwtEventPattern::KeySelect1 also selects the
@@ -178,10 +178,10 @@ public:
A common use case of QwtPickerDragLineMachine are pickers for A common use case of QwtPickerDragLineMachine are pickers for
distance measurements. distance measurements.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/ */
class QWT_EXPORT QwtPickerDragLineMachine: public QwtPickerMachine class QWT_EXPORT QwtPickerDragLineMachine: public QwtPickerMachine
{ {
public: public:

View File

@@ -27,23 +27,21 @@ static inline void qwtEnableLegendItems( QwtPlot *plot, bool on )
{ {
if ( on ) if ( on )
{ {
QObject::connect( QObject::connect(
plot, SIGNAL( legendDataChanged( plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
const QVariant &, const QList<QwtLegendData> & ) ), plot, SLOT(updateLegendItems(QVariant,QList<QwtLegendData>))
plot, SLOT( updateLegendItems( );
const QVariant &, const QList<QwtLegendData> & ) ) );
} }
else else
{ {
QObject::disconnect( QObject::disconnect(
plot, SIGNAL( legendDataChanged( plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>) ),
const QVariant &, const QList<QwtLegendData> & ) ), plot, SLOT( updateLegendItems(QVariant,QList<QwtLegendData>))
plot, SLOT( updateLegendItems( );
const QVariant &, const QList<QwtLegendData> & ) ) );
} }
} }
static void qwtSetTabOrder( static void qwtSetTabOrder(
QWidget *first, QWidget *second, bool withChildren ) QWidget *first, QWidget *second, bool withChildren )
{ {
QList<QWidget *> tabChain; QList<QWidget *> tabChain;
@@ -195,7 +193,7 @@ void QwtPlot::initPlot( const QwtText &title )
QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ). QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ).
In opposite to using conventional C++ techniques like virtual methods In opposite to using conventional C++ techniques like virtual methods
they allow to use canvas implementations that are derived from they allow to use canvas implementations that are derived from
QWidget or QGLWidget. QWidget or QGLWidget.
The following meta methods could be implemented: The following meta methods could be implemented:
@@ -209,7 +207,7 @@ void QwtPlot::initPlot( const QwtText &title )
When the canvas doesn't have any special border ( f.e rounded corners ) When the canvas doesn't have any special border ( f.e rounded corners )
it is o.k. not to implement this method. it is o.k. not to implement this method.
The default canvas is a QwtPlotCanvas The default canvas is a QwtPlotCanvas
\param canvas Canvas Widget \param canvas Canvas Widget
\sa canvas() \sa canvas()
@@ -316,7 +314,7 @@ void QwtPlot::setAutoReplot( bool tf )
d_data->autoReplot = tf; d_data->autoReplot = tf;
} }
/*! /*!
\return true if the autoReplot option is set. \return true if the autoReplot option is set.
\sa setAutoReplot() \sa setAutoReplot()
*/ */
@@ -370,7 +368,7 @@ const QwtTextLabel *QwtPlot::titleLabel() const
} }
/*! /*!
Change the text the footer Change the text the footer
\param text New text of the footer \param text New text of the footer
*/ */
void QwtPlot::setFooter( const QString &text ) void QwtPlot::setFooter( const QString &text )
@@ -383,7 +381,7 @@ void QwtPlot::setFooter( const QString &text )
} }
/*! /*!
Change the text the footer Change the text the footer
\param text New text of the footer \param text New text of the footer
*/ */
void QwtPlot::setFooter( const QwtText &text ) void QwtPlot::setFooter( const QwtText &text )
@@ -559,7 +557,7 @@ void QwtPlot::replot()
if ( d_data->canvas ) if ( d_data->canvas )
{ {
const bool ok = QMetaObject::invokeMethod( const bool ok = QMetaObject::invokeMethod(
d_data->canvas, "replot", Qt::DirectConnection ); d_data->canvas, "replot", Qt::DirectConnection );
if ( !ok ) if ( !ok )
{ {
@@ -605,13 +603,24 @@ void QwtPlot::updateLayout()
d_data->footerLabel->show(); d_data->footerLabel->show();
} }
else else
{
d_data->footerLabel->hide(); d_data->footerLabel->hide();
}
for ( int axisId = 0; axisId < axisCnt; axisId++ ) for ( int axisId = 0; axisId < axisCnt; axisId++ )
{ {
QwtScaleWidget* scaleWidget = axisWidget( axisId );
if ( axisEnabled( 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 1
if ( axisId == xBottom || axisId == xTop ) if ( axisId == xBottom || axisId == xTop )
@@ -626,14 +635,16 @@ void QwtPlot::updateLayout()
r.translate( -scaleRect[ axisId ].x(), r.translate( -scaleRect[ axisId ].x(),
-scaleRect[axisId].y() ); -scaleRect[axisId].y() );
axisWidget( axisId )->setMask( r ); scaleWidget->setMask( r );
} }
#endif #endif
if ( !axisWidget( axisId )->isVisibleTo( this ) ) if ( !scaleWidget->isVisibleTo( this ) )
axisWidget( axisId )->show(); scaleWidget->show();
} }
else else
axisWidget( axisId )->hide(); {
scaleWidget->hide();
}
} }
if ( d_data->legend ) if ( d_data->legend )
@@ -710,7 +721,7 @@ void QwtPlot::updateCanvasMargins()
double margins[axisCnt]; double margins[axisCnt];
getCanvasMarginsHint( maps, canvas()->contentsRect(), getCanvasMarginsHint( maps, canvas()->contentsRect(),
margins[yLeft], margins[xTop], margins[yRight], margins[xBottom] ); margins[yLeft], margins[xTop], margins[yRight], margins[xBottom] );
bool doUpdate = false; bool doUpdate = false;
for ( int axisId = 0; axisId < axisCnt; axisId++ ) for ( int axisId = 0; axisId < axisCnt; axisId++ )
{ {
@@ -752,8 +763,8 @@ void QwtPlot::drawCanvas( QPainter *painter )
\param maps QwtPlot::axisCnt maps, mapping between plot and paint device coordinates \param maps QwtPlot::axisCnt maps, mapping between plot and paint device coordinates
\note Usually canvasRect is contentsRect() of the plot canvas. \note Usually canvasRect is contentsRect() of the plot canvas.
Due to a bug in Qt this rectangle might be wrong for certain Due to a bug in Qt this rectangle might be wrong for certain
frame styles ( f.e QFrame::Box ) and it might be necessary to frame styles ( f.e QFrame::Box ) and it might be necessary to
fix the margins manually using QWidget::setContentsMargins() fix the margins manually using QWidget::setContentsMargins()
*/ */
@@ -900,7 +911,7 @@ bool QwtPlot::axisValid( int axisId )
with a best fit number of columns from left to right. with a best fit number of columns from left to right.
insertLegend() will set the plot widget as parent for the legend. insertLegend() will set the plot widget as parent for the legend.
The legend will be deleted in the destructor of the plot or when The legend will be deleted in the destructor of the plot or when
another legend is inserted. another legend is inserted.
Legends, that are not inserted into the layout of the plot widget Legends, that are not inserted into the layout of the plot widget
@@ -938,12 +949,9 @@ void QwtPlot::insertLegend( QwtAbstractLegend *legend,
if ( d_data->legend ) if ( d_data->legend )
{ {
connect( this, connect(
SIGNAL( legendDataChanged( this, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
const QVariant &, const QList<QwtLegendData> & ) ), d_data->legend, SLOT(updateLegend(QVariant,QList<QwtLegendData>) )
d_data->legend,
SLOT( updateLegend(
const QVariant &, const QList<QwtLegendData> & ) )
); );
if ( d_data->legend->parent() != this ) if ( d_data->legend->parent() != this )
@@ -1074,7 +1082,7 @@ void QwtPlot::updateLegendItems( const QVariant &itemInfo,
} }
/*! /*!
\brief Attach/Detach a plot item \brief Attach/Detach a plot item
\param plotItem Plot item \param plotItem Plot item
\param on When true attach the item, otherwise detach it \param on When true attach the item, otherwise detach it
@@ -1102,7 +1110,7 @@ void QwtPlot::attachItem( QwtPlotItem *plotItem, bool on )
if ( on ) if ( on )
insertItem( plotItem ); insertItem( plotItem );
else else
removeItem( plotItem ); removeItem( plotItem );
Q_EMIT itemAttached( plotItem, on ); Q_EMIT itemAttached( plotItem, on );
@@ -1154,7 +1162,7 @@ QVariant QwtPlot::itemToInfo( QwtPlotItem *plotItem ) const
\brief Identify the plot item according to an item info object, \brief Identify the plot item according to an item info object,
that has bee generated from itemToInfo(). that has bee generated from itemToInfo().
The default implementation simply tries to unwrap a QwtPlotItem The default implementation simply tries to unwrap a QwtPlotItem
pointer: pointer:
\code \code

View File

@@ -40,42 +40,43 @@ class QwtTextLabel;
are calculated from the plot items, using algorithms (QwtScaleEngine) which are calculated from the plot items, using algorithms (QwtScaleEngine) which
can be configured separately for each axis. can be configured separately for each axis.
The simpleplot example is a good starting point to see how to set up a The simpleplot example is a good starting point to see how to set up a
plot widget. plot widget.
\image html plot.png \image html plot.png
\par Example \par Example
The following example shows (schematically) the most simple The following example shows (schematically) the most simple
way to use QwtPlot. By default, only the left and bottom axes are way to use QwtPlot. By default, only the left and bottom axes are
visible and their scales are computed automatically. visible and their scales are computed automatically.
\verbatim \code
#include <qwt_plot.h> #include <qwt_plot.h>
#include <qwt_plot_curve.h> #include <qwt_plot_curve.h>
QwtPlot *myPlot = new QwtPlot("Two Curves", parent); QwtPlot *myPlot = new QwtPlot( "Two Curves", parent );
// add curves // add curves
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); QwtPlotCurve *curve1 = new QwtPlotCurve( "Curve 1" );
QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); QwtPlotCurve *curve2 = new QwtPlotCurve( "Curve 2" );
// connect or copy the data to the curves // connect or copy the data to the curves
curve1->setData(...); curve1->setData( ... );
curve2->setData(...); curve2->setData( ... );
curve1->attach(myPlot); curve1->attach( myPlot );
curve2->attach(myPlot); curve2->attach( myPlot );
// finally, refresh the plot // finally, refresh the plot
myPlot->replot(); myPlot->replot();
\endverbatim \endcode
\endpar
*/ */
class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( QBrush canvasBackground Q_PROPERTY( QBrush canvasBackground
READ canvasBackground WRITE setCanvasBackground ) READ canvasBackground WRITE setCanvasBackground )
Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot ) Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
@@ -121,7 +122,7 @@ public:
//! The legend will be right from the QwtPlot::yRight axis. //! The legend will be right from the QwtPlot::yRight axis.
RightLegend, RightLegend,
//! The legend will be below the footer //! The legend will be below the footer
BottomLegend, BottomLegend,
//! The legend will be above the title //! The legend will be above the title
@@ -149,7 +150,7 @@ public:
// Title // Title
void setTitle( const QString & ); void setTitle( const QString & );
void setTitle( const QwtText &t ); void setTitle( const QwtText & );
QwtText title() const; QwtText title() const;
QwtTextLabel *titleLabel(); QwtTextLabel *titleLabel();
@@ -158,7 +159,7 @@ public:
// Footer // Footer
void setFooter( const QString & ); void setFooter( const QString & );
void setFooter( const QwtText &t ); void setFooter( const QwtText & );
QwtText footer() const; QwtText footer() const;
QwtTextLabel *footerLabel(); QwtTextLabel *footerLabel();
@@ -191,10 +192,10 @@ public:
void enableAxis( int axisId, bool tf = true ); void enableAxis( int axisId, bool tf = true );
bool axisEnabled( int axisId ) const; bool axisEnabled( int axisId ) const;
void setAxisFont( int axisId, const QFont &f ); void setAxisFont( int axisId, const QFont & );
QFont axisFont( int axisId ) const; 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 setAxisScaleDiv( int axisId, const QwtScaleDiv & );
void setAxisScaleDraw( int axisId, QwtScaleDraw * ); void setAxisScaleDraw( int axisId, QwtScaleDraw * );
@@ -224,7 +225,7 @@ public:
// Legend // Legend
void insertLegend( QwtAbstractLegend *, void insertLegend( QwtAbstractLegend *,
LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 ); LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
QwtAbstractLegend *legend(); QwtAbstractLegend *legend();
@@ -244,7 +245,7 @@ public:
void updateAxes(); void updateAxes();
void updateCanvasMargins(); void updateCanvasMargins();
virtual void getCanvasMarginsHint( virtual void getCanvasMarginsHint(
const QwtScaleMap maps[], const QRectF &canvasRect, const QwtScaleMap maps[], const QRectF &canvasRect,
double &left, double &top, double &right, double &bottom) const; double &left, double &top, double &right, double &bottom) const;
@@ -267,7 +268,7 @@ Q_SIGNALS:
void itemAttached( QwtPlotItem *plotItem, bool on ); void itemAttached( QwtPlotItem *plotItem, bool on );
/*! /*!
A signal with the attributes how to update A signal with the attributes how to update
the legend entries for a plot item. the legend entries for a plot item.
\param itemInfo Info about a plot item, build from itemToInfo() \param itemInfo Info about a plot item, build from itemToInfo()
@@ -276,7 +277,7 @@ Q_SIGNALS:
\sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
*/ */
void legendDataChanged( const QVariant &itemInfo, void legendDataChanged( const QVariant &itemInfo,
const QList<QwtLegendData> &data ); const QList<QwtLegendData> &data );
public Q_SLOTS: public Q_SLOTS:
@@ -290,7 +291,7 @@ protected:
private Q_SLOTS: private Q_SLOTS:
void updateLegendItems( const QVariant &itemInfo, void updateLegendItems( const QVariant &itemInfo,
const QList<QwtLegendData> &data ); const QList<QwtLegendData> &legendData );
private: private:
friend class QwtPlotItem; friend class QwtPlotItem;

View File

@@ -180,8 +180,8 @@ int QwtPlotAbstractBarChart::margin() const
/*! /*!
\brief Set the baseline \brief Set the baseline
The baseline is the origin for the chart. Each bar is The baseline is the origin for the chart. Each bar is
painted from the baseline in the direction of the sample painted from the baseline in the direction of the sample
value. In case of a horizontal orientation() the baseline value. In case of a horizontal orientation() the baseline
is interpreted as x - otherwise as y - value. is interpreted as x - otherwise as y - value.
@@ -200,7 +200,7 @@ void QwtPlotAbstractBarChart::setBaseline( double value )
} }
} }
/*! /*!
\return Value for the origin of the bar chart \return Value for the origin of the bar chart
\sa setBaseline(), QwtPlotSeriesItem::orientation() \sa setBaseline(), QwtPlotSeriesItem::orientation()
*/ */
@@ -285,7 +285,7 @@ double QwtPlotAbstractBarChart::sampleWidth( const QwtScaleMap &map,
\sa layoutPolicy(), layoutHint(), QwtPlotItem::Margins \sa layoutPolicy(), layoutHint(), QwtPlotItem::Margins
QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins() QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
*/ */
void QwtPlotAbstractBarChart::getCanvasMarginHint( const QwtScaleMap &xMap, void QwtPlotAbstractBarChart::getCanvasMarginHint( const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtScaleMap &yMap, const QRectF &canvasRect,
double &left, double &top, double &right, double &bottom ) const double &left, double &top, double &right, double &bottom ) const
{ {

View File

@@ -17,7 +17,7 @@
/*! /*!
\brief Abstract base class for bar chart items \brief Abstract base class for bar chart items
In opposite to almost all other plot items bar charts can't be In opposite to almost all other plot items bar charts can't be
displayed inside of their bounding rectangle and need a special displayed inside of their bounding rectangle and need a special
API how to calculate the width of the bars and how they affect API how to calculate the width of the bars and how they affect
the layout of the attached plot. the layout of the attached plot.
@@ -78,7 +78,7 @@ public:
void setBaseline( double ); void setBaseline( double );
double baseline() const; double baseline() const;
virtual void getCanvasMarginHint( virtual void getCanvasMarginHint(
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, const QRectF &canvasRect,
double &left, double &top, double &right, double &bottom) const; double &left, double &top, double &right, double &bottom) const;
@@ -86,7 +86,7 @@ public:
protected: protected:
double sampleWidth( const QwtScaleMap &map, double sampleWidth( const QwtScaleMap &map,
double canvasSize, double dataSize, double canvasSize, double boundingSize,
double value ) const; double value ) const;
private: private:

View File

@@ -67,7 +67,7 @@ void QwtPlot::initAxesData()
d.scaleEngine = new QwtLinearScaleEngine; d.scaleEngine = new QwtLinearScaleEngine;
d.scaleWidget->setTransformation( d.scaleWidget->setTransformation(
d.scaleEngine->transformation() ); d.scaleEngine->transformation() );
d.scaleWidget->setFont( fscl ); d.scaleWidget->setFont( fscl );
@@ -147,7 +147,7 @@ void QwtPlot::setAxisScaleEngine( int axisId, QwtScaleEngine *scaleEngine )
delete d.scaleEngine; delete d.scaleEngine;
d.scaleEngine = scaleEngine; d.scaleEngine = scaleEngine;
d_axisData[axisId]->scaleWidget->setTransformation( d_axisData[axisId]->scaleWidget->setTransformation(
scaleEngine->transformation() ); scaleEngine->transformation() );
d.isValid = false; d.isValid = false;
@@ -189,7 +189,6 @@ bool QwtPlot::axisAutoScale( int axisId ) const
return d_axisData[axisId]->doAutoScale; return d_axisData[axisId]->doAutoScale;
else else
return false; return false;
} }
/*! /*!
@@ -288,7 +287,7 @@ QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId )
} }
/*! /*!
\brief Return the step size parameter that has been set in setAxisScale. \brief Return the step size parameter that has been set in setAxisScale.
This doesn't need to be the step size of the current scale. This doesn't need to be the step size of the current scale.
@@ -309,7 +308,7 @@ double QwtPlot::axisStepSize( int axisId ) const
\brief Return the current interval of the specified axis \brief Return the current interval of the specified axis
This is only a convenience function for axisScaleDiv( axisId )->interval(); This is only a convenience function for axisScaleDiv( axisId )->interval();
\param axisId Axis index \param axisId Axis index
\return Scale interval \return Scale interval
@@ -433,8 +432,8 @@ void QwtPlot::setAxisAutoScale( int axisId, bool on )
/*! /*!
\brief Disable autoscaling and specify a fixed scale for a selected axis. \brief Disable autoscaling and specify a fixed scale for a selected axis.
In updateAxes() the scale engine calculates a scale division from the In updateAxes() the scale engine calculates a scale division from the
specified parameters, that will be assigned to the scale widget. So specified parameters, that will be assigned to the scale widget. So
updates of the scale widget usually happen delayed with the next replot. updates of the scale widget usually happen delayed with the next replot.
\param axisId Axis index \param axisId Axis index
@@ -466,7 +465,7 @@ void QwtPlot::setAxisScale( int axisId, double min, double max, double stepSize
\brief Disable autoscaling and specify a fixed scale for a selected axis. \brief Disable autoscaling and specify a fixed scale for a selected axis.
The scale division will be stored locally only until the next call The scale division will be stored locally only until the next call
of updateAxes(). So updates of the scale widget usually happen delayed with of updateAxes(). So updates of the scale widget usually happen delayed with
the next replot. the next replot.
\param axisId Axis index \param axisId Axis index
@@ -614,26 +613,26 @@ void QwtPlot::setAxisTitle( int axisId, const QwtText &title )
axisWidget( axisId )->setTitle( title ); axisWidget( axisId )->setTitle( title );
} }
/*! /*!
\brief Rebuild the axes scales \brief Rebuild the axes scales
In case of autoscaling the boundaries of a scale are calculated In case of autoscaling the boundaries of a scale are calculated
from the bounding rectangles of all plot items, having the from the bounding rectangles of all plot items, having the
QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ).
Then a scale division is calculated ( QwtScaleEngine::didvideScale() ) Then a scale division is calculated ( QwtScaleEngine::didvideScale() )
and assigned to scale widget. and assigned to scale widget.
When the scale boundaries have been assigned with setAxisScale() a When the scale boundaries have been assigned with setAxisScale() a
scale division is calculated ( QwtScaleEngine::didvideScale() ) scale division is calculated ( QwtScaleEngine::didvideScale() )
for this interval and assigned to the scale widget. for this interval and assigned to the scale widget.
When the scale has been set explicitly by setAxisScaleDiv() the When the scale has been set explicitly by setAxisScaleDiv() the
locally stored scale division gets assigned to the scale widget. locally stored scale division gets assigned to the scale widget.
The scale widget indicates modifications by emitting a The scale widget indicates modifications by emitting a
QwtScaleWidget::scaleDivChanged() signal. QwtScaleWidget::scaleDivChanged() signal.
updateAxes() is usually called by replot(). updateAxes() is usually called by replot().
\sa setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot() \sa setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot()
QwtPlotItem::boundingRect() QwtPlotItem::boundingRect()

View File

@@ -21,7 +21,7 @@ public:
legendMode( QwtPlotBarChart::LegendChartTitle ) legendMode( QwtPlotBarChart::LegendChartTitle )
{ {
} }
~PrivateData() ~PrivateData()
{ {
delete symbol; delete symbol;
@@ -120,7 +120,7 @@ void QwtPlotBarChart::setSamples( QwtSeriesData<QPointF> *data )
\brief Assign a symbol \brief Assign a symbol
The bar chart will take the ownership of the symbol, hence the previously The bar chart will take the ownership of the symbol, hence the previously
set symbol will be delete by setting a new one. If \p symbol is set symbol will be delete by setting a new one. If \p symbol is
\c NULL no symbol will be drawn. \c NULL no symbol will be drawn.
\param symbol Symbol \param symbol Symbol
@@ -304,7 +304,7 @@ void QwtPlotBarChart::drawSample( QPainter *painter,
} }
/*! /*!
Draw a bar Draw a bar
\param painter Painter \param painter Painter
\param sampleIndex Index of the sample represented by the bar \param sampleIndex Index of the sample represented by the bar
@@ -312,10 +312,10 @@ void QwtPlotBarChart::drawSample( QPainter *painter,
\param rect Bounding rectangle of the bar \param rect Bounding rectangle of the bar
*/ */
void QwtPlotBarChart::drawBar( QPainter *painter, void QwtPlotBarChart::drawBar( QPainter *painter,
int sampleIndex, const QPointF &sample, int sampleIndex, const QPointF &sample,
const QwtColumnRect &rect ) const const QwtColumnRect &rect ) const
{ {
const QwtColumnSymbol *specialSym = const QwtColumnSymbol *specialSym =
specialSymbol( sampleIndex, sample ); specialSymbol( sampleIndex, sample );
const QwtColumnSymbol *sym = specialSym; const QwtColumnSymbol *sym = specialSym;
@@ -329,17 +329,17 @@ void QwtPlotBarChart::drawBar( QPainter *painter,
else else
{ {
// we build a temporary default symbol // we build a temporary default symbol
QwtColumnSymbol sym( QwtColumnSymbol::Box ); QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box );
sym.setLineWidth( 1 ); columnSymbol.setLineWidth( 1 );
sym.setFrameStyle( QwtColumnSymbol::Plain ); columnSymbol.setFrameStyle( QwtColumnSymbol::Plain );
sym.draw( painter, rect ); columnSymbol.draw( painter, rect );
} }
delete specialSym; delete specialSym;
} }
/*! /*!
Needs to be overloaded to return a Needs to be overloaded to return a
non default symbol for a specific sample non default symbol for a specific sample
\param sampleIndex Index of the sample represented by the bar \param sampleIndex Index of the sample represented by the bar
@@ -347,7 +347,7 @@ void QwtPlotBarChart::drawBar( QPainter *painter,
\return NULL, indicating to use the default symbol \return NULL, indicating to use the default symbol
*/ */
QwtColumnSymbol *QwtPlotBarChart::specialSymbol( QwtColumnSymbol *QwtPlotBarChart::specialSymbol(
int sampleIndex, const QPointF &sample ) const int sampleIndex, const QPointF &sample ) const
{ {
Q_UNUSED( sampleIndex ); Q_UNUSED( sampleIndex );
@@ -428,13 +428,13 @@ QList<QwtLegendData> QwtPlotBarChart::legendData() const
the bar corresponding to index - otherwise the bar the bar corresponding to index - otherwise the bar
displays the default symbol. displays the default symbol.
\param index Index of the legend entry \param index Index of the legend entry
\param size Icon size \param size Icon size
\sa setLegendMode(), drawBar(), \sa setLegendMode(), drawBar(),
QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/ */
QwtGraphic QwtPlotBarChart::legendIcon( QwtGraphic QwtPlotBarChart::legendIcon(
int index, const QSizeF &size ) const int index, const QSizeF &size ) const
{ {
QwtColumnRect column; QwtColumnRect column;
@@ -452,7 +452,7 @@ QwtGraphic QwtPlotBarChart::legendIcon(
int barIndex = -1; int barIndex = -1;
if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles ) if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
barIndex = index; barIndex = index;
drawBar( &painter, barIndex, QPointF(), column ); drawBar( &painter, barIndex, QPointF(), column );
return icon; return icon;

View File

@@ -23,8 +23,8 @@ class QwtColumnSymbol;
Each bar might be customized individually by implementing Each bar might be customized individually by implementing
a specialSymbol(). Otherwise it is rendered using a default symbol. a specialSymbol(). Otherwise it is rendered using a default symbol.
Depending on its orientation() the bars are displayed horizontally Depending on its orientation() the bars are displayed horizontally
or vertically. The bars cover the interval between the baseline() or vertically. The bars cover the interval between the baseline()
and the value. and the value.
By activating the LegendBarTitles mode each sample will have By activating the LegendBarTitles mode each sample will have
@@ -50,7 +50,7 @@ public:
*/ */
enum LegendMode enum LegendMode
{ {
/*! /*!
One entry on the legend showing the default symbol One entry on the legend showing the default symbol
and the title() of the chart and the title() of the chart
@@ -67,7 +67,7 @@ public:
LegendBarTitles LegendBarTitles
}; };
explicit QwtPlotBarChart( const QString &title = QString::null ); explicit QwtPlotBarChart( const QString &title = QString() );
explicit QwtPlotBarChart( const QwtText &title ); explicit QwtPlotBarChart( const QwtText &title );
virtual ~QwtPlotBarChart(); virtual ~QwtPlotBarChart();
@@ -76,7 +76,7 @@ public:
void setSamples( const QVector<QPointF> & ); void setSamples( const QVector<QPointF> & );
void setSamples( const QVector<double> & ); void setSamples( const QVector<double> & );
void setSamples( QwtSeriesData<QPointF> *series ); void setSamples( QwtSeriesData<QPointF> * );
void setSymbol( QwtColumnSymbol * ); void setSymbol( QwtColumnSymbol * );
const QwtColumnSymbol *symbol() const; const QwtColumnSymbol *symbol() const;
@@ -90,7 +90,7 @@ public:
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;
virtual QwtColumnSymbol *specialSymbol( virtual QwtColumnSymbol *specialSymbol(
int sampleIndex, const QPointF& ) const; int sampleIndex, const QPointF& ) const;
virtual QwtText barTitle( int sampleIndex ) const; virtual QwtText barTitle( int sampleIndex ) const;
@@ -102,7 +102,7 @@ protected:
int index, const QPointF& sample ) const; int index, const QPointF& sample ) const;
virtual void drawBar( QPainter *, virtual void drawBar( QPainter *,
int sampleIndex, const QPointF& point, int sampleIndex, const QPointF& sample,
const QwtColumnRect & ) const; const QwtColumnRect & ) const;
QList<QwtLegendData> legendData() const; QList<QwtLegendData> legendData() const;

View File

@@ -48,6 +48,12 @@ public:
border.rectList += rects[i]; 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 ) virtual void drawPath( const QPainterPath &path )
{ {
const QRectF rect( QPointF( 0.0, 0.0 ), d_size ); const QRectF rect( QPointF( 0.0, 0.0 ), d_size );
@@ -72,7 +78,7 @@ public:
for ( int i = 0; i < path.elementCount(); i++ ) for ( int i = 0; i < path.elementCount(); i++ )
{ {
QPainterPath::Element el = path.elementAt(i); QPainterPath::Element el = path.elementAt(i);
switch( el.type ) switch( el.type )
{ {
case QPainterPath::MoveToElement: case QPainterPath::MoveToElement:
@@ -97,7 +103,7 @@ public:
if ( clipRects.size() > 0 ) if ( clipRects.size() > 0 )
{ {
QRectF r = clipRects.last(); QRectF r = clipRects.last();
r.setCoords( r.setCoords(
qMin( r.left(), el.x ), qMin( r.left(), el.x ),
qMin( r.top(), el.y ), qMin( r.top(), el.y ),
qMax( r.right(), el.x ), qMax( r.right(), el.x ),
@@ -169,7 +175,7 @@ static void qwtDrawBackground( QPainter *painter, QwtPlotCanvas *canvas )
if ( !borderClip.isEmpty() ) if ( !borderClip.isEmpty() )
painter->setClipPath( borderClip, Qt::IntersectClip ); painter->setClipPath( borderClip, Qt::IntersectClip );
const QBrush &brush = const QBrush &brush =
canvas->palette().brush( canvas->backgroundRole() ); canvas->palette().brush( canvas->backgroundRole() );
if ( brush.style() == Qt::TexturePattern ) if ( brush.style() == Qt::TexturePattern )
@@ -185,8 +191,8 @@ static void qwtDrawBackground( QPainter *painter, QwtPlotCanvas *canvas )
if ( brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode ) if ( brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode )
{ {
rects += canvas->rect(); rects += canvas->rect();
} }
else else
{ {
rects = painter->clipRegion().rects(); rects = painter->clipRegion().rects();
} }
@@ -196,7 +202,7 @@ static void qwtDrawBackground( QPainter *painter, QwtPlotCanvas *canvas )
if ( painter->paintEngine()->type() == QPaintEngine::X11 ) if ( painter->paintEngine()->type() == QPaintEngine::X11 )
{ {
// Qt 4.7.1: gradients on X11 are broken ( subrects + // Qt 4.7.1: gradients on X11 are broken ( subrects +
// QGradient::StretchToDeviceMode ) and horrible slow. // QGradient::StretchToDeviceMode ) and horrible slow.
// As workaround we have to use the raster paintengine. // As workaround we have to use the raster paintengine.
// Even if the QImage -> QPixmap translation is slow // Even if the QImage -> QPixmap translation is slow
@@ -222,7 +228,7 @@ static void qwtDrawBackground( QPainter *painter, QwtPlotCanvas *canvas )
break; break;
} }
} }
QImage image( canvas->size(), format ); QImage image( canvas->size(), format );
QPainter p( &image ); QPainter p( &image );
@@ -267,7 +273,7 @@ static inline void qwtRevertPath( QPainterPath &path )
} }
} }
static QPainterPath qwtCombinePathList( const QRectF &rect, static QPainterPath qwtCombinePathList( const QRectF &rect,
const QList<QPainterPath> &pathList ) const QList<QPainterPath> &pathList )
{ {
if ( pathList.isEmpty() ) if ( pathList.isEmpty() )
@@ -285,7 +291,7 @@ static QPainterPath qwtCombinePathList( const QRectF &rect,
{ {
if ( br.center().y() < rect.center().y() ) if ( br.center().y() < rect.center().y() )
{ {
if ( qAbs( br.top() - rect.top() ) < if ( qAbs( br.top() - rect.top() ) <
qAbs( br.left() - rect.left() ) ) qAbs( br.left() - rect.left() ) )
{ {
index = 1; index = 1;
@@ -297,7 +303,7 @@ static QPainterPath qwtCombinePathList( const QRectF &rect,
} }
else else
{ {
if ( qAbs( br.bottom() - rect.bottom() ) < if ( qAbs( br.bottom() - rect.bottom() ) <
qAbs( br.left() - rect.left() ) ) qAbs( br.left() - rect.left() ) )
{ {
index = 6; index = 6;
@@ -315,7 +321,7 @@ static QPainterPath qwtCombinePathList( const QRectF &rect,
{ {
if ( br.center().y() < rect.center().y() ) if ( br.center().y() < rect.center().y() )
{ {
if ( qAbs( br.top() - rect.top() ) < if ( qAbs( br.top() - rect.top() ) <
qAbs( br.right() - rect.right() ) ) qAbs( br.right() - rect.right() ) )
{ {
index = 2; index = 2;
@@ -327,7 +333,7 @@ static QPainterPath qwtCombinePathList( const QRectF &rect,
} }
else else
{ {
if ( qAbs( br.bottom() - rect.bottom() ) < if ( qAbs( br.bottom() - rect.bottom() ) <
qAbs( br.right() - rect.right() ) ) qAbs( br.right() - rect.right() ) )
{ {
index = 5; index = 5;
@@ -339,7 +345,7 @@ static QPainterPath qwtCombinePathList( const QRectF &rect,
} }
if ( subPath.currentPosition().y() < br.center().y() ) if ( subPath.currentPosition().y() < br.center().y() )
qwtRevertPath( subPath ); qwtRevertPath( subPath );
} }
ordered[index] = subPath; ordered[index] = subPath;
} }
@@ -380,7 +386,7 @@ static QPainterPath qwtCombinePathList( const QRectF &rect,
#endif #endif
} }
static inline void qwtDrawStyledBackground( static inline void qwtDrawStyledBackground(
QWidget *w, QPainter *painter ) QWidget *w, QPainter *painter )
{ {
QStyleOption opt; QStyleOption opt;
@@ -417,7 +423,7 @@ static QWidget *qwtBackgroundWidget( QWidget *w )
return qwtBackgroundWidget( w->parentWidget() ); return qwtBackgroundWidget( w->parentWidget() );
} }
static void qwtFillBackground( QPainter *painter, static void qwtFillBackground( QPainter *painter,
QWidget *widget, const QVector<QRectF> &fillRects ) QWidget *widget, const QVector<QRectF> &fillRects )
{ {
if ( fillRects.isEmpty() ) if ( fillRects.isEmpty() )
@@ -520,7 +526,7 @@ public:
}; };
/*! /*!
\brief Constructor \brief Constructor
\param plot Parent plot widget \param plot Parent plot widget
@@ -594,7 +600,7 @@ void QwtPlotCanvas::setPaintAttribute( PaintAttribute attribute, bool on )
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
*d_data->backingStore = grab( rect() ); *d_data->backingStore = grab( rect() );
#else #else
*d_data->backingStore = *d_data->backingStore =
QPixmap::grabWidget( this, rect() ); QPixmap::grabWidget( this, rect() );
#endif #endif
} }
@@ -694,19 +700,19 @@ double QwtPlotCanvas::borderRadius() const
*/ */
bool QwtPlotCanvas::event( QEvent *event ) bool QwtPlotCanvas::event( QEvent *event )
{ {
if ( event->type() == QEvent::PolishRequest ) if ( event->type() == QEvent::PolishRequest )
{ {
if ( testPaintAttribute( QwtPlotCanvas::Opaque ) ) if ( testPaintAttribute( QwtPlotCanvas::Opaque ) )
{ {
// Setting a style sheet changes the // Setting a style sheet changes the
// Qt::WA_OpaquePaintEvent attribute, but we insist // Qt::WA_OpaquePaintEvent attribute, but we insist
// on painting the background. // on painting the background.
setAttribute( Qt::WA_OpaquePaintEvent, true ); setAttribute( Qt::WA_OpaquePaintEvent, true );
} }
} }
if ( event->type() == QEvent::PolishRequest || if ( event->type() == QEvent::PolishRequest ||
event->type() == QEvent::StyleChange ) event->type() == QEvent::StyleChange )
{ {
updateStyleSheetInfo(); updateStyleSheetInfo();
@@ -728,7 +734,14 @@ void QwtPlotCanvas::paintEvent( QPaintEvent *event )
d_data->backingStore != NULL ) d_data->backingStore != NULL )
{ {
QPixmap &bs = *d_data->backingStore; 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() ); bs = QwtPainter::backingStore( this, size() );
@@ -805,7 +818,7 @@ void QwtPlotCanvas::paintEvent( QPaintEvent *event )
drawCanvas( &painter, false ); drawCanvas( &painter, false );
if ( frameWidth() > 0 ) if ( frameWidth() > 0 )
drawBorder( &painter ); drawBorder( &painter );
} }
} }
@@ -814,15 +827,15 @@ void QwtPlotCanvas::paintEvent( QPaintEvent *event )
drawFocusIndicator( &painter ); drawFocusIndicator( &painter );
} }
void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground )
{ {
bool hackStyledBackground = false; bool hackStyledBackground = false;
if ( withBackground && testAttribute( Qt::WA_StyledBackground ) if ( withBackground && testAttribute( Qt::WA_StyledBackground )
&& testPaintAttribute( HackStyledBackground ) ) && testPaintAttribute( HackStyledBackground ) )
{ {
// Antialiasing rounded borders is done by // Antialiasing rounded borders is done by
// inserting pixels with colors between the // inserting pixels with colors between the
// border color and the color on the canvas, // border color and the color on the canvas,
// When the border is painted before the plot items // When the border is painted before the plot items
// these colors are interpolated for the canvas // these colors are interpolated for the canvas
@@ -852,7 +865,7 @@ void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground )
// paint background without border // paint background without border
painter->setPen( Qt::NoPen ); painter->setPen( Qt::NoPen );
painter->setBrush( d_data->styleSheet.background.brush ); painter->setBrush( d_data->styleSheet.background.brush );
painter->setBrushOrigin( d_data->styleSheet.background.origin ); painter->setBrushOrigin( d_data->styleSheet.background.origin );
painter->setClipPath( d_data->styleSheet.borderPath ); painter->setClipPath( d_data->styleSheet.borderPath );
painter->drawRect( contentsRect() ); painter->drawRect( contentsRect() );
@@ -893,7 +906,7 @@ void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground )
if ( !d_data->styleSheet.borderPath.isEmpty() ) if ( !d_data->styleSheet.borderPath.isEmpty() )
{ {
painter->setClipPath( painter->setClipPath(
d_data->styleSheet.borderPath, Qt::IntersectClip ); d_data->styleSheet.borderPath, Qt::IntersectClip );
} }
else else
@@ -929,7 +942,7 @@ void QwtPlotCanvas::drawBorder( QPainter *painter )
{ {
if ( frameWidth() > 0 ) if ( frameWidth() > 0 )
{ {
QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ),
d_data->borderRadius, d_data->borderRadius, d_data->borderRadius, d_data->borderRadius,
palette(), frameWidth(), frameStyle() ); palette(), frameWidth(), frameStyle() );
} }
@@ -952,7 +965,7 @@ void QwtPlotCanvas::drawBorder( QPainter *painter )
opt.rect = frameRect(); opt.rect = frameRect();
#endif #endif
switch (frameShape) switch (frameShape)
{ {
case QFrame::Box: case QFrame::Box:
case QFrame::HLine: case QFrame::HLine:
@@ -962,15 +975,15 @@ void QwtPlotCanvas::drawBorder( QPainter *painter )
{ {
opt.lineWidth = lineWidth(); opt.lineWidth = lineWidth();
opt.midLineWidth = midLineWidth(); opt.midLineWidth = midLineWidth();
break; break;
} }
default: default:
{ {
opt.lineWidth = frameWidth(); opt.lineWidth = frameWidth();
break; break;
} }
} }
if ( frameShadow == Sunken ) if ( frameShadow == Sunken )
opt.state |= QStyle::State_Sunken; opt.state |= QStyle::State_Sunken;
else if ( frameShadow == Raised ) else if ( frameShadow == Raised )
@@ -1029,13 +1042,13 @@ void QwtPlotCanvas::updateStyleSheetInfo()
return; return;
QwtStyleSheetRecorder recorder( size() ); QwtStyleSheetRecorder recorder( size() );
QPainter painter( &recorder ); QPainter painter( &recorder );
QStyleOption opt; QStyleOption opt;
opt.initFrom(this); opt.initFrom(this);
style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this); style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);
painter.end(); painter.end();
d_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty(); d_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty();
@@ -1045,7 +1058,7 @@ void QwtPlotCanvas::updateStyleSheetInfo()
{ {
if ( !recorder.border.rectList.isEmpty() ) if ( !recorder.border.rectList.isEmpty() )
{ {
d_data->styleSheet.borderPath = d_data->styleSheet.borderPath =
qwtCombinePathList( rect(), recorder.border.pathList ); qwtCombinePathList( rect(), recorder.border.pathList );
} }
} }
@@ -1096,6 +1109,6 @@ QPainterPath QwtPlotCanvas::borderPath( const QRect &rect ) const
path.addRoundedRect( r, d_data->borderRadius, d_data->borderRadius ); path.addRoundedRect( r, d_data->borderRadius, d_data->borderRadius );
return path; return path;
} }
return QPainterPath(); return QPainterPath();
} }

View File

@@ -19,7 +19,7 @@ class QPixmap;
/*! /*!
\brief Canvas of a QwtPlot. \brief Canvas of a QwtPlot.
Canvas is the widget where all plot items are displayed Canvas is the widget where all plot items are displayed
\sa QwtPlot::setCanvas(), QwtPlotGLCanvas \sa QwtPlot::setCanvas(), QwtPlotGLCanvas
@@ -42,8 +42,8 @@ public:
enum PaintAttribute enum PaintAttribute
{ {
/*! /*!
\brief Paint double buffered reusing the content \brief Paint double buffered reusing the content
of the pixmap buffer when possible. of the pixmap buffer when possible.
Using a backing store might improve the performance Using a backing store might improve the performance
significantly, when working with widget overlays ( like rubber bands ). significantly, when working with widget overlays ( like rubber bands ).
@@ -59,15 +59,15 @@ public:
of the plot canvas of the plot canvas
When using styled backgrounds Qt assumes, that the When using styled backgrounds Qt assumes, that the
canvas doesn't fill its area completely canvas doesn't fill its area completely
( f.e because of rounded borders ) and fills the area ( f.e because of rounded borders ) and fills the area
below the canvas. When this is done with gradients it might below the canvas. When this is done with gradients it might
result in a serious performance bottleneck - depending on the size. result in a serious performance bottleneck - depending on the size.
When the Opaque attribute is enabled the canvas tries to When the Opaque attribute is enabled the canvas tries to
identify the gaps with some heuristics and to fill those only. identify the gaps with some heuristics and to fill those only.
\warning Will not work for semitransparent backgrounds \warning Will not work for semitransparent backgrounds
*/ */
Opaque = 2, Opaque = 2,

View File

@@ -24,7 +24,7 @@
static void qwtUpdateLegendIconSize( QwtPlotCurve *curve ) static void qwtUpdateLegendIconSize( QwtPlotCurve *curve )
{ {
if ( curve->symbol() && if ( curve->symbol() &&
curve->testLegendAttribute( QwtPlotCurve::LegendShowSymbol ) ) curve->testLegendAttribute( QwtPlotCurve::LegendShowSymbol ) )
{ {
QSize sz = curve->symbol()->boundingRect().size(); QSize sz = curve->symbol()->boundingRect().size();
@@ -67,7 +67,7 @@ public:
baseline( 0.0 ), baseline( 0.0 ),
symbol( NULL ), symbol( NULL ),
attributes( 0 ), attributes( 0 ),
paintAttributes( paintAttributes(
QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ), QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ),
legendAttributes( 0 ) legendAttributes( 0 )
{ {
@@ -224,7 +224,7 @@ QwtPlotCurve::CurveStyle QwtPlotCurve::style() const
\brief Assign a symbol \brief Assign a symbol
The curve will take the ownership of the symbol, hence the previously The curve will take the ownership of the symbol, hence the previously
set symbol will be delete by setting a new one. If \p symbol is set symbol will be delete by setting a new one. If \p symbol is
\c NULL no symbol will be drawn. \c NULL no symbol will be drawn.
\param symbol Symbol \param symbol Symbol
@@ -474,7 +474,7 @@ void QwtPlotCurve::drawLines( QPainter *painter,
// then drawing the polyline itself // then drawing the polyline itself
if ( !doFit && !doFill ) if ( !doFit && !doFill )
doIntegers = true; doIntegers = true;
} }
#endif #endif
@@ -487,12 +487,12 @@ void QwtPlotCurve::drawLines( QPainter *painter,
if ( doIntegers ) if ( doIntegers )
{ {
QPolygon polyline = mapper.toPolygon( QPolygon polyline = mapper.toPolygon(
xMap, yMap, data(), from, to ); xMap, yMap, data(), from, to );
if ( d_data->paintAttributes & ClipPolygons ) if ( d_data->paintAttributes & ClipPolygons )
{ {
polyline = QwtClipper::clipPolygon( polyline = QwtClipper::clipPolygon(
clipRect.toAlignedRect(), polyline, false ); clipRect.toAlignedRect(), polyline, false );
} }
@@ -518,7 +518,7 @@ void QwtPlotCurve::drawLines( QPainter *painter,
if ( d_data->paintAttributes & ClipPolygons ) if ( d_data->paintAttributes & ClipPolygons )
{ {
polyline = QwtClipper::clipPolygonF( polyline = QwtClipper::clipPolygonF(
clipRect, polyline, false ); clipRect, polyline, false );
} }
@@ -556,8 +556,10 @@ void QwtPlotCurve::drawLines( QPainter *painter,
*/ */
void QwtPlotCurve::drawSticks( QPainter *painter, void QwtPlotCurve::drawSticks( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, 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->save();
painter->setRenderHint( QPainter::Antialiasing, false ); painter->setRenderHint( QPainter::Antialiasing, false );
@@ -639,7 +641,7 @@ void QwtPlotCurve::drawDots( QPainter *painter,
{ {
mapper.setFlag( QwtPointMapper::WeedOutPoints, false ); mapper.setFlag( QwtPointMapper::WeedOutPoints, false );
QPolygonF points = mapper.toPointsF( QPolygonF points = mapper.toPointsF(
xMap, yMap, data(), from, to ); xMap, yMap, data(), from, to );
QwtPainter::drawPoints( painter, points ); QwtPainter::drawPoints( painter, points );
@@ -648,7 +650,7 @@ void QwtPlotCurve::drawDots( QPainter *painter,
else if ( d_data->paintAttributes & ImageBuffer ) else if ( d_data->paintAttributes & ImageBuffer )
{ {
const QImage image = mapper.toImage( xMap, yMap, const QImage image = mapper.toImage( xMap, yMap,
data(), from, to, d_data->pen, data(), from, to, d_data->pen,
painter->testRenderHint( QPainter::Antialiasing ), painter->testRenderHint( QPainter::Antialiasing ),
renderThreadCount() ); renderThreadCount() );
@@ -679,13 +681,13 @@ void QwtPlotCurve::drawDots( QPainter *painter,
if ( doAlign ) if ( doAlign )
{ {
const QPolygon points = mapper.toPoints( const QPolygon points = mapper.toPoints(
xMap, yMap, data(), from, to ); xMap, yMap, data(), from, to );
QwtPainter::drawPoints( painter, points ); QwtPainter::drawPoints( painter, points );
} }
else else
{ {
const QPolygonF points = mapper.toPointsF( const QPolygonF points = mapper.toPointsF(
xMap, yMap, data(), from, to ); xMap, yMap, data(), from, to );
QwtPainter::drawPoints( painter, points ); QwtPainter::drawPoints( painter, points );
@@ -758,8 +760,11 @@ void QwtPlotCurve::drawSteps( QPainter *painter,
if ( d_data->paintAttributes & ClipPolygons ) if ( d_data->paintAttributes & ClipPolygons )
{ {
const QPolygonF clipped = QwtClipper::clipPolygonF( qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
canvasRect, polygon, false ); const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
const QPolygonF clipped = QwtClipper::clipPolygonF(
clipRect, polygon, false );
QwtPainter::drawPolyline( painter, clipped ); QwtPainter::drawPolyline( painter, clipped );
} }
@@ -880,7 +885,7 @@ void QwtPlotCurve::fillCurve( QPainter *painter,
} }
/*! /*!
\brief Complete a polygon to be a closed polygon including the \brief Complete a polygon to be a closed polygon including the
area between the original polygon and the baseline. area between the original polygon and the baseline.
\param painter Painter \param painter Painter
@@ -898,7 +903,7 @@ void QwtPlotCurve::closePolyline( QPainter *painter,
const bool doAlign = QwtPainter::roundingAlignment( painter ); const bool doAlign = QwtPainter::roundingAlignment( painter );
double baseline = d_data->baseline; double baseline = d_data->baseline;
if ( orientation() == Qt::Vertical ) if ( orientation() == Qt::Vertical )
{ {
if ( yMap.transformation() ) if ( yMap.transformation() )
@@ -943,9 +948,9 @@ void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
const QRectF &canvasRect, int from, int to ) const const QRectF &canvasRect, int from, int to ) const
{ {
QwtPointMapper mapper; QwtPointMapper mapper;
mapper.setFlag( QwtPointMapper::RoundPoints, mapper.setFlag( QwtPointMapper::RoundPoints,
QwtPainter::roundingAlignment( painter ) ); QwtPainter::roundingAlignment( painter ) );
mapper.setFlag( QwtPointMapper::WeedOutPoints, mapper.setFlag( QwtPointMapper::WeedOutPoints,
testPaintAttribute( QwtPlotCurve::FilterPoints ) ); testPaintAttribute( QwtPlotCurve::FilterPoints ) );
mapper.setBoundingRect( canvasRect ); mapper.setBoundingRect( canvasRect );
@@ -1046,13 +1051,13 @@ int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const
/*! /*!
\return Icon representing the curve on the legend \return Icon representing the curve on the legend
\param index Index of the legend entry \param index Index of the legend entry
( ignored as there is only one ) ( ignored as there is only one )
\param size Icon size \param size Icon size
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/ */
QwtGraphic QwtPlotCurve::legendIcon( int index, QwtGraphic QwtPlotCurve::legendIcon( int index,
const QSizeF &size ) const const QSizeF &size ) const
{ {
Q_UNUSED( index ); Q_UNUSED( index );
@@ -1150,10 +1155,10 @@ void QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data )
#ifndef QWT_NO_COMPAT #ifndef QWT_NO_COMPAT
/*! /*!
\brief Initialize the data by pointing to memory blocks which \brief Initialize the data by pointing to memory blocks which
are not managed by QwtPlotCurve. are not managed by QwtPlotCurve.
setRawSamples is provided for efficiency. setRawSamples is provided for efficiency.
It is important to keep the pointers It is important to keep the pointers
during the lifetime of the underlying QwtCPointerData class. during the lifetime of the underlying QwtCPointerData class.
@@ -1163,7 +1168,7 @@ void QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data )
\sa QwtCPointerData \sa QwtCPointerData
*/ */
void QwtPlotCurve::setRawSamples( void QwtPlotCurve::setRawSamples(
const double *xData, const double *yData, int size ) const double *xData, const double *yData, int size )
{ {
setData( new QwtCPointerData( xData, yData, size ) ); setData( new QwtCPointerData( xData, yData, size ) );
@@ -1180,7 +1185,7 @@ void QwtPlotCurve::setRawSamples(
\sa QwtPointArrayData \sa QwtPointArrayData
*/ */
void QwtPlotCurve::setSamples( void QwtPlotCurve::setSamples(
const double *xData, const double *yData, int size ) const double *xData, const double *yData, int size )
{ {
setData( new QwtPointArrayData( xData, yData, size ) ); setData( new QwtPointArrayData( xData, yData, size ) );

View File

@@ -33,7 +33,7 @@ class QwtCurveFitter;
\par Usage \par Usage
<dl><dt>a) Assign curve properties</dt> <dl><dt>a) Assign curve properties</dt>
<dd>When a curve is created, it is configured to draw black solid lines <dd>When a curve is created, it is configured to draw black solid lines
with in QwtPlotCurve::Lines style and no symbols. with in QwtPlotCurve::Lines style and no symbols.
You can change this by calling You can change this by calling
setPen(), setStyle() and setSymbol().</dd> setPen(), setStyle() and setSymbol().</dd>
<dt>b) Connect/Assign data.</dt> <dt>b) Connect/Assign data.</dt>
@@ -52,7 +52,7 @@ class QwtCurveFitter;
\sa QwtPointSeriesData, QwtSymbol, QwtScaleMap \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap
*/ */
class QWT_EXPORT QwtPlotCurve: class QWT_EXPORT QwtPlotCurve:
public QwtPlotSeriesItem, public QwtSeriesStore<QPointF> public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
{ {
public: public:
@@ -75,7 +75,7 @@ public:
Lines, Lines,
/*! /*!
Draw vertical or horizontal sticks ( depending on the Draw vertical or horizontal sticks ( depending on the
orientation() ) from a baseline which is defined by setBaseline(). orientation() ) from a baseline which is defined by setBaseline().
*/ */
Sticks, Sticks,
@@ -90,7 +90,7 @@ public:
/*! /*!
Draw dots at the locations of the data points. Note: Draw dots at the locations of the data points. Note:
This is different from a dotted line (see setPen()), and faster This is different from a dotted line (see setPen()), and faster
as a curve in QwtPlotCurve::NoStyle style and a symbol as a curve in QwtPlotCurve::NoStyle style and a symbol
painting a point. painting a point.
*/ */
Dots, Dots,
@@ -110,7 +110,7 @@ public:
enum CurveAttribute enum CurveAttribute
{ {
/*! /*!
For QwtPlotCurve::Steps only. For QwtPlotCurve::Steps only.
Draws a step function from the right to the left. Draws a step function from the right to the left.
*/ */
Inverted = 0x01, Inverted = 0x01,
@@ -141,13 +141,13 @@ public:
enum LegendAttribute enum LegendAttribute
{ {
/*! /*!
QwtPlotCurve tries to find a color representing the curve QwtPlotCurve tries to find a color representing the curve
and paints a rectangle with it. and paints a rectangle with it.
*/ */
LegendNoAttribute = 0x00, LegendNoAttribute = 0x00,
/*! /*!
If the style() is not QwtPlotCurve::NoCurve a line If the style() is not QwtPlotCurve::NoCurve a line
is painted with the curve pen(). is painted with the curve pen().
*/ */
LegendShowLine = 0x01, LegendShowLine = 0x01,
@@ -191,16 +191,16 @@ public:
FilterPoints = 0x02, FilterPoints = 0x02,
/*! /*!
Minimize memory usage that is temporarily needed for the Minimize memory usage that is temporarily needed for the
translated points, before they get painted. translated points, before they get painted.
This might slow down the performance of painting This might slow down the performance of painting
*/ */
MinimizeMemory = 0x04, MinimizeMemory = 0x04,
/*! /*!
Render the points to a temporary image and paint the image. Render the points to a temporary image and paint the image.
This is a very special optimization for Dots style, when This is a very special optimization for Dots style, when
having a huge amount of points. having a huge amount of points.
With a reasonable number of points QPainter::drawPoints() With a reasonable number of points QPainter::drawPoints()
will be faster. will be faster.
*/ */
@@ -210,7 +210,7 @@ public:
//! Paint attributes //! Paint attributes
typedef QFlags<PaintAttribute> PaintAttributes; typedef QFlags<PaintAttribute> PaintAttributes;
explicit QwtPlotCurve( const QString &title = QString::null ); explicit QwtPlotCurve( const QString &title = QString() );
explicit QwtPlotCurve( const QwtText &title ); explicit QwtPlotCurve( const QwtText &title );
virtual ~QwtPlotCurve(); virtual ~QwtPlotCurve();
@@ -270,32 +270,32 @@ protected:
void init(); void init();
virtual void drawCurve( QPainter *p, int style, virtual void drawCurve( QPainter *, int style,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; 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 QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;
virtual void drawLines( QPainter *p, virtual void drawLines( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;
virtual void drawSticks( QPainter *p, virtual void drawSticks( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;
virtual void drawDots( QPainter *p, virtual void drawDots( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;
virtual void drawSteps( QPainter *p, virtual void drawSteps( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;
virtual void fillCurve( QPainter *, virtual void fillCurve( QPainter *,
const QwtScaleMap &, const QwtScaleMap &, const QwtScaleMap &, const QwtScaleMap &,
const QRectF &canvasRect, QPolygonF & ) const; const QRectF &canvasRect, QPolygonF & ) const;
void closePolyline( QPainter *, void closePolyline( QPainter *,

View File

@@ -137,8 +137,8 @@ void QwtPlotDict::removeItem( QwtPlotItem *item )
void QwtPlotDict::detachItems( int rtti, bool autoDelete ) void QwtPlotDict::detachItems( int rtti, bool autoDelete )
{ {
PrivateData::ItemList list = d_data->itemList; PrivateData::ItemList list = d_data->itemList;
QwtPlotItemIterator it = list.begin(); QwtPlotItemIterator it = list.constBegin();
while ( it != list.end() ) while ( it != list.constEnd() )
{ {
QwtPlotItem *item = *it; QwtPlotItem *item = *it;
@@ -180,7 +180,7 @@ QwtPlotItemList QwtPlotDict::itemList( int rtti ) const
QwtPlotItemList items; QwtPlotItemList items;
PrivateData::ItemList list = d_data->itemList; 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; QwtPlotItem *item = *it;
if ( item->rtti() == rtti ) if ( item->rtti() == rtti )

View File

@@ -17,7 +17,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <qpixmap.h> #include <qpixmap.h>
static inline void qwtRenderItem( static inline void qwtRenderItem(
QPainter *painter, const QRect &canvasRect, QPainter *painter, const QRect &canvasRect,
QwtPlotSeriesItem *seriesItem, int from, int to ) QwtPlotSeriesItem *seriesItem, int from, int to )
{ {
@@ -109,7 +109,7 @@ bool QwtPlotDirectPainter::testAttribute( Attribute attribute ) const
} }
/*! /*!
En/Disables clipping En/Disables clipping
\param enable Enables clipping is true, disable it otherwise \param enable Enables clipping is true, disable it otherwise
\sa hasClipping(), clipRegion(), setClipRegion() \sa hasClipping(), clipRegion(), setClipRegion()
@@ -131,11 +131,11 @@ bool QwtPlotDirectPainter::hasClipping() const
/*! /*!
\brief Assign a clip region and enable clipping \brief Assign a clip region and enable clipping
Depending on the environment setting a proper clip region might improve Depending on the environment setting a proper clip region might improve
the performance heavily. F.e. on Qt embedded only the clipped part of the performance heavily. F.e. on Qt embedded only the clipped part of
the backing store will be copied to a ( maybe unaccelerated ) frame buffer the backing store will be copied to a ( maybe unaccelerated ) frame buffer
device. device.
\param region Clip region \param region Clip region
\sa clipRegion(), hasClipping(), setClipping() \sa clipRegion(), hasClipping(), setClipping()
*/ */
@@ -200,7 +200,7 @@ void QwtPlotDirectPainter::drawSeries(
} }
bool immediatePaint = true; bool immediatePaint = true;
if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) ) if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) )
{ {
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) ) if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
@@ -220,7 +220,7 @@ void QwtPlotDirectPainter::drawSeries(
if ( d_data->hasClipping ) if ( d_data->hasClipping )
{ {
d_data->painter.setClipRegion( d_data->painter.setClipRegion(
QRegion( canvasRect ) & d_data->clipRegion ); QRegion( canvasRect ) & d_data->clipRegion );
} }
else else
@@ -294,14 +294,14 @@ bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
if ( doCopyCache ) if ( doCopyCache )
{ {
QwtPlotCanvas *plotCanvas = QwtPlotCanvas *plotCanvas =
qobject_cast<QwtPlotCanvas *>( canvas ); qobject_cast<QwtPlotCanvas *>( canvas );
if ( plotCanvas ) if ( plotCanvas )
{ {
doCopyCache = qwtHasBackingStore( plotCanvas ); doCopyCache = qwtHasBackingStore( plotCanvas );
if ( doCopyCache ) if ( doCopyCache )
{ {
painter.drawPixmap( plotCanvas->contentsRect().topLeft(), painter.drawPixmap( plotCanvas->rect().topLeft(),
*plotCanvas->backingStore() ); *plotCanvas->backingStore() );
} }
} }

View File

@@ -29,7 +29,7 @@ class QwtPlotSeriesItem;
On certain environments it might be important to calculate a proper On certain environments it might be important to calculate a proper
clip region before painting. F.e. for Qt Embedded only the clipped part clip region before painting. F.e. for Qt Embedded only the clipped part
of the backing store will be copied to a ( maybe unaccelerated ) of the backing store will be copied to a ( maybe unaccelerated )
frame buffer. frame buffer.
\warning Incremental painting will only help when no replot is triggered \warning Incremental painting will only help when no replot is triggered
@@ -61,8 +61,8 @@ public:
/*! /*!
When QwtPlotCanvas::BackingStore is enabled the painter When QwtPlotCanvas::BackingStore is enabled the painter
has to paint to the backing store and the widget. In certain has to paint to the backing store and the widget. In certain
situations/environments it might be faster to paint to situations/environments it might be faster to paint to
the backing store only and then copy the backing store to the canvas. the backing store only and then copy the backing store to the canvas.
This flag can also be useful for settings, where Qt fills the This flag can also be useful for settings, where Qt fills the
the clip region with the widget background. the clip region with the widget background.

View 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 );
}

View 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

View File

@@ -39,22 +39,22 @@ public:
virtual int rtti() const; virtual int rtti() const;
void enableX( bool tf ); void enableX( bool );
bool xEnabled() const; bool xEnabled() const;
void enableY( bool tf ); void enableY( bool );
bool yEnabled() const; bool yEnabled() const;
void enableXMin( bool tf ); void enableXMin( bool );
bool xMinEnabled() const; bool xMinEnabled() const;
void enableYMin( bool tf ); void enableYMin( bool );
bool yMinEnabled() const; bool yMinEnabled() const;
void setXDiv( const QwtScaleDiv &sx ); void setXDiv( const QwtScaleDiv & );
const QwtScaleDiv &xScaleDiv() const; const QwtScaleDiv &xScaleDiv() const;
void setYDiv( const QwtScaleDiv &sy ); void setYDiv( const QwtScaleDiv & );
const QwtScaleDiv &yScaleDiv() const; const QwtScaleDiv &yScaleDiv() const;
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
@@ -65,19 +65,19 @@ public:
const QPen& majorPen() const; const QPen& majorPen() const;
void setMinorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); 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; const QPen& minorPen() const;
virtual void draw( QPainter *p, virtual void draw( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &rect ) const; const QRectF &canvasRect ) const;
virtual void updateScaleDiv( virtual void updateScaleDiv(
const QwtScaleDiv &xMap, const QwtScaleDiv &yMap ); const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv );
private: private:
void drawLines( QPainter *painter, const QRectF &, void drawLines( QPainter *, const QRectF &,
Qt::Orientation orientation, const QwtScaleMap &, Qt::Orientation, const QwtScaleMap &,
const QList<double> & ) const; const QList<double> & ) const;
class PrivateData; class PrivateData;

View File

@@ -122,21 +122,21 @@ QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style() const
/*! /*!
Build and assign a pen Build and assign a pen
In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
non cosmetic ( see QPen::isCosmetic() ). This method has been introduced non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
to hide this incompatibility. to hide this incompatibility.
\param color Pen color \param color Pen color
\param width Pen width \param width Pen width
\param style Pen style \param style Pen style
\sa pen(), brush() \sa pen(), brush()
*/ */
void QwtPlotHistogram::setPen( const QColor &color, qreal width, Qt::PenStyle style ) void QwtPlotHistogram::setPen( const QColor &color, qreal width, Qt::PenStyle style )
{ {
setPen( QPen( color, width, style ) ); setPen( QPen( color, width, style ) );
} }
/*! /*!
Assign a pen, that is used in a style() depending way. Assign a pen, that is used in a style() depending way.
@@ -303,15 +303,15 @@ void QwtPlotHistogram::setSamples(
/*! /*!
Assign a series of samples Assign a series of samples
setSamples() is just a wrapper for setData() without any additional setSamples() is just a wrapper for setData() without any additional
value - beside that it is easier to find for the developer. value - beside that it is easier to find for the developer.
\param data Data \param data Data
\warning The item takes ownership of the data object, deleting \warning The item takes ownership of the data object, deleting
it when its not used anymore. it when its not used anymore.
*/ */
void QwtPlotHistogram::setSamples( void QwtPlotHistogram::setSamples(
QwtSeriesData<QwtIntervalSample> *data ) QwtSeriesData<QwtIntervalSample> *data )
{ {
setData( data ); setData( data );
@@ -332,8 +332,10 @@ void QwtPlotHistogram::setSamples(
*/ */
void QwtPlotHistogram::drawSeries( QPainter *painter, void QwtPlotHistogram::drawSeries( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, 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 ) if ( !painter || dataSize() <= 0 )
return; return;
@@ -675,11 +677,11 @@ void QwtPlotHistogram::drawColumn( QPainter *painter,
/*! /*!
A plain rectangle without pen using the brush() A plain rectangle without pen using the brush()
\param index Index of the legend entry \param index Index of the legend entry
( ignored as there is only one ) ( ignored as there is only one )
\param size Icon size \param size Icon size
\return A graphic displaying the icon \return A graphic displaying the icon
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/ */
QwtGraphic QwtPlotHistogram::legendIcon( int index, QwtGraphic QwtPlotHistogram::legendIcon( int index,

View File

@@ -36,7 +36,7 @@ class QPolygonF;
\sa QwtPlotBarChart, QwtPlotMultiBarChart \sa QwtPlotBarChart, QwtPlotMultiBarChart
*/ */
class QWT_EXPORT QwtPlotHistogram: class QWT_EXPORT QwtPlotHistogram:
public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample> public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
{ {
public: public:
@@ -58,7 +58,7 @@ public:
/*! /*!
Draw a column for each interval. When a symbol() has been set Draw a column for each interval. When a symbol() has been set
the symbol is used otherwise the column is displayed as the symbol is used otherwise the column is displayed as
plain rectangle using pen() and brush(). plain rectangle using pen() and brush().
*/ */
Columns, Columns,
@@ -76,7 +76,7 @@ public:
UserStyle = 100 UserStyle = 100
}; };
explicit QwtPlotHistogram( const QString &title = QString::null ); explicit QwtPlotHistogram( const QString &title = QString() );
explicit QwtPlotHistogram( const QwtText &title ); explicit QwtPlotHistogram( const QwtText &title );
virtual ~QwtPlotHistogram(); virtual ~QwtPlotHistogram();
@@ -92,7 +92,7 @@ public:
void setSamples( const QVector<QwtIntervalSample> & ); void setSamples( const QVector<QwtIntervalSample> & );
void setSamples( QwtSeriesData<QwtIntervalSample> * ); void setSamples( QwtSeriesData<QwtIntervalSample> * );
void setBaseline( double reference ); void setBaseline( double );
double baseline() const; double baseline() const;
void setStyle( HistogramStyle style ); void setStyle( HistogramStyle style );
@@ -101,7 +101,7 @@ public:
void setSymbol( const QwtColumnSymbol * ); void setSymbol( const QwtColumnSymbol * );
const QwtColumnSymbol *symbol() const; const QwtColumnSymbol *symbol() const;
virtual void drawSeries( QPainter *p, virtual void drawSeries( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;

View File

@@ -153,15 +153,15 @@ void QwtPlotIntervalCurve::setSamples(
/*! /*!
Assign a series of samples Assign a series of samples
setSamples() is just a wrapper for setData() without any additional setSamples() is just a wrapper for setData() without any additional
value - beside that it is easier to find for the developer. value - beside that it is easier to find for the developer.
\param data Data \param data Data
\warning The item takes ownership of the data object, deleting \warning The item takes ownership of the data object, deleting
it when its not used anymore. it when its not used anymore.
*/ */
void QwtPlotIntervalCurve::setSamples( void QwtPlotIntervalCurve::setSamples(
QwtSeriesData<QwtIntervalSample> *data ) QwtSeriesData<QwtIntervalSample> *data )
{ {
setData( data ); setData( data );
@@ -222,21 +222,21 @@ const QwtIntervalSymbol *QwtPlotIntervalCurve::symbol() const
/*! /*!
Build and assign a pen Build and assign a pen
In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
non cosmetic ( see QPen::isCosmetic() ). This method has been introduced non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
to hide this incompatibility. to hide this incompatibility.
\param color Pen color \param color Pen color
\param width Pen width \param width Pen width
\param style Pen style \param style Pen style
\sa pen(), brush() \sa pen(), brush()
*/ */
void QwtPlotIntervalCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style ) void QwtPlotIntervalCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )
{ {
setPen( QPen( color, width, style ) ); setPen( QPen( color, width, style ) );
} }
/*! /*!
\brief Assign a pen \brief Assign a pen
@@ -298,7 +298,7 @@ const QBrush& QwtPlotIntervalCurve::brush() const
QRectF QwtPlotIntervalCurve::boundingRect() const QRectF QwtPlotIntervalCurve::boundingRect() const
{ {
QRectF rect = QwtPlotSeriesItem::boundingRect(); QRectF rect = QwtPlotSeriesItem::boundingRect();
if ( rect.isValid() && orientation() == Qt::Vertical ) if ( orientation() == Qt::Vertical )
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
return rect; return rect;
@@ -545,13 +545,13 @@ void QwtPlotIntervalCurve::drawSymbols(
In case of Tube style() the icon is a plain rectangle filled with the brush(). In case of Tube style() the icon is a plain rectangle filled with the brush().
If a symbol is assigned it is scaled to size. If a symbol is assigned it is scaled to size.
\param index Index of the legend entry \param index Index of the legend entry
( ignored as there is only one ) ( ignored as there is only one )
\param size Icon size \param size Icon size
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/ */
QwtGraphic QwtPlotIntervalCurve::legendIcon( QwtGraphic QwtPlotIntervalCurve::legendIcon(
int index, const QSizeF &size ) const int index, const QSizeF &size ) const
{ {
Q_UNUSED( index ); Q_UNUSED( index );

View File

@@ -24,7 +24,7 @@ class QwtIntervalSymbol;
that is displayed for each interval. QwtPlotIntervalCurve might be used that is displayed for each interval. QwtPlotIntervalCurve might be used
to display error bars or the area between 2 curves. to display error bars or the area between 2 curves.
*/ */
class QWT_EXPORT QwtPlotIntervalCurve: class QWT_EXPORT QwtPlotIntervalCurve:
public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample> public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
{ {
public: public:
@@ -76,7 +76,7 @@ public:
//! Paint attributes //! Paint attributes
typedef QFlags<PaintAttribute> PaintAttributes; typedef QFlags<PaintAttribute> PaintAttributes;
explicit QwtPlotIntervalCurve( const QString &title = QString::null ); explicit QwtPlotIntervalCurve( const QString &title = QString() );
explicit QwtPlotIntervalCurve( const QwtText &title ); explicit QwtPlotIntervalCurve( const QwtText &title );
virtual ~QwtPlotIntervalCurve(); virtual ~QwtPlotIntervalCurve();
@@ -102,7 +102,7 @@ public:
void setSymbol( const QwtIntervalSymbol * ); void setSymbol( const QwtIntervalSymbol * );
const QwtIntervalSymbol *symbol() const; const QwtIntervalSymbol *symbol() const;
virtual void drawSeries( QPainter *p, virtual void drawSeries( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const; const QRectF &canvasRect, int from, int to ) const;

View File

@@ -94,7 +94,7 @@ void QwtPlotItem::attach( QwtPlot *plot )
} }
/*! /*!
\brief This method detaches a QwtPlotItem from any \brief This method detaches a QwtPlotItem from any
QwtPlot it has been associated with. QwtPlot it has been associated with.
detach() is equivalent to calling attach( NULL ) detach() is equivalent to calling attach( NULL )
@@ -304,8 +304,8 @@ bool QwtPlotItem::testRenderHint( RenderHint hint ) const
} }
/*! /*!
On multi core systems rendering of certain plot item On multi core systems rendering of certain plot item
( f.e QwtPlotRasterItem ) can be done in parallel in ( f.e QwtPlotRasterItem ) can be done in parallel in
several threads. several threads.
The default setting is set to 1. The default setting is set to 1.
@@ -362,13 +362,13 @@ QSize QwtPlotItem::legendIconSize() const
The default implementation returns an invalid icon The default implementation returns an invalid icon
\param index Index of the legend entry \param index Index of the legend entry
( usually there is only one ) ( usually there is only one )
\param size Icon size \param size Icon size
\sa setLegendIconSize(), legendData() \sa setLegendIconSize(), legendData()
*/ */
QwtGraphic QwtPlotItem::legendIcon( QwtGraphic QwtPlotItem::legendIcon(
int index, const QSizeF &size ) const int index, const QSizeF &size ) const
{ {
Q_UNUSED( index ) Q_UNUSED( index )
@@ -388,22 +388,22 @@ QwtGraphic QwtPlotItem::legendIcon(
\return A filled rectangle \return A filled rectangle
*/ */
QwtGraphic QwtPlotItem::defaultIcon( QwtGraphic QwtPlotItem::defaultIcon(
const QBrush &brush, const QSizeF &size ) const const QBrush &brush, const QSizeF &size ) const
{ {
QwtGraphic icon; QwtGraphic icon;
if ( !size.isEmpty() ) if ( !size.isEmpty() )
{ {
icon.setDefaultSize( size ); icon.setDefaultSize( size );
QRectF r( 0, 0, size.width(), size.height() ); QRectF r( 0, 0, size.width(), size.height() );
QPainter painter( &icon ); QPainter painter( &icon );
painter.fillRect( r, brush ); painter.fillRect( r, brush );
} }
return icon; return icon;
} }
//! Show the item //! Show the item
void QwtPlotItem::show() void QwtPlotItem::show()
@@ -557,11 +557,11 @@ QRectF QwtPlotItem::boundingRect() const
\param right Returns the right margin \param right Returns the right margin
\param bottom Returns the bottom 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() \sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
*/ */
void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap, void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtScaleMap &yMap, const QRectF &canvasRect,
double &left, double &top, double &right, double &bottom ) const double &left, double &top, double &right, double &bottom ) const
{ {
@@ -582,11 +582,11 @@ void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,
displays one entry for each bar. displays one entry for each bar.
QwtLegendData is basically a list of QVariants that makes it QwtLegendData is basically a list of QVariants that makes it
possible to overload and reimplement legendData() to possible to overload and reimplement legendData() to
return almost any type of information, that is understood return almost any type of information, that is understood
by the receiver that acts as the legend. by the receiver that acts as the legend.
The default implementation returns one entry with The default implementation returns one entry with
the title() of the item and the legendIcon(). the title() of the item and the legendIcon().
\return Data, that is needed to represent the item on the legend \return Data, that is needed to represent the item on the legend
@@ -598,19 +598,19 @@ QList<QwtLegendData> QwtPlotItem::legendData() const
QwtText label = title(); QwtText label = title();
label.setRenderFlags( label.renderFlags() & Qt::AlignLeft ); label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
QVariant titleValue; QVariant titleValue;
qVariantSetValue( titleValue, label ); qVariantSetValue( titleValue, label );
data.setValue( QwtLegendData::TitleRole, titleValue ); data.setValue( QwtLegendData::TitleRole, titleValue );
const QwtGraphic graphic = legendIcon( 0, legendIconSize() ); const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
if ( !graphic.isNull() ) if ( !graphic.isNull() )
{ {
QVariant iconValue; QVariant iconValue;
qVariantSetValue( iconValue, graphic ); qVariantSetValue( iconValue, graphic );
data.setValue( QwtLegendData::IconRole, iconValue ); data.setValue( QwtLegendData::IconRole, iconValue );
} }
QList<QwtLegendData> list; QList<QwtLegendData> list;
list += data; list += data;
@@ -658,7 +658,7 @@ void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv,
need to enable the QwtPlotItem::Legend flag and to implement need to enable the QwtPlotItem::Legend flag and to implement
legendData() and legendIcon() legendData() and legendIcon()
*/ */
void QwtPlotItem::updateLegend( const QwtPlotItem *item, void QwtPlotItem::updateLegend( const QwtPlotItem *item,
const QList<QwtLegendData> &data ) const QList<QwtLegendData> &data )
{ {
Q_UNUSED( item ); Q_UNUSED( item );

View File

@@ -123,7 +123,7 @@ public:
//! For QwtPlotZoneItem //! For QwtPlotZoneItem
Rtti_PlotZone, Rtti_PlotZone,
/*! /*!
Values >= Rtti_PlotUserItem are reserved for plot items Values >= Rtti_PlotUserItem are reserved for plot items
not implemented in the Qwt library. not implemented in the Qwt library.
*/ */
@@ -134,9 +134,9 @@ public:
\brief Plot Item Attributes \brief Plot Item Attributes
Various aspects of a plot widget depend on the attributes of Various aspects of a plot widget depend on the attributes of
the attached plot items. If and how a single plot item the attached plot items. If and how a single plot item
participates in these updates depends on its attributes. participates in these updates depends on its attributes.
\sa setItemAttribute(), testItemAttribute(), ItemInterest \sa setItemAttribute(), testItemAttribute(), ItemInterest
*/ */
enum ItemAttribute enum ItemAttribute
@@ -153,7 +153,7 @@ public:
/*! /*!
The item needs extra space to display something outside The item needs extra space to display something outside
its bounding rectangle. its bounding rectangle.
\sa getCanvasMarginHint() \sa getCanvasMarginHint()
*/ */
Margins = 0x04 Margins = 0x04
@@ -174,13 +174,13 @@ public:
*/ */
enum ItemInterest enum ItemInterest
{ {
/*! /*!
The item is interested in updates of the scales The item is interested in updates of the scales
\sa updateScaleDiv() \sa updateScaleDiv()
*/ */
ScaleInterest = 0x01, ScaleInterest = 0x01,
/*! /*!
The item is interested in updates of the legend ( of other items ) The item is interested in updates of the legend ( of other items )
This flag is intended for items, that want to implement a legend This flag is intended for items, that want to implement a legend
for displaying entries of other plot item. for displaying entries of other plot item.
@@ -268,12 +268,12 @@ public:
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;
virtual void getCanvasMarginHint( virtual void getCanvasMarginHint(
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasSize, const QRectF &canvasRect,
double &left, double &top, double &right, double &bottom) const; double &left, double &top, double &right, double &bottom) const;
virtual void updateScaleDiv( virtual void updateScaleDiv(
const QwtScaleDiv&, const QwtScaleDiv& ); const QwtScaleDiv&, const QwtScaleDiv& );
virtual void updateLegend( const QwtPlotItem *, virtual void updateLegend( const QwtPlotItem *,

View File

@@ -163,8 +163,8 @@ void QwtPlotLayout::LayoutData::init( const QwtPlot *plot, const QRectF &rect )
// canvas // canvas
plot->canvas()->getContentsMargins( plot->canvas()->getContentsMargins(
&canvas.contentsMargins[ QwtPlot::yLeft ], &canvas.contentsMargins[ QwtPlot::yLeft ],
&canvas.contentsMargins[ QwtPlot::xTop ], &canvas.contentsMargins[ QwtPlot::xTop ],
&canvas.contentsMargins[ QwtPlot::yRight ], &canvas.contentsMargins[ QwtPlot::yRight ],
&canvas.contentsMargins[ QwtPlot::xBottom ] ); &canvas.contentsMargins[ QwtPlot::xBottom ] );
@@ -844,16 +844,16 @@ QRectF QwtPlotLayout::alignLegend( const QRectF &canvasRect,
\param rect Bounding rectangle for title, footer, axes and canvas. \param rect Bounding rectangle for title, footer, axes and canvas.
\param dimTitle Expanded height of the title widget \param dimTitle Expanded height of the title widget
\param dimFooter Expanded height of the footer 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 \sa Options
*/ */
void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect, 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; dimTitle = dimFooter = 0;
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
dimAxis[axis] = 0; dimAxes[axis] = 0;
int backboneOffset[QwtPlot::axisCnt]; int backboneOffset[QwtPlot::axisCnt];
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) 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 ) != d_data->layoutData.scale[QwtPlot::yRight].isEnabled )
{ {
// center to the canvas // 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 ) ); 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 ) != d_data->layoutData.scale[QwtPlot::yRight].isEnabled )
{ {
// center to the canvas // 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 ) ); int d = qCeil( d_data->layoutData.footer.text.heightForWidth( w ) );
@@ -935,37 +935,37 @@ void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
double length; double length;
if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom ) if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom )
{ {
length = rect.width() - dimAxis[QwtPlot::yLeft] length = rect.width() - dimAxes[QwtPlot::yLeft]
- dimAxis[QwtPlot::yRight]; - dimAxes[QwtPlot::yRight];
length -= scaleData.start + scaleData.end; length -= scaleData.start + scaleData.end;
if ( dimAxis[QwtPlot::yRight] > 0 ) if ( dimAxes[QwtPlot::yRight] > 0 )
length -= 1; length -= 1;
length += qMin( dimAxis[QwtPlot::yLeft], length += qMin( dimAxes[QwtPlot::yLeft],
scaleData.start - backboneOffset[QwtPlot::yLeft] ); scaleData.start - backboneOffset[QwtPlot::yLeft] );
length += qMin( dimAxis[QwtPlot::yRight], length += qMin( dimAxes[QwtPlot::yRight],
scaleData.end - backboneOffset[QwtPlot::yRight] ); scaleData.end - backboneOffset[QwtPlot::yRight] );
} }
else // QwtPlot::yLeft, QwtPlot::yRight else // QwtPlot::yLeft, QwtPlot::yRight
{ {
length = rect.height() - dimAxis[QwtPlot::xTop] length = rect.height() - dimAxes[QwtPlot::xTop]
- dimAxis[QwtPlot::xBottom]; - dimAxes[QwtPlot::xBottom];
length -= scaleData.start + scaleData.end; length -= scaleData.start + scaleData.end;
length -= 1; length -= 1;
if ( dimAxis[QwtPlot::xBottom] <= 0 ) if ( dimAxes[QwtPlot::xBottom] <= 0 )
length -= 1; length -= 1;
if ( dimAxis[QwtPlot::xTop] <= 0 ) if ( dimAxes[QwtPlot::xTop] <= 0 )
length -= 1; length -= 1;
if ( dimAxis[QwtPlot::xBottom] > 0 ) if ( dimAxes[QwtPlot::xBottom] > 0 )
{ {
length += qMin( length += qMin(
d_data->layoutData.scale[QwtPlot::xBottom].tickOffset, d_data->layoutData.scale[QwtPlot::xBottom].tickOffset,
double( scaleData.start - backboneOffset[QwtPlot::xBottom] ) ); double( scaleData.start - backboneOffset[QwtPlot::xBottom] ) );
} }
if ( dimAxis[QwtPlot::xTop] > 0 ) if ( dimAxes[QwtPlot::xTop] > 0 )
{ {
length += qMin( length += qMin(
d_data->layoutData.scale[QwtPlot::xTop].tickOffset, 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; done = false;
} }
} }
@@ -1019,7 +1019,7 @@ void QwtPlotLayout::alignScales( Options options,
if ( !( options & IgnoreFrames ) ) if ( !( options & IgnoreFrames ) )
{ {
backboneOffset[axis] += backboneOffset[axis] +=
d_data->layoutData.canvas.contentsMargins[axis]; d_data->layoutData.canvas.contentsMargins[axis];
} }
} }
@@ -1088,7 +1088,7 @@ void QwtPlotLayout::alignScales( Options options,
*/ */
const double cRight = canvasRect.right(); // qreal -> double const double cRight = canvasRect.right(); // qreal -> double
canvasRect.setRight( qMin( cRight, axisRect.right() + dx ) ); canvasRect.setRight( qMin( cRight, axisRect.right() + dx ) );
} }
const double maxRight = rightScaleRect.right(); const double maxRight = rightScaleRect.right();
const double right = axisRect.right() - rightOffset; const double right = axisRect.right() - rightOffset;

View File

@@ -41,7 +41,7 @@ public:
*/ */
IgnoreScrollbars = 0x02, IgnoreScrollbars = 0x02,
//! Ignore all frames. //! Ignore all frames.
IgnoreFrames = 0x04, IgnoreFrames = 0x04,
//! Ignore the legend. //! Ignore the legend.
@@ -61,7 +61,7 @@ public:
virtual ~QwtPlotLayout(); virtual ~QwtPlotLayout();
void setCanvasMargin( int margin, int axis = -1 ); void setCanvasMargin( int margin, int axis = -1 );
int canvasMargin( int axis ) const; int canvasMargin( int axisId ) const;
void setAlignCanvasToScales( bool ); void setAlignCanvasToScales( bool );
@@ -81,7 +81,7 @@ public:
virtual QSize minimumSizeHint( const QwtPlot * ) const; virtual QSize minimumSizeHint( const QwtPlot * ) const;
virtual void activate( const QwtPlot *, virtual void activate( const QwtPlot *,
const QRectF &rect, Options options = 0x00 ); const QRectF &plotRect, Options options = 0x00 );
virtual void invalidate(); virtual void invalidate();

View File

@@ -48,7 +48,7 @@ private:
QRect d_rect; QRect d_rect;
}; };
QwtLegendLayoutItem::QwtLegendLayoutItem( QwtLegendLayoutItem::QwtLegendLayoutItem(
const QwtPlotLegendItem *legendItem, const QwtPlotItem *plotItem ): const QwtPlotLegendItem *legendItem, const QwtPlotItem *plotItem ):
d_legendItem( legendItem ), d_legendItem( legendItem ),
d_plotItem( plotItem) d_plotItem( plotItem)
@@ -166,7 +166,7 @@ public:
QwtDynGridLayout *layout; QwtDynGridLayout *layout;
}; };
//! Constructor //! Constructor
QwtPlotLegendItem::QwtPlotLegendItem(): QwtPlotLegendItem::QwtPlotLegendItem():
QwtPlotItem( QwtText( "Legend" ) ) QwtPlotItem( QwtText( "Legend" ) )
{ {
@@ -193,13 +193,13 @@ int QwtPlotLegendItem::rtti() const
\brief Set the alignmnet \brief Set the alignmnet
Alignment means the position of the legend relative Alignment means the position of the legend relative
to the geometry of the plot canvas. to the geometry of the plot canvas.
\param alignment Alignment flags \param alignment Alignment flags
\sa alignment(), setMaxColumns() \sa alignment(), setMaxColumns()
\note To align a legend with many items horizontally \note To align a legend with many items horizontally
the number of columns need to be limited the number of columns need to be limited
*/ */
void QwtPlotLegendItem::setAlignment( Qt::Alignment alignment ) void QwtPlotLegendItem::setAlignment( Qt::Alignment alignment )
@@ -261,7 +261,7 @@ void QwtPlotLegendItem::setMargin( int margin )
margin = qMax( margin, 0 ); margin = qMax( margin, 0 );
if ( margin != this->margin() ) if ( margin != this->margin() )
{ {
d_data->layout->setContentsMargins( d_data->layout->setContentsMargins(
margin, margin, margin, margin ); margin, margin, margin, margin );
itemChanged(); itemChanged();
@@ -417,7 +417,7 @@ int QwtPlotLegendItem::borderDistance() const
/*! /*!
Set the radius for the border Set the radius for the border
\param radius A value <= 0 defines a rectangular border \param radius A value <= 0 defines a rectangular border
\sa borderRadius(), setBorderPen() \sa borderRadius(), setBorderPen()
*/ */
@@ -494,7 +494,7 @@ QBrush QwtPlotLegendItem::backgroundBrush() const
/*! /*!
\brief Set the background mode \brief Set the background mode
Depending on the mode the complete legend or each item Depending on the mode the complete legend or each item
might have an background. might have an background.
The default setting is LegendBackground. The default setting is LegendBackground.
@@ -510,7 +510,7 @@ void QwtPlotLegendItem::setBackgroundMode( BackgroundMode mode )
} }
} }
/*! /*!
\return backgroundMode \return backgroundMode
\sa setBackgroundMode(), backgroundBrush(), drawBackground() \sa setBackgroundMode(), backgroundBrush(), drawBackground()
*/ */
@@ -567,10 +567,10 @@ void QwtPlotLegendItem::draw( QPainter *painter,
if ( d_data->backgroundMode == QwtPlotLegendItem::LegendBackground ) if ( d_data->backgroundMode == QwtPlotLegendItem::LegendBackground )
drawBackground( painter, d_data->layout->geometry() ); drawBackground( painter, d_data->layout->geometry() );
for ( int i = 0; i < d_data->layout->count(); i++ ) for ( int i = 0; i < d_data->layout->count(); i++ )
{ {
const QwtLegendLayoutItem *layoutItem = const QwtLegendLayoutItem *layoutItem =
static_cast<QwtLegendLayoutItem *>( d_data->layout->itemAt( i ) ); static_cast<QwtLegendLayoutItem *>( d_data->layout->itemAt( i ) );
if ( d_data->backgroundMode == QwtPlotLegendItem::ItemBackground ) if ( d_data->backgroundMode == QwtPlotLegendItem::ItemBackground )
@@ -594,17 +594,17 @@ void QwtPlotLegendItem::draw( QPainter *painter,
\sa setBorderRadius(), setBorderPen(), \sa setBorderRadius(), setBorderPen(),
setBackgroundBrush(), setBackgroundMode() setBackgroundBrush(), setBackgroundMode()
*/ */
void QwtPlotLegendItem::drawBackground( void QwtPlotLegendItem::drawBackground(
QPainter *painter, const QRectF &rect ) const QPainter *painter, const QRectF &rect ) const
{ {
painter->save(); painter->save();
painter->setPen( d_data->borderPen ); painter->setPen( d_data->borderPen );
painter->setBrush( d_data->backgroundBrush ); painter->setBrush( d_data->backgroundBrush );
const double radius = d_data->borderRadius; const double radius = d_data->borderRadius;
painter->drawRoundedRect( rect, radius, radius ); painter->drawRoundedRect( rect, radius, radius );
painter->restore(); painter->restore();
} }
@@ -623,13 +623,13 @@ QRect QwtPlotLegendItem::geometry( const QRectF &canvasRect ) const
if ( d_data->alignment & Qt::AlignHCenter ) if ( d_data->alignment & Qt::AlignHCenter )
{ {
int x = qRound( canvasRect.center().x() ); int x = qRound( canvasRect.center().x() );
rect.moveCenter( QPoint( x, rect.center().y() ) ); rect.moveCenter( QPoint( x, rect.center().y() ) );
} }
else if ( d_data->alignment & Qt::AlignRight ) else if ( d_data->alignment & Qt::AlignRight )
{ {
rect.moveRight( qFloor( canvasRect.right() - margin ) ); rect.moveRight( qFloor( canvasRect.right() - margin ) );
} }
else else
{ {
rect.moveLeft( qCeil( canvasRect.left() + margin ) ); rect.moveLeft( qCeil( canvasRect.left() + margin ) );
} }
@@ -643,16 +643,16 @@ QRect QwtPlotLegendItem::geometry( const QRectF &canvasRect ) const
{ {
rect.moveBottom( qFloor( canvasRect.bottom() - margin ) ); rect.moveBottom( qFloor( canvasRect.bottom() - margin ) );
} }
else else
{ {
rect.moveTop( qCeil( canvasRect.top() + margin ) ); rect.moveTop( qCeil( canvasRect.top() + margin ) );
} }
return rect; return rect;
} }
/*! /*!
Update the legend items according to modifications of a Update the legend items according to modifications of a
plot item plot item
\param plotItem Plot item \param plotItem Plot item
@@ -666,7 +666,7 @@ void QwtPlotLegendItem::updateLegend( const QwtPlotItem *plotItem,
QList<QwtLegendLayoutItem *> layoutItems; QList<QwtLegendLayoutItem *> layoutItems;
QMap<const QwtPlotItem *, QList<QwtLegendLayoutItem *> >::iterator it = QMap<const QwtPlotItem *, QList<QwtLegendLayoutItem *> >::iterator it =
d_data->map.find( plotItem ); d_data->map.find( plotItem );
if ( it != d_data->map.end() ) if ( it != d_data->map.end() )
layoutItems = it.value(); layoutItems = it.value();
@@ -691,7 +691,7 @@ void QwtPlotLegendItem::updateLegend( const QwtPlotItem *plotItem,
{ {
for ( int i = 0; i < data.size(); i++ ) for ( int i = 0; i < data.size(); i++ )
{ {
QwtLegendLayoutItem *layoutItem = QwtLegendLayoutItem *layoutItem =
new QwtLegendLayoutItem( this, plotItem ); new QwtLegendLayoutItem( this, plotItem );
d_data->layout->addItem( layoutItem ); d_data->layout->addItem( layoutItem );
layoutItems += layoutItem; layoutItems += layoutItem;
@@ -740,7 +740,7 @@ void QwtPlotLegendItem::clearLegend()
\param rect Bounding rectangle for the entry \param rect Bounding rectangle for the entry
*/ */
void QwtPlotLegendItem::drawLegendData( QPainter *painter, void QwtPlotLegendItem::drawLegendData( QPainter *painter,
const QwtPlotItem *plotItem, const QwtLegendData &data, const QwtPlotItem *plotItem, const QwtLegendData &data,
const QRectF &rect ) const const QRectF &rect ) const
{ {
Q_UNUSED( plotItem ); Q_UNUSED( plotItem );
@@ -757,7 +757,7 @@ void QwtPlotLegendItem::drawLegendData( QPainter *painter,
{ {
QRectF iconRect( r.topLeft(), graphic.defaultSize() ); QRectF iconRect( r.topLeft(), graphic.defaultSize() );
iconRect.moveCenter( iconRect.moveCenter(
QPoint( iconRect.center().x(), rect.center().y() ) ); QPoint( iconRect.center().x(), rect.center().y() ) );
graphic.render( painter, iconRect, Qt::KeepAspectRatio ); graphic.render( painter, iconRect, Qt::KeepAspectRatio );
@@ -821,7 +821,7 @@ QSize QwtPlotLegendItem::minimumSize( const QwtLegendData &data ) const
\param data Attributes of the legend entry \param data Attributes of the legend entry
\param width Width \param width Width
*/ */
int QwtPlotLegendItem::heightForWidth( int QwtPlotLegendItem::heightForWidth(
const QwtLegendData &data, int width ) const const QwtLegendData &data, int width ) const
{ {
width -= 2 * d_data->itemMargin; width -= 2 * d_data->itemMargin;
@@ -841,7 +841,7 @@ int QwtPlotLegendItem::heightForWidth(
return qMax( graphic.height(), h ); return qMax( graphic.height(), h );
} }
/*! /*!
\return All plot items with an entry on the legend \return All plot items with an entry on the legend
\note A plot item might have more than one entry on the legend \note A plot item might have more than one entry on the legend
*/ */
@@ -854,7 +854,7 @@ QList< const QwtPlotItem * > QwtPlotLegendItem::plotItems() const
\return Geometries of the items of a plot item \return Geometries of the items of a plot item
\note Usually a plot item has only one entry on the legend \note Usually a plot item has only one entry on the legend
*/ */
QList< QRect > QwtPlotLegendItem::legendGeometries( QList< QRect > QwtPlotLegendItem::legendGeometries(
const QwtPlotItem *plotItem ) const const QwtPlotItem *plotItem ) const
{ {
QList<QwtLegendLayoutItem *> layoutItems; QList<QwtLegendLayoutItem *> layoutItems;

View File

@@ -23,19 +23,19 @@ class QFont;
It can be used together with a QwtLegend or instead of it It can be used together with a QwtLegend or instead of it
to have more space for the plot canvas. to have more space for the plot canvas.
In opposite to QwtLegend the legend item is not interactive. In opposite to QwtLegend the legend item is not interactive.
To identify mouse clicks on a legend item an event filter To identify mouse clicks on a legend item an event filter
needs to be installed catching mouse events ob the plot canvas. needs to be installed catching mouse events ob the plot canvas.
The geometries of the legend items are available using The geometries of the legend items are available using
legendGeometries(). legendGeometries().
The legend item is aligned to plot canvas according to The legend item is aligned to plot canvas according to
its alignment() flags. It might have a background for the its alignment() flags. It might have a background for the
complete legend ( usually semi transparent ) or for complete legend ( usually semi transparent ) or for
each legend item. each legend item.
\note An external QwtLegend with a transparent background \note An external QwtLegend with a transparent background
on top the plot canvas might be another option on top the plot canvas might be another option
with a similar effect. with a similar effect.
*/ */
@@ -45,7 +45,7 @@ public:
/*! /*!
\brief Background mode \brief Background mode
Depending on the mode the complete legend or each item Depending on the mode the complete legend or each item
might have an background. might have an background.
The default setting is LegendBackground. The default setting is LegendBackground.
@@ -83,11 +83,11 @@ public:
void setItemSpacing( int ); void setItemSpacing( int );
int itemSpacing() const; int itemSpacing() const;
void setFont( const QFont& ); void setFont( const QFont& );
QFont font() const; QFont font() const;
void setBorderDistance( int numPixels ); void setBorderDistance( int );
int borderDistance() const; int borderDistance() const;
void setBorderRadius( double ); void setBorderRadius( double );
@@ -105,9 +105,9 @@ public:
void setTextPen( const QPen & ); void setTextPen( const QPen & );
QPen textPen() const; QPen textPen() const;
virtual void draw( QPainter *p, virtual void draw( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &rect ) const; const QRectF &canvasRect ) const;
void clearLegend(); void clearLegend();
@@ -117,13 +117,13 @@ public:
virtual QRect geometry( const QRectF &canvasRect ) const; virtual QRect geometry( const QRectF &canvasRect ) const;
virtual QSize minimumSize( const QwtLegendData & ) 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< const QwtPlotItem * > plotItems() const;
QList< QRect > legendGeometries( const QwtPlotItem * ) const; QList< QRect > legendGeometries( const QwtPlotItem * ) const;
protected: protected:
virtual void drawLegendData( QPainter *painter, virtual void drawLegendData( QPainter *painter,
const QwtPlotItem *, const QwtLegendData &, const QRectF & ) const; const QwtPlotItem *, const QwtLegendData &, const QRectF & ) const;
virtual void drawBackground( QPainter *, const QRectF &rect ) const; virtual void drawBackground( QPainter *, const QRectF &rect ) const;

View File

@@ -134,7 +134,7 @@ void QwtPlotMarker::draw( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect ) const const QRectF &canvasRect ) const
{ {
const QPointF pos( xMap.transform( d_data->xValue ), const QPointF pos( xMap.transform( d_data->xValue ),
yMap.transform( d_data->yValue ) ); yMap.transform( d_data->yValue ) );
// draw lines // draw lines
@@ -147,7 +147,7 @@ void QwtPlotMarker::draw( QPainter *painter,
{ {
const QSizeF sz = d_data->symbol->size(); const QSizeF sz = d_data->symbol->size();
const QRectF clipRect = canvasRect.adjusted( const QRectF clipRect = canvasRect.adjusted(
-sz.width(), -sz.height(), sz.width(), sz.height() ); -sz.width(), -sz.height(), sz.width(), sz.height() );
if ( clipRect.contains( pos ) ) if ( clipRect.contains( pos ) )
@@ -337,7 +337,7 @@ void QwtPlotMarker::drawLabel( QPainter *painter,
/*! /*!
\brief Set the line style \brief Set the line style
\param style Line style. \param style Line style.
\sa lineStyle() \sa lineStyle()
*/ */
void QwtPlotMarker::setLineStyle( LineStyle style ) void QwtPlotMarker::setLineStyle( LineStyle style )
@@ -423,7 +423,7 @@ QwtText QwtPlotMarker::label() const
In all other styles the alignment is relative to the marker's position. In all other styles the alignment is relative to the marker's position.
\param align Alignment. \param align Alignment.
\sa labelAlignment(), labelOrientation() \sa labelAlignment(), labelOrientation()
*/ */
void QwtPlotMarker::setLabelAlignment( Qt::Alignment align ) void QwtPlotMarker::setLabelAlignment( Qt::Alignment align )
@@ -502,21 +502,21 @@ int QwtPlotMarker::spacing() const
return d_data->spacing; return d_data->spacing;
} }
/*! /*!
Build and assign a line pen Build and assign a line pen
In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
non cosmetic ( see QPen::isCosmetic() ). This method has been introduced non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
to hide this incompatibility. to hide this incompatibility.
\param color Pen color \param color Pen color
\param width Pen width \param width Pen width
\param style Pen style \param style Pen style
\sa pen(), brush() \sa pen(), brush()
*/ */
void QwtPlotMarker::setLinePen( const QColor &color, qreal width, Qt::PenStyle style ) void QwtPlotMarker::setLinePen( const QColor &color, qreal width, Qt::PenStyle style )
{ {
setLinePen( QPen( color, width, style ) ); setLinePen( QPen( color, width, style ) );
} }
@@ -548,13 +548,25 @@ const QPen &QwtPlotMarker::linePen() const
QRectF QwtPlotMarker::boundingRect() const QRectF QwtPlotMarker::boundingRect() const
{ {
return QRectF( d_data->xValue, d_data->yValue, 0.0, 0.0 ); // 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 \return Icon representing the marker on the legend
\param index Index of the legend entry \param index Index of the legend entry
( usually there is only one ) ( usually there is only one )
\param size Icon size \param size Icon size
@@ -585,7 +597,7 @@ QwtGraphic QwtPlotMarker::legendIcon( int index,
{ {
const double y = 0.5 * size.height(); const double y = 0.5 * size.height();
QwtPainter::drawLine( &painter, QwtPainter::drawLine( &painter,
0.0, y, size.width(), y ); 0.0, y, size.width(), y );
} }
@@ -594,7 +606,7 @@ QwtGraphic QwtPlotMarker::legendIcon( int index,
{ {
const double x = 0.5 * size.width(); const double x = 0.5 * size.width();
QwtPainter::drawLine( &painter, QwtPainter::drawLine( &painter,
x, 0.0, x, size.height() ); x, 0.0, x, size.height() );
} }
} }

View File

@@ -37,11 +37,11 @@ class QwtSymbol;
are valid. The interpretation of the alignment depends on the marker's are valid. The interpretation of the alignment depends on the marker's
line style. The alignment refers to the center point of line style. The alignment refers to the center point of
the marker, which means, for example, that the label would be printed the marker, which means, for example, that the label would be printed
left above the center point if the alignment was set to left above the center point if the alignment was set to
Qt::AlignLeft | Qt::AlignTop. Qt::AlignLeft | Qt::AlignTop.
\note QwtPlotTextLabel is intended to align a text label \note QwtPlotTextLabel is intended to align a text label
according to the geometry of canvas according to the geometry of canvas
( unrelated to plot coordinates ) ( unrelated to plot coordinates )
*/ */
@@ -68,7 +68,7 @@ public:
Cross Cross
}; };
explicit QwtPlotMarker( const QString &title = QString::null ); explicit QwtPlotMarker( const QString &title = QString() );
explicit QwtPlotMarker( const QwtText &title ); explicit QwtPlotMarker( const QwtText &title );
virtual ~QwtPlotMarker(); virtual ~QwtPlotMarker();
@@ -84,11 +84,11 @@ public:
void setValue( double, double ); void setValue( double, double );
void setValue( const QPointF & ); void setValue( const QPointF & );
void setLineStyle( LineStyle st ); void setLineStyle( LineStyle );
LineStyle lineStyle() const; LineStyle lineStyle() const;
void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); 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; const QPen &linePen() const;
void setSymbol( const QwtSymbol * ); void setSymbol( const QwtSymbol * );
@@ -106,7 +106,7 @@ public:
void setSpacing( int ); void setSpacing( int );
int spacing() const; int spacing() const;
virtual void draw( QPainter *p, virtual void draw( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF & ) const; const QRectF & ) const;
@@ -115,10 +115,10 @@ public:
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
protected: protected:
virtual void drawLines( QPainter *, virtual void drawLines( QPainter *,
const QRectF &, const QPointF & ) const; const QRectF &, const QPointF & ) const;
virtual void drawLabel( QPainter *, virtual void drawLabel( QPainter *,
const QRectF &, const QPointF & ) const; const QRectF &, const QPointF & ) const;
private: private:

View File

@@ -108,19 +108,19 @@ void QwtPlotMultiBarChart::setSamples(
/*! /*!
Assign a series of samples Assign a series of samples
setSamples() is just a wrapper for setData() without any additional setSamples() is just a wrapper for setData() without any additional
value - beside that it is easier to find for the developer. value - beside that it is easier to find for the developer.
\param data Data \param data Data
\warning The item takes ownership of the data object, deleting \warning The item takes ownership of the data object, deleting
it when its not used anymore. it when its not used anymore.
*/ */
void QwtPlotMultiBarChart::setSamples( void QwtPlotMultiBarChart::setSamples(
QwtSeriesData<QwtSetSample> *data ) QwtSeriesData<QwtSetSample> *data )
{ {
setData( data ); setData( data );
} }
/*! /*!
\brief Set the titles for the bars \brief Set the titles for the bars
@@ -137,7 +137,7 @@ void QwtPlotMultiBarChart::setBarTitles( const QList<QwtText> &titles )
itemChanged(); itemChanged();
} }
/*! /*!
\return Bar titles \return Bar titles
\sa setBarTitles(), legendData() \sa setBarTitles(), legendData()
*/ */
@@ -162,7 +162,7 @@ void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol *symbol )
if ( valueIndex < 0 ) if ( valueIndex < 0 )
return; return;
QMap<int, QwtColumnSymbol *>::iterator it = QMap<int, QwtColumnSymbol *>::iterator it =
d_data->symbolMap.find(valueIndex); d_data->symbolMap.find(valueIndex);
if ( it == d_data->symbolMap.end() ) if ( it == d_data->symbolMap.end() )
{ {
@@ -206,9 +206,9 @@ void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol *symbol )
const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const
{ {
QMap<int, QwtColumnSymbol *>::const_iterator it = 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();
} }
/*! /*!
@@ -219,12 +219,12 @@ const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const
\sa setSymbol(), specialSymbol(), drawBar() \sa setSymbol(), specialSymbol(), drawBar()
*/ */
QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex )
{ {
QMap<int, QwtColumnSymbol *>::iterator it = 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();
} }
/*! /*!
@@ -232,12 +232,7 @@ QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex )
*/ */
void QwtPlotMultiBarChart::resetSymbolMap() void QwtPlotMultiBarChart::resetSymbolMap()
{ {
for ( QMap<int, QwtColumnSymbol *>::iterator it qDeleteAll( d_data->symbolMap );
= d_data->symbolMap.begin(); it != d_data->symbolMap.end(); ++it )
{
delete it.value();
}
d_data->symbolMap.clear(); d_data->symbolMap.clear();
} }
@@ -252,16 +247,16 @@ void QwtPlotMultiBarChart::resetSymbolMap()
called. As soon as the symbol is painted this symbol gets deleted. called. As soon as the symbol is painted this symbol gets deleted.
When no symbol ( NULL ) is returned, the value will be displayed When no symbol ( NULL ) is returned, the value will be displayed
with the standard symbol that is used for all symbols with the same with the standard symbol that is used for all symbols with the same
valueIndex. valueIndex.
\param sampleIndex Index of the sample \param sampleIndex Index of the sample
\param valueIndex Index of the value in the set \param valueIndex Index of the value in the set
\return NULL, meaning that the value is not special \return NULL, meaning that the value is not special
*/ */
QwtColumnSymbol *QwtPlotMultiBarChart::specialSymbol( QwtColumnSymbol *QwtPlotMultiBarChart::specialSymbol(
int sampleIndex, int valueIndex ) const int sampleIndex, int valueIndex ) const
{ {
Q_UNUSED( sampleIndex ); Q_UNUSED( sampleIndex );
@@ -455,7 +450,7 @@ void QwtPlotMultiBarChart::drawSample( QPainter *painter,
\param canvasRect Contents rectangle of the canvas \param canvasRect Contents rectangle of the canvas
\param index Index of the sample to be painted \param index Index of the sample to be painted
\param sampleWidth Boundng width for all bars of the smaple \param sampleWidth Boundng width for all bars of the smaple
\param sample Sample \param sample Sample
\sa drawSeries(), sampleWidth() \sa drawSeries(), sampleWidth()
*/ */
@@ -535,13 +530,13 @@ void QwtPlotMultiBarChart::drawGroupedBars( QPainter *painter,
\param canvasRect Contents rectangle of the canvas \param canvasRect Contents rectangle of the canvas
\param index Index of the sample to be painted \param index Index of the sample to be painted
\param sampleWidth Width of the bars \param sampleWidth Width of the bars
\param sample Sample \param sample Sample
\sa drawSeries(), sampleWidth() \sa drawSeries(), sampleWidth()
*/ */
void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter, void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int index, const QRectF &canvasRect, int index,
double sampleWidth, const QwtSetSample& sample ) const double sampleWidth, const QwtSetSample& sample ) const
{ {
Q_UNUSED( canvasRect ); // clipping the bars ? Q_UNUSED( canvasRect ); // clipping the bars ?
@@ -567,7 +562,6 @@ void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter,
double sum = baseline(); double sum = baseline();
const int numBars = sample.set.size();
for ( int i = 0; i < numBars; i++ ) for ( int i = 0; i < numBars; i++ )
{ {
const double si = sample.set[ i ]; const double si = sample.set[ i ];
@@ -669,10 +663,10 @@ void QwtPlotMultiBarChart::drawBar( QPainter *painter,
else else
{ {
// we build a temporary default symbol // we build a temporary default symbol
QwtColumnSymbol sym( QwtColumnSymbol::Box ); QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box );
sym.setLineWidth( 1 ); columnSymbol.setLineWidth( 1 );
sym.setFrameStyle( QwtColumnSymbol::Plain ); columnSymbol.setFrameStyle( QwtColumnSymbol::Plain );
sym.draw( painter, rect ); columnSymbol.draw( painter, rect );
} }
delete specialSym; delete specialSym;
@@ -701,7 +695,7 @@ QList<QwtLegendData> QwtPlotMultiBarChart::legendData() const
if ( !legendIconSize().isEmpty() ) if ( !legendIconSize().isEmpty() )
{ {
QVariant iconValue; QVariant iconValue;
qVariantSetValue( iconValue, qVariantSetValue( iconValue,
legendIcon( i, legendIconSize() ) ); legendIcon( i, legendIconSize() ) );
data.setValue( QwtLegendData::IconRole, iconValue ); data.setValue( QwtLegendData::IconRole, iconValue );
@@ -718,7 +712,7 @@ QList<QwtLegendData> QwtPlotMultiBarChart::legendData() const
\param index Index of the bar \param index Index of the bar
\param size Icon size \param size Icon size
\return An icon showing a bar \return An icon showing a bar
\sa drawBar(), legendData() \sa drawBar(), legendData()
*/ */

View File

@@ -19,26 +19,26 @@ class QwtColumnSymbol;
/*! /*!
\brief QwtPlotMultiBarChart displays a series of a samples that consist \brief QwtPlotMultiBarChart displays a series of a samples that consist
each of a set of values. each of a set of values.
Each value is displayed as a bar, the bars of each set can be organized Each value is displayed as a bar, the bars of each set can be organized
side by side or accumulated. side by side or accumulated.
Each bar of a set is rendered by a QwtColumnSymbol, that is set by setSymbol(). Each bar of a set is rendered by a QwtColumnSymbol, that is set by setSymbol().
The bars of different sets use the same symbols. Exceptions are possible The bars of different sets use the same symbols. Exceptions are possible
by overloading specialSymbol() or overloading drawBar(). by overloading specialSymbol() or overloading drawBar().
Depending on its orientation() the bars are displayed horizontally Depending on its orientation() the bars are displayed horizontally
or vertically. The bars cover the interval between the baseline() or vertically. The bars cover the interval between the baseline()
and the value. and the value.
In opposite to most other plot items, QwtPlotMultiBarChart returns more In opposite to most other plot items, QwtPlotMultiBarChart returns more
than one entry for the legend - one for each symbol. than one entry for the legend - one for each symbol.
\sa QwtPlotBarChart, QwtPlotHistogram \sa QwtPlotBarChart, QwtPlotHistogram
QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline() QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
*/ */
class QWT_EXPORT QwtPlotMultiBarChart: class QWT_EXPORT QwtPlotMultiBarChart:
public QwtPlotAbstractBarChart, public QwtSeriesStore<QwtSetSample> public QwtPlotAbstractBarChart, public QwtSeriesStore<QwtSetSample>
{ {
public: public:
@@ -61,7 +61,7 @@ public:
Stacked Stacked
}; };
explicit QwtPlotMultiBarChart( const QString &title = QString::null ); explicit QwtPlotMultiBarChart( const QString &title = QString() );
explicit QwtPlotMultiBarChart( const QwtText &title ); explicit QwtPlotMultiBarChart( const QwtText &title );
virtual ~QwtPlotMultiBarChart(); virtual ~QwtPlotMultiBarChart();
@@ -78,8 +78,8 @@ public:
void setStyle( ChartStyle style ); void setStyle( ChartStyle style );
ChartStyle style() const; ChartStyle style() const;
void setSymbol( int barIndex, QwtColumnSymbol *symbol ); void setSymbol( int valueIndex, QwtColumnSymbol * );
const QwtColumnSymbol *symbol( int barIndex ) const; const QwtColumnSymbol *symbol( int valueIndex ) const;
void resetSymbolMap(); void resetSymbolMap();
@@ -94,9 +94,9 @@ public:
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
protected: protected:
QwtColumnSymbol *symbol( int barIndex ); QwtColumnSymbol *symbol( int valueIndex );
virtual QwtColumnSymbol *specialSymbol( virtual QwtColumnSymbol *specialSymbol(
int sampleIndex, int valueIndex ) const; int sampleIndex, int valueIndex ) const;
virtual void drawSample( QPainter *painter, virtual void drawSample( QPainter *painter,
@@ -105,7 +105,7 @@ protected:
int index, const QwtSetSample& sample ) const; int index, const QwtSetSample& sample ) const;
virtual void drawBar( QPainter *, int sampleIndex, virtual void drawBar( QPainter *, int sampleIndex,
int barIndex, const QwtColumnRect & ) const; int valueIndex, const QwtColumnRect & ) const;
void drawStackedBars( QPainter *painter, void drawStackedBars( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtScaleMap &xMap, const QwtScaleMap &yMap,

View File

@@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library * Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen * Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann * Copyright (C) 2002 Uwe Rathmann
@@ -14,15 +14,34 @@
#include <qbitmap.h> #include <qbitmap.h>
#include <qstyle.h> #include <qstyle.h>
#include <qstyleoption.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 ) 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() ); const QRect r( 0, 0, size.width(), size.height() );
QPainterPath borderPath; QPainterPath borderPath;
( void )QMetaObject::invokeMethod( ( void )QMetaObject::invokeMethod(
const_cast< QWidget *>( canvas ), "borderPath", Qt::DirectConnection, const_cast< QWidget *>( canvas ), "borderPath", Qt::DirectConnection,
Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) ); Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) );
@@ -31,7 +50,12 @@ static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
if ( canvas->contentsRect() == canvas->rect() ) if ( canvas->contentsRect() == canvas->rect() )
return QBitmap(); return QBitmap();
#if QT_VERSION >= 0x050000
QBitmap mask( size * pixelRatio );
mask.setDevicePixelRatio( pixelRatio );
#else
QBitmap mask( size ); QBitmap mask( size );
#endif
mask.fill( Qt::color0 ); mask.fill( Qt::color0 );
QPainter painter( &mask ); QPainter painter( &mask );
@@ -40,7 +64,12 @@ static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
return mask; 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 ); QImage image( size, QImage::Format_ARGB32_Premultiplied );
#endif
image.fill( Qt::color0 ); image.fill( Qt::color0 );
QPainter painter( &image ); QPainter painter( &image );
@@ -63,12 +92,12 @@ static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
const QVariant borderRadius = canvas->property( "borderRadius" ); const QVariant borderRadius = canvas->property( "borderRadius" );
const QVariant frameWidth = canvas->property( "frameWidth" ); const QVariant frameWidth = canvas->property( "frameWidth" );
if ( borderRadius.type() == QVariant::Double if ( borderRadius.type() == QVariant::Double
&& frameWidth.type() == QVariant::Int ) && frameWidth.type() == QVariant::Int )
{ {
const double br = borderRadius.toDouble(); const double br = borderRadius.toDouble();
const int fw = frameWidth.toInt(); const int fw = frameWidth.toInt();
if ( br > 0.0 && fw > 0 ) if ( br > 0.0 && fw > 0 )
{ {
painter.setPen( QPen( Qt::color1, fw ) ); painter.setPen( QPen( Qt::color1, fw ) );
@@ -114,8 +143,8 @@ QwtPlotPanner::QwtPlotPanner( QWidget *canvas ):
{ {
d_data = new PrivateData(); d_data = new PrivateData();
connect( this, SIGNAL( panned( int, int ) ), connect( this, SIGNAL(panned(int,int)),
SLOT( moveCanvas( int, int ) ) ); SLOT(moveCanvas(int,int)) );
} }
//! Destructor //! Destructor
@@ -256,7 +285,7 @@ QBitmap QwtPlotPanner::contentsMask() const
\return Pixmap with the content of the canvas \return Pixmap with the content of the canvas
*/ */
QPixmap QwtPlotPanner::grab() const QPixmap QwtPlotPanner::grab() const
{ {
const QWidget *cv = canvas(); const QWidget *cv = canvas();
if ( cv && cv->inherits( "QGLWidget" ) ) if ( cv && cv->inherits( "QGLWidget" ) )
{ {
@@ -272,5 +301,5 @@ QPixmap QwtPlotPanner::grab() const
} }
return QwtPanner::grab(); return QwtPanner::grab();
} }

Some files were not shown because too many files have changed in this diff Show More