改进代码

master
feiyangqingyun 2021-10-08 10:51:37 +08:00
parent 1e6ba19f3a
commit 9b11b4be58
171 changed files with 2894 additions and 1940 deletions

View File

@ -21,7 +21,7 @@ class QVariant;
\brief Abstract base class for legend widgets
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
the QwtPlot::legendDataChanged() signal. But as these legends
@ -44,11 +44,11 @@ public:
\param painter Painter
\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
*/
virtual void renderLegend( QPainter *painter,
virtual void renderLegend( QPainter *painter,
const QRectF &rect, bool fillBackground ) const = 0;
//! \return True, when no plot item is inserted
@ -64,8 +64,8 @@ public Q_SLOTS:
\param itemInfo Info about an 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;
};
#endif
#endif

View File

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

View File

@ -25,8 +25,8 @@ public:
penWidth( 0 ),
minExtent( 0.0 )
{
components = QwtAbstractScaleDraw::Backbone
| QwtAbstractScaleDraw::Ticks
components = QwtAbstractScaleDraw::Backbone
| QwtAbstractScaleDraw::Ticks
| QwtAbstractScaleDraw::Labels;
tickLength[QwtScaleDiv::MinorTick] = 4.0;
@ -197,7 +197,7 @@ void QwtAbstractScaleDraw::draw( QPainter *painter,
{
painter->save();
QPen pen = painter->pen();
pen = painter->pen();
pen.setColor( palette.color( QPalette::WindowText ) );
pen.setCapStyle( Qt::FlatCap );
@ -226,7 +226,7 @@ void QwtAbstractScaleDraw::draw( QPainter *painter,
{
painter->save();
QPen pen = painter->pen();
pen = painter->pen();
pen.setColor( palette.color( QPalette::WindowText ) );
pen.setCapStyle( Qt::FlatCap );
@ -392,19 +392,18 @@ QwtText QwtAbstractScaleDraw::label( double value ) const
const QwtText &QwtAbstractScaleDraw::tickLabel(
const QFont &font, double value ) const
{
QMap<double, QwtText>::const_iterator it = d_data->labelCache.find( value );
if ( it == d_data->labelCache.end() )
{
QwtText lbl = label( value );
lbl.setRenderFlags( 0 );
lbl.setLayoutAttribute( QwtText::MinimumLayout );
QMap<double, QwtText>::const_iterator it1 = d_data->labelCache.constFind( value );
if ( it1 != d_data->labelCache.constEnd() )
return *it1;
( 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();
virtual ~QwtAbstractScaleDraw();
void setScaleDiv( const QwtScaleDiv &s );
void setScaleDiv( const QwtScaleDiv & );
const QwtScaleDiv& scaleDiv() const;
void setTransformation( QwtTransform * );
@ -68,7 +68,7 @@ public:
double tickLength( QwtScaleDiv::TickType ) const;
double maxTickLength() const;
void setSpacing( double margin );
void setSpacing( double );
double spacing() const;
void setPenWidth( int width );

View File

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

View File

@ -17,14 +17,14 @@
\brief An abstract base class for slider widgets with 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.
When the slider is nor readOnly() its value can be modified
by keyboard, mouse and wheel inputs.
When the slider is nor readOnly() its value can be modified
by keyboard, mouse and wheel inputs.
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
a fixed step size.
*/
@ -67,7 +67,7 @@ public:
void setPageSteps( uint );
uint pageSteps() const;
void setStepAlignment( bool );
void setStepAlignment( bool );
bool stepAlignment() const;
void setTracking( bool );
@ -80,15 +80,15 @@ public:
bool invertedControls() const;
public Q_SLOTS:
void setValue( double val );
void setValue( double value );
Q_SIGNALS:
/*!
\brief Notify a change of value.
When tracking is enabled (default setting),
this signal will be emitted every time the value changes.
When tracking is enabled (default setting),
this signal will be emitted every time the value changes.
\param value New value
@ -146,14 +146,14 @@ protected:
*/
virtual double scrolledTo( const QPoint &pos ) const = 0;
void incrementValue( int numSteps );
void incrementValue( int stepCount );
virtual void scaleChange();
protected:
virtual void sliderChange();
double incrementedValue(
double incrementedValue(
double value, int stepCount ) const;
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,8 +46,8 @@ private:
b = qBlue( 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 );
Thus adding 0.5 ( for rounding ) can be done in advance

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
#include <qpixmap.h>
#include <qevent.h>
/*!
/*!
\brief Constructor
Initializes a label map for multiples of 45 degrees
@ -48,7 +48,7 @@ QwtCompassScaleDraw::QwtCompassScaleDraw()
#endif
}
/*!
/*!
\brief Constructor
\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
or returns an null text.
\return Label, or QString::null
\return Label
\sa labelMap(), setLabelMap()
*/

View File

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

View File

@ -45,7 +45,7 @@ public:
\param north Position
\param colorGroup Color group
*/
virtual void draw( QPainter *painter,
virtual void draw( QPainter *painter,
const QPointF &center, double radius, double north,
QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0;
@ -62,13 +62,13 @@ public:
QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 );
virtual ~QwtSimpleCompassRose();
void setWidth( double w );
void setWidth( double );
double width() const;
void setNumThorns( int count );
void setNumThorns( int );
int numThorns() const;
void setNumThornLevels( int count );
void setNumThornLevels( int );
int numThornLevels() const;
void setShrinkFactor( double factor );
@ -78,7 +78,7 @@ public:
double north, QPalette::ColorGroup = QPalette::Active ) const;
static void drawRose( QPainter *, const QPalette &,
const QPointF &center, double radius, double origin, double width,
const QPointF &center, double radius, double north, double width,
int numThorns, int numThornLevels, double shrinkFactor );
private:
@ -86,4 +86,4 @@ private:
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.
The default number of buttons is set to 2. The default increments are:
@ -82,8 +82,8 @@ void QwtCounter::initCounter()
btn->installEventFilter( this );
layout->addWidget( btn );
connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) );
connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) );
connect( btn, SIGNAL(released()), SLOT(btnReleased()) );
connect( btn, SIGNAL(clicked()), SLOT(btnClicked()) );
d_data->buttonDown[i] = btn;
}
@ -93,8 +93,7 @@ void QwtCounter::initCounter()
d_data->valueEdit->setValidator( new QDoubleValidator( d_data->valueEdit ) );
layout->addWidget( d_data->valueEdit );
connect( d_data->valueEdit, SIGNAL( editingFinished() ),
SLOT( textChanged() ) );
connect( d_data->valueEdit, SIGNAL(editingFinished()), SLOT(textChanged()) );
layout->setStretchFactor( d_data->valueEdit, 10 );
@ -106,8 +105,8 @@ void QwtCounter::initCounter()
btn->installEventFilter( this );
layout->addWidget( btn );
connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) );
connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) );
connect( btn, SIGNAL(released()), SLOT(btnReleased()) );
connect( btn, SIGNAL(clicked()), SLOT(btnClicked()) );
d_data->buttonUp[i] = btn;
}
@ -130,13 +129,13 @@ QwtCounter::~QwtCounter()
delete d_data;
}
/*!
/*!
Set the counter to be in valid/invalid state
When the counter is set to invalid, no numbers are displayed and
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()
*/
@ -155,19 +154,19 @@ void QwtCounter::setValid( bool on )
}
else
{
d_data->valueEdit->setText( QString::null );
d_data->valueEdit->setText( QString() );
}
}
}
}
}
/*!
/*!
\return True, if the value is valid
\sa setValid(), setValue()
*/
bool QwtCounter::isValid() const
{
return d_data->isValid;
}
}
/*!
\brief Allow/disallow the user to manually edit the value
@ -180,7 +179,7 @@ void QwtCounter::setReadOnly( bool on )
d_data->valueEdit->setReadOnly( on );
}
/*!
/*!
\return True, when the line line edit is read only. (default is no)
\sa setReadOnly()
*/
@ -334,8 +333,8 @@ double QwtCounter::singleStep() const
/*!
\brief En/Disable wrapping
If wrapping is true stepping up from maximum() value will take
you to the minimum() value and vice versa.
If wrapping is true stepping up from maximum() value will take
you to the minimum() value and vice versa.
\param on En/Disable wrapping
\sa wrapping()

View File

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

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
\sa setChunkSize()
*/
@ -349,8 +348,10 @@ uint QwtWeedingCurveFitter::chunkSize() const
*/
QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const
{
QPolygonF fittedPoints;
if ( points.isEmpty() )
return points;
QPolygonF fittedPoints;
if ( d_data->chunkSize == 0 )
{
fittedPoints = simplify( points );

View File

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

View File

@ -31,7 +31,7 @@ static const QwtJulianDay maxJulianDayD = std::numeric_limits<int>::max();
#endif
static QString qwtExpandedFormat( const QString & format,
static QString qwtExpandedFormat( const QString & format,
const QDateTime &dateTime, QwtDate::Week0Type week0Type )
{
const int week = QwtDate::weekNumber( dateTime.date(), week0Type );
@ -194,7 +194,7 @@ static inline Qt::DayOfWeek qwtFirstDayOfWeek()
#endif
}
static inline void qwtFloorTime(
static inline void qwtFloorTime(
QwtDate::IntervalType intervalType, QDateTime &dt )
{
// 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 ) );
break;
}
}
default:
break;
}
@ -232,7 +232,7 @@ static inline void qwtFloorTime(
dt = dt.toTimeSpec( Qt::LocalTime );
}
static inline QDateTime qwtToTimeSpec(
static inline QDateTime qwtToTimeSpec(
const QDateTime &dt, Qt::TimeSpec spec )
{
if ( dt.timeSpec() == spec )
@ -254,6 +254,8 @@ static inline QDateTime qwtToTimeSpec(
return dt.toTimeSpec( spec );
}
#if 0
static inline double qwtToJulianDay( int year, int month, int day )
{
// code from QDate but using doubles to avoid overflows
@ -279,9 +281,11 @@ static inline qint64 qwtFloorDiv( int a, int b )
{
if ( a < 0 )
a -= b - 1;
return a / b;
}
}
#endif
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
\param value Number of milliseconds since the epoch,
\param value Number of milliseconds since the epoch,
1970-01-01T00:00:00 UTC
\param timeSpec Time specification
\return Datetime value
@ -372,7 +376,7 @@ double QwtDate::toDouble( const QDateTime &dateTime )
const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch;
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();
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
\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
will be ceiled to the next beginning of a month
\return Ceiled datetime
@ -450,7 +454,7 @@ QDateTime QwtDate::ceil( const QDateTime &dateTime, IntervalType intervalType )
case QwtDate::Month:
{
dt.setTime( QTime( 0, 0 ) );
dt.setDate( qwtToDate( dateTime.date().year(),
dt.setDate( qwtToDate( dateTime.date().year(),
dateTime.date().month() ) );
if ( dt < dateTime )
@ -483,14 +487,14 @@ QDateTime QwtDate::ceil( const QDateTime &dateTime, IntervalType intervalType )
Floor a datetime according the interval type
\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 will be ceiled to the next
the result will be ceiled to the next
beginning of a month
\return Floored datetime
\sa floor()
*/
QDateTime QwtDate::floor( const QDateTime &dateTime,
QDateTime QwtDate::floor( const QDateTime &dateTime,
IntervalType intervalType )
{
if ( dateTime.date() <= QwtDate::minDate() )
@ -532,7 +536,7 @@ QDateTime QwtDate::floor( const QDateTime &dateTime,
{
dt.setTime( QTime( 0, 0 ) );
const QDate date = qwtToDate( dt.date().year(),
const QDate date = qwtToDate( dt.date().year(),
dt.date().month() );
dt.setDate( date );
@ -555,7 +559,7 @@ QDateTime QwtDate::floor( const QDateTime &dateTime,
/*!
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.
- For Qt4 it is "Tue Jan 2 -4713"
@ -576,7 +580,7 @@ QDate QwtDate::minDate()
/*!
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.
- 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
The first day of a week depends on the current locale
( QLocale::firstDayOfWeek() ).
( QLocale::firstDayOfWeek() ).
\param year Year
\param type Option how to identify the first week
\return First day of week 0
\sa QLocale::firstDayOfWeek(), weekNumber()
*/
*/
QDate QwtDate::dateOfWeek0( int year, Week0Type type )
{
const Qt::DayOfWeek firstDayOfWeek = qwtFirstDayOfWeek();
@ -623,7 +627,7 @@ QDate QwtDate::dateOfWeek0( int year, Week0Type type )
if ( type == QwtDate::FirstThursday )
{
// according to ISO 8601 the first week is defined
// by the first thursday.
// by the first thursday.
int d = Qt::Thursday - firstDayOfWeek;
if ( d < 0 )
@ -640,7 +644,7 @@ QDate QwtDate::dateOfWeek0( int year, Week0Type type )
Find the week number of a date
- QwtDate::FirstThursday\n
Corresponding to ISO 8601 ( see QDate::weekNumber() ).
Corresponding to ISO 8601 ( see QDate::weekNumber() ).
- QwtDate::FirstDay\n
Number of weeks that have begun since dateOfWeek0().
@ -736,7 +740,7 @@ int QwtDate::utcOffset( const QDateTime &dateTime )
- ww\n
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
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
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],
Qt5 stores it as qint64 offering a huge range of valid dates.
As the significance of a double is below this ( assuming a
fraction of 52 bits ) the translation is not
bijective with rounding errors for dates very far from Epoch.
For a resolution of 1 ms those start to happen for dates above the
year 144683.
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.
As the significance of a double is below this ( assuming a
fraction of 52 bits ) the translation is not
bijective with rounding errors for dates very far from Epoch.
For a resolution of 1 ms those start to happen for dates above the
year 144683.
An axis for a date/time interval is expected to be aligned
and divided in time/date units like seconds, minutes, ...
@ -42,9 +42,9 @@
class QWT_EXPORT QwtDate
{
public:
/*!
/*!
How to identify the first week of year differs between
countries.
countries.
*/
enum Week0Type
{
@ -59,14 +59,14 @@ public:
/*!
"The week with January 1.1 in it."
In the U.S. this definition is more common than
FirstThursday.
*/
FirstDay
};
/*!
/*!
Classification of an time interval
Time intervals needs to be classified to decide how to
@ -108,7 +108,7 @@ public:
static QDate minDate();
static QDate maxDate();
static QDateTime toDateTime( double value,
static QDateTime toDateTime( double value,
Qt::TimeSpec = Qt::UTC );
static double toDouble( const QDateTime & );
@ -121,7 +121,7 @@ public:
static int utcOffset( const QDateTime & );
static QString toString( const QDateTime &,
static QString toString( const QDateTime &,
const QString & format, Week0Type );
};

View File

@ -36,7 +36,7 @@ public:
/*!
\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
for QwtDate::FirstThursday.
@ -109,7 +109,7 @@ int QwtDateScaleDraw::utcOffset() const
\sa week0Type().
\note week0Type has no effect beside for intervals classified as
QwtDate::Week.
QwtDate::Week.
*/
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()
*/
QwtDate::Week0Type QwtDateScaleDraw::week0Type() const
@ -133,10 +133,10 @@ QwtDate::Week0Type QwtDateScaleDraw::week0Type() const
\sa dateFormat(), dateFormatOfDate(), QwtDate::toString()
*/
void QwtDateScaleDraw::setDateFormat(
void QwtDateScaleDraw::setDateFormat(
QwtDate::IntervalType intervalType, const QString &format )
{
if ( intervalType >= QwtDate::Millisecond &&
if ( intervalType >= QwtDate::Millisecond &&
intervalType <= QwtDate::Year )
{
d_data->dateFormats[ intervalType ] = format;
@ -148,16 +148,16 @@ void QwtDateScaleDraw::setDateFormat(
\return Default format string for an datetime interval type
\sa setDateFormat(), dateFormatOfDate()
*/
QString QwtDateScaleDraw::dateFormat(
QString QwtDateScaleDraw::dateFormat(
QwtDate::IntervalType intervalType ) const
{
if ( intervalType >= QwtDate::Millisecond &&
if ( intervalType >= QwtDate::Millisecond &&
intervalType <= QwtDate::Year )
{
return d_data->dateFormats[ intervalType ];
}
return QString::null;
return QString();
}
/*!
@ -181,7 +181,7 @@ QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime &dateTime,
{
Q_UNUSED( dateTime )
if ( intervalType >= QwtDate::Millisecond &&
if ( intervalType >= QwtDate::Millisecond &&
intervalType <= QwtDate::Year )
{
return d_data->dateFormats[ intervalType ];
@ -204,7 +204,7 @@ QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime &dateTime,
QwtText QwtDateScaleDraw::label( double value ) const
{
const QDateTime dt = toDateTime( value );
const QString fmt = dateFormatOfDate(
const QString fmt = dateFormatOfDate(
dt, intervalType( scaleDiv() ) );
return QwtDate::toString( dt, fmt, d_data->week0Type );
@ -219,7 +219,7 @@ QwtText QwtDateScaleDraw::label( double value ) const
\sa dateFormatOfDate()
*/
QwtDate::IntervalType QwtDateScaleDraw::intervalType(
QwtDate::IntervalType QwtDateScaleDraw::intervalType(
const QwtScaleDiv &scaleDiv ) const
{
int intvType = QwtDate::Year;
@ -232,7 +232,7 @@ QwtDate::IntervalType QwtDateScaleDraw::intervalType(
const QDateTime dt = toDateTime( ticks[i] );
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 ) );
if ( dt0 != dt )

View File

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

View File

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

View File

@ -27,12 +27,12 @@
QwtDateScaleEngine supports representations depending
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.
Datetime values are expected as the number of milliseconds since
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().
\sa QwtDate, QwtPlot::setAxisScaleEngine(),
@ -52,19 +52,19 @@ public:
void setWeek0Type( QwtDate::Week0Type );
QwtDate::Week0Type week0Type() const;
void setMaxWeeks( int );
int maxWeeks() const;
virtual void autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const;
virtual QwtScaleDiv divideScale(
virtual QwtScaleDiv divideScale(
double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const;
virtual QwtDate::IntervalType intervalType(
virtual QwtDate::IntervalType intervalType(
const QDateTime &, const QDateTime &, int maxSteps ) const;
QDateTime toDateTime( double ) const;
@ -75,7 +75,7 @@ protected:
private:
QwtScaleDiv buildScaleDiv( const QDateTime &, const QDateTime &,
int maxMajorSteps, int maxMinorSteps,
int maxMajorSteps, int maxMinorSteps,
QwtDate::IntervalType ) const;
private:

View File

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

View File

@ -103,12 +103,12 @@ public:
void setMode( Mode );
Mode mode() const;
void setScaleArc( double min, double max );
void setScaleArc( double minArc, double maxArc );
void setMinScaleArc( double min );
void setMinScaleArc( double );
double minScaleArc() const;
void setMaxScaleArc( double min );
void setMaxScaleArc( double );
double maxScaleArc() const;
virtual void setOrigin( double );
@ -136,16 +136,16 @@ protected:
virtual void paintEvent( QPaintEvent * );
virtual void changeEvent( QEvent * );
virtual void drawFrame( QPainter *p );
virtual void drawFrame( QPainter * );
virtual void drawContents( QPainter * ) const;
virtual void drawFocusIndicator( QPainter * ) const;
void invalidateCache();
virtual void drawScale( QPainter *,
virtual void drawScale( QPainter *,
const QPointF &center, double radius ) const;
virtual void drawScaleContents( QPainter *painter,
virtual void drawScaleContents( QPainter *painter,
const QPointF &center, double radius ) const;
virtual void drawNeedle( QPainter *, const QPointF &,

View File

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

View File

@ -35,7 +35,7 @@ public:
const QPalette &palette() const;
virtual void draw( QPainter *painter, const QPointF &center,
double length, double direction,
double length, double direction,
QPalette::ColorGroup = QPalette::Active ) const;
protected:
@ -43,9 +43,9 @@ protected:
\brief Draw the needle
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.
\param painter Painter
@ -54,10 +54,10 @@ protected:
\sa setPalette(), palette()
*/
virtual void drawNeedle( QPainter *painter,
virtual void drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const = 0;
virtual void drawKnob( QPainter *, double width,
virtual void drawKnob( QPainter *, double width,
const QBrush &, bool sunken ) const;
private:
@ -132,7 +132,7 @@ public:
//! A needle with a triangular shape
TriangleStyle,
//! A thin needle
//! A thin needle
ThinStyle
};
@ -140,7 +140,7 @@ public:
const QColor &light = Qt::white, const QColor &dark = Qt::red );
protected:
virtual void drawNeedle( QPainter *,
virtual void drawNeedle( QPainter *,
double length, QPalette::ColorGroup ) const;
private:
@ -177,11 +177,11 @@ public:
const QColor &dark = Qt::gray );
protected:
virtual void drawNeedle( QPainter *,
virtual void drawNeedle( QPainter *,
double length, QPalette::ColorGroup ) const;
private:
Style d_style;
};
#endif
#endif

View File

@ -125,7 +125,7 @@ uint QwtDynGridLayout::maxColumns() const
return d_data->maxColumns;
}
/*!
/*!
\brief Add an item to the next free position.
\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() )
\param width Available width for all columns
@ -263,7 +263,7 @@ uint QwtDynGridLayout::columnsForWidth( int width ) const
return 0;
uint maxColumns = itemCount();
if ( d_data->maxColumns > 0 )
if ( d_data->maxColumns > 0 )
maxColumns = qMin( d_data->maxColumns, maxColumns );
if ( maxRowWidth( maxColumns ) <= width )

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@
#include <qpixmap.h>
#include <qpainterpath.h>
#include <qmath.h>
#include <QPainterPath>
static bool qwtHasScalablePen( const QPainter *painter )
{
const QPen pen = painter->pen();
@ -37,7 +37,7 @@ static bool qwtHasScalablePen( const QPainter *painter )
return scalablePen;
}
static QRectF qwtStrokedPathRect(
static QRectF qwtStrokedPathRect(
const QPainter *painter, const QPainterPath &path )
{
QPainterPathStroker stroker;
@ -63,8 +63,8 @@ static QRectF qwtStrokedPathRect(
return rect;
}
static inline void qwtExecCommand(
QPainter *painter, const QwtPainterCommand &cmd,
static inline void qwtExecCommand(
QPainter *painter, const QwtPainterCommand &cmd,
QwtGraphic::RenderHints renderHints,
const QTransform &transform,
const QTransform *initialTransform )
@ -121,7 +121,7 @@ static inline void qwtExecCommand(
case QwtPainterCommand::Image:
{
const QwtPainterCommand::ImageData *data = cmd.imageData();
painter->drawImage( data->rect, data->image,
painter->drawImage( data->rect, data->image,
data->subRect, data->flags );
break;
}
@ -129,44 +129,44 @@ static inline void qwtExecCommand(
{
const QwtPainterCommand::StateData *data = cmd.stateData();
if ( data->flags & QPaintEngine::DirtyPen )
if ( data->flags & QPaintEngine::DirtyPen )
painter->setPen( data->pen );
if ( data->flags & QPaintEngine::DirtyBrush )
if ( data->flags & QPaintEngine::DirtyBrush )
painter->setBrush( data->brush );
if ( data->flags & QPaintEngine::DirtyBrushOrigin )
if ( data->flags & QPaintEngine::DirtyBrushOrigin )
painter->setBrushOrigin( data->brushOrigin );
if ( data->flags & QPaintEngine::DirtyFont )
if ( data->flags & QPaintEngine::DirtyFont )
painter->setFont( data->font );
if ( data->flags & QPaintEngine::DirtyBackground )
if ( data->flags & QPaintEngine::DirtyBackground )
{
painter->setBackgroundMode( data->backgroundMode );
painter->setBackground( data->backgroundBrush );
}
if ( data->flags & QPaintEngine::DirtyTransform )
if ( data->flags & QPaintEngine::DirtyTransform )
{
painter->setTransform( data->transform * transform );
}
if ( data->flags & QPaintEngine::DirtyClipEnabled )
if ( data->flags & QPaintEngine::DirtyClipEnabled )
painter->setClipping( data->isClipEnabled );
if ( data->flags & QPaintEngine::DirtyClipRegion)
if ( data->flags & QPaintEngine::DirtyClipRegion)
{
painter->setClipRegion( data->clipRegion,
painter->setClipRegion( data->clipRegion,
data->clipOperation );
}
if ( data->flags & QPaintEngine::DirtyClipPath )
if ( data->flags & QPaintEngine::DirtyClipPath )
{
painter->setClipPath( data->clipPath, data->clipOperation );
}
if ( data->flags & QPaintEngine::DirtyHints)
if ( data->flags & QPaintEngine::DirtyHints)
{
const QPainter::RenderHints hints = data->renderHints;
@ -186,10 +186,10 @@ static inline void qwtExecCommand(
hints.testFlag( QPainter::NonCosmeticDefaultPen ) );
}
if ( data->flags & QPaintEngine::DirtyCompositionMode)
if ( data->flags & QPaintEngine::DirtyCompositionMode)
painter->setCompositionMode( data->compositionMode );
if ( data->flags & QPaintEngine::DirtyOpacity)
if ( data->flags & QPaintEngine::DirtyOpacity)
painter->setOpacity( data->opacity );
break;
@ -209,7 +209,7 @@ public:
// QVector needs a default constructor
}
PathInfo( const QRectF &pointRect,
PathInfo( const QRectF &pointRect,
const QRectF &boundingRect, bool scalablePen ):
d_pointRect( pointRect ),
d_boundingRect( boundingRect ),
@ -246,7 +246,7 @@ public:
return rect;
}
inline double scaleFactorX( const QRectF& pathRect,
inline double scaleFactorX( const QRectF& pathRect,
const QRectF &targetRect, bool scalePens ) const
{
if ( pathRect.width() <= 0.0 )
@ -257,7 +257,7 @@ public:
const double l = qAbs( pathRect.left() - 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();
double sx;
@ -267,7 +267,7 @@ public:
}
else
{
const double pw = qMax(
const double pw = qMax(
qAbs( d_boundingRect.left() - d_pointRect.left() ),
qAbs( d_boundingRect.right() - d_pointRect.right() ) );
@ -277,7 +277,7 @@ public:
return sx;
}
inline double scaleFactorY( const QRectF& pathRect,
inline double scaleFactorY( const QRectF& pathRect,
const QRectF &targetRect, bool scalePens ) const
{
if ( pathRect.height() <= 0.0 )
@ -288,7 +288,7 @@ public:
const double t = qAbs( pathRect.top() - 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();
double sy;
@ -298,7 +298,7 @@ public:
}
else
{
const double pw =
const double pw =
qMax( qAbs( d_boundingRect.top() - d_pointRect.top() ),
qAbs( d_boundingRect.bottom() - d_pointRect.bottom() ) );
@ -351,7 +351,7 @@ QwtGraphic::QwtGraphic():
/*!
\brief Copy constructor
\param other Source
\param other Source
\sa operator=()
*/
QwtGraphic::QwtGraphic( const QwtGraphic &other ):
@ -370,7 +370,7 @@ QwtGraphic::~QwtGraphic()
/*!
\brief Assignment operator
\param other Source
\param other Source
\return A reference of this object
*/
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()
*/
void QwtGraphic::reset()
void QwtGraphic::reset()
{
d_data->commands.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
rectangles of the images/pixmaps.
@ -477,10 +477,10 @@ QRectF QwtGraphic::controlPointRect() const
/*!
\brief Calculate the target rectangle for scaling the graphic
\param sx Horizontal scaling factor
\param sy Vertical scaling factor
\param sx Horizontal 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
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++ )
{
rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy,
rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy,
!d_data->renderHints.testFlag( RenderPensUnscaled ) );
}
@ -518,11 +518,11 @@ QSize QwtGraphic::sizeMetrics() const
The default size is used in all methods rendering the graphic,
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.
The default setting is an empty size.
\param size Default size
\sa defaultSize(), boundingRect()
@ -543,7 +543,7 @@ void QwtGraphic::setDefaultSize( const QSizeF &size )
of the bounding rectangle.
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
\sa setDefaultSize(), boundingRect()
@ -574,7 +574,7 @@ void QwtGraphic::render( QPainter *painter ) const
for ( int i = 0; i < numCommands; i++ )
{
qwtExecCommand( painter, commands[i],
qwtExecCommand( painter, commands[i],
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 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
{
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 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
{
if ( isEmpty() || rect.isEmpty() )
return;
double sx = 1.0;
double sx = 1.0;
double sy = 1.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 )
sy = rect.height() / d_data->pointRect.height();
const bool scalePens =
const bool scalePens =
!d_data->renderHints.testFlag( RenderPensUnscaled );
for ( int i = 0; i < d_data->pathInfos.size(); i++ )
{
const PathInfo info = d_data->pathInfos[i];
const double ssx = info.scaleFactorX(
const double ssx = info.scaleFactorX(
d_data->pointRect, rect, scalePens );
if ( ssx > 0.0 )
sx = qMin( sx, ssx );
const double ssy = info.scaleFactorY(
const double ssy = info.scaleFactorY(
d_data->pointRect, rect, scalePens );
if ( ssy > 0.0 )
@ -665,7 +665,7 @@ void QwtGraphic::render( QPainter *painter, const QRectF &rect,
if ( !scalePens && transform.isScaling() )
{
// 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
d_data->initialTransform = new QTransform();
@ -689,10 +689,10 @@ void QwtGraphic::render( QPainter *painter, const QRectF &rect,
\param painter Qt painter
\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.
*/
void QwtGraphic::render( QPainter *painter,
void QwtGraphic::render( QPainter *painter,
const QPointF &pos, Qt::Alignment alignment ) const
{
QRectF r( pos, defaultSize() );
@ -728,16 +728,16 @@ void QwtGraphic::render( QPainter *painter,
/*!
\brief Convert the graphic to a QPixmap
All pixels of the pixmap get initialized by Qt::transparent
before the graphic is scaled and rendered on it.
The size of the pixmap is the default size ( ceiled to integers )
of the graphic.
\return The graphic as pixmap in default size
\sa defaultSize(), toImage(), render()
*/
*/
QPixmap QwtGraphic::toPixmap() const
{
if ( isNull() )
@ -818,7 +818,7 @@ QImage QwtGraphic::toImage( const QSize &size,
/*!
\brief Convert the graphic to a QImage
All pixels of the image get initialized by 0 ( transparent )
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 )
of the graphic.
\return The graphic as image in default size
\sa defaultSize(), toPixmap(), render()
*/
@ -873,7 +873,7 @@ void QwtGraphic::drawPath( const QPainterPath &path )
QRectF pointRect = scaledPath.boundingRect();
QRectF boundingRect = pointRect;
if ( painter->pen().style() != Qt::NoPen
if ( painter->pen().style() != Qt::NoPen
&& painter->pen().brush().style() != Qt::NoBrush )
{
boundingRect = qwtStrokedPathRect( painter, path );
@ -882,7 +882,7 @@ void QwtGraphic::drawPath( const QPainterPath &path )
updateControlPointRect( pointRect );
updateBoundingRect( boundingRect );
d_data->pathInfos += PathInfo( pointRect,
d_data->pathInfos += PathInfo( pointRect,
boundingRect, qwtHasScalablePen( painter ) );
}
}
@ -896,7 +896,7 @@ void QwtGraphic::drawPath( const QPainterPath &path )
\sa QPaintEngine::drawPixmap()
*/
void QwtGraphic::drawPixmap( const QRectF &rect,
void QwtGraphic::drawPixmap( const QRectF &rect,
const QPixmap &pixmap, const QRectF &subRect )
{
const QPainter *painter = paintEngine()->painter();
@ -996,8 +996,8 @@ void QwtGraphic::setCommands( QVector< QwtPainterCommand > &commands )
if ( numCommands <= 0 )
return;
// to calculate a proper bounding rectangle we don't simply copy
// the commands.
// to calculate a proper bounding rectangle we don't simply copy
// the commands.
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
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
@ -15,7 +15,6 @@
#include <qmetatype.h>
#include <qimage.h>
#include <qpixmap.h>
#include "qpainterpath.h"
class QwtPainterCommand;
@ -37,37 +36,37 @@ class QwtPainterCommand;
- QSvgRenderer/QSvgGenerator\n
Unfortunately QSvgRenderer hides to much information about
its nodes in internal APIs, that are necessary for proper
layout calculations. Also it is derived from QObject and
its nodes in internal APIs, that are necessary for proper
layout calculations. Also it is derived from QObject and
can't be copied like QImage/QPixmap.
QwtGraphic maps all scalable drawing primitives to a QPainterPath
and stores them together with the painter state changes
( pen, brush, transformation ... ) in a list of QwtPaintCommands.
For being a complete QPaintDevice it also stores pixmaps or images,
what is somehow against the idea of the class, because these objects
and stores them together with the painter state changes
( pen, brush, transformation ... ) in a list of QwtPaintCommands.
For being a complete QPaintDevice it also stores pixmaps or images,
what is somehow against the idea of the class, because these objects
can't be scaled without a loss in quality.
The main issue about scaling a QwtGraphic object are the pens used for
drawing the outlines of the painter paths. While non cosmetic pens
( QPen::isCosmetic() ) are scaled with the same ratio as the path,
cosmetic pens have a fixed width. A graphic might have paths with
drawing the outlines of the painter paths. While non cosmetic pens
( QPen::isCosmetic() ) are scaled with the same ratio as the path,
cosmetic pens have a fixed width. A graphic might have paths with
different pens - cosmetic and non-cosmetic.
QwtGraphic caches 2 different rectangles:
- control point rectangle\n
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.
- bounding rectangle\n
The bounding rectangle extends the control point rectangle by
what is needed for rendering the outline with an unscaled pen.
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 )
scaling with a fixed aspect ratio always needs to be calculated from the
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 )
scaling with a fixed aspect ratio always needs to be calculated from the
control point rectangle.
\sa QwtPainterCommand
@ -75,14 +74,14 @@ class QwtPainterCommand;
class QWT_EXPORT QwtGraphic: public QwtNullPaintDevice
{
public:
/*!
/*!
Hint how to render a graphic
\sa setRenderHint(), testRenderHint()
*/
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
is set up internally in render().
@ -96,7 +95,7 @@ public:
RenderPensUnscaled = 0x1
};
/*!
/*!
\brief Render hints
The default setting is to disable all hints
@ -117,21 +116,21 @@ public:
void render( QPainter * ) const;
void render( QPainter *, const QSizeF &,
void render( QPainter *, const QSizeF &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
void render( QPainter *, const QRectF &,
void render( QPainter *, const QRectF &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
void render( QPainter *, const QPointF &,
Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
QPixmap toPixmap() const;
QPixmap toPixmap( const QSize &,
QPixmap toPixmap() const;
QPixmap toPixmap( const QSize &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
QImage toImage() const;
QImage toImage( const QSize &,
QImage toImage() const;
QImage toImage( const QSize &,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
QRectF scaledBoundingRect( double sx, double sy ) const;
@ -144,7 +143,7 @@ public:
void setDefaultSize( const QSizeF & );
QSizeF defaultSize() const;
void setRenderHint( RenderHint, bool on = true );
bool testRenderHint( RenderHint ) const;

View File

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

View File

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

View File

@ -68,7 +68,7 @@ QwtIntervalSymbol::~QwtIntervalSymbol()
}
//! \brief Assignment operator
QwtIntervalSymbol &QwtIntervalSymbol::operator=(
QwtIntervalSymbol &QwtIntervalSymbol::operator=(
const QwtIntervalSymbol &other )
{
*d_data = *other.d_data;
@ -76,14 +76,14 @@ QwtIntervalSymbol &QwtIntervalSymbol::operator=(
}
//! \brief Compare two symbols
bool QwtIntervalSymbol::operator==(
bool QwtIntervalSymbol::operator==(
const QwtIntervalSymbol &other ) const
{
return *d_data == *other.d_data;
}
//! \brief Compare two symbols
bool QwtIntervalSymbol::operator!=(
bool QwtIntervalSymbol::operator!=(
const QwtIntervalSymbol &other ) const
{
return !( *d_data == *other.d_data );
@ -152,9 +152,9 @@ const QBrush& QwtIntervalSymbol::brush() const
return d_data->brush;
}
/*!
/*!
Build and assign a pen
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
to hide this incompatibility.
@ -162,12 +162,12 @@ const QBrush& QwtIntervalSymbol::brush() const
\param color Pen color
\param width Pen width
\param style Pen style
\sa pen(), brush()
*/
void QwtIntervalSymbol::setPen( const QColor &color,
*/
void QwtIntervalSymbol::setPen( const QColor &color,
qreal width, Qt::PenStyle style )
{
{
setPen( QPen( color, width, style ) );
}
@ -221,7 +221,7 @@ void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,
QwtPainter::drawLine( painter, p1, p2 );
if ( d_data->width > pw )
{
if ( ( orientation == Qt::Horizontal )
if ( ( orientation == Qt::Horizontal )
&& ( p1.y() == p2.y() ) )
{
const double sw = d_data->width;
@ -232,7 +232,7 @@ void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,
QwtPainter::drawLine( painter,
p2.x(), y, p2.x(), y + sw );
}
else if ( ( orientation == Qt::Vertical )
else if ( ( orientation == Qt::Vertical )
&& ( p1.x() == p2.x() ) )
{
const double sw = d_data->width;
@ -273,7 +273,7 @@ void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,
}
else
{
if ( ( orientation == Qt::Horizontal )
if ( ( orientation == Qt::Horizontal )
&& ( p1.y() == p2.y() ) )
{
const double sw = d_data->width;

View File

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

View File

@ -119,7 +119,7 @@ QwtKnob::QwtKnob( QWidget* parent ):
setScale( 0.0, 10.0 );
setValue( 0.0 );
setSizePolicy( QSizePolicy::MinimumExpanding,
setSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding );
}
@ -130,7 +130,7 @@ QwtKnob::~QwtKnob()
}
/*!
\brief Set the knob type
\brief Set the knob type
\param knobStyle Knob type
\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 )
have to be set using setNumTurns().
The default angle is 270 degrees.
The default angle is 270 degrees.
\sa totalAngle(), setNumTurns()
*/
@ -205,7 +205,7 @@ void QwtKnob::setTotalAngle ( double angle )
}
}
/*!
/*!
\return the total angle
\sa setTotalAngle(), setNumTurns(), numTurns()
*/
@ -222,7 +222,7 @@ double QwtKnob::totalAngle() const
\sa numTurns(), totalAngle(), setTotalAngle()
*/
void QwtKnob::setNumTurns( int numTurns )
{
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.
\sa setNumTurns(), setTotalAngle(), totalAngle()
@ -335,7 +335,7 @@ QRect QwtKnob::knobRect() const
{
r.moveBottom( cr.bottom() - d );
}
else
else
{
r.moveCenter( QPoint( r.center().x(), cr.center().y() ) );
}
@ -400,7 +400,7 @@ double QwtKnob::scrolledTo( const QPoint &pos ) const
if ( !wrapping() )
{
const double boundedAngle =
const double boundedAngle =
qBound( scaleMap().p1(), angle, scaleMap().p2() );
d_data->mouseOffset += ( boundedAngle - angle );
@ -431,7 +431,7 @@ double QwtKnob::scrolledTo( const QPoint &pos ) const
return scaleMap().invTransform( angle );
}
/*!
/*!
Handle QEvent::StyleChange and QEvent::FontChange;
\param event Change event
*/
@ -478,7 +478,7 @@ void QwtKnob::paintEvent( QPaintEvent *event )
drawKnob( &painter, knobRect );
drawMarker( &painter, knobRect,
drawMarker( &painter, knobRect,
qwtNormalizeDegrees( scaleMap().transform( value() ) ) );
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( 1.0, c2 );
pen = QPen( gradient, d_data->borderWidth );
pen = QPen( gradient, d_data->borderWidth );
}
QBrush brush;
@ -524,7 +524,7 @@ void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
double off = 0.3 * knobRect.width();
QRadialGradient gradient( knobRect.center(),
knobRect.width(), knobRect.topLeft() + QPointF( off, off ) );
gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) );
gradient.setColorAt( 1.0, palette().color( QPalette::Button ) );
@ -552,7 +552,7 @@ void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
}
case QwtKnob::Sunken:
{
QLinearGradient gradient(
QLinearGradient gradient(
knobRect.topLeft(), knobRect.bottomRight() );
gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) );
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 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 )
*/
void QwtKnob::drawMarker( QPainter *painter,
void QwtKnob::drawMarker( QPainter *painter,
const QRectF &rect, double angle ) const
{
if ( d_data->markerStyle == NoMarker || !isValid() )
@ -607,13 +607,13 @@ void QwtKnob::drawMarker( QPainter *painter,
case Notch:
case Nub:
{
const double dotWidth =
const double dotWidth =
qMin( double( markerSize ), radius);
const double dotCenterDist = radius - 0.5 * dotWidth;
if ( dotCenterDist > 0.0 )
{
const QPointF center( xm - sinA * dotCenterDist,
const QPointF center( xm - sinA * dotCenterDist,
ym - cosA * dotCenterDist );
QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth );
@ -625,7 +625,7 @@ void QwtKnob::drawMarker( QPainter *painter,
if ( d_data->markerStyle == Notch )
qSwap( c1, c2 );
QLinearGradient gradient(
QLinearGradient gradient(
ellipse.topLeft(), ellipse.bottomRight() );
gradient.setColorAt( 0.0, c1 );
gradient.setColorAt( 1.0, c2 );
@ -639,13 +639,13 @@ void QwtKnob::drawMarker( QPainter *painter,
}
case Dot:
{
const double dotWidth =
const double dotWidth =
qMin( double( markerSize ), radius);
const double dotCenterDist = radius - 0.5 * dotWidth;
if ( dotCenterDist > 0.0 )
{
const QPointF center( xm - sinA * dotCenterDist,
const QPointF center( xm - sinA * dotCenterDist,
ym - cosA * dotCenterDist );
QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth );
@ -680,7 +680,7 @@ void QwtKnob::drawMarker( QPainter *painter,
painter->translate( rect.center() );
painter->rotate( angle - 90.0 );
QPolygonF polygon;
polygon += QPointF( re, 0.0 );
polygon += QPointF( rb, 0.5 * ( re - rb ) );
@ -704,7 +704,7 @@ void QwtKnob::drawMarker( QPainter *painter,
\param painter Painter
*/
void QwtKnob::drawFocusIndicator( QPainter *painter ) const
{
{
const QRect cr = contentsRect();
int w = d_data->knobWidth;
@ -722,13 +722,13 @@ void QwtKnob::drawFocusIndicator( QPainter *painter ) const
focusRect.moveCenter( cr.center() );
QwtPainter::drawFocusRect( painter, this, focusRect );
}
}
/*!
\brief Set the alignment of the knob
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
@ -757,13 +757,13 @@ Qt::Alignment QwtKnob::alignment() const
/*!
\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.
\param width New width
\sa knobWidth(), setAlignment()
\note Modifies the sizePolicy()
\note Modifies the sizePolicy()
*/
void QwtKnob::setKnobWidth( int width )
{
@ -827,7 +827,7 @@ void QwtKnob::setMarkerSize( int size )
}
}
/*!
/*!
\return Marker size
\sa setMarkerSize()
*/

View File

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

View File

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

View File

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

View File

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

View File

@ -21,11 +21,11 @@
\brief Attributes of an entry on a legend
QwtLegendData is an abstract container ( like QAbstractModel )
to exchange attributes, that are only known between to
the plot item and the legend.
to exchange attributes, that are only known between to
the plot item and the legend.
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.
\sa QwtLegend, QwtPlotLegendItem
@ -52,13 +52,13 @@ public:
enum Role
{
// The value is a Mode
ModeRole,
ModeRole,
// The value is a title
TitleRole,
TitleRole,
// The value is an icon
IconRole,
IconRole,
// Values < UserRole are reserved for internal use
UserRole = 32

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
#include "qwt_global.h"
#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
#define M_PI_2 (1.57079632679489661923)
#endif

View File

@ -81,10 +81,10 @@ QwtMatrixRasterData::ResampleMode QwtMatrixRasterData::resampleMode() const
\param axis X, Y or Z axis
\param interval Interval
\sa QwtRasterData::interval(), setValueMatrix()
*/
void QwtMatrixRasterData::setInterval(
void QwtMatrixRasterData::setInterval(
Qt::Axis axis, const QwtInterval &interval )
{
QwtRasterData::setInterval( axis, interval );
@ -96,7 +96,7 @@ void QwtMatrixRasterData::setInterval(
The positions of the values are calculated by dividing
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.
\param values Vector of values
@ -104,7 +104,7 @@ void QwtMatrixRasterData::setInterval(
\sa valueMatrix(), numColumns(), numRows(), setInterval()()
*/
void QwtMatrixRasterData::setValueMatrix(
void QwtMatrixRasterData::setValueMatrix(
const QVector<double> &values, int numColumns )
{
d_data->values = values;
@ -161,17 +161,17 @@ int QwtMatrixRasterData::numRows() const
/*!
\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
representing the data.
representing the data.
- 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.
- BilinearInterpolation\n
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
\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 v22 = d_data->value( row2, col2 );
const double x2 = xInterval.minValue() +
const double x2 = xInterval.minValue() +
( col2 + 0.5 ) * d_data->dx;
const double y2 = yInterval.minValue() +
const double y2 = yInterval.minValue() +
( row2 + 0.5 ) * d_data->dy;
const double rx = ( x2 - x ) / d_data->dx;
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
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
values for positions, that or not on the value matrix.
*/
@ -38,7 +38,7 @@ public:
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,
*/
BilinearInterpolation

View File

@ -10,7 +10,7 @@
#include "qwt_null_paintdevice.h"
#include <qpaintengine.h>
#include <qpixmap.h>
#include <QPainterPath>
class QwtNullPaintDevice::PrivateData
{
public:
@ -50,21 +50,21 @@ public:
virtual void drawPolygon(const QPointF *, int , PolygonDrawMode );
virtual void drawPolygon(const QPoint *, int , PolygonDrawMode );
virtual void drawPixmap(const QRectF &,
virtual void drawPixmap(const QRectF &,
const QPixmap &, const QRectF &);
virtual void drawTextItem(const QPointF &, const QTextItem &);
virtual void drawTiledPixmap(const QRectF &,
virtual void drawTiledPixmap(const QRectF &,
const QPixmap &, const QPointF &s);
virtual void drawImage(const QRectF &,
virtual void drawImage(const QRectF &,
const QImage &, const QRectF &, Qt::ImageConversionFlags );
private:
QwtNullPaintDevice *nullDevice();
};
QwtNullPaintDevice::PaintEngine::PaintEngine():
QPaintEngine( QPaintEngine::AllFeatures )
{
@ -282,7 +282,7 @@ void QwtNullPaintDevice::PaintEngine::drawPolygon(
device->drawPolygon( points, pointCount, mode );
}
void QwtNullPaintDevice::PaintEngine::drawPixmap(
void QwtNullPaintDevice::PaintEngine::drawPixmap(
const QRectF &rect, const QPixmap &pm, const QRectF &subRect )
{
QwtNullPaintDevice *device = nullDevice();
@ -309,7 +309,7 @@ void QwtNullPaintDevice::PaintEngine::drawTextItem(
}
void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(
const QRectF &rect, const QPixmap &pixmap,
const QRectF &rect, const QPixmap &pixmap,
const QPointF &subRect)
{
QwtNullPaintDevice *device = nullDevice();
@ -320,13 +320,13 @@ void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(
{
QPaintEngine::drawTiledPixmap( rect, pixmap, subRect );
return;
}
}
device->drawTiledPixmap( rect, pixmap, subRect );
}
void QwtNullPaintDevice::PaintEngine::drawImage(
const QRectF &rect, const QImage &image,
const QRectF &rect, const QImage &image,
const QRectF &subRect, Qt::ImageConversionFlags flags)
{
QwtNullPaintDevice *device = nullDevice();
@ -337,13 +337,13 @@ void QwtNullPaintDevice::PaintEngine::drawImage(
}
void QwtNullPaintDevice::PaintEngine::updateState(
const QPaintEngineState &state)
const QPaintEngineState &engineState)
{
QwtNullPaintDevice *device = nullDevice();
if ( device == NULL )
return;
device->updateState( state );
device->updateState( engineState );
}
inline QwtNullPaintDevice *QwtNullPaintDevice::PaintEngine::nullDevice()
@ -379,7 +379,7 @@ void QwtNullPaintDevice::setMode( Mode mode )
d_data->mode = mode;
}
/*!
/*!
\return Render mode
\sa setMode()
*/
@ -393,7 +393,7 @@ QPaintEngine *QwtNullPaintDevice::paintEngine() const
{
if ( d_engine == NULL )
{
QwtNullPaintDevice *that =
QwtNullPaintDevice *that =
const_cast< QwtNullPaintDevice * >( this );
that->d_engine = new PaintEngine();
@ -402,7 +402,7 @@ QPaintEngine *QwtNullPaintDevice::paintEngine() const
return d_engine;
}
/*!
/*!
See QPaintDevice::metric()
\param deviceMetric Type of metric
@ -414,7 +414,7 @@ int QwtNullPaintDevice::metric( PaintDeviceMetric deviceMetric ) const
{
int value;
switch ( deviceMetric )
switch ( deviceMetric )
{
case PdmWidth:
{
@ -529,7 +529,7 @@ void QwtNullPaintDevice::drawPoints(
//! See QPaintEngine::drawPolygon()
void QwtNullPaintDevice::drawPolygon(
const QPointF *points, int pointCount,
const QPointF *points, int pointCount,
QPaintEngine::PolygonDrawMode mode)
{
Q_UNUSED(points);
@ -539,7 +539,7 @@ void QwtNullPaintDevice::drawPolygon(
//! See QPaintEngine::drawPolygon()
void QwtNullPaintDevice::drawPolygon(
const QPoint *points, int pointCount,
const QPoint *points, int pointCount,
QPaintEngine::PolygonDrawMode mode)
{
Q_UNUSED(points);
@ -548,7 +548,7 @@ void QwtNullPaintDevice::drawPolygon(
}
//! See QPaintEngine::drawPixmap()
void QwtNullPaintDevice::drawPixmap( const QRectF &rect,
void QwtNullPaintDevice::drawPixmap( const QRectF &rect,
const QPixmap &pm, const QRectF &subRect )
{
Q_UNUSED(rect);
@ -566,7 +566,7 @@ void QwtNullPaintDevice::drawTextItem(
//! See QPaintEngine::drawTiledPixmap()
void QwtNullPaintDevice::drawTiledPixmap(
const QRectF &rect, const QPixmap &pixmap,
const QRectF &rect, const QPixmap &pixmap,
const QPointF &subRect)
{
Q_UNUSED(rect);
@ -576,7 +576,7 @@ void QwtNullPaintDevice::drawTiledPixmap(
//! See QPaintEngine::drawImage()
void QwtNullPaintDevice::drawImage(
const QRectF &rect, const QImage &image,
const QRectF &rect, const QImage &image,
const QRectF &subRect, Qt::ImageConversionFlags flags)
{
Q_UNUSED(rect);
@ -586,7 +586,7 @@ void QwtNullPaintDevice::drawImage(
}
//! See QPaintEngine::updateState()
void QwtNullPaintDevice::updateState(
void QwtNullPaintDevice::updateState(
const QPaintEngineState &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
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
@ -13,16 +13,15 @@
#include "qwt_global.h"
#include <qpaintdevice.h>
#include <qpaintengine.h>
#include "qpainterpath.h"
/*!
\brief A null paint device doing nothing
Sometimes important layout/rendering geometries are not
available or changeable from the public Qt class interface.
Sometimes important layout/rendering geometries are not
available or changeable from the public Qt class interface.
( 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.
F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify
@ -43,7 +42,7 @@ public:
All vector graphic primitives are painted by
the corresponding draw methods
*/
NormalMode,
NormalMode,
/*!
Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath
@ -77,7 +76,7 @@ public:
virtual QPaintEngine *paintEngine() const;
virtual int metric( PaintDeviceMetric metric ) const;
virtual int metric( PaintDeviceMetric ) const;
virtual void drawRects(const QRect *, int );
virtual void drawRects(const QRectF *, int );
@ -105,12 +104,12 @@ public:
virtual void drawTextItem(const QPointF &, const QTextItem &);
virtual void drawTiledPixmap(const QRectF &,
const QPixmap &, const QPointF &s);
const QPixmap &, const QPointF & );
virtual void drawImage(const QRectF &,
const QImage &, const QRectF &, Qt::ImageConversionFlags );
virtual void updateState( const QPaintEngineState &state );
virtual void updateState( const QPaintEngineState & );
protected:
//! \return Size needed to implement metric()

View File

@ -1,4 +1,4 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
@ -27,13 +27,12 @@
#include <qpaintengine.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include "qpainterpath.h"
#if QT_VERSION >= 0x050000
#include <qwindow.h>
#endif
#if QT_VERSION < 0x050000
#if QT_VERSION < 0x050000
#ifdef Q_WS_X11
#include <qx11info_x11.h>
@ -44,7 +43,7 @@
bool QwtPainter::d_polylineSplitting = true;
bool QwtPainter::d_roundingAlignment = true;
static inline bool qwtIsClippingNeeded(
static inline bool qwtIsClippingNeeded(
const QPainter *painter, QRectF &clipRect )
{
bool doClipping = false;
@ -142,6 +141,12 @@ static inline void qwtUnscaleFont( QPainter *painter )
*/
bool QwtPainter::isX11GraphicsSystem()
{
/*
The X11 paint engine has been removed with Qt 5.0, but
reintroduced with Qt 5.10. It can be enabled with
"export QT_XCB_NATIVE_PAINTING=1".
*/
static int onX11 = -1;
if ( onX11 < 0 )
{
@ -181,7 +186,7 @@ bool QwtPainter::isAligning( QPainter *painter )
default:;
}
const QTransform tr = painter->transform();
const QTransform &tr = painter->transform();
if ( tr.isRotating() || tr.isScaling() )
{
// we might have to check translations too
@ -196,10 +201,10 @@ bool QwtPainter::isAligning( QPainter *painter )
Enable whether coordinates should be rounded, before they are painted
to a paint engine that floors to integer values. For other paint engines
( 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 default setting is true.
The default setting is true.
\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
>= Qt 5.0 when drawing an antialiased polyline with a pen width >=2.
Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... )
for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked
around in this mode.
The default setting is true.
\sa polylineSplitting()
@ -397,7 +406,7 @@ void QwtPainter::drawSimpleRichText( QPainter *painter, const QRectF &rect,
painter->setWorldTransform( transform, true );
unscaledRect = transform.inverted().mapRect(rect);
}
}
}
txt->setDefaultFont( painter->font() );
txt->setPageSize( QSizeF( unscaledRect.width(), QWIDGETSIZE_MAX ) );
@ -452,7 +461,7 @@ void QwtPainter::drawPolygon( QPainter *painter, const QPolygonF &polygon )
QPolygonF cpa = polygon;
if ( deviceClipping )
cpa = QwtClipper::clipPolygonF( clipRect, polygon );
cpa = QwtClipper::clipPolygonF( clipRect, polygon, true );
painter->drawPolygon( cpa );
}
@ -501,7 +510,7 @@ void QwtPainter::drawPolygon( QPainter *painter, const QPolygon &polygon )
QPolygon cpa = polygon;
if ( deviceClipping )
cpa = QwtClipper::clipPolygon( clipRect, polygon );
cpa = QwtClipper::clipPolygon( clipRect, polygon, true );
painter->drawPolygon( cpa );
}
@ -537,7 +546,9 @@ void QwtPainter::drawPolyline( QPainter *painter,
polygon.constData(), polygon.size(), d_polylineSplitting );
}
else
{
qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting );
}
}
//! Wrapper for QPainter::drawPoint()
@ -565,7 +576,7 @@ void QwtPainter::drawPoint( QPainter *painter, const QPoint &pos )
const int minY = qCeil( clipRect.top() );
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 )
{
return;
@ -576,7 +587,7 @@ void QwtPainter::drawPoint( QPainter *painter, const QPoint &pos )
}
//! Wrapper for QPainter::drawPoints()
void QwtPainter::drawPoints( QPainter *painter,
void QwtPainter::drawPoints( QPainter *painter,
const QPoint *points, int pointCount )
{
QRectF clipRect;
@ -609,7 +620,7 @@ void QwtPainter::drawPoints( QPainter *painter,
}
//! Wrapper for QPainter::drawPoints()
void QwtPainter::drawPoints( QPainter *painter,
void QwtPainter::drawPoints( QPainter *painter,
const QPointF *points, int pointCount )
{
QRectF clipRect;
@ -690,13 +701,14 @@ void QwtPainter::drawFocusRect( QPainter *painter, const QWidget *widget,
opt.init( widget );
opt.rect = rect;
opt.state |= QStyle::State_HasFocus;
opt.backgroundColor = widget->palette().color( widget->backgroundRole() );
widget->style()->drawPrimitive( QStyle::PE_FrameFocusRect,
&opt, painter, widget );
widget->style()->drawPrimitive(
QStyle::PE_FrameFocusRect, &opt, painter, widget );
}
/*!
Draw a round frame
Draw a round frame
\param painter Painter
\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
*/
void QwtPainter::drawRoundFrame( QPainter *painter,
const QRectF &rect, const QPalette &palette,
const QRectF &rect, const QPalette &palette,
int lineWidth, int frameStyle )
{
enum Style
@ -786,7 +798,7 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
if ( shadow == QFrame::Plain )
{
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 );
QPainterPath path;
@ -805,12 +817,12 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
if ( shape == QFrame::Box )
{
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 );
const QRectF midRect2 = midRect1.adjusted(
const QRectF midRect2 = midRect1.adjusted(
midLineWidth, midLineWidth, -midLineWidth, -midLineWidth );
const QRectF innerRect = midRect2.adjusted(
const QRectF innerRect = midRect2.adjusted(
frameWidth, frameWidth, -frameWidth, -frameWidth );
QPainterPath path1;
@ -886,8 +898,8 @@ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
else
{
const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
const QRectF innerRect = outerRect.adjusted(
frameWidth - 1.0, frameWidth - 1.0,
const QRectF innerRect = outerRect.adjusted(
frameWidth - 1.0, frameWidth - 1.0,
-( frameWidth - 1.0 ), -( frameWidth - 1.0 ) );
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
*/
void QwtPainter::drawRoundedFrame( QPainter *painter,
const QRectF &rect, double xRadius, double yRadius,
void QwtPainter::drawRoundedFrame( QPainter *painter,
const QRectF &rect, double xRadius, double yRadius,
const QPalette &palette, int lineWidth, int frameStyle )
{
painter->save();
@ -950,10 +962,10 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
painter->setBrush( Qt::NoBrush );
double lw2 = lineWidth * 0.5;
QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 );
QRectF innerRect = rect.adjusted( lw2, lw2, -lw2, -lw2 );
QPainterPath path;
path.addRoundedRect( r, xRadius, yRadius );
path.addRoundedRect( innerRect, xRadius, yRadius );
enum Style
{
@ -972,27 +984,27 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
{
// move + 4 * ( cubicTo + lineTo )
QPainterPath pathList[8];
for ( int i = 0; i < 4; i++ )
{
const int j = i * 4 + 1;
pathList[ 2 * i ].moveTo(
path.elementAt(j - 1).x, path.elementAt( j - 1 ).y
);
);
pathList[ 2 * i ].cubicTo(
path.elementAt(j + 0).x, path.elementAt(j + 0).y,
path.elementAt(j + 1).x, path.elementAt(j + 1).y,
path.elementAt(j + 2).x, path.elementAt(j + 2).y );
pathList[ 2 * i + 1 ].moveTo(
path.elementAt(j + 2).x, path.elementAt(j + 2).y
);
);
pathList[ 2 * i + 1 ].lineTo(
path.elementAt(j + 3).x, path.elementAt(j + 3).y
);
}
);
}
QColor c1( palette.color( QPalette::Dark ) );
QColor c2( palette.color( QPalette::Light ) );
@ -1002,7 +1014,7 @@ void QwtPainter::drawRoundedFrame( QPainter *painter,
for ( int i = 0; i < 4; i++ )
{
QRectF r = pathList[2 * i].controlPointRect();
const QRectF r = pathList[2 * i].controlPointRect();
QPen arcPen;
arcPen.setCapStyle( Qt::FlatCap );
@ -1146,10 +1158,10 @@ void QwtPainter::drawColorBar( QPainter *painter,
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)
{
if ( brush.style() == Qt::TexturePattern )
if ( brush.style() == Qt::TexturePattern )
{
painter->save();
@ -1157,18 +1169,18 @@ static inline void qwtFillRect( const QWidget *widget, QPainter *painter,
painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
painter->restore();
}
}
else if ( brush.gradient() )
{
painter->save();
painter->setClipRect( rect );
painter->fillRect(0, 0, widget->width(),
painter->fillRect(0, 0, widget->width(),
widget->height(), brush);
painter->restore();
}
else
}
else
{
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
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.
\param widget Widget
\param pixmap Pixmap to be filled
\param offset Offset
\param offset Offset
\sa QPixmap::fill()
*/
void QwtPainter::fillPixmap( const QWidget *widget,
void QwtPainter::fillPixmap( const QWidget *widget,
QPixmap &pixmap, const QPoint &offset )
{
const QRect rect( offset, pixmap.size() );
@ -1195,10 +1207,10 @@ void QwtPainter::fillPixmap( const QWidget *widget,
QPainter painter( &pixmap );
painter.translate( -offset );
const QBrush autoFillBrush =
const QBrush autoFillBrush =
widget->palette().brush( widget->backgroundRole() );
if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) )
if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) )
{
const QBrush bg = widget->palette().brush( QPalette::Window );
qwtFillRect( widget, &painter, rect, bg);
@ -1207,13 +1219,13 @@ void QwtPainter::fillPixmap( const QWidget *widget,
if ( widget->autoFillBackground() )
qwtFillRect( widget, &painter, rect, autoFillBrush);
if ( widget->testAttribute(Qt::WA_StyledBackground) )
if ( widget->testAttribute(Qt::WA_StyledBackground) )
{
painter.setClipRegion( rect );
QStyleOption opt;
opt.initFrom( widget );
widget->style()->drawPrimitive( QStyle::PE_Widget,
widget->style()->drawPrimitive( QStyle::PE_Widget,
&opt, &painter, widget );
}
}
@ -1251,7 +1263,7 @@ void QwtPainter::drawBackgound( QPainter *painter,
/*!
\return A pixmap that can be used as backing store
\param widget Widget, for which the backinstore is intended
\param widget Widget, for which the backingstore is intended
\param size Size of the pixmap
*/
QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
@ -1284,7 +1296,7 @@ QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
pm = QPixmap( size );
#endif
#if QT_VERSION < 0x050000
#if QT_VERSION < 0x050000
#ifdef Q_WS_X11
if ( widget && isX11GraphicsSystem() )
{

View File

@ -17,7 +17,7 @@
#include <qpen.h>
#include <qline.h>
#include <qpalette.h>
#include <QPainterPath>
class QPainter;
class QBrush;
class QColor;
@ -50,7 +50,7 @@ public:
static void drawText( QPainter *, const QPointF &, const QString & );
static void drawText( QPainter *, double x, double y, double w, double h,
int flags, const QString & );
static void drawText( QPainter *, const QRectF &,
static void drawText( QPainter *, const QRectF &,
int flags, const QString & );
#ifndef QT_NO_RICHTEXT
@ -63,7 +63,7 @@ public:
static void fillRect( QPainter *, const QRectF &, const QBrush & );
static void drawEllipse( QPainter *, const QRectF & );
static void drawPie( QPainter *, const QRectF & r, int a, int alen );
static void drawPie( QPainter *, const QRectF &, int a, int alen );
static void drawLine( QPainter *, double x1, double y1, double x2, double y2 );
static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 );
@ -93,13 +93,13 @@ public:
static void drawRoundFrame( QPainter *,
const QRectF &, const QPalette &, int lineWidth, int frameStyle );
static void drawRoundedFrame( QPainter *,
static void drawRoundedFrame( QPainter *,
const QRectF &, double xRadius, double yRadius,
const QPalette &, int lineWidth, int frameStyle );
static void drawFrame( QPainter *, const QRectF &rect,
const QPalette &palette, QPalette::ColorRole foregroundRole,
int lineWidth, int midLineWidth, int frameStyle );
int frameWidth, int midLineWidth, int frameStyle );
static void drawFocusRect( QPainter *, const QWidget * );
static void drawFocusRect( QPainter *, const QWidget *, const QRect & );
@ -111,7 +111,7 @@ public:
static bool isAligning( QPainter *painter );
static bool isX11GraphicsSystem();
static void fillPixmap( const QWidget *,
static void fillPixmap( const QWidget *,
QPixmap &, const QPoint &offset = QPoint() );
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
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
@ -8,7 +8,6 @@
*****************************************************************************/
#include "qwt_painter_command.h"
#include "qpainterpath.h"
//! Construct an invalid command
QwtPainterCommand::QwtPainterCommand():
@ -64,10 +63,10 @@ QwtPainterCommand::QwtPainterCommand( const QRectF &rect,
d_imageData->flags = flags;
}
/*!
/*!
Constructor for State paint operation
\param state Paint engine state
*/
*/
QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
d_type( State )
{
@ -75,56 +74,56 @@ QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
d_stateData->flags = state.state();
if ( d_stateData->flags & QPaintEngine::DirtyPen )
if ( d_stateData->flags & QPaintEngine::DirtyPen )
d_stateData->pen = state.pen();
if ( d_stateData->flags & QPaintEngine::DirtyBrush )
if ( d_stateData->flags & QPaintEngine::DirtyBrush )
d_stateData->brush = state.brush();
if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin )
if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin )
d_stateData->brushOrigin = state.brushOrigin();
if ( d_stateData->flags & QPaintEngine::DirtyFont )
if ( d_stateData->flags & QPaintEngine::DirtyFont )
d_stateData->font = state.font();
if ( d_stateData->flags & QPaintEngine::DirtyBackground )
if ( d_stateData->flags & QPaintEngine::DirtyBackground )
{
d_stateData->backgroundMode = state.backgroundMode();
d_stateData->backgroundBrush = state.backgroundBrush();
}
if ( d_stateData->flags & QPaintEngine::DirtyTransform )
if ( d_stateData->flags & QPaintEngine::DirtyTransform )
d_stateData->transform = state.transform();
if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled )
if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled )
d_stateData->isClipEnabled = state.isClipEnabled();
if ( d_stateData->flags & QPaintEngine::DirtyClipRegion )
if ( d_stateData->flags & QPaintEngine::DirtyClipRegion )
{
d_stateData->clipRegion = state.clipRegion();
d_stateData->clipOperation = state.clipOperation();
}
if ( d_stateData->flags & QPaintEngine::DirtyClipPath )
if ( d_stateData->flags & QPaintEngine::DirtyClipPath )
{
d_stateData->clipPath = state.clipPath();
d_stateData->clipOperation = state.clipOperation();
}
if ( d_stateData->flags & QPaintEngine::DirtyHints )
if ( d_stateData->flags & QPaintEngine::DirtyHints )
d_stateData->renderHints = state.renderHints();
if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode )
if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode )
d_stateData->compositionMode = state.compositionMode();
if ( d_stateData->flags & QPaintEngine::DirtyOpacity )
if ( d_stateData->flags & QPaintEngine::DirtyOpacity )
d_stateData->opacity = state.opacity();
}
/*!
Copy constructor
\param other Command to be copied
*/
QwtPainterCommand::QwtPainterCommand(const QwtPainterCommand &other)
{
@ -214,25 +213,25 @@ void QwtPainterCommand::reset()
}
//! \return Painter path to be painted
QPainterPath *QwtPainterCommand::path()
QPainterPath *QwtPainterCommand::path()
{
return d_path;
}
//! \return Attributes how to paint a QPixmap
QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData()
QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData()
{
return d_pixmapData;
}
//! \return Attributes how to paint a QImage
QwtPainterCommand::ImageData* QwtPainterCommand::imageData()
QwtPainterCommand::ImageData* QwtPainterCommand::imageData()
{
return d_imageData;
}
//! \return Attributes of a state change
QwtPainterCommand::StateData* QwtPainterCommand::stateData()
QwtPainterCommand::StateData* QwtPainterCommand::stateData()
{
return d_stateData;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,23 +27,21 @@ static inline void qwtEnableLegendItems( QwtPlot *plot, bool on )
{
if ( on )
{
QObject::connect(
plot, SIGNAL( legendDataChanged(
const QVariant &, const QList<QwtLegendData> & ) ),
plot, SLOT( updateLegendItems(
const QVariant &, const QList<QwtLegendData> & ) ) );
QObject::connect(
plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
plot, SLOT(updateLegendItems(QVariant,QList<QwtLegendData>))
);
}
else
{
QObject::disconnect(
plot, SIGNAL( legendDataChanged(
const QVariant &, const QList<QwtLegendData> & ) ),
plot, SLOT( updateLegendItems(
const QVariant &, const QList<QwtLegendData> & ) ) );
QObject::disconnect(
plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>) ),
plot, SLOT( updateLegendItems(QVariant,QList<QwtLegendData>))
);
}
}
static void qwtSetTabOrder(
static void qwtSetTabOrder(
QWidget *first, QWidget *second, bool withChildren )
{
QList<QWidget *> tabChain;
@ -195,7 +193,7 @@ void QwtPlot::initPlot( const QwtText &title )
QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ).
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.
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 )
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
\sa canvas()
@ -316,7 +314,7 @@ void QwtPlot::setAutoReplot( bool tf )
d_data->autoReplot = tf;
}
/*!
/*!
\return true if the autoReplot option is set.
\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
*/
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
*/
void QwtPlot::setFooter( const QwtText &text )
@ -559,7 +557,7 @@ void QwtPlot::replot()
if ( d_data->canvas )
{
const bool ok = QMetaObject::invokeMethod(
const bool ok = QMetaObject::invokeMethod(
d_data->canvas, "replot", Qt::DirectConnection );
if ( !ok )
{
@ -605,13 +603,24 @@ void QwtPlot::updateLayout()
d_data->footerLabel->show();
}
else
{
d_data->footerLabel->hide();
}
for ( int axisId = 0; axisId < axisCnt; axisId++ )
{
QwtScaleWidget* scaleWidget = axisWidget( axisId );
if ( axisEnabled( axisId ) )
{
axisWidget( axisId )->setGeometry( scaleRect[axisId] );
if ( scaleRect[axisId] != scaleWidget->geometry() )
{
scaleWidget->setGeometry( scaleRect[axisId] );
int startDist, endDist;
scaleWidget->getBorderDistHint( startDist, endDist );
scaleWidget->setBorderDist( startDist, endDist );
}
#if 1
if ( axisId == xBottom || axisId == xTop )
@ -626,14 +635,16 @@ void QwtPlot::updateLayout()
r.translate( -scaleRect[ axisId ].x(),
-scaleRect[axisId].y() );
axisWidget( axisId )->setMask( r );
scaleWidget->setMask( r );
}
#endif
if ( !axisWidget( axisId )->isVisibleTo( this ) )
axisWidget( axisId )->show();
if ( !scaleWidget->isVisibleTo( this ) )
scaleWidget->show();
}
else
axisWidget( axisId )->hide();
{
scaleWidget->hide();
}
}
if ( d_data->legend )
@ -710,7 +721,7 @@ void QwtPlot::updateCanvasMargins()
double margins[axisCnt];
getCanvasMarginsHint( maps, canvas()->contentsRect(),
margins[yLeft], margins[xTop], margins[yRight], margins[xBottom] );
bool doUpdate = false;
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
\note Usually canvasRect is contentsRect() of the plot canvas.
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
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
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.
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.
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 )
{
connect( this,
SIGNAL( legendDataChanged(
const QVariant &, const QList<QwtLegendData> & ) ),
d_data->legend,
SLOT( updateLegend(
const QVariant &, const QList<QwtLegendData> & ) )
connect(
this, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
d_data->legend, SLOT(updateLegend(QVariant,QList<QwtLegendData>) )
);
if ( d_data->legend->parent() != this )
@ -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 on When true attach the item, otherwise detach it
@ -1102,7 +1110,7 @@ void QwtPlot::attachItem( QwtPlotItem *plotItem, bool on )
if ( on )
insertItem( plotItem );
else
else
removeItem( plotItem );
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,
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:
\code

View File

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

View File

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

View File

@ -17,7 +17,7 @@
/*!
\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
API how to calculate the width of the bars and how they affect
the layout of the attached plot.
@ -78,7 +78,7 @@ public:
void setBaseline( double );
double baseline() const;
virtual void getCanvasMarginHint(
virtual void getCanvasMarginHint(
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect,
double &left, double &top, double &right, double &bottom) const;
@ -86,7 +86,7 @@ public:
protected:
double sampleWidth( const QwtScaleMap &map,
double canvasSize, double dataSize,
double canvasSize, double boundingSize,
double value ) const;
private:

View File

@ -67,7 +67,7 @@ void QwtPlot::initAxesData()
d.scaleEngine = new QwtLinearScaleEngine;
d.scaleWidget->setTransformation(
d.scaleWidget->setTransformation(
d.scaleEngine->transformation() );
d.scaleWidget->setFont( fscl );
@ -147,7 +147,7 @@ void QwtPlot::setAxisScaleEngine( int axisId, QwtScaleEngine *scaleEngine )
delete d.scaleEngine;
d.scaleEngine = scaleEngine;
d_axisData[axisId]->scaleWidget->setTransformation(
d_axisData[axisId]->scaleWidget->setTransformation(
scaleEngine->transformation() );
d.isValid = false;
@ -189,7 +189,6 @@ bool QwtPlot::axisAutoScale( int axisId ) const
return d_axisData[axisId]->doAutoScale;
else
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.
@ -309,7 +308,7 @@ double QwtPlot::axisStepSize( int axisId ) const
\brief Return the current interval of the specified axis
This is only a convenience function for axisScaleDiv( axisId )->interval();
\param axisId Axis index
\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.
In updateAxes() the scale engine calculates a scale division from the
specified parameters, that will be assigned to the scale widget. So
In updateAxes() the scale engine calculates a scale division from the
specified parameters, that will be assigned to the scale widget. So
updates of the scale widget usually happen delayed with the next replot.
\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.
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.
\param axisId Axis index
@ -614,26 +613,26 @@ void QwtPlot::setAxisTitle( int axisId, const QwtText &title )
axisWidget( axisId )->setTitle( title );
}
/*!
/*!
\brief Rebuild the axes scales
In case of autoscaling the boundaries of a scale are calculated
from the bounding rectangles of all plot items, having the
QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ).
Then a scale division is calculated ( QwtScaleEngine::didvideScale() )
In case of autoscaling the boundaries of a scale are calculated
from the bounding rectangles of all plot items, having the
QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ).
Then a scale division is calculated ( QwtScaleEngine::didvideScale() )
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() )
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.
The scale widget indicates modifications by emitting a
The scale widget indicates modifications by emitting a
QwtScaleWidget::scaleDivChanged() signal.
updateAxes() is usually called by replot().
updateAxes() is usually called by replot().
\sa setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot()
QwtPlotItem::boundingRect()

View File

@ -21,7 +21,7 @@ public:
legendMode( QwtPlotBarChart::LegendChartTitle )
{
}
~PrivateData()
{
delete symbol;
@ -120,7 +120,7 @@ void QwtPlotBarChart::setSamples( QwtSeriesData<QPointF> *data )
\brief Assign a symbol
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.
\param symbol Symbol
@ -304,7 +304,7 @@ void QwtPlotBarChart::drawSample( QPainter *painter,
}
/*!
Draw a bar
Draw a bar
\param painter Painter
\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
*/
void QwtPlotBarChart::drawBar( QPainter *painter,
int sampleIndex, const QPointF &sample,
int sampleIndex, const QPointF &sample,
const QwtColumnRect &rect ) const
{
const QwtColumnSymbol *specialSym =
const QwtColumnSymbol *specialSym =
specialSymbol( sampleIndex, sample );
const QwtColumnSymbol *sym = specialSym;
@ -329,17 +329,17 @@ void QwtPlotBarChart::drawBar( QPainter *painter,
else
{
// we build a temporary default symbol
QwtColumnSymbol sym( QwtColumnSymbol::Box );
sym.setLineWidth( 1 );
sym.setFrameStyle( QwtColumnSymbol::Plain );
sym.draw( painter, rect );
QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box );
columnSymbol.setLineWidth( 1 );
columnSymbol.setFrameStyle( QwtColumnSymbol::Plain );
columnSymbol.draw( painter, rect );
}
delete specialSym;
}
/*!
Needs to be overloaded to return a
Needs to be overloaded to return a
non default symbol for a specific sample
\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
*/
QwtColumnSymbol *QwtPlotBarChart::specialSymbol(
QwtColumnSymbol *QwtPlotBarChart::specialSymbol(
int sampleIndex, const QPointF &sample ) const
{
Q_UNUSED( sampleIndex );
@ -428,13 +428,13 @@ QList<QwtLegendData> QwtPlotBarChart::legendData() const
the bar corresponding to index - otherwise the bar
displays the default symbol.
\param index Index of the legend entry
\param index Index of the legend entry
\param size Icon size
\sa setLegendMode(), drawBar(),
\sa setLegendMode(), drawBar(),
QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotBarChart::legendIcon(
QwtGraphic QwtPlotBarChart::legendIcon(
int index, const QSizeF &size ) const
{
QwtColumnRect column;
@ -452,7 +452,7 @@ QwtGraphic QwtPlotBarChart::legendIcon(
int barIndex = -1;
if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
barIndex = index;
drawBar( &painter, barIndex, QPointF(), column );
return icon;

View File

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

View File

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

View File

@ -19,7 +19,7 @@ class QPixmap;
/*!
\brief Canvas of a QwtPlot.
Canvas is the widget where all plot items are displayed
\sa QwtPlot::setCanvas(), QwtPlotGLCanvas
@ -42,8 +42,8 @@ public:
enum PaintAttribute
{
/*!
\brief Paint double buffered reusing the content
of the pixmap buffer when possible.
\brief Paint double buffered reusing the content
of the pixmap buffer when possible.
Using a backing store might improve the performance
significantly, when working with widget overlays ( like rubber bands ).
@ -59,15 +59,15 @@ public:
of the plot canvas
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
below the canvas. When this is done with gradients it might
result in a serious performance bottleneck - depending on the size.
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,

View File

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

View File

@ -33,7 +33,7 @@ class QwtCurveFitter;
\par Usage
<dl><dt>a) Assign curve properties</dt>
<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
setPen(), setStyle() and setSymbol().</dd>
<dt>b) Connect/Assign data.</dt>
@ -52,7 +52,7 @@ class QwtCurveFitter;
\sa QwtPointSeriesData, QwtSymbol, QwtScaleMap
*/
class QWT_EXPORT QwtPlotCurve:
class QWT_EXPORT QwtPlotCurve:
public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
{
public:
@ -75,7 +75,7 @@ public:
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().
*/
Sticks,
@ -90,7 +90,7 @@ public:
/*!
Draw dots at the locations of the data points. Note:
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.
*/
Dots,
@ -110,7 +110,7 @@ public:
enum CurveAttribute
{
/*!
For QwtPlotCurve::Steps only.
For QwtPlotCurve::Steps only.
Draws a step function from the right to the left.
*/
Inverted = 0x01,
@ -141,13 +141,13 @@ public:
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.
*/
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().
*/
LegendShowLine = 0x01,
@ -191,16 +191,16 @@ public:
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.
This might slow down the performance of painting
This might slow down the performance of painting
*/
MinimizeMemory = 0x04,
/*!
Render the points to a temporary image and paint the image.
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()
will be faster.
*/
@ -210,7 +210,7 @@ public:
//! Paint attributes
typedef QFlags<PaintAttribute> PaintAttributes;
explicit QwtPlotCurve( const QString &title = QString::null );
explicit QwtPlotCurve( const QString &title = QString() );
explicit QwtPlotCurve( const QwtText &title );
virtual ~QwtPlotCurve();
@ -270,32 +270,32 @@ protected:
void init();
virtual void drawCurve( QPainter *p, int style,
virtual void drawCurve( QPainter *, int style,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSymbols( QPainter *p, const QwtSymbol &,
virtual void drawSymbols( QPainter *, const QwtSymbol &,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawLines( QPainter *p,
virtual void drawLines( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSticks( QPainter *p,
virtual void drawSticks( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawDots( QPainter *p,
virtual void drawDots( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSteps( QPainter *p,
virtual void drawSteps( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void fillCurve( QPainter *,
const QwtScaleMap &, const QwtScaleMap &,
const QwtScaleMap &, const QwtScaleMap &,
const QRectF &canvasRect, QPolygonF & ) const;
void closePolyline( QPainter *,

View File

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

View File

@ -17,7 +17,7 @@
#include <qapplication.h>
#include <qpixmap.h>
static inline void qwtRenderItem(
static inline void qwtRenderItem(
QPainter *painter, const QRect &canvasRect,
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
\sa hasClipping(), clipRegion(), setClipRegion()
@ -131,11 +131,11 @@ bool QwtPlotDirectPainter::hasClipping() const
/*!
\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 backing store will be copied to a ( maybe unaccelerated ) frame buffer
device.
\param region Clip region
\sa clipRegion(), hasClipping(), setClipping()
*/
@ -200,7 +200,7 @@ void QwtPlotDirectPainter::drawSeries(
}
bool immediatePaint = true;
if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) )
if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) )
{
#if QT_VERSION < 0x050000
if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
@ -220,7 +220,7 @@ void QwtPlotDirectPainter::drawSeries(
if ( d_data->hasClipping )
{
d_data->painter.setClipRegion(
d_data->painter.setClipRegion(
QRegion( canvasRect ) & d_data->clipRegion );
}
else
@ -294,14 +294,14 @@ bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
if ( doCopyCache )
{
QwtPlotCanvas *plotCanvas =
QwtPlotCanvas *plotCanvas =
qobject_cast<QwtPlotCanvas *>( canvas );
if ( plotCanvas )
{
doCopyCache = qwtHasBackingStore( plotCanvas );
if ( doCopyCache )
{
painter.drawPixmap( plotCanvas->contentsRect().topLeft(),
painter.drawPixmap( plotCanvas->rect().topLeft(),
*plotCanvas->backingStore() );
}
}

View File

@ -29,7 +29,7 @@ class QwtPlotSeriesItem;
On certain environments it might be important to calculate a proper
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.
\warning Incremental painting will only help when no replot is triggered
@ -61,8 +61,8 @@ public:
/*!
When QwtPlotCanvas::BackingStore is enabled the painter
has to paint to the backing store and the widget. In certain
situations/environments it might be faster to paint to
has to paint to the backing store and the widget. In certain
situations/environments it might be faster to paint to
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
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;
void enableX( bool tf );
void enableX( bool );
bool xEnabled() const;
void enableY( bool tf );
void enableY( bool );
bool yEnabled() const;
void enableXMin( bool tf );
void enableXMin( bool );
bool xMinEnabled() const;
void enableYMin( bool tf );
void enableYMin( bool );
bool yMinEnabled() const;
void setXDiv( const QwtScaleDiv &sx );
void setXDiv( const QwtScaleDiv & );
const QwtScaleDiv &xScaleDiv() const;
void setYDiv( const QwtScaleDiv &sy );
void setYDiv( const QwtScaleDiv & );
const QwtScaleDiv &yScaleDiv() const;
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
@ -65,19 +65,19 @@ public:
const QPen& majorPen() const;
void setMinorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setMinorPen( const QPen &p );
void setMinorPen( const QPen & );
const QPen& minorPen() const;
virtual void draw( QPainter *p,
virtual void draw( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &rect ) const;
const QRectF &canvasRect ) const;
virtual void updateScaleDiv(
const QwtScaleDiv &xMap, const QwtScaleDiv &yMap );
virtual void updateScaleDiv(
const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv );
private:
void drawLines( QPainter *painter, const QRectF &,
Qt::Orientation orientation, const QwtScaleMap &,
void drawLines( QPainter *, const QRectF &,
Qt::Orientation, const QwtScaleMap &,
const QList<double> & ) const;
class PrivateData;

View File

@ -122,21 +122,21 @@ QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style() const
/*!
Build and assign a pen
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
to hide this incompatibility.
\param color Pen color
\param width Pen width
\param style Pen style
\sa pen(), brush()
*/
void QwtPlotHistogram::setPen( const QColor &color, qreal width, Qt::PenStyle style )
{
{
setPen( QPen( color, width, style ) );
}
}
/*!
Assign a pen, that is used in a style() depending way.
@ -303,15 +303,15 @@ void QwtPlotHistogram::setSamples(
/*!
Assign a series of samples
setSamples() is just a wrapper for setData() without any additional
value - beside that it is easier to find for the developer.
\param data Data
\warning The item takes ownership of the data object, deleting
it when its not used anymore.
*/
void QwtPlotHistogram::setSamples(
void QwtPlotHistogram::setSamples(
QwtSeriesData<QwtIntervalSample> *data )
{
setData( data );
@ -332,8 +332,10 @@ void QwtPlotHistogram::setSamples(
*/
void QwtPlotHistogram::drawSeries( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &, int from, int to ) const
const QRectF &canvasRect, int from, int to ) const
{
Q_UNUSED( canvasRect )
if ( !painter || dataSize() <= 0 )
return;
@ -675,11 +677,11 @@ void QwtPlotHistogram::drawColumn( QPainter *painter,
/*!
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 )
\param size Icon size
\return A graphic displaying the icon
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotHistogram::legendIcon( int index,

View File

@ -36,7 +36,7 @@ class QPolygonF;
\sa QwtPlotBarChart, QwtPlotMultiBarChart
*/
class QWT_EXPORT QwtPlotHistogram:
class QWT_EXPORT QwtPlotHistogram:
public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
{
public:
@ -58,7 +58,7 @@ public:
/*!
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().
*/
Columns,
@ -76,7 +76,7 @@ public:
UserStyle = 100
};
explicit QwtPlotHistogram( const QString &title = QString::null );
explicit QwtPlotHistogram( const QString &title = QString() );
explicit QwtPlotHistogram( const QwtText &title );
virtual ~QwtPlotHistogram();
@ -92,7 +92,7 @@ public:
void setSamples( const QVector<QwtIntervalSample> & );
void setSamples( QwtSeriesData<QwtIntervalSample> * );
void setBaseline( double reference );
void setBaseline( double );
double baseline() const;
void setStyle( HistogramStyle style );
@ -101,7 +101,7 @@ public:
void setSymbol( const QwtColumnSymbol * );
const QwtColumnSymbol *symbol() const;
virtual void drawSeries( QPainter *p,
virtual void drawSeries( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;

View File

@ -153,15 +153,15 @@ void QwtPlotIntervalCurve::setSamples(
/*!
Assign a series of samples
setSamples() is just a wrapper for setData() without any additional
value - beside that it is easier to find for the developer.
\param data Data
\warning The item takes ownership of the data object, deleting
it when its not used anymore.
*/
void QwtPlotIntervalCurve::setSamples(
void QwtPlotIntervalCurve::setSamples(
QwtSeriesData<QwtIntervalSample> *data )
{
setData( data );
@ -222,21 +222,21 @@ const QwtIntervalSymbol *QwtPlotIntervalCurve::symbol() const
/*!
Build and assign a pen
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
to hide this incompatibility.
\param color Pen color
\param width Pen width
\param style Pen style
\sa pen(), brush()
*/
void QwtPlotIntervalCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )
{
{
setPen( QPen( color, width, style ) );
}
}
/*!
\brief Assign a pen
@ -298,7 +298,7 @@ const QBrush& QwtPlotIntervalCurve::brush() const
QRectF QwtPlotIntervalCurve::boundingRect() const
{
QRectF rect = QwtPlotSeriesItem::boundingRect();
if ( rect.isValid() && orientation() == Qt::Vertical )
if ( orientation() == Qt::Vertical )
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
return rect;
@ -545,13 +545,13 @@ void QwtPlotIntervalCurve::drawSymbols(
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.
\param index Index of the legend entry
\param index Index of the legend entry
( ignored as there is only one )
\param size Icon size
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotIntervalCurve::legendIcon(
QwtGraphic QwtPlotIntervalCurve::legendIcon(
int index, const QSizeF &size ) const
{
Q_UNUSED( index );

View File

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

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.
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
( f.e QwtPlotRasterItem ) can be done in parallel in
On multi core systems rendering of certain plot item
( f.e QwtPlotRasterItem ) can be done in parallel in
several threads.
The default setting is set to 1.
@ -362,13 +362,13 @@ QSize QwtPlotItem::legendIconSize() const
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 )
\param size Icon size
\sa setLegendIconSize(), legendData()
*/
QwtGraphic QwtPlotItem::legendIcon(
QwtGraphic QwtPlotItem::legendIcon(
int index, const QSizeF &size ) const
{
Q_UNUSED( index )
@ -388,22 +388,22 @@ QwtGraphic QwtPlotItem::legendIcon(
\return A filled rectangle
*/
QwtGraphic QwtPlotItem::defaultIcon(
QwtGraphic QwtPlotItem::defaultIcon(
const QBrush &brush, const QSizeF &size ) const
{
{
QwtGraphic icon;
if ( !size.isEmpty() )
{
icon.setDefaultSize( size );
QRectF r( 0, 0, size.width(), size.height() );
QPainter painter( &icon );
painter.fillRect( r, brush );
}
}
return icon;
}
}
//! Show the item
void QwtPlotItem::show()
@ -557,11 +557,11 @@ QRectF QwtPlotItem::boundingRect() const
\param right Returns the right margin
\param bottom Returns the bottom margin
\return The default implementation returns 0 for all margins
The default implementation returns 0 for all margins
\sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
*/
void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,
void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QRectF &canvasRect,
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.
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
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().
\return Data, that is needed to represent the item on the legend
@ -598,19 +598,19 @@ QList<QwtLegendData> QwtPlotItem::legendData() const
QwtText label = title();
label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
QVariant titleValue;
qVariantSetValue( titleValue, label );
data.setValue( QwtLegendData::TitleRole, titleValue );
const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
if ( !graphic.isNull() )
{
{
QVariant iconValue;
qVariantSetValue( iconValue, graphic );
data.setValue( QwtLegendData::IconRole, iconValue );
}
}
QList<QwtLegendData> list;
list += data;
@ -658,7 +658,7 @@ void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv,
need to enable the QwtPlotItem::Legend flag and to implement
legendData() and legendIcon()
*/
void QwtPlotItem::updateLegend( const QwtPlotItem *item,
void QwtPlotItem::updateLegend( const QwtPlotItem *item,
const QList<QwtLegendData> &data )
{
Q_UNUSED( item );

View File

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

View File

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

View File

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

View File

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

View File

@ -23,19 +23,19 @@ class QFont;
It can be used together with a QwtLegend or instead of it
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
needs to be installed catching mouse events ob the plot canvas.
The geometries of the legend items are available using
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
complete legend ( usually semi transparent ) or for
each legend item.
\note An external QwtLegend with a transparent background
on top the plot canvas might be another option
\note An external QwtLegend with a transparent background
on top the plot canvas might be another option
with a similar effect.
*/
@ -45,7 +45,7 @@ public:
/*!
\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.
The default setting is LegendBackground.
@ -83,11 +83,11 @@ public:
void setItemSpacing( int );
int itemSpacing() const;
void setFont( const QFont& );
QFont font() const;
void setBorderDistance( int numPixels );
void setBorderDistance( int );
int borderDistance() const;
void setBorderRadius( double );
@ -105,9 +105,9 @@ public:
void setTextPen( const QPen & );
QPen textPen() const;
virtual void draw( QPainter *p,
virtual void draw( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &rect ) const;
const QRectF &canvasRect ) const;
void clearLegend();
@ -117,13 +117,13 @@ public:
virtual QRect geometry( const QRectF &canvasRect ) const;
virtual QSize minimumSize( const QwtLegendData & ) const;
virtual int heightForWidth( const QwtLegendData &, int w ) const;
virtual int heightForWidth( const QwtLegendData &, int width ) const;
QList< const QwtPlotItem * > plotItems() const;
QList< QRect > legendGeometries( const QwtPlotItem * ) const;
protected:
virtual void drawLegendData( QPainter *painter,
virtual void drawLegendData( QPainter *painter,
const QwtPlotItem *, const QwtLegendData &, const QRectF & ) 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 QRectF &canvasRect ) const
{
const QPointF pos( xMap.transform( d_data->xValue ),
const QPointF pos( xMap.transform( d_data->xValue ),
yMap.transform( d_data->yValue ) );
// draw lines
@ -147,7 +147,7 @@ void QwtPlotMarker::draw( QPainter *painter,
{
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() );
if ( clipRect.contains( pos ) )
@ -337,7 +337,7 @@ void QwtPlotMarker::drawLabel( QPainter *painter,
/*!
\brief Set the line style
\param style Line style.
\param style Line style.
\sa lineStyle()
*/
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.
\param align Alignment.
\param align Alignment.
\sa labelAlignment(), labelOrientation()
*/
void QwtPlotMarker::setLabelAlignment( Qt::Alignment align )
@ -502,21 +502,21 @@ int QwtPlotMarker::spacing() const
return d_data->spacing;
}
/*!
/*!
Build and assign a line pen
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
to hide this incompatibility.
\param color Pen color
\param width Pen width
\param style Pen style
\sa pen(), brush()
*/
*/
void QwtPlotMarker::setLinePen( const QColor &color, qreal width, Qt::PenStyle style )
{
{
setLinePen( QPen( color, width, style ) );
}
@ -548,13 +548,25 @@ const QPen &QwtPlotMarker::linePen() 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
\param index Index of the legend entry
\param index Index of the legend entry
( usually there is only one )
\param size Icon size
@ -585,7 +597,7 @@ QwtGraphic QwtPlotMarker::legendIcon( int index,
{
const double y = 0.5 * size.height();
QwtPainter::drawLine( &painter,
QwtPainter::drawLine( &painter,
0.0, y, size.width(), y );
}
@ -594,7 +606,7 @@ QwtGraphic QwtPlotMarker::legendIcon( int index,
{
const double x = 0.5 * size.width();
QwtPainter::drawLine( &painter,
QwtPainter::drawLine( &painter,
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
line style. The alignment refers to the center point of
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.
\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 )
*/
@ -68,7 +68,7 @@ public:
Cross
};
explicit QwtPlotMarker( const QString &title = QString::null );
explicit QwtPlotMarker( const QString &title = QString() );
explicit QwtPlotMarker( const QwtText &title );
virtual ~QwtPlotMarker();
@ -84,11 +84,11 @@ public:
void setValue( double, double );
void setValue( const QPointF & );
void setLineStyle( LineStyle st );
void setLineStyle( LineStyle );
LineStyle lineStyle() const;
void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setLinePen( const QPen &p );
void setLinePen( const QPen & );
const QPen &linePen() const;
void setSymbol( const QwtSymbol * );
@ -106,7 +106,7 @@ public:
void setSpacing( int );
int spacing() const;
virtual void draw( QPainter *p,
virtual void draw( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF & ) const;
@ -115,10 +115,10 @@ public:
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
protected:
virtual void drawLines( QPainter *,
virtual void drawLines( QPainter *,
const QRectF &, const QPointF & ) const;
virtual void drawLabel( QPainter *,
virtual void drawLabel( QPainter *,
const QRectF &, const QPointF & ) const;
private:

View File

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

View File

@ -19,26 +19,26 @@ class QwtColumnSymbol;
/*!
\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.
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
by overloading specialSymbol() or overloading drawBar().
Depending on its orientation() the bars are displayed horizontally
or vertically. The bars cover the interval between the baseline()
Depending on its orientation() the bars are displayed horizontally
or vertically. The bars cover the interval between the baseline()
and the value.
In opposite to most other plot items, QwtPlotMultiBarChart returns more
than one entry for the legend - one for each symbol.
\sa QwtPlotBarChart, QwtPlotHistogram
QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
*/
class QWT_EXPORT QwtPlotMultiBarChart:
class QWT_EXPORT QwtPlotMultiBarChart:
public QwtPlotAbstractBarChart, public QwtSeriesStore<QwtSetSample>
{
public:
@ -61,7 +61,7 @@ public:
Stacked
};
explicit QwtPlotMultiBarChart( const QString &title = QString::null );
explicit QwtPlotMultiBarChart( const QString &title = QString() );
explicit QwtPlotMultiBarChart( const QwtText &title );
virtual ~QwtPlotMultiBarChart();
@ -78,8 +78,8 @@ public:
void setStyle( ChartStyle style );
ChartStyle style() const;
void setSymbol( int barIndex, QwtColumnSymbol *symbol );
const QwtColumnSymbol *symbol( int barIndex ) const;
void setSymbol( int valueIndex, QwtColumnSymbol * );
const QwtColumnSymbol *symbol( int valueIndex ) const;
void resetSymbolMap();
@ -94,9 +94,9 @@ public:
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
protected:
QwtColumnSymbol *symbol( int barIndex );
QwtColumnSymbol *symbol( int valueIndex );
virtual QwtColumnSymbol *specialSymbol(
virtual QwtColumnSymbol *specialSymbol(
int sampleIndex, int valueIndex ) const;
virtual void drawSample( QPainter *painter,
@ -105,7 +105,7 @@ protected:
int index, const QwtSetSample& sample ) const;
virtual void drawBar( QPainter *, int sampleIndex,
int barIndex, const QwtColumnRect & ) const;
int valueIndex, const QwtColumnRect & ) const;
void drawStackedBars( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,

View File

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

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