diff --git a/qwtdemo/qwt/qwt_abstract_legend.h b/qwtdemo/qwt/qwt_abstract_legend.h index 18bd3f4..51a720c 100644 --- a/qwtdemo/qwt/qwt_abstract_legend.h +++ b/qwtdemo/qwt/qwt_abstract_legend.h @@ -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 &data ) = 0; }; -#endif +#endif diff --git a/qwtdemo/qwt/qwt_abstract_scale.cpp b/qwtdemo/qwt/qwt_abstract_scale.cpp index 3018b85..fd9ef2c 100644 --- a/qwtdemo/qwt/qwt_abstract_scale.cpp +++ b/qwtdemo/qwt/qwt_abstract_scale.cpp @@ -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( diff --git a/qwtdemo/qwt/qwt_abstract_scale.h b/qwtdemo/qwt/qwt_abstract_scale.h index 4ed6616..e6322c6 100644 --- a/qwtdemo/qwt/qwt_abstract_scale.h +++ b/qwtdemo/qwt/qwt_abstract_scale.h @@ -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 * ); diff --git a/qwtdemo/qwt/qwt_abstract_scale_draw.cpp b/qwtdemo/qwt/qwt_abstract_scale_draw.cpp index 9a26459..57a2c4a 100644 --- a/qwtdemo/qwt/qwt_abstract_scale_draw.cpp +++ b/qwtdemo/qwt/qwt_abstract_scale_draw.cpp @@ -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::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::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::iterator it2 = d_data->labelCache.insert( value, lbl ); + return *it2; } /*! diff --git a/qwtdemo/qwt/qwt_abstract_scale_draw.h b/qwtdemo/qwt/qwt_abstract_scale_draw.h index d0f1ec3..f818ded 100644 --- a/qwtdemo/qwt/qwt_abstract_scale_draw.h +++ b/qwtdemo/qwt/qwt_abstract_scale_draw.h @@ -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 ); diff --git a/qwtdemo/qwt/qwt_abstract_slider.cpp b/qwtdemo/qwt/qwt_abstract_slider.cpp index 7bac22e..7069596 100644 --- a/qwtdemo/qwt/qwt_abstract_slider.cpp +++ b/qwtdemo/qwt/qwt_abstract_slider.cpp @@ -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; } } diff --git a/qwtdemo/qwt/qwt_abstract_slider.h b/qwtdemo/qwt/qwt_abstract_slider.h index c91dcb6..be5c682 100644 --- a/qwtdemo/qwt/qwt_abstract_slider.h +++ b/qwtdemo/qwt/qwt_abstract_slider.h @@ -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: diff --git a/qwtdemo/qwt/qwt_analog_clock.cpp b/qwtdemo/qwt/qwt_analog_clock.cpp index 1d44a95..04dd37c 100644 --- a/qwtdemo/qwt/qwt_analog_clock.cpp +++ b/qwtdemo/qwt/qwt_analog_clock.cpp @@ -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 majorTicks; QList minorTicks; @@ -200,7 +200,7 @@ void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF ¢er, 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 ¢er, for ( int hand = 0; hand < NHands; hand++ ) { const double d = 360.0 - angle[hand] - origin(); - drawHand( painter, static_cast( hand ), + drawHand( painter, static_cast( hand ), center, radius, d, colorGroup ); } } diff --git a/qwtdemo/qwt/qwt_analog_clock.h b/qwtdemo/qwt/qwt_analog_clock.h index ffe27e2..8e9f01a 100644 --- a/qwtdemo/qwt/qwt_analog_clock.h +++ b/qwtdemo/qwt/qwt_analog_clock.h @@ -21,7 +21,7 @@ \image html analogclock.png \par Example - \code + \code #include QwtAnalogClock *clock = new QwtAnalogClock(...); diff --git a/qwtdemo/qwt/qwt_arrow_button.h b/qwtdemo/qwt/qwt_arrow_button.h index ae436fe..1a727d5 100644 --- a/qwtdemo/qwt/qwt_arrow_button.h +++ b/qwtdemo/qwt/qwt_arrow_button.h @@ -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; diff --git a/qwtdemo/qwt/qwt_clipper.cpp b/qwtdemo/qwt/qwt_clipper.cpp index 51614aa..8605b42 100644 --- a/qwtdemo/qwt/qwt_clipper.cpp +++ b/qwtdemo/qwt/qwt_clipper.cpp @@ -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( + m_buffer = static_cast( ::realloc( m_buffer, m_capacity * sizeof( Point ) ) ); } diff --git a/qwtdemo/qwt/qwt_clipper.h b/qwtdemo/qwt/qwt_clipper.h index 1b1820b..8d88b89 100644 --- a/qwtdemo/qwt/qwt_clipper.h +++ b/qwtdemo/qwt/qwt_clipper.h @@ -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 clipCircle( diff --git a/qwtdemo/qwt/qwt_color_map.cpp b/qwtdemo/qwt/qwt_color_map.cpp index 40d2dfc..4806bad 100644 --- a/qwtdemo/qwt/qwt_color_map.cpp +++ b/qwtdemo/qwt/qwt_color_map.cpp @@ -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 diff --git a/qwtdemo/qwt/qwt_color_map.h b/qwtdemo/qwt/qwt_color_map.h index bbd01b0..993e93f 100644 --- a/qwtdemo/qwt/qwt_color_map.h +++ b/qwtdemo/qwt/qwt_color_map.h @@ -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 rgbTable = colorTable( interval ); + return rgbTable[index]; // slow } } diff --git a/qwtdemo/qwt/qwt_column_symbol.cpp b/qwtdemo/qwt/qwt_column_symbol.cpp index d6f0f1a..f6b303e 100644 --- a/qwtdemo/qwt/qwt_column_symbol.cpp +++ b/qwtdemo/qwt/qwt_column_symbol.cpp @@ -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() ); } } } diff --git a/qwtdemo/qwt/qwt_column_symbol.h b/qwtdemo/qwt/qwt_column_symbol.h index 918fe4a..ccfbecb 100644 --- a/qwtdemo/qwt/qwt_column_symbol.h +++ b/qwtdemo/qwt/qwt_column_symbol.h @@ -136,7 +136,7 @@ public: QwtColumnSymbol( Style = NoStyle ); virtual ~QwtColumnSymbol(); - void setFrameStyle( FrameStyle style ); + void setFrameStyle( FrameStyle ); FrameStyle frameStyle() const; void setLineWidth( int width ); diff --git a/qwtdemo/qwt/qwt_compass.cpp b/qwtdemo/qwt/qwt_compass.cpp index 4e2c9ff..4deec75 100644 --- a/qwtdemo/qwt/qwt_compass.cpp +++ b/qwtdemo/qwt/qwt_compass.cpp @@ -17,7 +17,7 @@ #include #include -/*! +/*! \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 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() */ diff --git a/qwtdemo/qwt/qwt_compass_rose.cpp b/qwtdemo/qwt/qwt_compass_rose.cpp index 03e4365..05f7039 100644 --- a/qwtdemo/qwt/qwt_compass_rose.cpp +++ b/qwtdemo/qwt/qwt_compass_rose.cpp @@ -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 -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() */ diff --git a/qwtdemo/qwt/qwt_compass_rose.h b/qwtdemo/qwt/qwt_compass_rose.h index 9b715df..09cb496 100644 --- a/qwtdemo/qwt/qwt_compass_rose.h +++ b/qwtdemo/qwt/qwt_compass_rose.h @@ -45,7 +45,7 @@ public: \param north Position \param colorGroup Color group */ - virtual void draw( QPainter *painter, + virtual void draw( QPainter *painter, const QPointF ¢er, 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 ¢er, double radius, double origin, double width, + const QPointF ¢er, double radius, double north, double width, int numThorns, int numThornLevels, double shrinkFactor ); private: @@ -86,4 +86,4 @@ private: PrivateData *d_data; }; -#endif +#endif diff --git a/qwtdemo/qwt/qwt_counter.cpp b/qwtdemo/qwt/qwt_counter.cpp index 31c05c8..8fcb36f 100644 --- a/qwtdemo/qwt/qwt_counter.cpp +++ b/qwtdemo/qwt/qwt_counter.cpp @@ -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() diff --git a/qwtdemo/qwt/qwt_counter.h b/qwtdemo/qwt/qwt_counter.h index 8799edd..a276771 100644 --- a/qwtdemo/qwt/qwt_counter.h +++ b/qwtdemo/qwt/qwt_counter.h @@ -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; diff --git a/qwtdemo/qwt/qwt_curve_fitter.cpp b/qwtdemo/qwt/qwt_curve_fitter.cpp index 5f09d5d..ba73784 100644 --- a/qwtdemo/qwt/qwt_curve_fitter.cpp +++ b/qwtdemo/qwt/qwt_curve_fitter.cpp @@ -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 ); diff --git a/qwtdemo/qwt/qwt_curve_fitter.h b/qwtdemo/qwt/qwt_curve_fitter.h index eac376a..988edd2 100644 --- a/qwtdemo/qwt/qwt_curve_fitter.h +++ b/qwtdemo/qwt/qwt_curve_fitter.h @@ -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; diff --git a/qwtdemo/qwt/qwt_date.cpp b/qwtdemo/qwt/qwt_date.cpp index b71224e..c40f99b 100644 --- a/qwtdemo/qwt/qwt_date.cpp +++ b/qwtdemo/qwt/qwt_date.cpp @@ -31,7 +31,7 @@ static const QwtJulianDay maxJulianDayD = std::numeric_limits::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. diff --git a/qwtdemo/qwt/qwt_date.h b/qwtdemo/qwt/qwt_date.h index 30422a1..efc65d0 100644 --- a/qwtdemo/qwt/qwt_date.h +++ b/qwtdemo/qwt/qwt_date.h @@ -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 ); }; diff --git a/qwtdemo/qwt/qwt_date_scale_draw.cpp b/qwtdemo/qwt/qwt_date_scale_draw.cpp index cebde7b..b1ad31b 100644 --- a/qwtdemo/qwt/qwt_date_scale_draw.cpp +++ b/qwtdemo/qwt/qwt_date_scale_draw.cpp @@ -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( j ) ); if ( dt0 != dt ) diff --git a/qwtdemo/qwt/qwt_date_scale_draw.h b/qwtdemo/qwt/qwt_date_scale_draw.h index 54949b6..efe4306 100644 --- a/qwtdemo/qwt/qwt_date_scale_draw.h +++ b/qwtdemo/qwt/qwt_date_scale_draw.h @@ -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 &, diff --git a/qwtdemo/qwt/qwt_date_scale_engine.cpp b/qwtdemo/qwt/qwt_date_scale_engine.cpp index 491c99e..46ce2bd 100644 --- a/qwtdemo/qwt/qwt_date_scale_engine.cpp +++ b/qwtdemo/qwt/qwt_date_scale_engine.cpp @@ -13,7 +13,7 @@ #include #include -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 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( 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 mediumTicks; QList 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 mediumTicks; QList 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 majorTicks; QList 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 ); diff --git a/qwtdemo/qwt/qwt_date_scale_engine.h b/qwtdemo/qwt/qwt_date_scale_engine.h index 26bf4d3..0085f68 100644 --- a/qwtdemo/qwt/qwt_date_scale_engine.h +++ b/qwtdemo/qwt/qwt_date_scale_engine.h @@ -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: diff --git a/qwtdemo/qwt/qwt_dial.cpp b/qwtdemo/qwt/qwt_dial.cpp index aeeb151..413167e 100644 --- a/qwtdemo/qwt/qwt_dial.cpp +++ b/qwtdemo/qwt/qwt_dial.cpp @@ -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 ¢er, double radius ) const { QwtRoundScaleDraw *sd = const_cast( 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() diff --git a/qwtdemo/qwt/qwt_dial.h b/qwtdemo/qwt/qwt_dial.h index a409b4b..f884ba8 100644 --- a/qwtdemo/qwt/qwt_dial.h +++ b/qwtdemo/qwt/qwt_dial.h @@ -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 ¢er, double radius ) const; - virtual void drawScaleContents( QPainter *painter, + virtual void drawScaleContents( QPainter *painter, const QPointF ¢er, double radius ) const; virtual void drawNeedle( QPainter *, const QPointF &, diff --git a/qwtdemo/qwt/qwt_dial_needle.cpp b/qwtdemo/qwt/qwt_dial_needle.cpp index 2764ab1..49dd44a 100644 --- a/qwtdemo/qwt/qwt_dial_needle.cpp +++ b/qwtdemo/qwt/qwt_dial_needle.cpp @@ -13,7 +13,7 @@ #include "qwt_painter.h" #include #include -#include + #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 ¢er, double length, double direction, +void QwtDialNeedle::draw( QPainter *painter, + const QPointF ¢er, 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 ) diff --git a/qwtdemo/qwt/qwt_dial_needle.h b/qwtdemo/qwt/qwt_dial_needle.h index d84384a..2051f9b 100644 --- a/qwtdemo/qwt/qwt_dial_needle.h +++ b/qwtdemo/qwt/qwt_dial_needle.h @@ -35,7 +35,7 @@ public: const QPalette &palette() const; virtual void draw( QPainter *painter, const QPointF ¢er, - 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 diff --git a/qwtdemo/qwt/qwt_dyngrid_layout.cpp b/qwtdemo/qwt/qwt_dyngrid_layout.cpp index 9e0fa28..7ba2bb7 100644 --- a/qwtdemo/qwt/qwt_dyngrid_layout.cpp +++ b/qwtdemo/qwt/qwt_dyngrid_layout.cpp @@ -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 ) diff --git a/qwtdemo/qwt/qwt_dyngrid_layout.h b/qwtdemo/qwt/qwt_dyngrid_layout.h index dd20266..2ae6ee0 100644 --- a/qwtdemo/qwt/qwt_dyngrid_layout.h +++ b/qwtdemo/qwt/qwt_dyngrid_layout.h @@ -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 layoutItems( const QRect &, uint numCols ) const; + QList 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& rowHeight, QVector& colWidth ) const; - void stretchGrid( const QRect &rect, uint numCols, + void stretchGrid( const QRect &rect, uint numColumns, QVector& rowHeight, QVector& colWidth ) const; private: void init(); - int maxRowWidth( int numCols ) const; + int maxRowWidth( int numColumns ) const; class PrivateData; PrivateData *d_data; diff --git a/qwtdemo/qwt/qwt_event_pattern.cpp b/qwtdemo/qwt/qwt_event_pattern.cpp index 4637743..c0be695 100644 --- a/qwtdemo/qwt/qwt_event_pattern.cpp +++ b/qwtdemo/qwt/qwt_event_pattern.cpp @@ -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() \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 ) diff --git a/qwtdemo/qwt/qwt_event_pattern.h b/qwtdemo/qwt/qwt_event_pattern.h index 7c5d1a3..30c0c92 100644 --- a/qwtdemo/qwt/qwt_event_pattern.h +++ b/qwtdemo/qwt/qwt_event_pattern.h @@ -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 & ); void setKeyPattern( const QVector & ); diff --git a/qwtdemo/qwt/qwt_global.h b/qwtdemo/qwt/qwt_global.h index 736ccf1..df334bc 100644 --- a/qwtdemo/qwt/qwt_global.h +++ b/qwtdemo/qwt/qwt_global.h @@ -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 diff --git a/qwtdemo/qwt/qwt_graphic.cpp b/qwtdemo/qwt/qwt_graphic.cpp index b1c9ab9..7861be5 100644 --- a/qwtdemo/qwt/qwt_graphic.cpp +++ b/qwtdemo/qwt/qwt_graphic.cpp @@ -16,7 +16,7 @@ #include #include #include -#include + 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(); diff --git a/qwtdemo/qwt/qwt_graphic.h b/qwtdemo/qwt/qwt_graphic.h index 744ccb7..cbd41f9 100644 --- a/qwtdemo/qwt/qwt_graphic.h +++ b/qwtdemo/qwt/qwt_graphic.h @@ -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 #include #include -#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; diff --git a/qwtdemo/qwt/qwt_interval.cpp b/qwtdemo/qwt/qwt_interval.cpp index b7c6ee9..58195a5 100644 --- a/qwtdemo/qwt/qwt_interval.cpp +++ b/qwtdemo/qwt/qwt_interval.cpp @@ -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 diff --git a/qwtdemo/qwt/qwt_interval.h b/qwtdemo/qwt/qwt_interval.h index 68841e0..cf145b2 100644 --- a/qwtdemo/qwt/qwt_interval.h +++ b/qwtdemo/qwt/qwt_interval.h @@ -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 diff --git a/qwtdemo/qwt/qwt_interval_symbol.cpp b/qwtdemo/qwt/qwt_interval_symbol.cpp index 83c842d..b6845f5 100644 --- a/qwtdemo/qwt/qwt_interval_symbol.cpp +++ b/qwtdemo/qwt/qwt_interval_symbol.cpp @@ -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; diff --git a/qwtdemo/qwt/qwt_interval_symbol.h b/qwtdemo/qwt/qwt_interval_symbol.h index f32e1c4..9b937e1 100644 --- a/qwtdemo/qwt/qwt_interval_symbol.h +++ b/qwtdemo/qwt/qwt_interval_symbol.h @@ -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; }; diff --git a/qwtdemo/qwt/qwt_knob.cpp b/qwtdemo/qwt/qwt_knob.cpp index 2a2a356..241995b 100644 --- a/qwtdemo/qwt/qwt_knob.cpp +++ b/qwtdemo/qwt/qwt_knob.cpp @@ -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() */ diff --git a/qwtdemo/qwt/qwt_knob.h b/qwtdemo/qwt/qwt_knob.h index 852374c..8d1c7f0 100644 --- a/qwtdemo/qwt/qwt_knob.h +++ b/qwtdemo/qwt/qwt_knob.h @@ -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; diff --git a/qwtdemo/qwt/qwt_legend.cpp b/qwtdemo/qwt/qwt_legend.cpp index 4aca800..a2d4cc9 100644 --- a/qwtdemo/qwt/qwt_legend.cpp +++ b/qwtdemo/qwt/qwt_legend.cpp @@ -49,7 +49,7 @@ private: QList< Entry > d_entries; }; -void QwtLegendMap::insert( const QVariant &itemInfo, +void QwtLegendMap::insert( const QVariant &itemInfo, const QList &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 &data ) +void QwtLegend::updateLegend( const QVariant &itemInfo, + const QList &legendData ) { QList 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( 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(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( 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 itemRects = + const QList 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 diff --git a/qwtdemo/qwt/qwt_legend.h b/qwtdemo/qwt/qwt_legend.h index 3d8fca6..112638d 100644 --- a/qwtdemo/qwt/qwt_legend.h +++ b/qwtdemo/qwt/qwt_legend.h @@ -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 diff --git a/qwtdemo/qwt/qwt_legend_data.cpp b/qwtdemo/qwt/qwt_legend_data.cpp index cf0cb2c..0b53acd 100644 --- a/qwtdemo/qwt/qwt_legend_data.cpp +++ b/qwtdemo/qwt/qwt_legend_data.cpp @@ -123,7 +123,7 @@ QwtLegendData::Mode QwtLegendData::mode() const const int mode = qvariant_cast( modeValue ); return static_cast( mode ); } - + return QwtLegendData::ReadOnly; } diff --git a/qwtdemo/qwt/qwt_legend_data.h b/qwtdemo/qwt/qwt_legend_data.h index d83e132..2a968b6 100644 --- a/qwtdemo/qwt/qwt_legend_data.h +++ b/qwtdemo/qwt/qwt_legend_data.h @@ -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 diff --git a/qwtdemo/qwt/qwt_legend_label.cpp b/qwtdemo/qwt/qwt_legend_label.cpp index 19a7eb9..0eb6f3e 100644 --- a/qwtdemo/qwt/qwt_legend_label.cpp +++ b/qwtdemo/qwt/qwt_legend_label.cpp @@ -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 ); diff --git a/qwtdemo/qwt/qwt_legend_label.h b/qwtdemo/qwt/qwt_legend_label.h index f0a1584..fe07a38 100644 --- a/qwtdemo/qwt/qwt_legend_label.h +++ b/qwtdemo/qwt/qwt_legend_label.h @@ -77,4 +77,4 @@ private: PrivateData *d_data; }; -#endif +#endif diff --git a/qwtdemo/qwt/qwt_magnifier.cpp b/qwtdemo/qwt/qwt_magnifier.cpp index 55e7bb5..3bcef0b 100644 --- a/qwtdemo/qwt/qwt_magnifier.cpp +++ b/qwtdemo/qwt/qwt_magnifier.cpp @@ -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 ) diff --git a/qwtdemo/qwt/qwt_math.h b/qwtdemo/qwt/qwt_math.h index ed1d0b5..39a3c00 100644 --- a/qwtdemo/qwt/qwt_math.h +++ b/qwtdemo/qwt/qwt_math.h @@ -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 diff --git a/qwtdemo/qwt/qwt_matrix_raster_data.cpp b/qwtdemo/qwt/qwt_matrix_raster_data.cpp index 69355ad..129f92a 100644 --- a/qwtdemo/qwt/qwt_matrix_raster_data.cpp +++ b/qwtdemo/qwt/qwt_matrix_raster_data.cpp @@ -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 &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; diff --git a/qwtdemo/qwt/qwt_matrix_raster_data.h b/qwtdemo/qwt/qwt_matrix_raster_data.h index 0b107c9..cf58c12 100644 --- a/qwtdemo/qwt/qwt_matrix_raster_data.h +++ b/qwtdemo/qwt/qwt_matrix_raster_data.h @@ -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 diff --git a/qwtdemo/qwt/qwt_null_paintdevice.cpp b/qwtdemo/qwt/qwt_null_paintdevice.cpp index c645d8b..3baf0e9 100644 --- a/qwtdemo/qwt/qwt_null_paintdevice.cpp +++ b/qwtdemo/qwt/qwt_null_paintdevice.cpp @@ -10,7 +10,7 @@ #include "qwt_null_paintdevice.h" #include #include -#include + 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); diff --git a/qwtdemo/qwt/qwt_null_paintdevice.h b/qwtdemo/qwt/qwt_null_paintdevice.h index 320e619..e4e9cad 100644 --- a/qwtdemo/qwt/qwt_null_paintdevice.h +++ b/qwtdemo/qwt/qwt_null_paintdevice.h @@ -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 #include -#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() diff --git a/qwtdemo/qwt/qwt_painter.cpp b/qwtdemo/qwt/qwt_painter.cpp index 8cd3e2d..7959fe5 100644 --- a/qwtdemo/qwt/qwt_painter.cpp +++ b/qwtdemo/qwt/qwt_painter.cpp @@ -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 #include #include -#include "qpainterpath.h" #if QT_VERSION >= 0x050000 #include #endif -#if QT_VERSION < 0x050000 +#if QT_VERSION < 0x050000 #ifdef Q_WS_X11 #include @@ -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( 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() ) { diff --git a/qwtdemo/qwt/qwt_painter.h b/qwtdemo/qwt/qwt_painter.h index a38753d..c0a0ff7 100644 --- a/qwtdemo/qwt/qwt_painter.h +++ b/qwtdemo/qwt/qwt_painter.h @@ -17,7 +17,7 @@ #include #include #include -#include + 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, diff --git a/qwtdemo/qwt/qwt_painter_command.cpp b/qwtdemo/qwt/qwt_painter_command.cpp index 71afb63..39faca9 100644 --- a/qwtdemo/qwt/qwt_painter_command.cpp +++ b/qwtdemo/qwt/qwt_painter_command.cpp @@ -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; } diff --git a/qwtdemo/qwt/qwt_painter_command.h b/qwtdemo/qwt/qwt_painter_command.h index 967c78c..a2f509a 100644 --- a/qwtdemo/qwt/qwt_painter_command.h +++ b/qwtdemo/qwt/qwt_painter_command.h @@ -15,7 +15,7 @@ #include #include #include -#include + 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; diff --git a/qwtdemo/qwt/qwt_panner.cpp b/qwtdemo/qwt/qwt_panner.cpp index 18497a9..e6e6eb0 100644 --- a/qwtdemo/qwt/qwt_panner.cpp +++ b/qwtdemo/qwt/qwt_panner.cpp @@ -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 ); } diff --git a/qwtdemo/qwt/qwt_panner.h b/qwtdemo/qwt/qwt_panner.h index a0c6873..ab0eb2e 100644 --- a/qwtdemo/qwt/qwt_panner.h +++ b/qwtdemo/qwt/qwt_panner.h @@ -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 ); diff --git a/qwtdemo/qwt/qwt_picker.cpp b/qwtdemo/qwt/qwt_picker.cpp index dd65f9d..dfd7e9b 100644 --- a/qwtdemo/qwt/qwt_picker.cpp +++ b/qwtdemo/qwt/qwt_picker.cpp @@ -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; diff --git a/qwtdemo/qwt/qwt_picker.h b/qwtdemo/qwt/qwt_picker.h index 87d6805..e008e85 100644 --- a/qwtdemo/qwt/qwt_picker.h +++ b/qwtdemo/qwt/qwt_picker.h @@ -58,13 +58,16 @@ class QwtWidgetOverlay; position. \par Example - \verbatim #include -#include + \code + #include + #include -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(); diff --git a/qwtdemo/qwt/qwt_picker_machine.cpp b/qwtdemo/qwt/qwt_picker_machine.cpp index 09cfe6b..e281833 100644 --- a/qwtdemo/qwt/qwt_picker_machine.cpp +++ b/qwtdemo/qwt/qwt_picker_machine.cpp @@ -105,7 +105,7 @@ QList QwtPickerClickPointMachine::transition( { case QEvent::MouseButtonPress: { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, static_cast( event ) ) ) { cmdList += Begin; @@ -151,7 +151,7 @@ QList QwtPickerDragPointMachine::transition( { case QEvent::MouseButtonPress: { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, static_cast( event ) ) ) { if ( state() == 0 ) @@ -224,7 +224,7 @@ QList QwtPickerClickRectMachine::transition( { case QEvent::MouseButtonPress: { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, static_cast( event ) ) ) { switch ( state() ) @@ -259,7 +259,7 @@ QList QwtPickerClickRectMachine::transition( } case QEvent::MouseButtonRelease: { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, static_cast( event ) ) ) { if ( state() == 1 ) @@ -323,7 +323,7 @@ QList QwtPickerDragRectMachine::transition( { case QEvent::MouseButtonPress: { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, static_cast( event ) ) ) { if ( state() == 0 ) @@ -354,7 +354,7 @@ QList QwtPickerDragRectMachine::transition( } case QEvent::KeyPress: { - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, + if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, static_cast ( event ) ) ) { if ( state() == 0 ) @@ -395,7 +395,7 @@ QList QwtPickerPolygonMachine::transition( { case QEvent::MouseButtonPress: { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, static_cast( event ) ) ) { if ( state() == 0 ) @@ -410,7 +410,7 @@ QList QwtPickerPolygonMachine::transition( cmdList += Append; } } - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2, + if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2, static_cast( event ) ) ) { if ( state() == 1 ) diff --git a/qwtdemo/qwt/qwt_picker_machine.h b/qwtdemo/qwt/qwt_picker_machine.h index 6164b93..043ba48 100644 --- a/qwtdemo/qwt/qwt_picker_machine.h +++ b/qwtdemo/qwt/qwt_picker_machine.h @@ -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: diff --git a/qwtdemo/qwt/qwt_plot.cpp b/qwtdemo/qwt/qwt_plot.cpp index c76054c..d832c54 100644 --- a/qwtdemo/qwt/qwt_plot.cpp +++ b/qwtdemo/qwt/qwt_plot.cpp @@ -27,23 +27,21 @@ static inline void qwtEnableLegendItems( QwtPlot *plot, bool on ) { if ( on ) { - QObject::connect( - plot, SIGNAL( legendDataChanged( - const QVariant &, const QList & ) ), - plot, SLOT( updateLegendItems( - const QVariant &, const QList & ) ) ); + QObject::connect( + plot, SIGNAL(legendDataChanged(QVariant,QList)), + plot, SLOT(updateLegendItems(QVariant,QList)) + ); } else { - QObject::disconnect( - plot, SIGNAL( legendDataChanged( - const QVariant &, const QList & ) ), - plot, SLOT( updateLegendItems( - const QVariant &, const QList & ) ) ); + QObject::disconnect( + plot, SIGNAL(legendDataChanged(QVariant,QList) ), + plot, SLOT( updateLegendItems(QVariant,QList)) + ); } } -static void qwtSetTabOrder( +static void qwtSetTabOrder( QWidget *first, QWidget *second, bool withChildren ) { QList 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 & ) ), - d_data->legend, - SLOT( updateLegend( - const QVariant &, const QList & ) ) + connect( + this, SIGNAL(legendDataChanged(QVariant,QList)), + d_data->legend, SLOT(updateLegend(QVariant,QList) ) ); 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 diff --git a/qwtdemo/qwt/qwt_plot.h b/qwtdemo/qwt/qwt_plot.h index d662613..ca66f5e 100644 --- a/qwtdemo/qwt/qwt_plot.h +++ b/qwtdemo/qwt/qwt_plot.h @@ -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 -#include + 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 + #include -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 &data ); public Q_SLOTS: @@ -290,7 +291,7 @@ protected: private Q_SLOTS: void updateLegendItems( const QVariant &itemInfo, - const QList &data ); + const QList &legendData ); private: friend class QwtPlotItem; diff --git a/qwtdemo/qwt/qwt_plot_abstract_barchart.cpp b/qwtdemo/qwt/qwt_plot_abstract_barchart.cpp index 8f70ca8..82505f5 100644 --- a/qwtdemo/qwt/qwt_plot_abstract_barchart.cpp +++ b/qwtdemo/qwt/qwt_plot_abstract_barchart.cpp @@ -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 { diff --git a/qwtdemo/qwt/qwt_plot_abstract_barchart.h b/qwtdemo/qwt/qwt_plot_abstract_barchart.h index 3132a5f..6844d0d 100644 --- a/qwtdemo/qwt/qwt_plot_abstract_barchart.h +++ b/qwtdemo/qwt/qwt_plot_abstract_barchart.h @@ -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: diff --git a/qwtdemo/qwt/qwt_plot_axis.cpp b/qwtdemo/qwt/qwt_plot_axis.cpp index e3802f6..851777c 100644 --- a/qwtdemo/qwt/qwt_plot_axis.cpp +++ b/qwtdemo/qwt/qwt_plot_axis.cpp @@ -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() diff --git a/qwtdemo/qwt/qwt_plot_barchart.cpp b/qwtdemo/qwt/qwt_plot_barchart.cpp index b9db8e2..cf01b98 100644 --- a/qwtdemo/qwt/qwt_plot_barchart.cpp +++ b/qwtdemo/qwt/qwt_plot_barchart.cpp @@ -21,7 +21,7 @@ public: legendMode( QwtPlotBarChart::LegendChartTitle ) { } - + ~PrivateData() { delete symbol; @@ -120,7 +120,7 @@ void QwtPlotBarChart::setSamples( QwtSeriesData *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 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; diff --git a/qwtdemo/qwt/qwt_plot_barchart.h b/qwtdemo/qwt/qwt_plot_barchart.h index d47bfb9..0df2541 100644 --- a/qwtdemo/qwt/qwt_plot_barchart.h +++ b/qwtdemo/qwt/qwt_plot_barchart.h @@ -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 & ); void setSamples( const QVector & ); - void setSamples( QwtSeriesData *series ); + void setSamples( QwtSeriesData * ); 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 legendData() const; diff --git a/qwtdemo/qwt/qwt_plot_canvas.cpp b/qwtdemo/qwt/qwt_plot_canvas.cpp index af3b0e1..9438f15 100644 --- a/qwtdemo/qwt/qwt_plot_canvas.cpp +++ b/qwtdemo/qwt/qwt_plot_canvas.cpp @@ -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 &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 &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(); } diff --git a/qwtdemo/qwt/qwt_plot_canvas.h b/qwtdemo/qwt/qwt_plot_canvas.h index 32b7061..c79e4e4 100644 --- a/qwtdemo/qwt/qwt_plot_canvas.h +++ b/qwtdemo/qwt/qwt_plot_canvas.h @@ -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, diff --git a/qwtdemo/qwt/qwt_plot_curve.cpp b/qwtdemo/qwt/qwt_plot_curve.cpp index 43e7b08..2e6925b 100644 --- a/qwtdemo/qwt/qwt_plot_curve.cpp +++ b/qwtdemo/qwt/qwt_plot_curve.cpp @@ -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 *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 *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 ) ); diff --git a/qwtdemo/qwt/qwt_plot_curve.h b/qwtdemo/qwt/qwt_plot_curve.h index 3421abf..7a07224 100644 --- a/qwtdemo/qwt/qwt_plot_curve.h +++ b/qwtdemo/qwt/qwt_plot_curve.h @@ -33,7 +33,7 @@ class QwtCurveFitter; \par Usage
a) Assign curve properties
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().
b) Connect/Assign data.
@@ -52,7 +52,7 @@ class QwtCurveFitter; \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap */ -class QWT_EXPORT QwtPlotCurve: +class QWT_EXPORT QwtPlotCurve: public QwtPlotSeriesItem, public QwtSeriesStore { 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 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 *, diff --git a/qwtdemo/qwt/qwt_plot_dict.cpp b/qwtdemo/qwt/qwt_plot_dict.cpp index 17c61ed..a5ce0aa 100644 --- a/qwtdemo/qwt/qwt_plot_dict.cpp +++ b/qwtdemo/qwt/qwt_plot_dict.cpp @@ -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 ) diff --git a/qwtdemo/qwt/qwt_plot_directpainter.cpp b/qwtdemo/qwt/qwt_plot_directpainter.cpp index 9350d2d..8b99138 100644 --- a/qwtdemo/qwt/qwt_plot_directpainter.cpp +++ b/qwtdemo/qwt/qwt_plot_directpainter.cpp @@ -17,7 +17,7 @@ #include #include -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( canvas ); if ( plotCanvas ) { doCopyCache = qwtHasBackingStore( plotCanvas ); if ( doCopyCache ) { - painter.drawPixmap( plotCanvas->contentsRect().topLeft(), + painter.drawPixmap( plotCanvas->rect().topLeft(), *plotCanvas->backingStore() ); } } diff --git a/qwtdemo/qwt/qwt_plot_directpainter.h b/qwtdemo/qwt/qwt_plot_directpainter.h index b555c87..3561838 100644 --- a/qwtdemo/qwt/qwt_plot_directpainter.h +++ b/qwtdemo/qwt/qwt_plot_directpainter.h @@ -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. diff --git a/qwtdemo/qwt/qwt_plot_glcanvas.cpp b/qwtdemo/qwt/qwt_plot_glcanvas.cpp new file mode 100644 index 0000000..996c0ad --- /dev/null +++ b/qwtdemo/qwt/qwt_plot_glcanvas.cpp @@ -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 +#include +#include +#include +#include + +#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 ); +} diff --git a/qwtdemo/qwt/qwt_plot_glcanvas.h b/qwtdemo/qwt/qwt_plot_glcanvas.h new file mode 100644 index 0000000..7ca9b5a --- /dev/null +++ b/qwtdemo/qwt/qwt_plot_glcanvas.h @@ -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 +#include + +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 diff --git a/qwtdemo/qwt/qwt_plot_grid.h b/qwtdemo/qwt/qwt_plot_grid.h index 16d984c..1150d12 100644 --- a/qwtdemo/qwt/qwt_plot_grid.h +++ b/qwtdemo/qwt/qwt_plot_grid.h @@ -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 & ) const; class PrivateData; diff --git a/qwtdemo/qwt/qwt_plot_histogram.cpp b/qwtdemo/qwt/qwt_plot_histogram.cpp index 4464f03..b6ffaf3 100644 --- a/qwtdemo/qwt/qwt_plot_histogram.cpp +++ b/qwtdemo/qwt/qwt_plot_histogram.cpp @@ -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 *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, diff --git a/qwtdemo/qwt/qwt_plot_histogram.h b/qwtdemo/qwt/qwt_plot_histogram.h index b96bddd..cdd62bb 100644 --- a/qwtdemo/qwt/qwt_plot_histogram.h +++ b/qwtdemo/qwt/qwt_plot_histogram.h @@ -36,7 +36,7 @@ class QPolygonF; \sa QwtPlotBarChart, QwtPlotMultiBarChart */ -class QWT_EXPORT QwtPlotHistogram: +class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem, public QwtSeriesStore { 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 & ); void setSamples( QwtSeriesData * ); - 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; diff --git a/qwtdemo/qwt/qwt_plot_intervalcurve.cpp b/qwtdemo/qwt/qwt_plot_intervalcurve.cpp index 200ea39..529b3db 100644 --- a/qwtdemo/qwt/qwt_plot_intervalcurve.cpp +++ b/qwtdemo/qwt/qwt_plot_intervalcurve.cpp @@ -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 *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 ); diff --git a/qwtdemo/qwt/qwt_plot_intervalcurve.h b/qwtdemo/qwt/qwt_plot_intervalcurve.h index 624d82f..8b00bd3 100644 --- a/qwtdemo/qwt/qwt_plot_intervalcurve.h +++ b/qwtdemo/qwt/qwt_plot_intervalcurve.h @@ -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 { public: @@ -76,7 +76,7 @@ public: //! Paint attributes typedef QFlags 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; diff --git a/qwtdemo/qwt/qwt_plot_item.cpp b/qwtdemo/qwt/qwt_plot_item.cpp index 4cb03bb..253c221 100644 --- a/qwtdemo/qwt/qwt_plot_item.cpp +++ b/qwtdemo/qwt/qwt_plot_item.cpp @@ -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 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 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 &data ) { Q_UNUSED( item ); diff --git a/qwtdemo/qwt/qwt_plot_item.h b/qwtdemo/qwt/qwt_plot_item.h index c76634e..1581c37 100644 --- a/qwtdemo/qwt/qwt_plot_item.h +++ b/qwtdemo/qwt/qwt_plot_item.h @@ -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 *, diff --git a/qwtdemo/qwt/qwt_plot_layout.cpp b/qwtdemo/qwt/qwt_plot_layout.cpp index 4db33b9..b5003ee 100644 --- a/qwtdemo/qwt/qwt_plot_layout.cpp +++ b/qwtdemo/qwt/qwt_plot_layout.cpp @@ -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; diff --git a/qwtdemo/qwt/qwt_plot_layout.h b/qwtdemo/qwt/qwt_plot_layout.h index c72c04f..3850494 100644 --- a/qwtdemo/qwt/qwt_plot_layout.h +++ b/qwtdemo/qwt/qwt_plot_layout.h @@ -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(); diff --git a/qwtdemo/qwt/qwt_plot_legenditem.cpp b/qwtdemo/qwt/qwt_plot_legenditem.cpp index 06a1f36..a52f8af 100644 --- a/qwtdemo/qwt/qwt_plot_legenditem.cpp +++ b/qwtdemo/qwt/qwt_plot_legenditem.cpp @@ -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( 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 layoutItems; - QMap >::iterator it = + QMap >::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 layoutItems; diff --git a/qwtdemo/qwt/qwt_plot_legenditem.h b/qwtdemo/qwt/qwt_plot_legenditem.h index 378551e..052750e 100644 --- a/qwtdemo/qwt/qwt_plot_legenditem.h +++ b/qwtdemo/qwt/qwt_plot_legenditem.h @@ -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; diff --git a/qwtdemo/qwt/qwt_plot_marker.cpp b/qwtdemo/qwt/qwt_plot_marker.cpp index d88debf..9a0f9e3 100644 --- a/qwtdemo/qwt/qwt_plot_marker.cpp +++ b/qwtdemo/qwt/qwt_plot_marker.cpp @@ -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() ); } } diff --git a/qwtdemo/qwt/qwt_plot_marker.h b/qwtdemo/qwt/qwt_plot_marker.h index 2c726ce..ee8b14d 100644 --- a/qwtdemo/qwt/qwt_plot_marker.h +++ b/qwtdemo/qwt/qwt_plot_marker.h @@ -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: diff --git a/qwtdemo/qwt/qwt_plot_multi_barchart.cpp b/qwtdemo/qwt/qwt_plot_multi_barchart.cpp index 7ee6166..3f73cda 100644 --- a/qwtdemo/qwt/qwt_plot_multi_barchart.cpp +++ b/qwtdemo/qwt/qwt_plot_multi_barchart.cpp @@ -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 *data ) -{ +{ setData( data ); -} +} /*! \brief Set the titles for the bars @@ -137,7 +137,7 @@ void QwtPlotMultiBarChart::setBarTitles( const QList &titles ) itemChanged(); } -/*! +/*! \return Bar titles \sa setBarTitles(), legendData() */ @@ -162,7 +162,7 @@ void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol *symbol ) if ( valueIndex < 0 ) return; - QMap::iterator it = + QMap::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::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::iterator it = - d_data->symbolMap.find( valueIndex ); + QMap::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::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 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 QwtPlotMultiBarChart::legendData() const \param index Index of the bar \param size Icon size - + \return An icon showing a bar \sa drawBar(), legendData() */ diff --git a/qwtdemo/qwt/qwt_plot_multi_barchart.h b/qwtdemo/qwt/qwt_plot_multi_barchart.h index 8349255..2d15904 100644 --- a/qwtdemo/qwt/qwt_plot_multi_barchart.h +++ b/qwtdemo/qwt/qwt_plot_multi_barchart.h @@ -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 { 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, diff --git a/qwtdemo/qwt/qwt_plot_panner.cpp b/qwtdemo/qwt/qwt_plot_panner.cpp index 2c5cbc6..b7daa05 100644 --- a/qwtdemo/qwt/qwt_plot_panner.cpp +++ b/qwtdemo/qwt/qwt_plot_panner.cpp @@ -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 #include #include -#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 +#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(); -} +} diff --git a/qwtdemo/qwt/qwt_plot_picker.cpp b/qwtdemo/qwt/qwt_plot_picker.cpp index 1c0733d..f66b645 100644 --- a/qwtdemo/qwt/qwt_plot_picker.cpp +++ b/qwtdemo/qwt/qwt_plot_picker.cpp @@ -192,6 +192,9 @@ int QwtPlotPicker::yAxis() const */ QwtText QwtPlotPicker::trackerText( const QPoint &pos ) const { + if ( plot() == NULL ) + return QwtText(); + return trackerTextF( invTransform( pos ) ); } diff --git a/qwtdemo/qwt/qwt_plot_rasteritem.cpp b/qwtdemo/qwt/qwt_plot_rasteritem.cpp index c5677d7..5b39523 100644 --- a/qwtdemo/qwt/qwt_plot_rasteritem.cpp +++ b/qwtdemo/qwt/qwt_plot_rasteritem.cpp @@ -190,7 +190,7 @@ static QImage qwtExpandImage(const QImage &image, yy2 = sz.height(); } - const quint32 *line1 = + const quint32 *line1 = reinterpret_cast( image.scanLine( y1 ) ); for ( int x1 = 0; x1 < w; x1++ ) @@ -222,14 +222,14 @@ static QImage qwtExpandImage(const QImage &image, const quint32 rgb( line1[x1] ); for ( int y2 = yy1; y2 < yy2; y2++ ) { - quint32 *line2 = reinterpret_cast( + quint32 *line2 = reinterpret_cast( expanded.scanLine( y2 ) ); - for ( int x2 = xx1; x2 < xx2; x2++ ) + for ( int x2 = xx1; x2 < xx2; x2++ ) line2[x2] = rgb; - } - } - } + } + } + } break; } case 8: @@ -240,26 +240,26 @@ static QImage qwtExpandImage(const QImage &image, if ( y1 == 0 ) { yy1 = 0; - } + } else { yy1 = qRound( y1 * ph - py0 ); if ( yy1 < 0 ) - yy1 = 0; - } - + yy1 = 0; + } + int yy2; if ( y1 == h - 1 ) { yy2 = sz.height(); - } + } else { yy2 = qRound( ( y1 + 1 ) * ph - py0 ); if ( yy2 > sz.height() ) yy2 = sz.height(); } - + const uchar *line1 = image.scanLine( y1 ); for ( int x1 = 0; x1 < w; x1++ ) @@ -292,17 +292,17 @@ static QImage qwtExpandImage(const QImage &image, { uchar *line2 = expanded.scanLine( y2 ); memset( line2 + xx1, line1[x1], xx2 - xx1 ); - } - } + } + } } break; } default: expanded = image; } - + return expanded; -} +} static QRectF qwtExpandToPixels(const QRectF &rect, const QRectF &pixelRect) { @@ -384,7 +384,7 @@ static bool qwtUseCache( QwtPlotRasterItem::CachePolicy policy, return doCache; } -static void qwtToRgba( const QImage* from, QImage* to, +static void qwtToRgba( const QImage* from, QImage* to, const QRect& tile, int alpha ) { const QRgb mask1 = qRgba( 0, 0, 0, alpha ); @@ -572,16 +572,16 @@ void QwtPlotRasterItem::invalidateCache() \brief Pixel hint The geometry of a pixel is used to calculated the resolution and - alignment of the rendered image. + alignment of the rendered image. - Width and height of the hint need to be the horizontal - and vertical distances between 2 neighbored points. - The center of the hint has to be the position of any point + Width and height of the hint need to be the horizontal + and vertical distances between 2 neighbored points. + The center of the hint has to be the position of any point ( it doesn't matter which one ). Limiting the resolution of the image might significantly improve the performance and heavily reduce the amount of memory when rendering - a QImage from the raster data. + a QImage from the raster data. The default implementation returns an empty rectangle (QRectF()), meaning, that the image will be rendered in target device ( f.e screen ) @@ -663,7 +663,7 @@ void QwtPlotRasterItem::draw( QPainter *painter, else { /* - If only one dimension is of the data pixel is higher + If only one dimension is of the data pixel is higher we expand the pixel rect to the resolution of the target device. */ @@ -689,7 +689,7 @@ void QwtPlotRasterItem::draw( QPainter *painter, // When we have no information about position and size of // data pixels we render in resolution of the paint device. - image = compose(xxMap, yyMap, + image = compose(xxMap, yyMap, area, paintRect, paintRect.size().toSize(), doCache); if ( image.isNull() ) return; @@ -697,19 +697,19 @@ void QwtPlotRasterItem::draw( QPainter *painter, // Remove pixels at the boundaries, when explicitly // excluded in the intervals - imageRect = qwtStripRect(paintRect, area, + imageRect = qwtStripRect(paintRect, area, xxMap, yyMap, xInterval, yInterval); if ( imageRect != paintRect ) { - const QRect r( + const QRect r( qRound( imageRect.x() - paintRect.x()), qRound( imageRect.y() - paintRect.y() ), qRound( imageRect.width() ), qRound( imageRect.height() ) ); - + image = image.copy(r); - } + } } else { @@ -734,30 +734,30 @@ void QwtPlotRasterItem::draw( QPainter *painter, imageSize.setWidth( qRound( imageArea.width() / pixelRect.width() ) ); imageSize.setHeight( qRound( imageArea.height() / pixelRect.height() ) ); - image = compose(xxMap, yyMap, + image = compose(xxMap, yyMap, imageArea, paintRect, imageSize, doCache ); if ( image.isNull() ) return; - imageRect = qwtStripRect(paintRect, area, + imageRect = qwtStripRect(paintRect, area, xxMap, yyMap, xInterval, yInterval); if ( ( image.width() > 1 || image.height() > 1 ) && testPaintAttribute( PaintInDeviceResolution ) ) { - // Because of rounding errors the pixels - // need to be expanded manually to rectangles of + // Because of rounding errors the pixels + // need to be expanded manually to rectangles of // different sizes - image = qwtExpandImage(image, xxMap, yyMap, + image = qwtExpandImage(image, xxMap, yyMap, imageArea, area, paintRect, xInterval, yInterval ); } } painter->save(); painter->setWorldTransform( QTransform() ); - + QwtPainter::drawImage( painter, imageRect, image ); painter->restore(); @@ -768,7 +768,7 @@ void QwtPlotRasterItem::draw( QPainter *painter, This method is intended to be reimplemented by derived classes. The default implementation returns an invalid interval. - + \param axis X, Y, or Z axis */ QwtInterval QwtPlotRasterItem::interval(Qt::Axis axis) const @@ -816,9 +816,9 @@ QRectF QwtPlotRasterItem::boundingRect() const return r.normalized(); } -QImage QwtPlotRasterItem::compose( +QImage QwtPlotRasterItem::compose( const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &imageArea, const QRectF &paintRect, + const QRectF &imageArea, const QRectF &paintRect, const QSize &imageSize, bool doCache) const { QImage image; @@ -841,14 +841,14 @@ QImage QwtPlotRasterItem::compose( if ( paintRect.toRect().width() > imageSize.width() ) dx = imageArea.width() / imageSize.width(); - const QwtScaleMap xxMap = + const QwtScaleMap xxMap = imageMap(Qt::Horizontal, xMap, imageArea, imageSize, dx); - + double dy = 0.0; if ( paintRect.toRect().height() > imageSize.height() ) dy = imageArea.height() / imageSize.height(); - const QwtScaleMap yyMap = + const QwtScaleMap yyMap = imageMap(Qt::Vertical, yMap, imageArea, imageSize, dy); image = renderImage( xxMap, yyMap, imageArea, imageSize ); diff --git a/qwtdemo/qwt/qwt_plot_rasteritem.h b/qwtdemo/qwt/qwt_plot_rasteritem.h index f411816..7555b3b 100644 --- a/qwtdemo/qwt/qwt_plot_rasteritem.h +++ b/qwtdemo/qwt/qwt_plot_rasteritem.h @@ -50,10 +50,10 @@ public: /*! renderImage() is called, whenever the image cache is not valid, - or the scales, or the size of the canvas has changed. + or the scales, or the size of the canvas has changed. - This type of cache is useful for improving the performance - of hide/show operations or manipulations of the alpha value. + This type of cache is useful for improving the performance + of hide/show operations or manipulations of the alpha value. All other situations are handled by the canvas backing store. */ PaintCache @@ -68,11 +68,11 @@ public: /*! When the image is rendered according to the data pixels ( QwtRasterData::pixelHint() ) it can be expanded to paint - device resolution before it is passed to QPainter. - The expansion algorithm rounds the pixel borders in the same + device resolution before it is passed to QPainter. + The expansion algorithm rounds the pixel borders in the same way as the axis ticks, what is usually better than the scaling algorithm implemented in Qt. - Disabling this flag might make sense, to reduce the size of a + Disabling this flag might make sense, to reduce the size of a document/file. If this is possible for a document format depends on the implementation of the specific QPaintEngine. */ @@ -83,7 +83,7 @@ public: //! Paint attributes typedef QFlags PaintAttributes; - explicit QwtPlotRasterItem( const QString& title = QString::null ); + explicit QwtPlotRasterItem( const QString& title = QString() ); explicit QwtPlotRasterItem( const QwtText& title ); virtual ~QwtPlotRasterItem(); @@ -98,9 +98,9 @@ public: void invalidateCache(); - virtual void draw( QPainter *p, + virtual void draw( QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &rect ) const; + const QRectF &canvasRect ) const; virtual QRectF pixelHint( const QRectF & ) const; @@ -109,10 +109,10 @@ public: protected: /*! - \brief Render an image + \brief Render an image An implementation of render() might iterate over all - pixels of imageRect. Each pixel has to be translated into + pixels of imageRect. Each pixel has to be translated into the corresponding position in scale coordinates using the maps. This position can be used to look up a value in a implementation specific way and to map it into a color. @@ -121,7 +121,7 @@ protected: \param yMap Y-Scale Map \param area Requested area for the image in scale coordinates \param imageSize Requested size of the image - + \return Rendered image */ virtual QImage renderImage( const QwtScaleMap &xMap, diff --git a/qwtdemo/qwt/qwt_plot_renderer.cpp b/qwtdemo/qwt/qwt_plot_renderer.cpp index 0f72ab6..549c4bc 100644 --- a/qwtdemo/qwt/qwt_plot_renderer.cpp +++ b/qwtdemo/qwt/qwt_plot_renderer.cpp @@ -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,27 +14,64 @@ #include "qwt_abstract_legend.h" #include "qwt_scale_widget.h" #include "qwt_scale_engine.h" +#include "qwt_scale_map.h" #include "qwt_text.h" #include "qwt_text_label.h" #include "qwt_math.h" + #include -#include "qpainterpath.h" -#include #include #include -#include #include #include -#include -#include #include +#include + #ifndef QWT_NO_SVG #ifdef QT_SVG_LIB -#include +#if QT_VERSION >= 0x040500 +#define QWT_FORMAT_SVG 1 +#endif #endif #endif -static QPainterPath qwtCanvasClip( +#ifndef QT_NO_PRINTER +#define QWT_FORMAT_PDF 1 +#endif + +#ifndef QT_NO_PDF + +// QPdfWriter::setResolution() has been introduced with +// Qt 5.3. Guess it is o.k. to stay with QPrinter for older +// versions. + +#if QT_VERSION >= 0x050300 + +#ifndef QWT_FORMAT_PDF +#define QWT_FORMAT_PDF 1 +#endif + +#define QWT_PDF_WRITER 1 + +#endif +#endif + +#ifndef QT_NO_PRINTER +// postscript support has been dropped in Qt5 +#if QT_VERSION < 0x050000 +#define QWT_FORMAT_POSTSCRIPT 1 +#endif +#endif + +#if QWT_FORMAT_SVG +#include +#endif + +#if QWT_PDF_WRITER +#include +#endif + +static QPainterPath qwtCanvasClip( const QWidget* canvas, const QRectF &canvasRect ) { // The clip region is calculated in integers @@ -58,6 +95,14 @@ static QPainterPath qwtCanvasClip( return clipPath; } +static inline QFont qwtResolvedFont( const QWidget *widget ) +{ + QFont font = widget->font(); + font.resolve( QFont::AllPropertiesResolved ); + + return font; +} + class QwtPlotRenderer::PrivateData { public: @@ -71,7 +116,7 @@ public: QwtPlotRenderer::LayoutFlags layoutFlags; }; -/*! +/*! Constructor \param parent Parent object */ @@ -239,9 +284,20 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot, const QRectF documentRect( 0.0, 0.0, size.width(), size.height() ); const QString fmt = format.toLower(); - if ( fmt == "pdf" ) + if ( fmt == QLatin1String( "pdf" ) ) { -#ifndef QT_NO_PRINTER +#if QWT_FORMAT_PDF + +#if QWT_PDF_WRITER + QPdfWriter pdfWriter( fileName ); + pdfWriter.setPageSizeMM( sizeMM ); + pdfWriter.setTitle( title ); + pdfWriter.setPageMargins( QMarginsF() ); + pdfWriter.setResolution( resolution ); + + QPainter painter( &pdfWriter ); + render( plot, &painter, documentRect ); +#else QPrinter printer; printer.setOutputFormat( QPrinter::PdfFormat ); printer.setColorMode( QPrinter::Color ); @@ -253,12 +309,12 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot, QPainter painter( &printer ); render( plot, &painter, documentRect ); +#endif #endif } - else if ( fmt == "ps" ) + else if ( fmt == QLatin1String( "ps" ) ) { -#if QT_VERSION < 0x050000 -#ifndef QT_NO_PRINTER +#if QWT_FORMAT_POSTSCRIPT QPrinter printer; printer.setOutputFormat( QPrinter::PostScriptFormat ); printer.setColorMode( QPrinter::Color ); @@ -270,14 +326,11 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot, QPainter painter( &printer ); render( plot, &painter, documentRect ); -#endif #endif } - else if ( fmt == "svg" ) + else if ( fmt == QLatin1String( "svg" ) ) { -#ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB -#if QT_VERSION >= 0x040500 +#if QWT_FORMAT_SVG QSvgGenerator generator; generator.setTitle( title ); generator.setFileName( fileName ); @@ -286,8 +339,6 @@ void QwtPlotRenderer::renderDocument( QwtPlot *plot, QPainter painter( &generator ); render( plot, &painter, documentRect ); -#endif -#endif #endif } else @@ -367,9 +418,7 @@ void QwtPlotRenderer::renderTo( #endif -#ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB -#if QT_VERSION >= 0x040500 +#if QWT_FORMAT_SVG /*! \brief Render the plot to a QSvgGenerator @@ -395,8 +444,7 @@ void QwtPlotRenderer::renderTo( QPainter p( &generator ); render( plot, &p, rect ); } -#endif -#endif + #endif /*! @@ -461,11 +509,6 @@ void QwtPlotRenderer::render( QwtPlot *plot, if ( !plot->axisEnabled( axisId ) ) { - int left = 0; - int right = 0; - int top = 0; - int bottom = 0; - // When we have a scale the frame is painted on // the position of the backbone - otherwise we // need to introduce a margin around the canvas @@ -487,7 +530,6 @@ void QwtPlotRenderer::render( QwtPlot *plot, default: break; } - layoutRect.adjust( left, top, right, bottom ); } } } @@ -500,8 +542,7 @@ void QwtPlotRenderer::render( QwtPlot *plot, ( d_data->discardFlags & DiscardCanvasFrame ) ) { layoutOptions |= QwtPlotLayout::IgnoreFrames; - } - + } if ( d_data->discardFlags & DiscardLegend ) layoutOptions |= QwtPlotLayout::IgnoreLegend; @@ -591,18 +632,18 @@ void QwtPlotRenderer::render( QwtPlot *plot, \param plot Plot widget \param painter Painter - \param rect Bounding rectangle + \param titleRect Bounding rectangle for the title */ void QwtPlotRenderer::renderTitle( const QwtPlot *plot, - QPainter *painter, const QRectF &rect ) const + QPainter *painter, const QRectF &titleRect ) const { - painter->setFont( plot->titleLabel()->font() ); + painter->setFont( qwtResolvedFont( plot->titleLabel() ) ); const QColor color = plot->titleLabel()->palette().color( QPalette::Active, QPalette::Text ); painter->setPen( color ); - plot->titleLabel()->text().draw( painter, rect ); + plot->titleLabel()->text().draw( painter, titleRect ); } /*! @@ -610,35 +651,34 @@ void QwtPlotRenderer::renderTitle( const QwtPlot *plot, \param plot Plot widget \param painter Painter - \param rect Bounding rectangle + \param footerRect Bounding rectangle for the footer */ void QwtPlotRenderer::renderFooter( const QwtPlot *plot, - QPainter *painter, const QRectF &rect ) const + QPainter *painter, const QRectF &footerRect ) const { - painter->setFont( plot->footerLabel()->font() ); + painter->setFont( qwtResolvedFont( plot->footerLabel() ) ); const QColor color = plot->footerLabel()->palette().color( QPalette::Active, QPalette::Text ); painter->setPen( color ); - plot->footerLabel()->text().draw( painter, rect ); + plot->footerLabel()->text().draw( painter, footerRect ); } - /*! Render the legend into a given rectangle. \param plot Plot widget \param painter Painter - \param rect Bounding rectangle + \param legendRect Bounding rectangle for the legend */ void QwtPlotRenderer::renderLegend( const QwtPlot *plot, - QPainter *painter, const QRectF &rect ) const + QPainter *painter, const QRectF &legendRect ) const { if ( plot->legend() ) { bool fillBackground = !( d_data->discardFlags & DiscardBackground ); - plot->legend()->renderLegend( painter, rect, fillBackground ); + plot->legend()->renderLegend( painter, legendRect, fillBackground ); } } @@ -652,12 +692,12 @@ void QwtPlotRenderer::renderLegend( const QwtPlot *plot, \param startDist Start border distance \param endDist End border distance \param baseDist Base distance - \param rect Bounding rectangle + \param scaleRect Bounding rectangle for the scale */ void QwtPlotRenderer::renderScale( const QwtPlot *plot, QPainter *painter, int axisId, int startDist, int endDist, int baseDist, - const QRectF &rect ) const + const QRectF &scaleRect ) const { if ( !plot->axisEnabled( axisId ) ) return; @@ -666,7 +706,7 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot, if ( scaleWidget->isColorBarEnabled() && scaleWidget->colorBarWidth() > 0 ) { - scaleWidget->drawColorBar( painter, scaleWidget->colorBarRect( rect ) ); + scaleWidget->drawColorBar( painter, scaleWidget->colorBarRect( scaleRect ) ); baseDist += scaleWidget->colorBarWidth() + scaleWidget->spacing(); } @@ -679,33 +719,33 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot, { case QwtPlot::yLeft: { - x = rect.right() - 1.0 - baseDist; - y = rect.y() + startDist; - w = rect.height() - startDist - endDist; + x = scaleRect.right() - 1.0 - baseDist; + y = scaleRect.y() + startDist; + w = scaleRect.height() - startDist - endDist; align = QwtScaleDraw::LeftScale; break; } case QwtPlot::yRight: { - x = rect.left() + baseDist; - y = rect.y() + startDist; - w = rect.height() - startDist - endDist; + x = scaleRect.left() + baseDist; + y = scaleRect.y() + startDist; + w = scaleRect.height() - startDist - endDist; align = QwtScaleDraw::RightScale; break; } case QwtPlot::xTop: { - x = rect.left() + startDist; - y = rect.bottom() - 1.0 - baseDist; - w = rect.width() - startDist - endDist; + x = scaleRect.left() + startDist; + y = scaleRect.bottom() - 1.0 - baseDist; + w = scaleRect.width() - startDist - endDist; align = QwtScaleDraw::TopScale; break; } case QwtPlot::xBottom: { - x = rect.left() + startDist; - y = rect.top() + baseDist; - w = rect.width() - startDist - endDist; + x = scaleRect.left() + startDist; + y = scaleRect.top() + baseDist; + w = scaleRect.width() - startDist - endDist; align = QwtScaleDraw::BottomScale; break; } @@ -713,9 +753,9 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot, return; } - scaleWidget->drawTitle( painter, align, rect ); + scaleWidget->drawTitle( painter, align, scaleRect ); - painter->setFont( scaleWidget->font() ); + painter->setFont( qwtResolvedFont( scaleWidget ) ); QwtScaleDraw *sd = const_cast( scaleWidget->scaleDraw() ); const QPointF sdPos = sd->pos(); @@ -740,12 +780,12 @@ void QwtPlotRenderer::renderScale( const QwtPlot *plot, \param plot Plot widget \param painter Painter - \param map Maps mapping between plot and paint device coordinates + \param maps Maps mapping between plot and paint device coordinates \param canvasRect Canvas rectangle */ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, - QPainter *painter, const QRectF &canvasRect, - const QwtScaleMap *map ) const + QPainter *painter, const QRectF &canvasRect, + const QwtScaleMap *maps ) const { const QWidget *canvas = plot->canvas(); @@ -771,7 +811,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, painter->save(); painter->setClipRect( canvasRect ); - plot->drawItems( painter, canvasRect, map ); + plot->drawItems( painter, canvasRect, maps ); painter->restore(); } @@ -795,7 +835,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, else painter->setClipPath( clipPath ); - plot->drawItems( painter, canvasRect, map ); + plot->drawItems( painter, canvasRect, maps ); painter->restore(); } @@ -814,7 +854,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, clipPath = qwtCanvasClip( canvas, canvasRect ); } - QRectF innerRect = canvasRect.adjusted( + QRectF innerRect = canvasRect.adjusted( frameWidth, frameWidth, -frameWidth, -frameWidth ); painter->save(); @@ -833,7 +873,7 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, QwtPainter::drawBackgound( painter, innerRect, canvas ); } - plot->drawItems( painter, innerRect, map ); + plot->drawItems( painter, innerRect, maps ); painter->restore(); @@ -845,17 +885,14 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, canvas->property( "frameShadow" ).toInt() | canvas->property( "frameShape" ).toInt(); - const int frameWidth = canvas->property( "frameWidth" ).toInt(); - - const QVariant borderRadius = canvas->property( "borderRadius" ); - if ( borderRadius.type() == QVariant::Double + if ( borderRadius.type() == QVariant::Double && borderRadius.toDouble() > 0.0 ) { - const double r = borderRadius.toDouble(); + const double radius = borderRadius.toDouble(); QwtPainter::drawRoundedFrame( painter, canvasRect, - r, r, canvas->palette(), frameWidth, frameStyle ); + radius, radius, canvas->palette(), frameWidth, frameStyle ); } else { @@ -933,7 +970,7 @@ bool QwtPlotRenderer::updateCanvasMargins( QwtPlot *plot, { double margins[QwtPlot::axisCnt]; plot->getCanvasMarginsHint( maps, canvasRect, - margins[QwtPlot::yLeft], margins[QwtPlot::xTop], + margins[QwtPlot::yLeft], margins[QwtPlot::xTop], margins[QwtPlot::yRight], margins[QwtPlot::xBottom] ); bool marginsChanged = false; @@ -963,29 +1000,29 @@ bool QwtPlotRenderer::updateCanvasMargins( QwtPlot *plot, */ bool QwtPlotRenderer::exportTo( QwtPlot *plot, const QString &documentName, const QSizeF &sizeMM, int resolution ) -{ +{ if ( plot == NULL ) return false; - + QString fileName = documentName; - // What about translation + // What about translation #ifndef QT_NO_FILEDIALOG const QList imageFormats = QImageWriter::supportedImageFormats(); - + QStringList filter; -#ifndef QT_NO_PRINTER +#if QWT_FORMAT_PDF filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)"; #endif -#ifndef QWT_NO_SVG +#if QWT_FORMAT_SVG filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)"; #endif -#ifndef QT_NO_PRINTER +#if QWT_FORMAT_POSTSCRIPT filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)"; #endif - + if ( imageFormats.size() > 0 ) { QString imageFilter( tr( "Images" ) ); @@ -994,22 +1031,22 @@ bool QwtPlotRenderer::exportTo( QwtPlot *plot, const QString &documentName, { if ( i > 0 ) imageFilter += " "; - imageFilter += "*."; + imageFilter += "*."; imageFilter += imageFormats[i]; - } + } imageFilter += ")"; - + filter += imageFilter; - } - + } + fileName = QFileDialog::getSaveFileName( NULL, tr( "Export File Name" ), fileName, filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); -#endif +#endif if ( fileName.isEmpty() ) return false; renderDocument( plot, fileName, sizeMM, resolution ); return true; -} +} diff --git a/qwtdemo/qwt/qwt_plot_renderer.h b/qwtdemo/qwt/qwt_plot_renderer.h index 68ffcd1..e653d81 100644 --- a/qwtdemo/qwt/qwt_plot_renderer.h +++ b/qwtdemo/qwt/qwt_plot_renderer.h @@ -60,7 +60,7 @@ public: //! Don't render the footer of the plot DiscardFooter = 0x10, - /*! + /*! Don't render the frame of the canvas \note This flag has no effect when using @@ -127,27 +127,27 @@ public: void renderTo( QwtPlot *, QPrinter & ) const; #endif - void renderTo( QwtPlot *, QPaintDevice &p ) const; + void renderTo( QwtPlot *, QPaintDevice & ) const; virtual void render( QwtPlot *, - QPainter *, const QRectF &rect ) const; + QPainter *, const QRectF &plotRect ) const; virtual void renderTitle( const QwtPlot *, - QPainter *, const QRectF & ) const; + QPainter *, const QRectF &titleRect ) const; virtual void renderFooter( const QwtPlot *, - QPainter *, const QRectF & ) const; + QPainter *, const QRectF &footerRect ) const; virtual void renderScale( const QwtPlot *, QPainter *, int axisId, int startDist, int endDist, - int baseDist, const QRectF & ) const; + int baseDist, const QRectF &scaleRect ) const; virtual void renderCanvas( const QwtPlot *, QPainter *, const QRectF &canvasRect, const QwtScaleMap* maps ) const; - virtual void renderLegend( - const QwtPlot *, QPainter *, const QRectF & ) const; + virtual void renderLegend( + const QwtPlot *, QPainter *, const QRectF &legendRect ) const; bool exportTo( QwtPlot *, const QString &documentName, const QSizeF &sizeMM = QSizeF( 300, 200 ), int resolution = 85 ); diff --git a/qwtdemo/qwt/qwt_plot_rescaler.h b/qwtdemo/qwt/qwt_plot_rescaler.h index 0a4890f..72032e1 100644 --- a/qwtdemo/qwt/qwt_plot_rescaler.h +++ b/qwtdemo/qwt/qwt_plot_rescaler.h @@ -116,7 +116,7 @@ protected: virtual void canvasResizeEvent( QResizeEvent * ); virtual void rescale( const QSize &oldSize, const QSize &newSize ) const; - virtual QwtInterval expandScale( + virtual QwtInterval expandScale( int axis, const QSize &oldSize, const QSize &newSize ) const; virtual QwtInterval syncScale( diff --git a/qwtdemo/qwt/qwt_plot_scaleitem.cpp b/qwtdemo/qwt/qwt_plot_scaleitem.cpp index 212f8de..1471aff 100644 --- a/qwtdemo/qwt/qwt_plot_scaleitem.cpp +++ b/qwtdemo/qwt/qwt_plot_scaleitem.cpp @@ -349,7 +349,7 @@ void QwtPlotScaleItem::draw( QPainter *painter, if ( d_data->scaleDivFromAxis ) { - const QwtInterval interval = + const QwtInterval interval = d_data->scaleInterval( canvasRect, xMap, yMap ); if ( interval != sd->scaleDiv().interval() ) @@ -447,7 +447,7 @@ void QwtPlotScaleItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv, if ( d_data->scaleDivFromAxis && scaleDraw ) { - const QwtScaleDiv &scaleDiv = + const QwtScaleDiv &scaleDiv = scaleDraw->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv; const QwtPlot *plt = plot(); @@ -455,7 +455,7 @@ void QwtPlotScaleItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv, { const QRectF canvasRect = plt->canvas()->contentsRect(); - const QwtInterval interval = d_data->scaleInterval( + const QwtInterval interval = d_data->scaleInterval( canvasRect, plt->canvasMap( xAxis() ), plt->canvasMap( yAxis() ) ); QwtScaleDiv sd = scaleDiv; diff --git a/qwtdemo/qwt/qwt_plot_scaleitem.h b/qwtdemo/qwt/qwt_plot_scaleitem.h index ead67a3..a40a3c5 100644 --- a/qwtdemo/qwt/qwt_plot_scaleitem.h +++ b/qwtdemo/qwt/qwt_plot_scaleitem.h @@ -32,16 +32,16 @@ class QPalette; aligned to a canvas border. \par Example - The following example shows how to replace the left axis, by a scale item - at the x position 0.0. - \verbatim -QwtPlotScaleItem *scaleItem = - new QwtPlotScaleItem(QwtScaleDraw::RightScale, 0.0); -scaleItem->setFont(plot->axisWidget(QwtPlot::yLeft)->font()); -scaleItem->attach(plot); + The following example shows how to replace the left axis, by a scale item + at the x position 0.0. + \code + QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem( QwtScaleDraw::RightScale, 0.0 ); + scaleItem->setFont( plot->axisWidget( QwtPlot::yLeft )->font() ); + scaleItem->attach(plot); -plot->enableAxis(QwtPlot::yLeft, false); -\endverbatim + plot->enableAxis( QwtPlot::yLeft, false ); + \endcode + \endpar */ class QWT_EXPORT QwtPlotScaleItem: public QwtPlotItem @@ -75,14 +75,14 @@ public: void setPosition( double pos ); double position() const; - void setBorderDistance( int numPixels ); + void setBorderDistance( int ); int borderDistance() const; void setAlignment( QwtScaleDraw::Alignment ); - virtual void draw( QPainter *p, + virtual void draw( QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &rect ) const; + const QRectF &canvasRect ) const; virtual void updateScaleDiv( const QwtScaleDiv &, const QwtScaleDiv & ); diff --git a/qwtdemo/qwt/qwt_plot_seriesitem.cpp b/qwtdemo/qwt/qwt_plot_seriesitem.cpp index e5007ef..715aee1 100644 --- a/qwtdemo/qwt/qwt_plot_seriesitem.cpp +++ b/qwtdemo/qwt/qwt_plot_seriesitem.cpp @@ -39,6 +39,7 @@ QwtPlotSeriesItem::QwtPlotSeriesItem( const QString &title ): QwtPlotItem( QwtText( title ) ) { d_data = new PrivateData(); + setItemInterest( QwtPlotItem::ScaleInterest, true ); } //! Destructor @@ -98,13 +99,13 @@ QRectF QwtPlotSeriesItem::boundingRect() const void QwtPlotSeriesItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv ) -{ +{ const QRectF rect = QRectF( xScaleDiv.lowerBound(), yScaleDiv.lowerBound(), xScaleDiv.range(), yScaleDiv.range() ); - + setRectOfInterest( rect ); -} +} void QwtPlotSeriesItem::dataChanged() { diff --git a/qwtdemo/qwt/qwt_plot_seriesitem.h b/qwtdemo/qwt/qwt_plot_seriesitem.h index f58334a..98f974d 100644 --- a/qwtdemo/qwt/qwt_plot_seriesitem.h +++ b/qwtdemo/qwt/qwt_plot_seriesitem.h @@ -23,7 +23,7 @@ class QWT_EXPORT QwtPlotSeriesItem: public QwtPlotItem, public virtual QwtAbstractSeriesStore { public: - explicit QwtPlotSeriesItem( const QString &title = QString::null ); + explicit QwtPlotSeriesItem( const QString &title = QString() ); explicit QwtPlotSeriesItem( const QwtText &title ); virtual ~QwtPlotSeriesItem(); @@ -31,7 +31,7 @@ public: void setOrientation( Qt::Orientation ); Qt::Orientation orientation() const; - virtual void draw( QPainter *p, + virtual void draw( QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF & ) const; @@ -52,7 +52,7 @@ public: virtual QRectF boundingRect() const; - virtual void updateScaleDiv( + virtual void updateScaleDiv( const QwtScaleDiv &, const QwtScaleDiv & ); protected: diff --git a/qwtdemo/qwt/qwt_plot_shapeitem.cpp b/qwtdemo/qwt/qwt_plot_shapeitem.cpp index 6415e93..db7896b 100644 --- a/qwtdemo/qwt/qwt_plot_shapeitem.cpp +++ b/qwtdemo/qwt/qwt_plot_shapeitem.cpp @@ -207,7 +207,7 @@ QRectF QwtPlotShapeItem::boundingRect() const \param rect Rectangle \sa setShape(), setPolygon(), shape() */ -void QwtPlotShapeItem::setRect( const QRectF &rect ) +void QwtPlotShapeItem::setRect( const QRectF &rect ) { QPainterPath path; path.addRect( rect ); @@ -262,21 +262,21 @@ QPainterPath QwtPlotShapeItem::shape() const return d_data->shape; } -/*! +/*! 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 QwtPlotShapeItem::setPen( const QColor &color, qreal width, Qt::PenStyle style ) -{ +{ setPen( QPen( color, width, style ) ); } @@ -335,7 +335,7 @@ QBrush QwtPlotShapeItem::brush() const /*! \brief Set the tolerance for the weeding optimization - After translating the shape into target device coordinate + After translating the shape into target device coordinate ( usually widget geometries ) the painter path can be simplified by a point weeding algorithm ( Douglas-Peucker ). @@ -383,7 +383,7 @@ void QwtPlotShapeItem::draw( QPainter *painter, if ( d_data->shape.isEmpty() ) return; - if ( d_data->pen.style() == Qt::NoPen + if ( d_data->pen.style() == Qt::NoPen && d_data->brush.style() == Qt::NoBrush ) { return; @@ -403,7 +403,7 @@ void QwtPlotShapeItem::draw( QPainter *painter, const bool doAlign = QwtPainter::roundingAlignment( painter ); - QPainterPath path = qwtTransformPath( xMap, yMap, + QPainterPath path = qwtTransformPath( xMap, yMap, d_data->shape, doAlign ); if ( testPaintAttribute( QwtPlotShapeItem::ClipPolygons ) ) @@ -450,7 +450,7 @@ void QwtPlotShapeItem::draw( QPainter *painter, /*! \return A rectangle filled with the color of the brush ( or the pen ) - \param index Index of the legend entry + \param index Index of the legend entry ( usually there is only one ) \param size Icon size diff --git a/qwtdemo/qwt/qwt_plot_shapeitem.h b/qwtdemo/qwt/qwt_plot_shapeitem.h index 76f78a1..964882c 100644 --- a/qwtdemo/qwt/qwt_plot_shapeitem.h +++ b/qwtdemo/qwt/qwt_plot_shapeitem.h @@ -15,7 +15,7 @@ #include /*! - \brief A plot item, which displays any graphical shape, + \brief A plot item, which displays any graphical shape, that can be defined by a QPainterPath A QPainterPath is a shape composed from intersecting and uniting @@ -60,11 +60,11 @@ public: //! Display a scaled down version of the shape LegendShape, - //! Display a filled rectangle + //! Display a filled rectangle LegendColor }; - explicit QwtPlotShapeItem( const QString &title = QString::null ); + explicit QwtPlotShapeItem( const QString &title = QString() ); explicit QwtPlotShapeItem( const QwtText &title ); virtual ~QwtPlotShapeItem(); @@ -93,9 +93,9 @@ public: virtual QRectF boundingRect() const; - virtual void draw( QPainter *p, + virtual void draw( QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &rect ) const; + const QRectF &canvasRect ) const; virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; diff --git a/qwtdemo/qwt/qwt_plot_spectrocurve.cpp b/qwtdemo/qwt/qwt_plot_spectrocurve.cpp index 5a2a023..d948d14 100644 --- a/qwtdemo/qwt/qwt_plot_spectrocurve.cpp +++ b/qwtdemo/qwt/qwt_plot_spectrocurve.cpp @@ -117,19 +117,19 @@ void QwtPlotSpectroCurve::setSamples( const QVector &samples ) /*! 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. + it when its not used anymore. */ void QwtPlotSpectroCurve::setSamples( QwtSeriesData *data ) { setData( data ); -} +} /*! Change the color map @@ -310,7 +310,7 @@ void QwtPlotSpectroCurve::drawDots( QPainter *painter, const unsigned char index = d_data->colorMap->colorIndex( d_data->colorRange, sample.z() ); - painter->setPen( QPen( QColor::fromRgba( d_data->colorTable[index] ), + painter->setPen( QPen( QColor::fromRgba( d_data->colorTable[index] ), d_data->penWidth ) ); } diff --git a/qwtdemo/qwt/qwt_plot_spectrocurve.h b/qwtdemo/qwt/qwt_plot_spectrocurve.h index 1972c3e..8f3b45f 100644 --- a/qwtdemo/qwt/qwt_plot_spectrocurve.h +++ b/qwtdemo/qwt/qwt_plot_spectrocurve.h @@ -21,7 +21,7 @@ class QwtColorMap; \brief Curve that displays 3D points as dots, where the z coordinate is mapped to a color. */ -class QWT_EXPORT QwtPlotSpectroCurve: +class QWT_EXPORT QwtPlotSpectroCurve: public QwtPlotSeriesItem, QwtSeriesStore { public: @@ -35,7 +35,7 @@ public: //! Paint attributes typedef QFlags PaintAttributes; - explicit QwtPlotSpectroCurve( const QString &title = QString::null ); + explicit QwtPlotSpectroCurve( const QString &title = QString() ); explicit QwtPlotSpectroCurve( const QwtText &title ); virtual ~QwtPlotSpectroCurve(); @@ -59,7 +59,7 @@ public: const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to ) const; - void setPenWidth(double width); + void setPenWidth( double ); double penWidth() const; protected: diff --git a/qwtdemo/qwt/qwt_plot_spectrogram.cpp b/qwtdemo/qwt/qwt_plot_spectrogram.cpp index e7a9fec..10657de 100644 --- a/qwtdemo/qwt/qwt_plot_spectrogram.cpp +++ b/qwtdemo/qwt/qwt_plot_spectrogram.cpp @@ -161,22 +161,22 @@ const QwtColorMap *QwtPlotSpectrogram::colorMap() const return d_data->colorMap; } -/*! +/*! Build and assign the default pen for the contour lines - + 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 QwtPlotSpectrogram::setDefaultContourPen( + */ +void QwtPlotSpectrogram::setDefaultContourPen( const QColor &color, qreal width, Qt::PenStyle style ) -{ +{ setDefaultContourPen( QPen( color, width, style ) ); } @@ -362,7 +362,7 @@ QwtInterval QwtPlotSpectrogram::interval(Qt::Axis axis) const \brief Pixel hint The geometry of a pixel is used to calculated the resolution and - alignment of the rendered image. + alignment of the rendered image. The default implementation returns data()->pixelHint( rect ); @@ -371,7 +371,7 @@ QwtInterval QwtPlotSpectrogram::interval(Qt::Axis axis) const \return Bounding rectangle of a pixel - \sa QwtPlotRasterItem::pixelHint(), QwtRasterData::pixelHint(), + \sa QwtPlotRasterItem::pixelHint(), QwtRasterData::pixelHint(), render(), renderImage() */ QRectF QwtPlotSpectrogram::pixelHint( const QRectF &area ) const @@ -402,7 +402,7 @@ QImage QwtPlotSpectrogram::renderImage( const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &imageSize ) const { - if ( imageSize.isEmpty() || d_data->data == NULL + if ( imageSize.isEmpty() || d_data->data == NULL || d_data->colorMap == NULL ) { return QImage(); @@ -546,7 +546,7 @@ void QwtPlotSpectrogram::renderTile( \sa drawContourLines(), QwtRasterData::contourLines() */ -QSize QwtPlotSpectrogram::contourRasterSize( +QSize QwtPlotSpectrogram::contourRasterSize( const QRectF &area, const QRect &rect ) const { QSize raster = rect.size() / 2; diff --git a/qwtdemo/qwt/qwt_plot_spectrogram.h b/qwtdemo/qwt/qwt_plot_spectrogram.h index 1aa6989..2ae7d29 100644 --- a/qwtdemo/qwt/qwt_plot_spectrogram.h +++ b/qwtdemo/qwt/qwt_plot_spectrogram.h @@ -55,7 +55,7 @@ public: //! Display modes typedef QFlags DisplayModes; - explicit QwtPlotSpectrogram( const QString &title = QString::null ); + explicit QwtPlotSpectrogram( const QString &title = QString() ); virtual ~QwtPlotSpectrogram(); void setDisplayMode( DisplayMode, bool on = true ); @@ -71,7 +71,7 @@ public: virtual QwtInterval interval(Qt::Axis) const; virtual QRectF pixelHint( const QRectF & ) const; - void setDefaultContourPen( const QColor &, + void setDefaultContourPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); void setDefaultContourPen( const QPen & ); QPen defaultContourPen() const; @@ -86,9 +86,9 @@ public: virtual int rtti() const; - virtual void draw( QPainter *p, + virtual void draw( QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &rect ) const; + const QRectF &canvasRect ) const; protected: virtual QImage renderImage( @@ -101,12 +101,12 @@ protected: virtual QwtRasterData::ContourLines renderContourLines( const QRectF &rect, const QSize &raster ) const; - virtual void drawContourLines( QPainter *p, + virtual void drawContourLines( QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtRasterData::ContourLines& lines ) const; + const QwtRasterData::ContourLines& ) const; void renderTile( const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRect &imageRect, QImage *image ) const; + const QRect &tile, QImage * ) const; private: class PrivateData; diff --git a/qwtdemo/qwt/qwt_plot_svgitem.cpp b/qwtdemo/qwt/qwt_plot_svgitem.cpp new file mode 100644 index 0000000..dd318da --- /dev/null +++ b/qwtdemo/qwt/qwt_plot_svgitem.cpp @@ -0,0 +1,219 @@ +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** + * Qwt Widget Library + * Copyright (C) 1997 Josef Wilgen + * Copyright (C) 2002 Uwe Rathmann + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the Qwt License, Version 1.0 + *****************************************************************************/ + +#include "qwt_plot_svgitem.h" +#include "qwt_scale_map.h" +#include "qwt_painter.h" +#include +#include + +class QwtPlotSvgItem::PrivateData +{ +public: + PrivateData() + { + } + + QRectF boundingRect; + QSvgRenderer renderer; +}; + +/*! + \brief Constructor + + Sets the following item attributes: + - QwtPlotItem::AutoScale: true + - QwtPlotItem::Legend: false + + \param title Title +*/ +QwtPlotSvgItem::QwtPlotSvgItem( const QString& title ): + QwtPlotItem( QwtText( title ) ) +{ + init(); +} + +/*! + \brief Constructor + + Sets the following item attributes: + - QwtPlotItem::AutoScale: true + - QwtPlotItem::Legend: false + + \param title Title +*/ +QwtPlotSvgItem::QwtPlotSvgItem( const QwtText& title ): + QwtPlotItem( title ) +{ + init(); +} + +//! Destructor +QwtPlotSvgItem::~QwtPlotSvgItem() +{ + delete d_data; +} + +void QwtPlotSvgItem::init() +{ + d_data = new PrivateData(); + d_data->boundingRect = QwtPlotItem::boundingRect(); + + setItemAttribute( QwtPlotItem::AutoScale, true ); + setItemAttribute( QwtPlotItem::Legend, false ); + + setZ( 8.0 ); +} + +//! \return QwtPlotItem::Rtti_PlotSVG +int QwtPlotSvgItem::rtti() const +{ + return QwtPlotItem::Rtti_PlotSVG; +} + +/*! + Load a SVG file + + \param rect Bounding rectangle + \param fileName SVG file name + + \return true, if the SVG file could be loaded +*/ +bool QwtPlotSvgItem::loadFile( const QRectF &rect, + const QString &fileName ) +{ + d_data->boundingRect = rect; + const bool ok = d_data->renderer.load( fileName ); + + legendChanged(); + itemChanged(); + + return ok; +} + +/*! + Load SVG data + + \param rect Bounding rectangle + \param data in SVG format + + \return true, if the SVG data could be loaded +*/ +bool QwtPlotSvgItem::loadData( const QRectF &rect, + const QByteArray &data ) +{ + d_data->boundingRect = rect; + const bool ok = d_data->renderer.load( data ); + + legendChanged(); + itemChanged(); + + return ok; +} + +//! Bounding rectangle of the item +QRectF QwtPlotSvgItem::boundingRect() const +{ + return d_data->boundingRect; +} + +//! \return Renderer used to render the SVG data +const QSvgRenderer &QwtPlotSvgItem::renderer() const +{ + return d_data->renderer; +} + +//! \return Renderer used to render the SVG data +QSvgRenderer &QwtPlotSvgItem::renderer() +{ + return d_data->renderer; +} + +/*! + Draw the SVG item + + \param painter Painter + \param xMap X-Scale Map + \param yMap Y-Scale Map + \param canvasRect Contents rect of the plot canvas +*/ +void QwtPlotSvgItem::draw( QPainter *painter, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect ) const +{ + const QRectF cRect = QwtScaleMap::invTransform( + xMap, yMap, canvasRect.toRect() ); + const QRectF bRect = boundingRect(); + if ( bRect.isValid() && cRect.isValid() ) + { + QRectF rect = bRect; + if ( bRect.contains( cRect ) ) + rect = cRect; + + const QRectF r = QwtScaleMap::transform( xMap, yMap, rect ); + render( painter, viewBox( rect ), r ); + } +} + +/*! + Render the SVG data + + \param painter Painter + \param viewBox View Box, see QSvgRenderer::viewBox() + \param rect Target rectangle on the paint device +*/ +void QwtPlotSvgItem::render( QPainter *painter, + const QRectF &viewBox, const QRectF &rect ) const +{ + if ( !viewBox.isValid() ) + return; + + QRectF r = rect; + + if ( QwtPainter::roundingAlignment( painter ) ) + { + r.setLeft ( qRound( r.left() ) ); + r.setRight ( qRound( r.right() ) ); + r.setTop ( qRound( r.top() ) ); + r.setBottom ( qRound( r.bottom() ) ); + } + + d_data->renderer.setViewBox( viewBox ); + d_data->renderer.render( painter, r ); +} + +/*! + Calculate the view box from rect and boundingRect(). + + \param rect Rectangle in scale coordinates + \return View box, see QSvgRenderer::viewBox() +*/ +QRectF QwtPlotSvgItem::viewBox( const QRectF &rect ) const +{ + const QSize sz = d_data->renderer.defaultSize(); + const QRectF br = boundingRect(); + + if ( !rect.isValid() || !br.isValid() || sz.isNull() ) + return QRectF(); + + QwtScaleMap xMap; + xMap.setScaleInterval( br.left(), br.right() ); + xMap.setPaintInterval( 0, sz.width() ); + + QwtScaleMap yMap; + yMap.setScaleInterval( br.top(), br.bottom() ); + yMap.setPaintInterval( sz.height(), 0 ); + + const double x1 = xMap.transform( rect.left() ); + const double x2 = xMap.transform( rect.right() ); + const double y1 = yMap.transform( rect.bottom() ); + const double y2 = yMap.transform( rect.top() ); + + return QRectF( x1, y1, x2 - x1, y2 - y1 ); +} diff --git a/qwtdemo/qwt/qwt_plot_svgitem.h b/qwtdemo/qwt/qwt_plot_svgitem.h new file mode 100644 index 0000000..a7cd029 --- /dev/null +++ b/qwtdemo/qwt/qwt_plot_svgitem.h @@ -0,0 +1,61 @@ +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** + * Qwt Widget Library + * Copyright (C) 1997 Josef Wilgen + * Copyright (C) 2002 Uwe Rathmann + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the Qwt License, Version 1.0 + *****************************************************************************/ + +#ifndef QWT_PLOT_SVGITEM_H +#define QWT_PLOT_SVGITEM_H + +#include "qwt_global.h" +#include "qwt_plot_item.h" +#include + +class QSvgRenderer; +class QByteArray; + +/*! + \brief A plot item, which displays + data in Scalable Vector Graphics (SVG) format. + + SVG images are often used to display maps +*/ + +class QWT_EXPORT QwtPlotSvgItem: public QwtPlotItem +{ +public: + explicit QwtPlotSvgItem( const QString& title = QString() ); + explicit QwtPlotSvgItem( const QwtText& title ); + virtual ~QwtPlotSvgItem(); + + bool loadFile( const QRectF&, const QString &fileName ); + bool loadData( const QRectF&, const QByteArray & ); + + virtual QRectF boundingRect() const; + + virtual void draw( QPainter *, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect ) const; + + virtual int rtti() const; + +protected: + const QSvgRenderer &renderer() const; + QSvgRenderer &renderer(); + + void render( QPainter *, + const QRectF &viewBox, const QRectF &rect ) const; + + QRectF viewBox( const QRectF &rect ) const; + +private: + void init(); + + class PrivateData; + PrivateData *d_data; +}; + +#endif diff --git a/qwtdemo/qwt/qwt_plot_textlabel.cpp b/qwtdemo/qwt/qwt_plot_textlabel.cpp index 6308e27..5fee659 100644 --- a/qwtdemo/qwt/qwt_plot_textlabel.cpp +++ b/qwtdemo/qwt/qwt_plot_textlabel.cpp @@ -15,7 +15,7 @@ #include static QRect qwtItemRect( int renderFlags, - const QRectF &rect, const QSizeF &itemSize ) + const QRectF &rect, const QSizeF &itemSize ) { int x; if ( renderFlags & Qt::AlignLeft ) @@ -32,7 +32,7 @@ static QRect qwtItemRect( int renderFlags, } int y; - if ( renderFlags & Qt::AlignTop ) + if ( renderFlags & Qt::AlignTop ) { y = rect.top(); } @@ -49,7 +49,7 @@ static QRect qwtItemRect( int renderFlags, } class QwtPlotTextLabel::PrivateData -{ +{ public: PrivateData(): margin( 5 ) @@ -60,7 +60,7 @@ public: int margin; QPixmap pixmap; -}; +}; /*! \brief Constructor @@ -101,7 +101,7 @@ int QwtPlotTextLabel::rtti() const } /*! - Set the text + Set the text The label will be aligned to the plot canvas according to the alignment flags of text. @@ -210,12 +210,12 @@ void QwtPlotTextLabel::draw( QPainter *painter, if ( d_data->text.borderPen().style() != Qt::NoPen ) pw = qMax( d_data->text.borderPen().width(), 1 ); - QRect pixmapRect; + QRect pixmapRect; pixmapRect.setLeft( qFloor( rect.left() ) - pw ); pixmapRect.setTop( qFloor( rect.top() ) - pw ); pixmapRect.setRight( qCeil( rect.right() ) + pw ); pixmapRect.setBottom( qCeil( rect.bottom() ) + pw ); - + #define QWT_HIGH_DPI 1 #if QT_VERSION >= 0x050100 && QWT_HIGH_DPI @@ -224,7 +224,7 @@ void QwtPlotTextLabel::draw( QPainter *painter, #else const QSize scaledSize = pixmapRect.size(); #endif - if ( d_data->pixmap.isNull() || + if ( d_data->pixmap.isNull() || ( scaledSize != d_data->pixmap.size() ) ) { d_data->pixmap = QPixmap( scaledSize ); @@ -233,7 +233,7 @@ void QwtPlotTextLabel::draw( QPainter *painter, #endif d_data->pixmap.fill( Qt::transparent ); - const QRect r( pw, pw, + const QRect r( pw, pw, pixmapRect.width() - 2 * pw, pixmapRect.height() - 2 * pw ); QPainter pmPainter( &d_data->pixmap ); @@ -259,7 +259,7 @@ void QwtPlotTextLabel::draw( QPainter *painter, \sa setMargin(), QwtText::renderFlags(), QwtText::textSize() */ -QRectF QwtPlotTextLabel::textRect( +QRectF QwtPlotTextLabel::textRect( const QRectF &rect, const QSizeF &textSize ) const { return qwtItemRect( d_data->text.renderFlags(), rect, textSize ); diff --git a/qwtdemo/qwt/qwt_plot_textlabel.h b/qwtdemo/qwt/qwt_plot_textlabel.h index c7b8496..6fbe6ca 100644 --- a/qwtdemo/qwt/qwt_plot_textlabel.h +++ b/qwtdemo/qwt/qwt_plot_textlabel.h @@ -21,28 +21,28 @@ In opposite to QwtPlotMarker the position of the label is unrelated to plot coordinates. - + As drawing a text is an expensive operation the label is cached in a pixmap to speed up replots. \par Example - The following code shows how to add a title. + The following code shows how to add a title. + \code + QwtText title( "Plot Title" ); + title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop ); -\verbatim - QwtText title( "Plot Title" ); - title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop ); + QFont font; + font.setBold( true ); + title.setFont( font ); - QFont font; - font.setBold( true ); - title.setFont( font ); - - QwtPlotTextLabel *titleItem = new QwtPlotTextLabel(); - titleItem->setText( title ); - titleItem->attach( this ); -\endverbatim + QwtPlotTextLabel *titleItem = new QwtPlotTextLabel(); + titleItem->setText( title ); + titleItem->attach( plot ); + \endcode + \endpar \sa QwtPlotMarker -*/ +*/ class QWT_EXPORT QwtPlotTextLabel: public QwtPlotItem { diff --git a/qwtdemo/qwt/qwt_plot_tradingcurve.cpp b/qwtdemo/qwt/qwt_plot_tradingcurve.cpp index 04d877b..fdaf38a 100644 --- a/qwtdemo/qwt/qwt_plot_tradingcurve.cpp +++ b/qwtdemo/qwt/qwt_plot_tradingcurve.cpp @@ -134,19 +134,19 @@ void QwtPlotTradingCurve::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. + it when its not used anymore. */ void QwtPlotTradingCurve::setSamples( QwtSeriesData *data ) { setData( data ); -} +} /*! Set the symbol style @@ -176,22 +176,22 @@ QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle() const return d_data->symbolStyle; } -/*! +/*! Build and assign the symbol 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 QwtPlotTradingCurve::setSymbolPen( + */ +void QwtPlotTradingCurve::setSymbolPen( const QColor &color, qreal width, Qt::PenStyle style ) -{ +{ setSymbolPen( QPen( color, width, style ) ); } @@ -235,12 +235,14 @@ QPen QwtPlotTradingCurve::symbolPen() const void QwtPlotTradingCurve::setSymbolBrush( Direction direction, const QBrush &brush ) { - if ( direction < 0 || direction >= 2 ) + // silencing -Wtautological-constant-out-of-range-compare + const int index = static_cast< int >( direction ); + if ( index < 0 || index >= 2 ) return; - if ( brush != d_data->symbolBrush[ direction ] ) + if ( brush != d_data->symbolBrush[ index ] ) { - d_data->symbolBrush[ direction ] = brush; + d_data->symbolBrush[ index ] = brush; legendChanged(); itemChanged(); @@ -256,10 +258,11 @@ void QwtPlotTradingCurve::setSymbolBrush( */ QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const { - if ( direction < 0 || direction >= 2 ) + const int index = static_cast< int >( direction ); + if ( index < 0 || index >= 2 ) return QBrush(); - return d_data->symbolBrush[ direction ]; + return d_data->symbolBrush[ index ]; } /*! @@ -272,7 +275,7 @@ QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const \param extent Symbol width in scale coordinates - \sa symbolExtent(), scaledSymbolWidth(), + \sa symbolExtent(), scaledSymbolWidth(), setMinSymbolWidth(), setMaxSymbolWidth() */ void QwtPlotTradingCurve::setSymbolExtent( double extent ) @@ -337,7 +340,7 @@ void QwtPlotTradingCurve::setMaxSymbolWidth( double width ) if ( width != d_data->maxSymbolWidth ) { d_data->maxSymbolWidth = width; - + legendChanged(); itemChanged(); } @@ -359,7 +362,7 @@ double QwtPlotTradingCurve::maxSymbolWidth() const QRectF QwtPlotTradingCurve::boundingRect() const { QRectF rect = QwtPlotSeriesItem::boundingRect(); - if ( rect.isValid() && orientation() == Qt::Vertical ) + if ( orientation() == Qt::Vertical ) rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); return rect; @@ -486,14 +489,14 @@ void QwtPlotTradingCurve::drawSymbols( QPainter *painter, { case Bar: { - drawBar( painter, translatedSample, + drawBar( painter, translatedSample, orient, inverted, symbolWidth ); break; } case CandleStick: { painter->setBrush( d_data->symbolBrush[ brushIndex ] ); - drawCandleStick( painter, translatedSample, + drawCandleStick( painter, translatedSample, orient, symbolWidth ); break; } @@ -520,7 +523,7 @@ void QwtPlotTradingCurve::drawSymbols( QPainter *painter, \param symbolStyle Symbol style \param sample Samples already translated into paint device coordinates \param orientation Vertical or horizontal - \param inverted True, when the opposite scale + \param inverted True, when the opposite scale ( Qt::Vertical: x, Qt::Horizontal: y ) is increasing in the opposite direction as QPainter coordinates. \param symbolWidth Width of the symbol in paint device coordinates @@ -554,7 +557,7 @@ void QwtPlotTradingCurve::drawUserSymbol( QPainter *painter, \sa Bar */ void QwtPlotTradingCurve::drawBar( QPainter *painter, - const QwtOHLCSample &sample, Qt::Orientation orientation, + const QwtOHLCSample &sample, Qt::Orientation orientation, bool inverted, double width ) const { double w2 = 0.5 * width; @@ -593,7 +596,7 @@ void QwtPlotTradingCurve::drawBar( QPainter *painter, \sa CandleStick */ void QwtPlotTradingCurve::drawCandleStick( QPainter *painter, - const QwtOHLCSample &sample, Qt::Orientation orientation, + const QwtOHLCSample &sample, Qt::Orientation orientation, double width ) const { const double t = sample.time; @@ -627,7 +630,7 @@ void QwtPlotTradingCurve::drawCandleStick( QPainter *painter, /*! \return A rectangle filled with the color of the symbol pen - \param index Index of the legend entry + \param index Index of the legend entry ( usually there is only one ) \param size Icon size @@ -670,7 +673,7 @@ double QwtPlotTradingCurve::scaledSymbolWidth( const QwtScaleMap *map = ( orientation() == Qt::Vertical ) ? &xMap : &yMap; - const double pos = map->transform( map->s1() + d_data->symbolExtent ); + const double pos = map->transform( map->s1() + d_data->symbolExtent ); double width = qAbs( pos - map->p1() ); diff --git a/qwtdemo/qwt/qwt_plot_tradingcurve.h b/qwtdemo/qwt/qwt_plot_tradingcurve.h index 8a4121f..30b1b22 100644 --- a/qwtdemo/qwt/qwt_plot_tradingcurve.h +++ b/qwtdemo/qwt/qwt_plot_tradingcurve.h @@ -21,7 +21,7 @@ QwtPlotTradingCurve supports candlestick or bar ( OHLC ) charts that are used in the domain of technical analysis. - While the length ( height or width depending on orientation() ) + While the length ( height or width depending on orientation() ) of each symbol depends on the corresponding OHLC sample the size of the other dimension can be controlled using: @@ -31,11 +31,11 @@ The extent is a size in scale coordinates, so that the symbol width is increasing when the plot is zoomed in. Minimum/Maximum width - is in widget coordinates independent from the zoom level. - When setting the minimum and maximum to the same value, the width of - the symbol is fixed. + is in widget coordinates independent from the zoom level. + When setting the minimum and maximum to the same value, the width of + the symbol is fixed. */ -class QWT_EXPORT QwtPlotTradingCurve: +class QWT_EXPORT QwtPlotTradingCurve: public QwtPlotSeriesItem, QwtSeriesStore { public: @@ -101,7 +101,7 @@ public: //! Paint attributes typedef QFlags PaintAttributes; - explicit QwtPlotTradingCurve( const QString &title = QString::null ); + explicit QwtPlotTradingCurve( const QString &title = QString() ); explicit QwtPlotTradingCurve( const QwtText &title ); virtual ~QwtPlotTradingCurve(); @@ -117,7 +117,7 @@ public: void setSymbolStyle( SymbolStyle style ); SymbolStyle symbolStyle() const; - void setSymbolPen( const QColor &, + void setSymbolPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); void setSymbolPen( const QPen & ); QPen symbolPen() const; @@ -125,7 +125,7 @@ public: void setSymbolBrush( Direction, const QBrush & ); QBrush symbolBrush( Direction ) const; - void setSymbolExtent( double width ); + void setSymbolExtent( double ); double symbolExtent() const; void setMinSymbolWidth( double ); @@ -150,14 +150,14 @@ protected: const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to ) const; - virtual void drawUserSymbol( QPainter *, + virtual void drawUserSymbol( QPainter *, SymbolStyle, const QwtOHLCSample &, + Qt::Orientation, bool inverted, double symbolWidth ) const; + + void drawBar( QPainter *painter, const QwtOHLCSample &, Qt::Orientation, bool inverted, double width ) const; - void drawBar( QPainter *painter, const QwtOHLCSample &, - Qt::Orientation, bool inverted, double width ) const; - - void drawCandleStick( QPainter *, const QwtOHLCSample &, + void drawCandleStick( QPainter *, const QwtOHLCSample &, Qt::Orientation, double width ) const; virtual double scaledSymbolWidth( diff --git a/qwtdemo/qwt/qwt_plot_xml.cpp b/qwtdemo/qwt/qwt_plot_xml.cpp index 5332a78..532ddc7 100644 --- a/qwtdemo/qwt/qwt_plot_xml.cpp +++ b/qwtdemo/qwt/qwt_plot_xml.cpp @@ -28,7 +28,7 @@ void QwtPlot::applyProperties( const QString & /* xmlDocument */ ) This method is intended for manipulating the plot widget from a specific editor in the Qwt designer plugin. - \return QString::null + \return QString() \warning The plot editor has never been implemented. */ QString QwtPlot::grabProperties() const @@ -37,6 +37,6 @@ QString QwtPlot::grabProperties() const // Temporary dummy code, for designer tests return title().text(); #else - return QString::null; + return QString(); #endif } diff --git a/qwtdemo/qwt/qwt_plot_zoneitem.cpp b/qwtdemo/qwt/qwt_plot_zoneitem.cpp index f4ef696..7589769 100644 --- a/qwtdemo/qwt/qwt_plot_zoneitem.cpp +++ b/qwtdemo/qwt/qwt_plot_zoneitem.cpp @@ -13,7 +13,7 @@ #include class QwtPlotZoneItem::PrivateData -{ +{ public: PrivateData(): orientation( Qt::Vertical ), @@ -23,12 +23,12 @@ public: c.setAlpha( 100 ); brush = QBrush( c ); } - + Qt::Orientation orientation; QPen pen; QBrush brush; QwtInterval interval; -}; +}; /*! \brief Constructor @@ -67,26 +67,26 @@ int QwtPlotZoneItem::rtti() const return QwtPlotItem::Rtti_PlotZone; } -/*! +/*! 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 QwtPlotZoneItem::setPen( const QColor &color, qreal width, Qt::PenStyle style ) -{ +{ setPen( QPen( color, width, style ) ); } /*! - \brief Assign a pen + \brief Assign a pen The pen is used to draw the border lines of the zone @@ -111,9 +111,9 @@ const QPen &QwtPlotZoneItem::pen() const return d_data->pen; } -/*! - \brief Assign a brush - +/*! + \brief Assign a brush + The brush is used to fill the zone \param brush Brush @@ -140,8 +140,8 @@ const QBrush &QwtPlotZoneItem::brush() const /*! \brief Set the orientation of the zone - A horizontal zone highlights an interval of the y axis, - a vertical zone of the x axis. It is unbounded in the + A horizontal zone highlights an interval of the y axis, + a vertical zone of the x axis. It is unbounded in the opposite direction. \sa orientation(), QwtPlotItem::setAxes() @@ -195,9 +195,9 @@ void QwtPlotZoneItem::setInterval( const QwtInterval &interval ) if ( d_data->interval != interval ) { d_data->interval = interval; - itemChanged(); - } -} + itemChanged(); + } +} /*! \return Zone interval @@ -206,7 +206,7 @@ void QwtPlotZoneItem::setInterval( const QwtInterval &interval ) QwtInterval QwtPlotZoneItem::interval() const { return d_data->interval; -} +} /*! Draw the zone @@ -285,7 +285,7 @@ void QwtPlotZoneItem::draw( QPainter *painter, } } -/*! +/*! The bounding rectangle is build from the interval in one direction and something invalid for the opposite direction. diff --git a/qwtdemo/qwt/qwt_plot_zoneitem.h b/qwtdemo/qwt/qwt_plot_zoneitem.h index f78226a..c3d0327 100644 --- a/qwtdemo/qwt/qwt_plot_zoneitem.h +++ b/qwtdemo/qwt/qwt_plot_zoneitem.h @@ -20,15 +20,15 @@ class QBrush; /*! \brief A plot item, which displays a zone - A horizontal zone highlights an interval of the y axis - a vertical + A horizontal zone highlights an interval of the y axis - a vertical zone an interval of the x axis - and is unbounded in the opposite direction. - It is filled with a brush and its border lines are optionally displayed with a pen. + It is filled with a brush and its border lines are optionally displayed with a pen. - \note For displaying an area that is bounded for x and y coordinates + \note For displaying an area that is bounded for x and y coordinates use QwtPlotShapeItem */ -class QWT_EXPORT QwtPlotZoneItem: +class QWT_EXPORT QwtPlotZoneItem: public QwtPlotItem { public: diff --git a/qwtdemo/qwt/qwt_plot_zoomer.cpp b/qwtdemo/qwt/qwt_plot_zoomer.cpp index 35e83c6..1ad06a0 100644 --- a/qwtdemo/qwt/qwt_plot_zoomer.cpp +++ b/qwtdemo/qwt/qwt_plot_zoomer.cpp @@ -13,7 +13,7 @@ #include "qwt_picker_machine.h" #include -static QwtInterval qwtExpandedZoomInterval( double v1, double v2, +static QwtInterval qwtExpandedZoomInterval( double v1, double v2, double minRange, const QwtTransform* transform ) { double min = v1; diff --git a/qwtdemo/qwt/qwt_plot_zoomer.h b/qwtdemo/qwt/qwt_plot_zoomer.h index 1bc05b4..ed2a637 100644 --- a/qwtdemo/qwt/qwt_plot_zoomer.h +++ b/qwtdemo/qwt/qwt_plot_zoomer.h @@ -22,14 +22,14 @@ The selection is supported by a rubber band and optionally by displaying the coordinates of the current mouse position. - Zooming can be repeated as often as possible, limited only by + Zooming can be repeated as often as possible, limited only by maxStackDepth() or minZoomSize(). Each rectangle is pushed on a stack. - The default setting how to select rectangles is + The default setting how to select rectangles is a QwtPickerDragRectMachine with the following bindings: - QwtEventPattern::MouseSelect1\n - The first point of the zoom rectangle is selected by a mouse press, + The first point of the zoom rectangle is selected by a mouse press, the second point from the position, where the mouse is released. - QwtEventPattern::KeySelect1\n @@ -44,7 +44,7 @@ - QwtEventPattern::MouseSelect3, QwtEventPattern::KeyUndo\n Zoom out one position on the zoom stack - + - QwtEventPattern::MouseSelect6, QwtEventPattern::KeyRedo\n Zoom in one position on the zoom stack @@ -52,9 +52,9 @@ Zoom to the zoom base The setKeyPattern() and setMousePattern() functions can be used - to configure the zoomer actions. The following example - shows, how to configure the 'I' and 'O' keys for zooming in and out - one position on the zoom stack. The "Home" key is used to + to configure the zoomer actions. The following example + shows, how to configure the 'I' and 'O' keys for zooming in and out + one position on the zoom stack. The "Home" key is used to "unzoom" the plot. \code @@ -102,11 +102,11 @@ public: uint zoomRectIndex() const; public Q_SLOTS: - void moveBy( double x, double y ); + void moveBy( double dx, double dy ); virtual void moveTo( const QPointF & ); virtual void zoom( const QRectF & ); - virtual void zoom( int up ); + virtual void zoom( int offset ); Q_SIGNALS: /*! diff --git a/qwtdemo/qwt/qwt_point_3d.cpp b/qwtdemo/qwt/qwt_point_3d.cpp index 27e4c1e..24fb80e 100644 --- a/qwtdemo/qwt/qwt_point_3d.cpp +++ b/qwtdemo/qwt/qwt_point_3d.cpp @@ -13,7 +13,7 @@ QDebug operator<<( QDebug debug, const QwtPoint3D &point ) { - debug.nospace() << "QwtPoint3D(" << point.x() + debug.nospace() << "QwtPoint3D(" << point.x() << "," << point.y() << "," << point.z() << ")"; return debug.space(); } diff --git a/qwtdemo/qwt/qwt_point_data.cpp b/qwtdemo/qwt/qwt_point_data.cpp index e82247f..9bee1f0 100644 --- a/qwtdemo/qwt/qwt_point_data.cpp +++ b/qwtdemo/qwt/qwt_point_data.cpp @@ -286,7 +286,7 @@ QPointF QwtSyntheticPointData::sample( size_t index ) const equidistant steps. If !interval().isValid() the interval is calculated from the "rectangle of interest". - \param index Index of the requested point + \param index Index of the requested point \return Calculated x coordinate \sa interval(), rectOfInterest(), y() @@ -296,7 +296,7 @@ double QwtSyntheticPointData::x( uint index ) const const QwtInterval &interval = d_interval.isValid() ? d_interval : d_intervalOfInterest; - if ( !interval.isValid() ) + if ( !interval.isValid() ) return 0.0; if ( d_size <= 1 ) diff --git a/qwtdemo/qwt/qwt_point_data.h b/qwtdemo/qwt/qwt_point_data.h index c4c9c0c..0a9d76c 100644 --- a/qwtdemo/qwt/qwt_point_data.h +++ b/qwtdemo/qwt/qwt_point_data.h @@ -25,7 +25,7 @@ public: virtual QRectF boundingRect() const; virtual size_t size() const; - virtual QPointF sample( size_t i ) const; + virtual QPointF sample( size_t index ) const; const QVector &xData() const; const QVector &yData() const; @@ -45,7 +45,7 @@ public: virtual QRectF boundingRect() const; virtual size_t size() const; - virtual QPointF sample( size_t i ) const; + virtual QPointF sample( size_t index ) const; const double *xData() const; const double *yData() const; @@ -122,7 +122,7 @@ public: QwtInterval interval() const; virtual QRectF boundingRect() const; - virtual QPointF sample( size_t i ) const; + virtual QPointF sample( size_t index ) const; /*! Calculate a y value for a x value diff --git a/qwtdemo/qwt/qwt_point_mapper.cpp b/qwtdemo/qwt/qwt_point_mapper.cpp index 01e8f75..59f3381 100644 --- a/qwtdemo/qwt/qwt_point_mapper.cpp +++ b/qwtdemo/qwt/qwt_point_mapper.cpp @@ -22,7 +22,7 @@ #include #if !defined(QT_NO_QFUTURE) -#define QWT_USE_THREADS 0 +#define QWT_USE_THREADS 1 #endif #endif @@ -42,7 +42,7 @@ public: static void qwtRenderDots( const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtDotsCommand command, const QPoint &pos, QImage *image ) + const QwtDotsCommand command, const QPoint &pos, QImage *image ) { const QRgb rgb = command.rgb; QRgb *bits = reinterpret_cast( image->bits() ); @@ -94,7 +94,7 @@ struct QwtRoundF }; struct QwtNoRoundF -{ +{ inline double operator()( double value ) { return value; @@ -105,10 +105,10 @@ struct QwtNoRoundF // the bounding rectangle template -static inline Polygon qwtToPoints( +static inline Polygon qwtToPoints( const QRectF &boundingRect, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtSeriesData *series, + const QwtSeriesData *series, int from, int to, Round round ) { Polygon polyline( to - from + 1 ); @@ -168,7 +168,7 @@ static inline QPolygon qwtToPointsI( const QwtSeriesData *series, int from, int to ) { - return qwtToPoints( + return qwtToPoints( boundingRect, xMap, yMap, series, from, to, QwtRoundI() ); } @@ -179,7 +179,7 @@ static inline QPolygonF qwtToPointsF( const QwtSeriesData *series, int from, int to, Round round ) { - return qwtToPoints( + return qwtToPoints( boundingRect, xMap, yMap, series, from, to, round ); } @@ -187,9 +187,9 @@ static inline QPolygonF qwtToPointsF( // points mapped to the same position template -static inline Polygon qwtToPolylineFiltered( +static inline Polygon qwtToPolylineFiltered( const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtSeriesData *series, + const QwtSeriesData *series, int from, int to, Round round ) { // in curves with many points consecutive points @@ -238,7 +238,7 @@ static inline QPolygonF qwtToPolylineFilteredF( { return qwtToPolylineFiltered( xMap, yMap, series, from, to, round ); -} +} template static inline Polygon qwtToPointsFiltered( @@ -282,7 +282,7 @@ static inline QPolygon qwtToPointsFilteredI( { return qwtToPointsFiltered( boundingRect, xMap, yMap, series, from, to ); -} +} static inline QPolygonF qwtToPointsFilteredF( const QRectF &boundingRect, @@ -389,7 +389,7 @@ QRectF QwtPointMapper::boundingRect() const \brief Translate a series of points into a QPolygonF When the WeedOutPoints flag is enabled consecutive points, - that are mapped to the same position will be one point. + that are mapped to the same position will be one point. When RoundPoints is set all points are rounded to integers but returned as PolygonF - what only makes sense @@ -413,12 +413,12 @@ QPolygonF QwtPointMapper::toPolygonF( { if ( d_data->flags & RoundPoints ) { - polyline = qwtToPolylineFilteredF( + polyline = qwtToPolylineFilteredF( xMap, yMap, series, from, to, QwtRoundF() ); } else { - polyline = qwtToPolylineFilteredF( + polyline = qwtToPolylineFilteredF( xMap, yMap, series, from, to, QwtNoRoundF() ); } } @@ -426,12 +426,12 @@ QPolygonF QwtPointMapper::toPolygonF( { if ( d_data->flags & RoundPoints ) { - polyline = qwtToPointsF( qwtInvalidRect, + polyline = qwtToPointsF( qwtInvalidRect, xMap, yMap, series, from, to, QwtRoundF() ); } else { - polyline = qwtToPointsF( qwtInvalidRect, + polyline = qwtToPointsF( qwtInvalidRect, xMap, yMap, series, from, to, QwtNoRoundF() ); } } @@ -443,7 +443,7 @@ QPolygonF QwtPointMapper::toPolygonF( \brief Translate a series of points into a QPolygon When the WeedOutPoints flag is enabled consecutive points, - that are mapped to the same position will be one point. + that are mapped to the same position will be one point. \param xMap x map \param yMap y map @@ -461,12 +461,12 @@ QPolygon QwtPointMapper::toPolygon( if ( d_data->flags & WeedOutPoints ) { - polyline = qwtToPolylineFilteredI( + polyline = qwtToPolylineFilteredI( xMap, yMap, series, from, to ); } else { - polyline = qwtToPointsI( + polyline = qwtToPointsI( qwtInvalidRect, xMap, yMap, series, from, to ); } @@ -477,16 +477,16 @@ QPolygon QwtPointMapper::toPolygon( \brief Translate a series into a QPolygonF - WeedOutPoints & RoundPoints & boundingRect().isValid() - All points that are mapped to the same position + All points that are mapped to the same position will be one point. Points outside of the bounding rectangle are ignored. - + - WeedOutPoints & RoundPoints & !boundingRect().isValid() - All consecutive points that are mapped to the same position + All consecutive points that are mapped to the same position will one point - - WeedOutPoints & !RoundPoints - All consecutive points that are mapped to the same position + - WeedOutPoints & !RoundPoints + All consecutive points that are mapped to the same position will one point - !WeedOutPoints & boundingRect().isValid() @@ -515,17 +515,17 @@ QPolygonF QwtPointMapper::toPointsF( if ( d_data->flags & RoundPoints ) { if ( d_data->boundingRect.isValid() ) - { + { points = qwtToPointsFilteredF( d_data->boundingRect, xMap, yMap, series, from, to ); } else - { + { // without a bounding rectangle all we can // do is to filter out duplicates of // consecutive points - points = qwtToPolylineFilteredF( + points = qwtToPolylineFilteredF( xMap, yMap, series, from, to, QwtRoundF() ); } } @@ -534,7 +534,7 @@ QPolygonF QwtPointMapper::toPointsF( // when rounding is not allowed we can't use // qwtToPointsFilteredF - points = qwtToPolylineFilteredF( + points = qwtToPolylineFilteredF( xMap, yMap, series, from, to, QwtNoRoundF() ); } } @@ -559,12 +559,12 @@ QPolygonF QwtPointMapper::toPointsF( \brief Translate a series of points into a QPolygon - WeedOutPoints & boundingRect().isValid() - All points that are mapped to the same position + All points that are mapped to the same position will be one point. Points outside of the bounding rectangle are ignored. - + - WeedOutPoints & !boundingRect().isValid() - All consecutive points that are mapped to the same position + All consecutive points that are mapped to the same position will one point - !WeedOutPoints & boundingRect().isValid() @@ -596,13 +596,13 @@ QPolygon QwtPointMapper::toPoints( // when we don't have the bounding rectangle all // we can do is to filter out consecutive duplicates - points = qwtToPolylineFilteredI( + points = qwtToPolylineFilteredI( xMap, yMap, series, from, to ); } } else { - points = qwtToPointsI( + points = qwtToPointsI( d_data->boundingRect, xMap, yMap, series, from, to ); } @@ -630,7 +630,7 @@ QPolygon QwtPointMapper::toPoints( */ QImage QwtPointMapper::toImage( const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtSeriesData *series, int from, int to, + const QwtSeriesData *series, int from, int to, const QPen &pen, bool antialiased, uint numThreads ) const { Q_UNUSED( antialiased ) @@ -680,7 +680,7 @@ QImage QwtPointMapper::toImage( command.from = index0; command.to = index0 + numPoints - 1; - futures += QtConcurrent::run( &qwtRenderDots, + futures += QtConcurrent::run( &qwtRenderDots, xMap, yMap, command, pos, &image ); } } diff --git a/qwtdemo/qwt/qwt_point_mapper.h b/qwtdemo/qwt/qwt_point_mapper.h index 44351d9..fd7ad7e 100644 --- a/qwtdemo/qwt/qwt_point_mapper.h +++ b/qwtdemo/qwt/qwt_point_mapper.h @@ -22,14 +22,14 @@ class QPolygon; \brief A helper class for translating a series of points QwtPointMapper is a collection of methods and optimizations - for translating a series of points into paint device coordinates. - It is used by QwtPlotCurve but might also be useful for + for translating a series of points into paint device coordinates. + It is used by QwtPlotCurve but might also be useful for similar plot items displaying a QwtSeriesData. */ class QWT_EXPORT QwtPointMapper { public: - /*! + /*! \brief Flags affecting the transformation process \sa setFlag(), setFlags() */ @@ -38,14 +38,14 @@ public: //! Round points to integer values RoundPoints = 0x01, - /*! + /*! Try to remove points, that are translated to the same position. */ WeedOutPoints = 0x02 }; - /*! + /*! \brief Flags affecting the transformation process \sa setFlag(), setFlags() */ @@ -76,7 +76,7 @@ public: const QwtSeriesData *series, int from, int to ) const; QImage toImage( const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtSeriesData *series, int from, int to, + const QwtSeriesData *series, int from, int to, const QPen &, bool antialiased, uint numThreads ) const; private: diff --git a/qwtdemo/qwt/qwt_point_polar.cpp b/qwtdemo/qwt/qwt_point_polar.cpp index 644bcf1..2bd8ec0 100644 --- a/qwtdemo/qwt/qwt_point_polar.cpp +++ b/qwtdemo/qwt/qwt_point_polar.cpp @@ -111,7 +111,7 @@ QwtPointPolar QwtPointPolar::normalized() const QDebug operator<<( QDebug debug, const QwtPointPolar &point ) { - debug.nospace() << "QwtPointPolar(" + debug.nospace() << "QwtPointPolar(" << point.azimuth() << "," << point.radius() << ")"; return debug.space(); diff --git a/qwtdemo/qwt/qwt_point_polar.h b/qwtdemo/qwt/qwt_point_polar.h index 2b0a162..f369215 100644 --- a/qwtdemo/qwt/qwt_point_polar.h +++ b/qwtdemo/qwt/qwt_point_polar.h @@ -188,9 +188,9 @@ inline QPointF qwtFastPolar2Pos( const QPointF &pole, inline QPointF qwtFastDegree2Pos( const QPointF &pole, double radius, double angle ) -{ +{ return qwtFastPolar2Pos( pole, radius, angle / 180.0 * M_PI ); -} +} inline QwtPointPolar qwtFastPos2Polar( const QPointF &pos ) { @@ -198,4 +198,4 @@ inline QwtPointPolar qwtFastPos2Polar( const QPointF &pos ) qSqrt( qwtSqr( pos.x() ) + qwtSqr( pos.y() ) ) ); } -#endif +#endif diff --git a/qwtdemo/qwt/qwt_raster_data.cpp b/qwtdemo/qwt/qwt_raster_data.cpp index 9ea11cb..8125e03 100644 --- a/qwtdemo/qwt/qwt_raster_data.cpp +++ b/qwtdemo/qwt/qwt_raster_data.cpp @@ -216,20 +216,20 @@ void QwtRasterData::discardRaster() /*! \brief 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. - - Width and height of the hint need to be the horizontal - and vertical distances between 2 neighbored points. - The center of the hint has to be the position of any point + representing the data. + + Width and height of the hint need to be the horizontal + and vertical distances between 2 neighbored points. + The center of the hint has to be the position of any point ( it doesn't matter which one ). An empty hint indicates, that there are values for any detail level. Limiting the resolution of the image might significantly improve the performance and heavily reduce the amount of memory when rendering - a QImage from the raster data. + a QImage from the raster data. The default implementation returns an empty rectangle recommending to render in target device ( f.e. screen ) resolution. @@ -237,12 +237,12 @@ void QwtRasterData::discardRaster() \param area In most implementations the resolution of the data doesn't depend on the requested area. - \return Bounding rectangle of a pixel + \return Bounding rectangle of a pixel */ QRectF QwtRasterData::pixelHint( const QRectF &area ) const { Q_UNUSED( area ); - return QRectF(); + return QRectF(); } /*! diff --git a/qwtdemo/qwt/qwt_round_scale_draw.h b/qwtdemo/qwt/qwt_round_scale_draw.h index 54971bb..e072cc3 100644 --- a/qwtdemo/qwt/qwt_round_scale_draw.h +++ b/qwtdemo/qwt/qwt_round_scale_draw.h @@ -45,7 +45,7 @@ public: virtual double extent( const QFont & ) const; protected: - virtual void drawTick( QPainter *, double val, double len ) const; + virtual void drawTick( QPainter *, double value, double len ) const; virtual void drawBackbone( QPainter * ) const; virtual void drawLabel( QPainter *, double val ) const; diff --git a/qwtdemo/qwt/qwt_sampling_thread.h b/qwtdemo/qwt/qwt_sampling_thread.h index 9b1a908..e85c5d6 100644 --- a/qwtdemo/qwt/qwt_sampling_thread.h +++ b/qwtdemo/qwt/qwt_sampling_thread.h @@ -1,3 +1,12 @@ +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** + * Qwt Widget Library + * Copyright (C) 1997 Josef Wilgen + * Copyright (C) 2002 Uwe Rathmann + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the Qwt License, Version 1.0 + *****************************************************************************/ + #ifndef _QWT_SAMPLING_THREAD_H_ #define _QWT_SAMPLING_THREAD_H_ diff --git a/qwtdemo/qwt/qwt_scale_div.cpp b/qwtdemo/qwt/qwt_scale_div.cpp index 2fd3d3f..a514ff3 100644 --- a/qwtdemo/qwt/qwt_scale_div.cpp +++ b/qwtdemo/qwt/qwt_scale_div.cpp @@ -70,7 +70,7 @@ QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, \note lowerBound might be greater than upperBound for inverted scales */ QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, - const QList &minorTicks, + const QList &minorTicks, const QList &mediumTicks, const QList &majorTicks ): d_lowerBound( lowerBound ), @@ -132,7 +132,7 @@ void QwtScaleDiv::setLowerBound( double lowerBound ) double QwtScaleDiv::lowerBound() const { return d_lowerBound; -} +} /*! Set the second boundary @@ -143,7 +143,7 @@ double QwtScaleDiv::lowerBound() const void QwtScaleDiv::setUpperBound( double upperBound ) { d_upperBound = upperBound; -} +} /*! \return upper bound @@ -218,7 +218,7 @@ bool QwtScaleDiv::contains( double value ) const return value >= min && value <= max; } -/*! +/*! Invert the scale division \sa inverted() */ @@ -238,7 +238,7 @@ void QwtScaleDiv::invert() } } -/*! +/*! \return A scale division with inverted boundaries and ticks \sa invert() */ @@ -250,7 +250,7 @@ QwtScaleDiv QwtScaleDiv::inverted() const return other; } -/*! +/*! Return a scale division with an interval [lowerBound, upperBound] where all ticks outside this interval are removed @@ -261,7 +261,7 @@ QwtScaleDiv QwtScaleDiv::inverted() const \note lowerBound might be greater than upperBound for inverted scales */ -QwtScaleDiv QwtScaleDiv::bounded( +QwtScaleDiv QwtScaleDiv::bounded( double lowerBound, double upperBound ) const { const double min = qMin( lowerBound, upperBound ); diff --git a/qwtdemo/qwt/qwt_scale_div.h b/qwtdemo/qwt/qwt_scale_div.h index 85d75e1..f4d8de6 100644 --- a/qwtdemo/qwt/qwt_scale_div.h +++ b/qwtdemo/qwt/qwt_scale_div.h @@ -55,7 +55,7 @@ public: NTickTypes }; - explicit QwtScaleDiv( double lowerBound = 0.0, + explicit QwtScaleDiv( double lowerBound = 0.0, double upperBound = 0.0 ); explicit QwtScaleDiv( const QwtInterval &, QList[NTickTypes] ); @@ -63,7 +63,7 @@ public: explicit QwtScaleDiv( double lowerBound, double upperBound, QList[NTickTypes] ); - explicit QwtScaleDiv( double lowerBound, double upperBound, + explicit QwtScaleDiv( double lowerBound, double upperBound, const QList &minorTicks, const QList &mediumTicks, const QList &majorTicks ); diff --git a/qwtdemo/qwt/qwt_scale_draw.cpp b/qwtdemo/qwt/qwt_scale_draw.cpp index 920c6b9..c3e1926 100644 --- a/qwtdemo/qwt/qwt_scale_draw.cpp +++ b/qwtdemo/qwt/qwt_scale_draw.cpp @@ -117,7 +117,7 @@ Qt::Orientation QwtScaleDraw::orientation() const \param start Start border distance \param end End border distance */ -void QwtScaleDraw::getBorderDistHint( +void QwtScaleDraw::getBorderDistHint( const QFont &font, int &start, int &end ) const { start = 0; @@ -234,7 +234,7 @@ int QwtScaleDraw::minLabelDist( const QFont &font ) const maxDist = dist; } - double angle = qwtRadians( labelRotation() ); + double angle = qwtRadians( labelRotation() ); if ( vertical ) angle += M_PI / 2; @@ -347,7 +347,7 @@ int QwtScaleDraw::minLength( const QFont &font ) const /*! Find the position, where to paint a label - The position has a distance that depends on the length of the ticks + The position has a distance that depends on the length of the ticks in direction of the alignment(). \param value Value diff --git a/qwtdemo/qwt/qwt_scale_draw.h b/qwtdemo/qwt/qwt_scale_draw.h index 005e834..c9eef3a 100644 --- a/qwtdemo/qwt/qwt_scale_draw.h +++ b/qwtdemo/qwt/qwt_scale_draw.h @@ -35,19 +35,19 @@ public: Alignment of the scale draw \sa setAlignment(), alignment() */ - enum Alignment - { + enum Alignment + { //! The scale is below - BottomScale, + BottomScale, //! The scale is above - TopScale, + TopScale, //! The scale is left - LeftScale, + LeftScale, //! The scale is right - RightScale + RightScale }; QwtScaleDraw(); @@ -80,19 +80,19 @@ public: int maxLabelHeight( const QFont & ) const; int maxLabelWidth( const QFont & ) const; - QPointF labelPosition( double val ) const; + QPointF labelPosition( double value ) const; - QRectF labelRect( const QFont &, double val ) const; - QSizeF labelSize( const QFont &, double val ) const; + QRectF labelRect( const QFont &, double value ) const; + QSizeF labelSize( const QFont &, double value ) const; - QRect boundingLabelRect( const QFont &, double val ) const; + QRect boundingLabelRect( const QFont &, double value ) const; protected: QTransform labelTransformation( const QPointF &, const QSizeF & ) const; - virtual void drawTick( QPainter *, double val, double len ) const; + virtual void drawTick( QPainter *, double value, double len ) const; virtual void drawBackbone( QPainter * ) const; - virtual void drawLabel( QPainter *, double val ) const; + virtual void drawLabel( QPainter *, double value ) const; private: QwtScaleDraw( const QwtScaleDraw & ); diff --git a/qwtdemo/qwt/qwt_scale_engine.cpp b/qwtdemo/qwt/qwt_scale_engine.cpp index b4fe236..afc6646 100644 --- a/qwtdemo/qwt/qwt_scale_engine.cpp +++ b/qwtdemo/qwt/qwt_scale_engine.cpp @@ -31,7 +31,7 @@ static inline QwtInterval qwtLogInterval( double base, const QwtInterval &interv qwtLog( base, interval.maxValue() ) ); } -static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval ) +static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval ) { return QwtInterval( qPow( base, interval.minValue() ), qPow( base, interval.maxValue() ) ); @@ -51,7 +51,7 @@ static inline long double qwtIntervalWidthL( const QwtInterval &interval ) // this version often doesn't find the best ticks: f.e for 15: 5, 10 static double qwtStepSize( double intervalSize, int maxSteps, uint base ) { - const double minStep = + const double minStep = QwtScaleArithmetic::divideInterval( intervalSize, maxSteps, base ); if ( minStep != 0.0 ) @@ -170,8 +170,8 @@ double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps ) \return Calculated step size */ -double QwtScaleArithmetic::divideInterval( - double intervalSize, int numSteps, uint base ) +double QwtScaleArithmetic::divideInterval( + double intervalSize, int numSteps, uint base ) { if ( numSteps <= 0 ) return 0.0; @@ -268,7 +268,7 @@ void QwtScaleEngine::setTransformation( QwtTransform *transform ) } /*! - Create and return a clone of the transformation + Create and return a clone of the transformation of the engine. When the engine has no special transformation NULL is returned, indicating no transformation. @@ -339,7 +339,7 @@ void QwtScaleEngine::setMargins( double lower, double upper ) double QwtScaleEngine::divideInterval( double intervalSize, int numSteps ) const { - return QwtScaleArithmetic::divideInterval( + return QwtScaleArithmetic::divideInterval( intervalSize, numSteps, d_data->base ); } @@ -467,16 +467,16 @@ QwtScaleEngine::Attributes QwtScaleEngine::attributes() const /*! \brief Specify a reference point - \param r new reference value + \param reference New reference value The reference point is needed if options IncludeReference or Symmetric are active. Its default value is 0.0. \sa Attribute */ -void QwtScaleEngine::setReference( double r ) +void QwtScaleEngine::setReference( double reference ) { - d_data->referenceValue = r; + d_data->referenceValue = reference; } /*! @@ -501,7 +501,7 @@ double QwtScaleEngine::reference() const \sa base() */ void QwtScaleEngine::setBase( uint base ) -{ +{ d_data->base = qMax( base, 2U ); } @@ -558,7 +558,7 @@ void QwtLinearScaleEngine::autoScale( int maxNumSteps, if ( interval.width() == 0.0 ) interval = buildInterval( interval.minValue() ); - stepSize = QwtScaleArithmetic::divideInterval( + stepSize = QwtScaleArithmetic::divideInterval( interval.width(), qMax( maxNumSteps, 1 ), base() ); if ( !testAttribute( QwtScaleEngine::Floating ) ) @@ -606,7 +606,7 @@ QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2, if ( maxMajorSteps < 1 ) maxMajorSteps = 1; - stepSize = QwtScaleArithmetic::divideInterval( + stepSize = QwtScaleArithmetic::divideInterval( interval.width(), maxMajorSteps, base() ); } @@ -756,7 +756,7 @@ QwtInterval QwtLinearScaleEngine::align( double x1 = interval.minValue(); double x2 = interval.maxValue(); - // when there is no rounding beside some effect, when + // when there is no rounding beside some effect, when // calculating with doubles, we keep the original value const double eps = 0.000000000001; // since Qt 4.8: qFuzzyIsNull @@ -867,7 +867,7 @@ void QwtLogScaleEngine::autoScale( int maxNumSteps, if ( interval.width() == 0.0 ) interval = buildInterval( interval.minValue() ); - stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(), + stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(), qMax( maxNumSteps, 1 ) ); if ( stepSize < 1.0 ) stepSize = 1.0; @@ -927,7 +927,7 @@ QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2, if ( maxMajorSteps < 1 ) maxMajorSteps = 1; - stepSize = divideInterval( + stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(), maxMajorSteps ); if ( stepSize < 1.0 ) stepSize = 1.0; // major step must be >= 1 decade @@ -1032,8 +1032,8 @@ void QwtLogScaleEngine::buildMinorTicks( double minStep = divideInterval( stepSize, maxMinorSteps + 1 ); if ( minStep == 0.0 ) return; - - const int numSteps = qRound( stepSize / minStep ); + + const int numSteps = qRound( stepSize / minStep ); int mediumTickIndex = -1; if ( ( numSteps > 2 ) && ( numSteps % 2 == 0 ) ) @@ -1087,7 +1087,7 @@ void QwtLogScaleEngine::buildMinorTicks( } if ( numTicks < 1 ) - return; + return; int mediumTickIndex = -1; if ( ( numTicks > 2 ) && ( numTicks % 2 ) ) diff --git a/qwtdemo/qwt/qwt_scale_engine.h b/qwtdemo/qwt/qwt_scale_engine.h index 30e75fd..7bd9474 100644 --- a/qwtdemo/qwt/qwt_scale_engine.h +++ b/qwtdemo/qwt/qwt_scale_engine.h @@ -25,9 +25,9 @@ public: static double ceilEps( double value, double intervalSize ); static double floorEps( double value, double intervalSize ); - static double divideEps( double interval, double steps ); + static double divideEps( double intervalSize, double numSteps ); - static double divideInterval( double interval, + static double divideInterval( double intervalSize, int numSteps, uint base ); }; @@ -39,13 +39,13 @@ public: The layout of the scale can be varied with setAttribute(). - Qwt offers implementations for logarithmic and linear scales. + Qwt offers implementations for logarithmic and linear scales. */ class QWT_EXPORT QwtScaleEngine { public: - /*! + /*! Layout attributes \sa setAttribute(), testAttribute(), reference(), lowerMargin(), upperMargin() @@ -64,7 +64,7 @@ public: /*! The endpoints of the scale are supposed to be equal the - outmost included values plus the specified margins + outmost included values plus the specified margins (see setMargins()). If this attribute is *not* set, the endpoints of the scale will be integer multiples of the step size. @@ -90,7 +90,7 @@ public: void setAttributes( Attributes ); Attributes attributes() const; - void setReference( double reference ); + void setReference( double ); double reference() const; void setMargins( double lower, double upper ); @@ -128,12 +128,12 @@ public: QwtTransform *transformation() const; protected: - bool contains( const QwtInterval &, double val ) const; + bool contains( const QwtInterval &, double value ) const; QList strip( const QList&, const QwtInterval & ) const; - double divideInterval( double interval, int numSteps ) const; + double divideInterval( double intervalSize, int numSteps ) const; - QwtInterval buildInterval( double v ) const; + QwtInterval buildInterval( double value ) const; private: class PrivateData; @@ -153,19 +153,19 @@ public: QwtLinearScaleEngine( uint base = 10 ); virtual ~QwtLinearScaleEngine(); - virtual void autoScale( int maxSteps, + virtual void autoScale( int maxNumSteps, double &x1, double &x2, double &stepSize ) const; virtual QwtScaleDiv divideScale( double x1, double x2, - int numMajorSteps, int numMinorSteps, - double stepSize = 0.0 ) const; + int maxMajorSteps, int maxMinorSteps, + double stepSize = 0.0 ) const; protected: QwtInterval align( const QwtInterval&, double stepSize ) const; void buildTicks( - const QwtInterval &, double stepSize, int maxMinSteps, + const QwtInterval &, double stepSize, int maxMinorSteps, QList ticks[QwtScaleDiv::NTickTypes] ) const; QList buildMajorTicks( @@ -193,18 +193,18 @@ public: QwtLogScaleEngine( uint base = 10 ); virtual ~QwtLogScaleEngine(); - virtual void autoScale( int maxSteps, + virtual void autoScale( int maxNumSteps, double &x1, double &x2, double &stepSize ) const; virtual QwtScaleDiv divideScale( double x1, double x2, - int numMajorSteps, int numMinorSteps, + int maxMajorSteps, int maxMinorSteps, double stepSize = 0.0 ) const; protected: QwtInterval align( const QwtInterval&, double stepSize ) const; void buildTicks( - const QwtInterval &, double stepSize, int maxMinSteps, + const QwtInterval &, double stepSize, int maxMinorSteps, QList ticks[QwtScaleDiv::NTickTypes] ) const; QList buildMajorTicks( diff --git a/qwtdemo/qwt/qwt_scale_map.cpp b/qwtdemo/qwt/qwt_scale_map.cpp index c3fbad6..2a65535 100644 --- a/qwtdemo/qwt/qwt_scale_map.cpp +++ b/qwtdemo/qwt/qwt_scale_map.cpp @@ -93,7 +93,7 @@ const QwtTransform *QwtScaleMap::transformation() const \brief Specify the borders of the scale interval \param s1 first border \param s2 second border - \warning scales might be aligned to + \warning scales might be aligned to transformation depending boundaries */ void QwtScaleMap::setScaleInterval( double s1, double s2 ) @@ -186,9 +186,9 @@ QRectF QwtScaleMap::transform( const QwtScaleMap &xMap, QPointF QwtScaleMap::invTransform( const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QPointF &pos ) { - return QPointF( - xMap.invTransform( pos.x() ), - yMap.invTransform( pos.y() ) + return QPointF( + xMap.invTransform( pos.x() ), + yMap.invTransform( pos.y() ) ); } @@ -205,8 +205,8 @@ QPointF QwtScaleMap::invTransform( const QwtScaleMap &xMap, QPointF QwtScaleMap::transform( const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QPointF &pos ) { - return QPointF( - xMap.transform( pos.x() ), + return QPointF( + xMap.transform( pos.x() ), yMap.transform( pos.y() ) ); } diff --git a/qwtdemo/qwt/qwt_scale_map.h b/qwtdemo/qwt/qwt_scale_map.h index c07f1ce..ae54a2e 100644 --- a/qwtdemo/qwt/qwt_scale_map.h +++ b/qwtdemo/qwt/qwt_scale_map.h @@ -24,7 +24,7 @@ class QRectF; \brief A scale map QwtScaleMap offers transformations from the coordinate system - of a scale into the linear coordinate system of a paint device + of a scale into the linear coordinate system of a paint device and vice versa. */ class QWT_EXPORT QwtScaleMap diff --git a/qwtdemo/qwt/qwt_scale_widget.cpp b/qwtdemo/qwt/qwt_scale_widget.cpp index d34ada5..698468a 100644 --- a/qwtdemo/qwt/qwt_scale_widget.cpp +++ b/qwtdemo/qwt/qwt_scale_widget.cpp @@ -145,6 +145,8 @@ void QwtScaleWidget::setLayoutFlag( LayoutFlag flag, bool on ) d_data->layoutFlags |= flag; else d_data->layoutFlags &= ~flag; + + update(); } } @@ -767,9 +769,9 @@ int QwtScaleWidget::dimForLength( int length, const QFont &scaleFont ) const The maximum of this distance an the minimum border distance is returned. - \param start Return parameter for the border width at + \param start Return parameter for the border width at the beginning of the scale - \param end Return parameter for the border width at the + \param end Return parameter for the border width at the end of the scale \warning @@ -807,9 +809,9 @@ void QwtScaleWidget::setMinBorderDist( int start, int end ) Get the minimum value for the distances of the scale's endpoints from the widget borders. - \param start Return parameter for the border width at + \param start Return parameter for the border width at the beginning of the scale - \param end Return parameter for the border width at the + \param end Return parameter for the border width at the end of the scale \sa setMinBorderDist(), getBorderDistHint() diff --git a/qwtdemo/qwt/qwt_scale_widget.h b/qwtdemo/qwt/qwt_scale_widget.h index 067723d..c983b1e 100644 --- a/qwtdemo/qwt/qwt_scale_widget.h +++ b/qwtdemo/qwt/qwt_scale_widget.h @@ -39,7 +39,7 @@ public: enum LayoutFlag { /*! - The title of vertical scales is painted from top to bottom. + The title of vertical scales is painted from top to bottom. Otherwise it is painted from bottom to top. */ TitleInverted = 1 @@ -64,7 +64,7 @@ public: void setLayoutFlag( LayoutFlag, bool on ); bool testLayoutFlag( LayoutFlag ) const; - void setBorderDist( int start, int end ); + void setBorderDist( int dist1, int dist2 ); int startBorderDist() const; int endBorderDist() const; @@ -76,10 +76,10 @@ public: void setMargin( int ); int margin() const; - void setSpacing( int td ); + void setSpacing( int ); int spacing() const; - void setScaleDiv( const QwtScaleDiv &sd ); + void setScaleDiv( const QwtScaleDiv & ); void setTransformation( QwtTransform * ); void setScaleDraw( QwtScaleDraw * ); @@ -119,10 +119,10 @@ protected: virtual void paintEvent( QPaintEvent * ); virtual void resizeEvent( QResizeEvent * ); - void draw( QPainter *p ) const; + void draw( QPainter * ) const; void scaleChange(); - void layoutScale( bool update = true ); + void layoutScale( bool update_geometry = true ); private: void initScale( QwtScaleDraw::Alignment ); diff --git a/qwtdemo/qwt/qwt_series_data.h b/qwtdemo/qwt/qwt_series_data.h index afd8b1a..7f8516d 100644 --- a/qwtdemo/qwt/qwt_series_data.h +++ b/qwtdemo/qwt/qwt_series_data.h @@ -25,23 +25,23 @@ needs to be displayed, without having to copy it, it is recommended to implement an individual data access. - A subclass of QwtSeriesData must implement: + A subclass of QwtSeriesData must implement: - - size()\n + - size()\n Should return number of data points. - sample()\n Should return values x and y values of the sample at specific position as QPointF object. - - boundingRect()\n + - boundingRect()\n Should return the bounding rectangle of the data series. It is used for autoscaling and might help certain algorithms for displaying the data. You can use qwtBoundingRect() for an implementation - but often it is possible to implement a more efficient algorithm + but often it is possible to implement a more efficient algorithm depending on the characteristics of the series. The member d_boundingRect is intended for caching the calculated rectangle. - + */ template class QwtSeriesData @@ -53,6 +53,8 @@ public: //! Destructor virtual ~QwtSeriesData(); +#ifndef QWT_PYTHON_WRAPPER + //! \return Number of samples virtual size_t size() const = 0; @@ -77,6 +79,13 @@ public: */ virtual QRectF boundingRect() const = 0; +#else + // Needed for generating the python bindings, but not for using them ! + virtual size_t size() const { return 0; } + virtual T sample( size_t i ) const { return T(); } + virtual QRectF boundingRect() const { return d_boundingRect; } +#endif + /*! Set a the "rect of interest" @@ -85,7 +94,7 @@ public: It can be used to implement different levels of details. The default implementation does nothing. - + \param rect Rectangle of interest */ virtual void setRectOfInterest( const QRectF &rect ); @@ -274,56 +283,53 @@ QWT_EXPORT QRectF qwtBoundingRect( \par Example The following example shows finds a point of curve from an x coordinate + \code + #include + #include - \verbatim -#include -#include + struct compareX + { + inline bool operator()( const double x, const QPointF &pos ) const + { + return ( x < pos.x() ); + } + }; -struct compareX -{ - inline bool operator()( const double x, const QPointF &pos ) const - { - return ( x < pos.x() ); - } -}; + QLineF curveLineAt( const QwtPlotCurve *curve, double x ) + { + int index = qwtUpperSampleIndex( + *curve->data(), x, compareX() ); -QLineF curveLineAt( const QwtPlotCurve *curve, double x ) -{ - int index = qwtUpperSampleIndex( - *curve->data(), x, compareX() ); - - if ( index == -1 && - x == curve->sample( curve->dataSize() - 1 ).x() ) - { - // the last sample is excluded from qwtUpperSampleIndex - index = curve->dataSize() - 1; - } + if ( index == -1 && + x == curve->sample( curve->dataSize() - 1 ).x() ) + { + // the last sample is excluded from qwtUpperSampleIndex + index = curve->dataSize() - 1; + } - QLineF line; // invalid - if ( index > 0 ) - { - line.setP1( curve->sample( index - 1 ) ); - line.setP2( curve->sample( index ) ); - } + QLineF line; // invalid + if ( index > 0 ) + { + line.setP1( curve->sample( index - 1 ) ); + line.setP2( curve->sample( index ) ); + } - return line; -} + return line; + } -\endverbatim + \endcode + \endpar + \param series Series of samples + \param value Value + \param lessThan Compare operation - \param series Series of samples - \param value Value - \param lessThan Compare operation - - \note The samples must be sorted according to the order specified - by the lessThan object - -of the range [begin, end) and returns the position of the one-past-the-last occurrence of value. If no such item is found, returns the position where the item should be inserted. + \note The samples must be sorted according to the order specified + by the lessThan object */ template inline int qwtUpperSampleIndex( const QwtSeriesData &series, - double value, LessThan lessThan ) + double value, LessThan lessThan ) { const int indexMax = series.size() - 1; diff --git a/qwtdemo/qwt/qwt_series_store.h b/qwtdemo/qwt/qwt_series_store.h index cb841a4..14c91ab 100644 --- a/qwtdemo/qwt/qwt_series_store.h +++ b/qwtdemo/qwt/qwt_series_store.h @@ -27,6 +27,7 @@ protected: //! Destructor virtual ~QwtAbstractSeriesStore() {} +#ifndef QWT_PYTHON_WRAPPER //! dataChanged() indicates, that the series has been changed. virtual void dataChanged() = 0; @@ -41,6 +42,13 @@ protected: //! \return Number of samples virtual size_t dataSize() const = 0; +#else + // Needed for generating the python bindings, but not for using them ! + virtual void dataChanged() {} + virtual void setRectOfInterest( const QRectF & ) {} + virtual QRectF dataRect() const { return QRectF( 0.0, 0.0, -1.0, -1.0 ); } + virtual size_t dataSize() const { return 0; } +#endif }; /*! diff --git a/qwtdemo/qwt/qwt_slider.cpp b/qwtdemo/qwt/qwt_slider.cpp index 101814f..2c655ee 100644 --- a/qwtdemo/qwt/qwt_slider.cpp +++ b/qwtdemo/qwt/qwt_slider.cpp @@ -20,7 +20,7 @@ #include #include -static QSize qwtHandleSize( const QSize &size, +static QSize qwtHandleSize( const QSize &size, Qt::Orientation orientation, bool hasTrough ) { QSize handleSize = size; @@ -41,7 +41,7 @@ static QSize qwtHandleSize( const QSize &size, return handleSize; } -static QwtScaleDraw::Alignment qwtScaleDrawAlignment( +static QwtScaleDraw::Alignment qwtScaleDrawAlignment( Qt::Orientation orientation, QwtSlider::ScalePosition scalePos ) { QwtScaleDraw::Alignment align; @@ -107,7 +107,7 @@ public: }; /*! Construct vertical slider in QwtSlider::Trough style - with a scale to the left. + with a scale to the left. The scale is initialized to [0.0, 100.0] and the value set to 0.0. @@ -130,7 +130,7 @@ QwtSlider::QwtSlider( QWidget *parent ): The scale is initialized to [0.0, 100.0] and the value set to 0.0. \param parent Parent widget - \param orientation Orientation of the slider. + \param orientation Orientation of the slider. */ QwtSlider::QwtSlider( Qt::Orientation orientation, QWidget *parent ): QwtAbstractSlider( parent ) @@ -157,7 +157,7 @@ void QwtSlider::initSlider( Qt::Orientation orientation ) d_data->orientation = orientation; - scaleDraw()->setAlignment( + scaleDraw()->setAlignment( qwtScaleDrawAlignment( orientation, d_data->scalePosition ) ); scaleDraw()->setLength( 100 ); @@ -178,7 +178,7 @@ void QwtSlider::setOrientation( Qt::Orientation orientation ) d_data->orientation = orientation; - scaleDraw()->setAlignment( + scaleDraw()->setAlignment( qwtScaleDrawAlignment( orientation, d_data->scalePosition ) ); if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) ) @@ -215,14 +215,14 @@ void QwtSlider::setScalePosition( ScalePosition scalePosition ) return; d_data->scalePosition = scalePosition; - scaleDraw()->setAlignment( + scaleDraw()->setAlignment( qwtScaleDrawAlignment( d_data->orientation, scalePosition ) ); if ( testAttribute( Qt::WA_WState_Polished ) ) layoutSlider( true ); } -/*! +/*! \return Position of the scale \sa setScalePosition() */ @@ -411,7 +411,7 @@ int QwtSlider::updateInterval() const \param painter Painter \param sliderRect Bounding rectangle of the slider */ -void QwtSlider::drawSlider( +void QwtSlider::drawSlider( QPainter *painter, const QRect &sliderRect ) const { QRect innerRect( sliderRect ); @@ -433,7 +433,7 @@ void QwtSlider::drawSlider( const int slotExtent = 4; const int slotMargin = 4; - QRect slotRect; + QRect slotRect; if ( orientation() == Qt::Horizontal ) { int slotOffset = qMax( 1, handleSize.width() / 2 - slotMargin ); @@ -469,12 +469,12 @@ void QwtSlider::drawSlider( \param handleRect Bounding rectangle of the handle \param pos Position of the handle marker in widget coordinates */ -void QwtSlider::drawHandle( QPainter *painter, +void QwtSlider::drawHandle( QPainter *painter, const QRect &handleRect, int pos ) const { const int bw = d_data->borderWidth; - qDrawShadePanel( painter, + qDrawShadePanel( painter, handleRect, palette(), false, bw, &palette().brush( QPalette::Button ) ); @@ -496,14 +496,14 @@ void QwtSlider::drawHandle( QPainter *painter, \param pos Mouse position - \retval True, when handleRect() contains pos + \retval True, when handleRect() contains pos \sa scrolledTo() */ bool QwtSlider::isScrollPosition( const QPoint &pos ) const { if ( handleRect().contains( pos ) ) { - const double v = ( orientation() == Qt::Horizontal ) + const double v = ( orientation() == Qt::Horizontal ) ? pos.x() : pos.y(); d_data->mouseOffset = v - transform( value() ); @@ -524,7 +524,7 @@ bool QwtSlider::isScrollPosition( const QPoint &pos ) const */ double QwtSlider::scrolledTo( const QPoint &pos ) const { - int p = ( orientation() == Qt::Horizontal ) + int p = ( orientation() == Qt::Horizontal ) ? pos.x() : pos.y(); p -= d_data->mouseOffset; @@ -628,7 +628,7 @@ void QwtSlider::mouseReleaseEvent( QMouseEvent *event ) inside the sliderRect(). \param event Mouse event -*/ +*/ void QwtSlider::timerEvent( QTimerEvent *event ) { if ( event->timerId() != d_data->repeatTimerId ) @@ -662,9 +662,9 @@ void QwtSlider::timerEvent( QTimerEvent *event ) // restart the timer with a shorter interval killTimer( d_data->repeatTimerId ); d_data->repeatTimerId = startTimer( updateInterval() ); - + d_data->timerTick = true; - } + } } /*! @@ -709,7 +709,7 @@ void QwtSlider::resizeEvent( QResizeEvent *event ) */ void QwtSlider::changeEvent( QEvent *event ) { - if ( event->type() == QEvent::StyleChange || + if ( event->type() == QEvent::StyleChange || event->type() == QEvent::FontChange ) { if ( testAttribute( Qt::WA_WState_Polished ) ) @@ -739,7 +739,7 @@ void QwtSlider::layoutSlider( bool update_geometry ) /* The marker line of the handle needs to be aligned to - the scale. But the marker is in the center + the scale. But the marker is in the center and we need space enough to display the rest of the handle. But the scale itself usually needs margins for displaying @@ -877,7 +877,7 @@ void QwtSlider::setGroove( bool on ) if ( d_data->hasGroove != on ) { d_data->hasGroove = on; - + if ( testAttribute( Qt::WA_WState_Polished ) ) layoutSlider( true ); } @@ -890,7 +890,7 @@ void QwtSlider::setGroove( bool on ) bool QwtSlider::hasGroove() const { return d_data->hasGroove; -} +} /*! \return minimumSizeHint() @@ -917,7 +917,7 @@ QSize QwtSlider::minimumSizeHint() const if ( d_data->hasTrough ) bw = d_data->borderWidth; - int sliderLength = 0; + int sliderLength = 0; int scaleExtent = 0; if ( d_data->scalePosition != QwtSlider::NoScale ) diff --git a/qwtdemo/qwt/qwt_slider.h b/qwtdemo/qwt/qwt_slider.h index d1b36ba..183480f 100644 --- a/qwtdemo/qwt/qwt_slider.h +++ b/qwtdemo/qwt/qwt_slider.h @@ -83,7 +83,7 @@ public: void setHandleSize( const QSize & ); QSize handleSize() const; - void setBorderWidth( int bw ); + void setBorderWidth( int ); int borderWidth() const; void setSpacing( int ); diff --git a/qwtdemo/qwt/qwt_symbol.cpp b/qwtdemo/qwt/qwt_symbol.cpp index 5448b63..9dd0408 100644 --- a/qwtdemo/qwt/qwt_symbol.cpp +++ b/qwtdemo/qwt/qwt_symbol.cpp @@ -31,7 +31,7 @@ namespace QwtTriangle }; } -static QwtGraphic qwtPathGraphic( const QPainterPath &path, +static QwtGraphic qwtPathGraphic( const QPainterPath &path, const QPen &pen, const QBrush& brush ) { QwtGraphic graphic; @@ -46,19 +46,19 @@ static QwtGraphic qwtPathGraphic( const QPainterPath &path, return graphic; } -static inline QRectF qwtScaledBoundingRect( +static inline QRectF qwtScaledBoundingRect( const QwtGraphic &graphic, const QSizeF size ) { QSizeF scaledSize = size; if ( scaledSize.isEmpty() ) scaledSize = graphic.defaultSize(); - + const QSizeF sz = graphic.controlPointRect().size(); double sx = 1.0; if ( sz.width() > 0.0 ) sx = scaledSize.width() / sz.width(); - + double sy = 1.0; if ( sz.height() > 0.0 ) sy = scaledSize.height() / sz.height(); @@ -83,7 +83,7 @@ static inline void qwtDrawPixmapSymbols( QPainter *painter, QPixmap pm = symbol.pixmap(); if ( pm.size() != size ) pm = pm.scaled( size ); - + QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() ); if ( symbol.isPinPointEnabled() ) pinPoint = symbol.pinPoint(); @@ -94,15 +94,15 @@ static inline void qwtDrawPixmapSymbols( QPainter *painter, { const QPointF pos = transform.map( points[i] ) - pinPoint; - QwtPainter::drawPixmap( painter, + QwtPainter::drawPixmap( painter, QRect( pos.toPoint(), pm.size() ), pm ); } } #ifndef QWT_NO_SVG -static inline void qwtDrawSvgSymbols( QPainter *painter, - const QPointF *points, int numPoints, +static inline void qwtDrawSvgSymbols( QPainter *painter, + const QPointF *points, int numPoints, QSvgRenderer *renderer, const QwtSymbol &symbol ) { if ( renderer == NULL || !renderer->isValid() ) @@ -131,14 +131,14 @@ static inline void qwtDrawSvgSymbols( QPainter *painter, const double x = points[i].x() - dx; const double y = points[i].y() - dy; - renderer->render( painter, + renderer->render( painter, QRectF( x, y, sz.width(), sz.height() ) ); } } #endif -static inline void qwtDrawGraphicSymbols( QPainter *painter, +static inline void qwtDrawGraphicSymbols( QPainter *painter, const QPointF *points, int numPoints, const QwtGraphic &graphic, const QwtSymbol &symbol ) { @@ -875,7 +875,7 @@ QwtSymbol::QwtSymbol( QwtSymbol::Style style, const QBrush &brush, \sa setPath(), setBrush(), setPen(), setSize() */ -QwtSymbol::QwtSymbol( const QPainterPath &path, +QwtSymbol::QwtSymbol( const QPainterPath &path, const QBrush &brush, const QPen &pen ) { d_data = new PrivateData( QwtSymbol::Path, brush, pen, QSize() ); @@ -918,7 +918,7 @@ QwtSymbol::CachePolicy QwtSymbol::cachePolicy() const /*! \brief Set a painter path as symbol - The symbol is represented by a painter path, where the + The symbol is represented by a painter path, where the origin ( 0, 0 ) of the path coordinate system is mapped to the position of the symbol. @@ -926,36 +926,38 @@ QwtSymbol::CachePolicy QwtSymbol::cachePolicy() const to fit into the size. Otherwise the symbol size depends on the bounding rectangle of the path. - The following code defines a symbol drawing an arrow: + \par Example + The following code defines a symbol drawing an arrow: - \verbatim -#include + \code + #include -QwtSymbol *symbol = new QwtSymbol(); + QwtSymbol *symbol = new QwtSymbol(); -QPen pen( Qt::black, 2 ); -pen.setJoinStyle( Qt::MiterJoin ); + QPen pen( Qt::black, 2 ); + pen.setJoinStyle( Qt::MiterJoin ); -symbol->setPen( pen ); -symbol->setBrush( Qt::red ); + symbol->setPen( pen ); + symbol->setBrush( Qt::red ); -QPainterPath path; -path.moveTo( 0, 8 ); -path.lineTo( 0, 5 ); -path.lineTo( -3, 5 ); -path.lineTo( 0, 0 ); -path.lineTo( 3, 5 ); -path.lineTo( 0, 5 ); + QPainterPath path; + path.moveTo( 0, 8 ); + path.lineTo( 0, 5 ); + path.lineTo( -3, 5 ); + path.lineTo( 0, 0 ); + path.lineTo( 3, 5 ); + path.lineTo( 0, 5 ); -QTransform transform; -transform.rotate( -30.0 ); -path = transform.map( path ); + QTransform transform; + transform.rotate( -30.0 ); + path = transform.map( path ); -symbol->setPath( path ); -symbol->setPinPoint( QPointF( 0.0, 0.0 ) ); + symbol->setPath( path ); + symbol->setPinPoint( QPointF( 0.0, 0.0 ) ); -setSize( 10, 14 ); -\endverbatim + setSize( 10, 14 ); + \endcode + \endpar \param path Painter path @@ -1236,10 +1238,10 @@ void QwtSymbol::setColor( const QColor &color ) The position of a complex symbol is not always aligned to its center ( f.e an arrow, where the peak points to a position ). The pin point - defines the position inside of a Pixmap, Graphic, SvgDocument + defines the position inside of a Pixmap, Graphic, SvgDocument or PainterPath symbol where the represented point has to be aligned to. - + \param pos Position \param enable En/Disable the pin point alignment @@ -1340,12 +1342,12 @@ void QwtSymbol::drawSymbols( QPainter *painter, case QwtSymbol::Pixmap: { if ( !d_data->size.isEmpty() && - d_data->size != d_data->pixmap.pixmap.size() ) + d_data->size != d_data->pixmap.pixmap.size() ) { useCache = true; } break; - } + } default: useCache = true; } @@ -1357,8 +1359,6 @@ void QwtSymbol::drawSymbols( QPainter *painter, { const QRect br = boundingRect(); - const QRect rect( 0, 0, br.width(), br.height() ); - if ( d_data->cache.pixmap.isNull() ) { d_data->cache.pixmap = QwtPainter::backingStore( NULL, br.size() ); @@ -1401,7 +1401,7 @@ void QwtSymbol::drawSymbols( QPainter *painter, the legend. \param painter Painter - \param rect Target rectangle for the symbol + \param rect Target rectangle for the symbol */ void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const { @@ -1410,18 +1410,18 @@ void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const if ( d_data->style == QwtSymbol::Graphic ) { - d_data->graphic.graphic.render( + d_data->graphic.graphic.render( painter, rect, Qt::KeepAspectRatio ); } else if ( d_data->style == QwtSymbol::Path ) { if ( d_data->path.graphic.isNull() ) { - d_data->path.graphic = qwtPathGraphic( + d_data->path.graphic = qwtPathGraphic( d_data->path.path, d_data->pen, d_data->brush ); } - d_data->path.graphic.render( + d_data->path.graphic.render( painter, rect, Qt::KeepAspectRatio ); return; } @@ -1444,7 +1444,7 @@ void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const scaledRect = rect; } - d_data->svg.renderer->render( + d_data->svg.renderer->render( painter, scaledRect ); } #endif @@ -1455,7 +1455,7 @@ void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const // scale the symbol size to fit into rect. - const double ratio = qMin( rect.width() / br.width(), + const double ratio = qMin( rect.width() / br.width(), rect.height() / br.height() ); painter->save(); @@ -1468,7 +1468,7 @@ void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const const QPointF pos; renderSymbols( painter, &pos, 1 ); - + d_data->isPinPointEnabled = isPinPointEnabled; painter->restore(); @@ -1569,11 +1569,11 @@ void QwtSymbol::renderSymbols( QPainter *painter, { if ( d_data->path.graphic.isNull() ) { - d_data->path.graphic = qwtPathGraphic( d_data->path.path, + d_data->path.graphic = qwtPathGraphic( d_data->path.path, d_data->pen, d_data->brush ); } - qwtDrawGraphicSymbols( painter, points, numPoints, + qwtDrawGraphicSymbols( painter, points, numPoints, d_data->path.graphic, *this ); break; } @@ -1584,14 +1584,14 @@ void QwtSymbol::renderSymbols( QPainter *painter, } case QwtSymbol::Graphic: { - qwtDrawGraphicSymbols( painter, points, numPoints, + qwtDrawGraphicSymbols( painter, points, numPoints, d_data->graphic.graphic, *this ); break; } case QwtSymbol::SvgDocument: { #ifndef QWT_NO_SVG - qwtDrawSvgSymbols( painter, points, numPoints, + qwtDrawSvgSymbols( painter, points, numPoints, d_data->svg.renderer, *this ); #endif break; @@ -1653,7 +1653,7 @@ QRect QwtSymbol::boundingRect() const d_data->path.path, d_data->pen, d_data->brush ); } - rect = qwtScaledBoundingRect( + rect = qwtScaledBoundingRect( d_data->path.graphic, d_data->size ); pinPointTranslation = true; @@ -1665,14 +1665,14 @@ QRect QwtSymbol::boundingRect() const rect.setSize( d_data->pixmap.pixmap.size() ); else rect.setSize( d_data->size ); - + pinPointTranslation = true; break; } case QwtSymbol::Graphic: { - rect = qwtScaledBoundingRect( + rect = qwtScaledBoundingRect( d_data->graphic.graphic, d_data->size ); pinPointTranslation = true; diff --git a/qwtdemo/qwt/qwt_symbol.h b/qwtdemo/qwt/qwt_symbol.h index 81f16e0..538778d 100644 --- a/qwtdemo/qwt/qwt_symbol.h +++ b/qwtdemo/qwt/qwt_symbol.h @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -12,7 +12,6 @@ #include "qwt_global.h" #include -#include "qpainterpath.h" class QPainter; class QRect; @@ -22,6 +21,7 @@ class QPen; class QColor; class QPointF; class QPolygonF; +class QPainterPath; class QPixmap; class QByteArray; class QwtGraphic; @@ -85,7 +85,7 @@ public: Hexagon, /*! - The symbol is represented by a painter path, where the + The symbol is represented by a painter path, where the origin ( 0, 0 ) of the path coordinate system is mapped to the position of the symbol. @@ -131,7 +131,7 @@ public: to a pixmap and to paint this pixmap. F.e. the raster paint engine is a pure software renderer - where in cache mode a draw operation usually ends in + where in cache mode a draw operation usually ends in raster operation with the the backing store, that are usually faster, than the algorithms for rendering polygons. But the opposite can be expected for graphic pipelines @@ -141,7 +141,7 @@ public: \sa setCachePolicy(), cachePolicy() - \note The policy has no effect, when the symbol is painted + \note The policy has no effect, when the symbol is painted to a vector graphics format ( PDF, SVG ). \warning Since Qt 4.8 raster is the default backend on X11 */ @@ -154,10 +154,10 @@ public: //! Always use a pixmap cache Cache, - /*! + /*! Use a cache when one of the following conditions is true: - - The symbol is rendered with the software + - The symbol is rendered with the software renderer ( QPaintEngine::Raster ) */ AutoCache @@ -175,7 +175,7 @@ public: void setSize( const QSize & ); void setSize( int width, int height = -1 ); - const QSize& size() const; + const QSize &size() const; void setPinPoint( const QPointF &pos, bool enable = true ); QPointF pinPoint() const; @@ -185,12 +185,12 @@ public: virtual void setColor( const QColor & ); - void setBrush( const QBrush& b ); - const QBrush& brush() const; + void setBrush( const QBrush & ); + const QBrush &brush() const; void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); void setPen( const QPen & ); - const QPen& pen() const; + const QPen &pen() const; void setStyle( Style ); Style style() const; diff --git a/qwtdemo/qwt/qwt_system_clock.cpp b/qwtdemo/qwt/qwt_system_clock.cpp index fb0c5be..831d14f 100644 --- a/qwtdemo/qwt/qwt_system_clock.cpp +++ b/qwtdemo/qwt/qwt_system_clock.cpp @@ -32,12 +32,12 @@ QwtSystemClock::~QwtSystemClock() { delete d_data; } - + bool QwtSystemClock::isNull() const { return d_data->timer.isValid(); } - + void QwtSystemClock::start() { d_data->timer.start(); @@ -54,7 +54,7 @@ double QwtSystemClock::elapsed() const const qint64 nsecs = d_data->timer.nsecsElapsed(); return nsecs / 1e6; } - + #else // !USE_ELAPSED_TIMER #include @@ -356,7 +356,7 @@ void QwtSystemClock::start() } /*! - Set the start time to the current time + Set the start time to the current time \return Time, that is elapsed since the previous start time. */ double QwtSystemClock::restart() diff --git a/qwtdemo/qwt/qwt_system_clock.h b/qwtdemo/qwt/qwt_system_clock.h index b134b11..27b3a6a 100644 --- a/qwtdemo/qwt/qwt_system_clock.h +++ b/qwtdemo/qwt/qwt_system_clock.h @@ -22,8 +22,11 @@ Precision and time intervals are multiples of milliseconds (ms). + ( QwtSystemClock is obsolete since Qt 4.8 as QElapsedTimer offers the same + precision ) + \note The implementation uses high-resolution performance counter on Windows, - mach_absolute_time() on the Mac or POSIX timers on other systems. + mach_absolute_time() on the Mac or POSIX timers on other systems. If none is available it falls back on QTimer. */ diff --git a/qwtdemo/qwt/qwt_text.cpp b/qwtdemo/qwt/qwt_text.cpp index 0328486..dd9c4e3 100644 --- a/qwtdemo/qwt/qwt_text.cpp +++ b/qwtdemo/qwt/qwt_text.cpp @@ -61,8 +61,8 @@ QwtTextEngineDict::QwtTextEngineDict() QwtTextEngineDict::~QwtTextEngineDict() { - for ( EngineMap::const_iterator it = d_map.begin(); - it != d_map.end(); ++it ) + for ( EngineMap::const_iterator it = d_map.constBegin(); + it != d_map.constEnd(); ++it ) { const QwtTextEngine *textEngine = engine( it ); delete textEngine; @@ -107,13 +107,10 @@ void QwtTextEngineDict::setTextEngine( QwtText::TextFormat format, if ( format == QwtText::PlainText && engine == NULL ) return; - EngineMap::const_iterator it = d_map.find( format ); - if ( it != d_map.end() ) + EngineMap::const_iterator it = d_map.constFind( format ); + if ( it != d_map.constEnd() ) { - const QwtTextEngine *e = this->engine( it ); - if ( e ) - delete e; - + delete this->engine( it ); d_map.remove( format ); } diff --git a/qwtdemo/qwt/qwt_text.h b/qwtdemo/qwt/qwt_text.h index 0d18658..81f88a4 100644 --- a/qwtdemo/qwt/qwt_text.h +++ b/qwtdemo/qwt/qwt_text.h @@ -80,10 +80,13 @@ public: /*! Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine to display the text. The Qwt MathML extension offers such an engine - based on the MathML renderer of the Qt solutions package. + based on the MathML renderer of the former Qt solutions package. To enable MathML support the following code needs to be added to the application: -\verbatim QwtText::setTextEngine(QwtText::MathMLText, new QwtMathMLTextEngine()); \endverbatim + + \code + QwtText::setTextEngine( QwtText::MathMLText, new QwtMathMLTextEngine() ); + \endcode */ MathMLText, @@ -139,7 +142,7 @@ public: //! Layout attributes typedef QFlags LayoutAttributes; - QwtText( const QString & = QString::null, + QwtText( const QString & = QString(), TextFormat textFormat = AutoText ); QwtText( const QwtText & ); ~QwtText(); @@ -161,7 +164,7 @@ public: QFont usedFont( const QFont & ) const; - void setRenderFlags( int flags ); + void setRenderFlags( int ); int renderFlags() const; void setColor( const QColor & ); @@ -189,7 +192,7 @@ public: void draw( QPainter *painter, const QRectF &rect ) const; - static const QwtTextEngine *textEngine( + static const QwtTextEngine *textEngine( const QString &text, QwtText::TextFormat = AutoText ); static const QwtTextEngine *textEngine( QwtText::TextFormat ); diff --git a/qwtdemo/qwt/qwt_text_engine.cpp b/qwtdemo/qwt/qwt_text_engine.cpp index c51a1b3..f2ba095 100644 --- a/qwtdemo/qwt/qwt_text_engine.cpp +++ b/qwtdemo/qwt/qwt_text_engine.cpp @@ -85,14 +85,15 @@ public: const QString fontKey = font.key(); QMap::const_iterator it = - d_ascentCache.find( fontKey ); - if ( it == d_ascentCache.end() ) - { - int ascent = findAscent( font ); - it = d_ascentCache.insert( fontKey, ascent ); - } + d_ascentCache.constFind( fontKey ); - return ( *it ); + if ( it != d_ascentCache.constEnd() ) + return *it; + + const int ascent = findAscent( font ); + d_ascentCache.insert( fontKey, ascent ); + + return ascent; } private: @@ -115,7 +116,7 @@ private: int row = 0; for ( row = 0; row < img.height(); row++ ) { - const QRgb *line = reinterpret_cast( + const QRgb *line = reinterpret_cast( img.scanLine( row ) ); const int w = pm.width(); diff --git a/qwtdemo/qwt/qwt_text_engine.h b/qwtdemo/qwt/qwt_text_engine.h index 90f95ff..20c12b3 100644 --- a/qwtdemo/qwt/qwt_text_engine.h +++ b/qwtdemo/qwt/qwt_text_engine.h @@ -25,10 +25,10 @@ class QPainter; specific text format. They are used by QwtText to render a text. QwtPlainTextEngine and QwtRichTextEngine are part of the Qwt library. - The implementation of QwtMathMLTextEngine uses code from the + The implementation of QwtMathMLTextEngine uses code from the Qt solution package. Because of license implications it is built into a separate library. - + \sa QwtText::setTextEngine() */ diff --git a/qwtdemo/qwt/qwt_text_label.cpp b/qwtdemo/qwt/qwt_text_label.cpp index b97c3a4..de2289b 100644 --- a/qwtdemo/qwt/qwt_text_label.cpp +++ b/qwtdemo/qwt/qwt_text_label.cpp @@ -89,7 +89,7 @@ QString QwtTextLabel::plainText() const \sa QwtText */ -void QwtTextLabel::setText( const QString &text, +void QwtTextLabel::setText( const QString &text, QwtText::TextFormat textFormat ) { d_data->text.setText( text, textFormat ); diff --git a/qwtdemo/qwt/qwt_text_label.h b/qwtdemo/qwt/qwt_text_label.h index c481a24..57c3cf2 100644 --- a/qwtdemo/qwt/qwt_text_label.h +++ b/qwtdemo/qwt/qwt_text_label.h @@ -63,7 +63,7 @@ public: virtual void drawText( QPainter *, const QRectF & ); protected: - virtual void paintEvent( QPaintEvent *e ); + virtual void paintEvent( QPaintEvent * ); virtual void drawContents( QPainter * ); private: diff --git a/qwtdemo/qwt/qwt_thermo.cpp b/qwtdemo/qwt/qwt_thermo.cpp index ab6ae80..ed1267e 100644 --- a/qwtdemo/qwt/qwt_thermo.cpp +++ b/qwtdemo/qwt/qwt_thermo.cpp @@ -19,7 +19,7 @@ #include #include -static inline void qwtDrawLine( QPainter *painter, int pos, +static inline void qwtDrawLine( QPainter *painter, int pos, const QColor &color, const QRect &pipeRect, const QRect &liquidRect, Qt::Orientation orientation ) { @@ -58,11 +58,11 @@ QVector qwtTickList( const QwtScaleDiv &scaleDiv ) const double v = ticks[i]; if ( v > lowerLimit && v < upperLimit ) values += v; - } - } + } + } values += upperLimit; - + return values; } @@ -248,15 +248,15 @@ void QwtThermo::paintEvent( QPaintEvent *event ) const int bw = d_data->borderWidth; const QBrush brush = palette().brush( QPalette::Base ); - qDrawShadePanel( &painter, + qDrawShadePanel( &painter, tRect.adjusted( -bw, -bw, bw, bw ), - palette(), true, bw, + palette(), true, bw, d_data->autoFillPipe ? &brush : NULL ); drawLiquid( &painter, tRect ); } -/*! +/*! Resize event handler \param event Resize event */ @@ -266,7 +266,7 @@ void QwtThermo::resizeEvent( QResizeEvent *event ) layoutThermo( false ); } -/*! +/*! Qt change event handler \param event Event */ @@ -410,7 +410,7 @@ QRect QwtThermo::pipeRect() const if ( d_data->scalePosition == QwtThermo::LeadingScale ) pipeRect.setLeft( bw ); - else + else pipeRect.setLeft( cr.left() + cr.width() - bw - d_data->pipeWidth ); pipeRect.setWidth( d_data->pipeWidth ); @@ -539,7 +539,7 @@ void QwtThermo::scaleChange() \param painter Painter \param pipeRect Bounding rectangle of the pipe without borders */ -void QwtThermo::drawLiquid( +void QwtThermo::drawLiquid( QPainter *painter, const QRect &pipeRect ) const { painter->save(); @@ -581,7 +581,7 @@ void QwtThermo::drawLiquid( { const double v = scaleMap.invTransform( pos ); - qwtDrawLine( painter, pos, + qwtDrawLine( painter, pos, d_data->colorMap->color( interval, v ), pipeRect, liquidRect, d_data->orientation ); } @@ -707,10 +707,10 @@ const QwtColorMap *QwtThermo::colorMap() const /*! \brief Change the brush of the liquid. - + Changes the QPalette::ButtonText brush of the palette. - \param brush New brush. + \param brush New brush. \sa fillBrush(), QWidget::setPalette() */ void QwtThermo::setFillBrush( const QBrush& brush ) @@ -721,7 +721,7 @@ void QwtThermo::setFillBrush( const QBrush& brush ) } /*! - \return Liquid ( QPalette::ButtonText ) brush. + \return Liquid ( QPalette::ButtonText ) brush. \sa setFillBrush(), QWidget::palette() */ QBrush QwtThermo::fillBrush() const @@ -734,7 +734,7 @@ QBrush QwtThermo::fillBrush() const Changes the QPalette::Highlight brush of the palette. - \param brush New brush. + \param brush New brush. \sa alarmBrush(), QWidget::setPalette() \warning The alarm threshold has no effect, when @@ -824,7 +824,7 @@ void QwtThermo::setAlarmEnabled( bool on ) update(); } -/*! +/*! \return True, when the alarm threshold is enabled. \warning The alarm threshold has no effect, when @@ -893,7 +893,7 @@ QSize QwtThermo::minimumSizeHint() const */ QRect QwtThermo::fillRect( const QRect &pipeRect ) const { - double origin; + double origin; if ( d_data->originMode == OriginMinimum ) { origin = qMin( lowerBound(), upperBound() ); @@ -914,7 +914,7 @@ QRect QwtThermo::fillRect( const QRect &pipeRect ) const if ( to < from ) qSwap( from, to ); - + QRect fillRect = pipeRect; if ( d_data->orientation == Qt::Horizontal ) { @@ -946,7 +946,7 @@ QRect QwtThermo::alarmRect( const QRect &fillRect ) const return alarmRect; const bool inverted = ( upperBound() < lowerBound() ); - + bool increasing; if ( d_data->originMode == OriginCustom ) { @@ -960,7 +960,7 @@ QRect QwtThermo::alarmRect( const QRect &fillRect ) const const QwtScaleMap map = scaleDraw()->scaleMap(); const int alarmPos = qRound( map.transform( d_data->alarmLevel ) ); const int valuePos = qRound( map.transform( d_data->value ) ); - + if ( d_data->orientation == Qt::Horizontal ) { int v1, v2; @@ -1002,4 +1002,4 @@ QRect QwtThermo::alarmRect( const QRect &fillRect ) const } return alarmRect; -} +} diff --git a/qwtdemo/qwt/qwt_thermo.h b/qwtdemo/qwt/qwt_thermo.h index b9aa67d..a5c6aa5 100644 --- a/qwtdemo/qwt/qwt_thermo.h +++ b/qwtdemo/qwt/qwt_thermo.h @@ -29,7 +29,7 @@ class QwtColorMap; \image html sysinfo.png The fill colors might be calculated from an optional color map - If no color map has been assigned QwtThermo uses the + If no color map has been assigned QwtThermo uses the following colors/brushes from the widget palette: - QPalette::Base @@ -52,7 +52,7 @@ class QWT_EXPORT QwtThermo: public QwtAbstractScale Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation ) - Q_PROPERTY( ScalePosition scalePosition + Q_PROPERTY( ScalePosition scalePosition READ scalePosition WRITE setScalePosition ) Q_PROPERTY( OriginMode originMode READ originMode WRITE setOriginMode ) @@ -112,7 +112,7 @@ public: void setSpacing( int ); int spacing() const; - void setBorderWidth( int w ); + void setBorderWidth( int ); int borderWidth() const; void setOriginMode( OriginMode ); @@ -121,23 +121,23 @@ public: void setOrigin( double ); double origin() const; - void setFillBrush( const QBrush &b ); + void setFillBrush( const QBrush & ); QBrush fillBrush() const; - void setAlarmBrush( const QBrush &b ); + void setAlarmBrush( const QBrush & ); QBrush alarmBrush() const; - void setAlarmLevel( double v ); + void setAlarmLevel( double ); double alarmLevel() const; - void setAlarmEnabled( bool tf ); + void setAlarmEnabled( bool ); bool alarmEnabled() const; void setColorMap( QwtColorMap * ); QwtColorMap *colorMap(); const QwtColorMap *colorMap() const; - void setPipeWidth( int w ); + void setPipeWidth( int ); int pipeWidth() const; void setRangeFlags( QwtInterval::BorderFlags ); @@ -152,7 +152,7 @@ public: const QwtScaleDraw *scaleDraw() const; public Q_SLOTS: - virtual void setValue( double val ); + virtual void setValue( double ); protected: virtual void drawLiquid( QPainter *, const QRect & ) const; diff --git a/qwtdemo/qwt/qwt_transform.cpp b/qwtdemo/qwt/qwt_transform.cpp index c1e7bdd..d51955f 100644 --- a/qwtdemo/qwt/qwt_transform.cpp +++ b/qwtdemo/qwt/qwt_transform.cpp @@ -18,7 +18,7 @@ //! Smallest allowed value for logarithmic scales: 1.0e-150 const double QwtLogTransform::LogMin = 1.0e-150; - + //! Largest allowed value for logarithmic scales: 1.0e150 const double QwtLogTransform::LogMax = 1.0e150; @@ -42,7 +42,7 @@ QwtTransform::~QwtTransform() { } -/*! +/*! \param value Value to be bounded \return value unmodified */ @@ -62,7 +62,7 @@ QwtNullTransform::~QwtNullTransform() { } -/*! +/*! \param value Value to be transformed \return value unmodified */ @@ -71,7 +71,7 @@ double QwtNullTransform::transform( double value ) const return value; } -/*! +/*! \param value Value to be transformed \return value unmodified */ @@ -97,7 +97,7 @@ QwtLogTransform::~QwtLogTransform() { } -/*! +/*! \param value Value to be transformed \return log( value ) */ @@ -106,7 +106,7 @@ double QwtLogTransform::transform( double value ) const return ::log( value ); } -/*! +/*! \param value Value to be transformed \return exp( value ) */ @@ -115,7 +115,7 @@ double QwtLogTransform::invTransform( double value ) const return qExp( value ); } -/*! +/*! \param value Value to be bounded \return qBound( LogMin, value, LogMax ) */ @@ -145,7 +145,7 @@ QwtPowerTransform::~QwtPowerTransform() { } -/*! +/*! \param value Value to be transformed \return Exponentiation preserving the sign */ @@ -155,10 +155,10 @@ double QwtPowerTransform::transform( double value ) const return -qPow( -value, 1.0 / d_exponent ); else return qPow( value, 1.0 / d_exponent ); - + } -/*! +/*! \param value Value to be transformed \return Inverse exponentiation preserving the sign */ diff --git a/qwtdemo/qwt/qwt_transform.h b/qwtdemo/qwt/qwt_transform.h index cfc7027..49fcb6e 100644 --- a/qwtdemo/qwt/qwt_transform.h +++ b/qwtdemo/qwt/qwt_transform.h @@ -72,7 +72,7 @@ public: \brief Null transformation QwtNullTransform returns the values unmodified. - + */ class QWT_EXPORT QwtNullTransform: public QwtTransform { @@ -91,15 +91,15 @@ public: QwtLogTransform modifies the values using log() and exp(). \note In the calculations of QwtScaleMap the base of the log function - has no effect on the mapping. So QwtLogTransform can be used + has no effect on the mapping. So QwtLogTransform can be used for log2(), log10() or any other logarithmic scale. */ class QWT_EXPORT QwtLogTransform: public QwtTransform -{ +{ public: QwtLogTransform(); virtual ~QwtLogTransform(); - + virtual double transform( double value ) const; virtual double invTransform( double value ) const; @@ -119,7 +119,7 @@ public: /*! \brief A transformation using pow() - QwtPowerTransform preserves the sign of a value. + QwtPowerTransform preserves the sign of a value. F.e. a transformation with a factor of 2 transforms a value of -3 to -9 and v.v. Thus QwtPowerTransform can be used for scales including negative values. diff --git a/qwtdemo/qwt/qwt_wheel.cpp b/qwtdemo/qwt/qwt_wheel.cpp index 5078184..25e3125 100644 --- a/qwtdemo/qwt/qwt_wheel.cpp +++ b/qwtdemo/qwt/qwt_wheel.cpp @@ -54,7 +54,7 @@ public: inverted( false ), wrapping( false ) { - }; + } Qt::Orientation orientation; double viewAngle; @@ -113,8 +113,8 @@ QwtWheel::~QwtWheel() /*! \brief En/Disable tracking - If tracking is enabled (the default), the wheel emits the valueChanged() - signal while the wheel is moving. If tracking is disabled, the wheel + If tracking is enabled (the default), the wheel emits the valueChanged() + signal while the wheel is moving. If tracking is disabled, the wheel emits the valueChanged() signal only when the wheel movement is terminated. The wheelMoved() signal is emitted regardless id tracking is enabled or not. @@ -161,7 +161,7 @@ int QwtWheel::updateInterval() const /*! \brief Mouse press event handler - Start movement of the wheel. + Start movement of the wheel. \param event Mouse event */ @@ -208,13 +208,13 @@ void QwtWheel::mouseMoveEvent( QMouseEvent *event ) d_data->speed = ( mouseValue - d_data->mouseValue ) / ms; } - - d_data->mouseValue = mouseValue; + + d_data->mouseValue = mouseValue; double value = boundedValue( mouseValue - d_data->mouseOffset ); if ( d_data->stepAlignment ) value = alignedValue( value ); - + if ( value != d_data->value ) { d_data->value = value; @@ -237,7 +237,7 @@ void QwtWheel::mouseMoveEvent( QMouseEvent *event ) it starts flying. \param event Mouse event -*/ +*/ void QwtWheel::mouseReleaseEvent( QMouseEvent *event ) { @@ -259,7 +259,7 @@ void QwtWheel::mouseReleaseEvent( QMouseEvent *event ) if ( startFlying ) { - d_data->flyingValue = + d_data->flyingValue = boundedValue( d_data->mouseValue - d_data->mouseOffset ); d_data->timerId = startTimer( d_data->updateInterval ); @@ -280,7 +280,7 @@ void QwtWheel::mouseReleaseEvent( QMouseEvent *event ) \brief Qt timer event The flying wheel effect is implemented using a timer - + \param event Timer event \sa updateInterval() @@ -322,7 +322,7 @@ void QwtWheel::timerEvent( QTimerEvent *event ) /*! \brief Handle wheel events - In/Decrement the value + In/Decrement the value \param event Wheel event */ @@ -341,7 +341,7 @@ void QwtWheel::wheelEvent( QWheelEvent *event ) double increment = 0.0; - if ( ( event->modifiers() & Qt::ControlModifier) || + if ( ( event->modifiers() & Qt::ControlModifier) || ( event->modifiers() & Qt::ShiftModifier ) ) { // one page regardless of delta @@ -383,12 +383,12 @@ void QwtWheel::wheelEvent( QWheelEvent *event ) Step to maximum() - Qt::Key_Up\n - In case of a horizontal or not inverted vertical wheel the value + In case of a horizontal or not inverted vertical wheel the value will be incremented by the step size. For an inverted vertical wheel the value will be decremented by the step size. - Qt::Key_Down\n - In case of a horizontal or not inverted vertical wheel the value + In case of a horizontal or not inverted vertical wheel the value will be decremented by the step size. For an inverted vertical wheel the value will be incremented by the step size. @@ -481,7 +481,7 @@ void QwtWheel::keyPressEvent( QKeyEvent *event ) if ( event->isAccepted() ) stopFlying(); - + if ( increment != 0.0 ) { value = boundedValue( d_data->value + increment ); @@ -551,7 +551,7 @@ void QwtWheel::setWheelBorderWidth( int borderWidth ) } /*! - \return Wheel border width + \return Wheel border width \sa setWheelBorderWidth() */ int QwtWheel::wheelBorderWidth() const @@ -560,7 +560,7 @@ int QwtWheel::wheelBorderWidth() const } /*! - \brief Set the border width + \brief Set the border width The border defaults to 2. @@ -574,7 +574,7 @@ void QwtWheel::setBorderWidth( int width ) } /*! - \return Border width + \return Border width \sa setBorderWidth() */ int QwtWheel::borderWidth() const @@ -682,7 +682,7 @@ double QwtWheel::viewAngle() const return d_data->viewAngle; } -/*! +/*! Determine the value corresponding to a specified point \param pos Position @@ -723,7 +723,7 @@ double QwtWheel::valueAt( const QPoint &pos ) const return val; } -/*! +/*! \brief Qt Paint Event \param event Paint event */ @@ -736,7 +736,7 @@ void QwtWheel::paintEvent( QPaintEvent *event ) opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - qDrawShadePanel( &painter, + qDrawShadePanel( &painter, contentsRect(), palette(), true, d_data->borderWidth ); drawWheelBackground( &painter, wheelRect() ); @@ -752,7 +752,7 @@ void QwtWheel::paintEvent( QPaintEvent *event ) \param painter Painter \param rect Geometry for the wheel */ -void QwtWheel::drawWheelBackground( +void QwtWheel::drawWheelBackground( QPainter *painter, const QRectF &rect ) { painter->save(); @@ -760,7 +760,7 @@ void QwtWheel::drawWheelBackground( QPalette pal = palette(); // draw shaded background - QLinearGradient gradient( rect.topLeft(), + QLinearGradient gradient( rect.topLeft(), ( d_data->orientation == Qt::Horizontal ) ? rect.topRight() : rect.bottomLeft() ); gradient.setColorAt( 0.0, pal.color( QPalette::Button ) ); gradient.setColorAt( 0.2, pal.color( QPalette::Midlight ) ); @@ -771,9 +771,9 @@ void QwtWheel::drawWheelBackground( // draw internal border - const QPen lightPen( palette().color( QPalette::Light ), + const QPen lightPen( palette().color( QPalette::Light ), d_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap ); - const QPen darkPen( pal.color( QPalette::Dark ), + const QPen darkPen( pal.color( QPalette::Dark ), d_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap ); const double bw2 = 0.5 * d_data->wheelBorderWidth; @@ -781,21 +781,21 @@ void QwtWheel::drawWheelBackground( if ( d_data->orientation == Qt::Horizontal ) { painter->setPen( lightPen ); - painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ), + painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ), QPointF( rect.right(), rect.top() + bw2 ) ); painter->setPen( darkPen ); - painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ), + painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ), QPointF( rect.right(), rect.bottom() - bw2 ) ); } else // Qt::Vertical { painter->setPen( lightPen ); - painter->drawLine( QPointF( rect.left() + bw2, rect.top() ), + painter->drawLine( QPointF( rect.left() + bw2, rect.top() ), QPointF( rect.left() + bw2, rect.bottom() ) ); painter->setPen( darkPen ); - painter->drawLine( QPointF( rect.right() - bw2, rect.top() ), + painter->drawLine( QPointF( rect.right() - bw2, rect.top() ), QPointF( rect.right() - bw2, rect.bottom() ) ); } @@ -817,9 +817,9 @@ void QwtWheel::drawTicks( QPainter *painter, const QRectF &rect ) return; } - const QPen lightPen( palette().color( QPalette::Light ), + const QPen lightPen( palette().color( QPalette::Light ), 0, Qt::SolidLine, Qt::FlatCap ); - const QPen darkPen( palette().color( QPalette::Dark ), + const QPen darkPen( palette().color( QPalette::Dark ), 0, Qt::SolidLine, Qt::FlatCap ); const double cnvFactor = qAbs( d_data->totalAngle / range ); @@ -856,7 +856,7 @@ void QwtWheel::drawTicks( QPainter *painter, const QRectF &rect ) const double off = radius * ( sinArc + s ) / sinArc; double tickPos; - if ( d_data->inverted ) + if ( d_data->inverted ) tickPos = rect.left() + off; else tickPos = rect.right() - off; @@ -864,10 +864,10 @@ void QwtWheel::drawTicks( QPainter *painter, const QRectF &rect ) if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) ) { painter->setPen( darkPen ); - painter->drawLine( QPointF( tickPos - 1 , l1 ), + painter->drawLine( QPointF( tickPos - 1 , l1 ), QPointF( tickPos - 1, l2 ) ); painter->setPen( lightPen ); - painter->drawLine( QPointF( tickPos, l1 ), + painter->drawLine( QPointF( tickPos, l1 ), QPointF( tickPos, l2 ) ); } } @@ -906,10 +906,10 @@ void QwtWheel::drawTicks( QPainter *painter, const QRectF &rect ) if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) ) { painter->setPen( darkPen ); - painter->drawLine( QPointF( l1, tickPos - 1 ), + painter->drawLine( QPointF( l1, tickPos - 1 ), QPointF( l2, tickPos - 1 ) ); painter->setPen( lightPen ); - painter->drawLine( QPointF( l1, tickPos ), + painter->drawLine( QPointF( l1, tickPos ), QPointF( l2, tickPos ) ); } } @@ -1013,12 +1013,12 @@ bool QwtWheel::stepAlignment() const } /*! - \brief Set the page step count - + \brief Set the page step count + pageStepCount is a multiplicator for the single step size that typically corresponds to the user pressing PageUp or PageDown. - - A value of 0 disables page stepping. + + A value of 0 disables page stepping. The default value is 1. @@ -1030,7 +1030,7 @@ void QwtWheel::setPageStepCount( int count ) d_data->pageStepCount = qMax( 0, count ); } -/*! +/*! \return Page step count \sa setPageStepCount(), singleStep() */ @@ -1149,10 +1149,10 @@ double QwtWheel::value() const An inverted wheel increases its values in the opposite direction. The direction of an inverted horizontal wheel will be from right to left an inverted vertical wheel will increase from bottom to top. - + \param on En/Disable inverted appearance \sa isInverted() - + */ void QwtWheel::setInverted( bool on ) { @@ -1175,8 +1175,8 @@ bool QwtWheel::isInverted() 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() @@ -1250,13 +1250,13 @@ void QwtWheel::stopFlying() double QwtWheel::boundedValue( double value ) const { const double range = d_data->maximum - d_data->minimum; - + if ( d_data->wrapping && range >= 0.0 ) { if ( value < d_data->minimum ) { value += ::ceil( ( d_data->minimum - value ) / range ) * range; - } + } else if ( value > d_data->maximum ) { value -= ::ceil( ( value - d_data->maximum ) / range ) * range; @@ -1292,7 +1292,7 @@ double QwtWheel::alignedValue( double value ) const value = d_data->maximum; } } - } + } return value; } diff --git a/qwtdemo/qwt/qwt_wheel.h b/qwtdemo/qwt/qwt_wheel.h index 846543b..e36c158 100644 --- a/qwtdemo/qwt/qwt_wheel.h +++ b/qwtdemo/qwt/qwt_wheel.h @@ -77,10 +77,10 @@ public: void setBorderWidth( int ); int borderWidth() const; - void setInverted( bool tf ); + void setInverted( bool ); bool isInverted() const; - void setWrapping( bool tf ); + void setWrapping( bool ); bool wrapping() const; void setSingleStep( double ); @@ -92,18 +92,18 @@ public: void setStepAlignment( bool on ); bool stepAlignment() const; - void setRange( double vmin, double vmax ); + void setRange( double min, double max ); - void setMinimum( double min ); + void setMinimum( double ); double minimum() const; - void setMaximum( double max ); + void setMaximum( double ); double maximum() const; void setUpdateInterval( int ); int updateInterval() const; - void setTracking( bool enable ); + void setTracking( bool ); bool isTracking() const; double mass() const; @@ -120,7 +120,7 @@ Q_SIGNALS: \brief Notify a change of value. When tracking is enabled this signal will be emitted every - time the value changes. + time the value changes. \param value new value \sa setTracking() diff --git a/qwtdemo/qwt/qwt_widget_overlay.cpp b/qwtdemo/qwt/qwt_widget_overlay.cpp index c7a41e4..5974413 100644 --- a/qwtdemo/qwt/qwt_widget_overlay.cpp +++ b/qwtdemo/qwt/qwt_widget_overlay.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -13,7 +13,6 @@ #include #include #include -#include "qpainterpath.h" static QImage::Format qwtMaskImageFormat() { @@ -23,8 +22,8 @@ static QImage::Format qwtMaskImageFormat() return QImage::Format_ARGB32_Premultiplied; } -static QRegion qwtAlphaMask( - const QImage& image, const QVector rects ) +static QRegion qwtAlphaMask( + const QImage& image, const QVector &rects ) { const int w = image.width(); const int h = image.height(); @@ -42,33 +41,33 @@ static QRegion qwtAlphaMask( y1 = qMax( y1, 0 ); y2 = qMin( y2, h - 1 ); - for ( int y = y1; y <= y2; ++y ) + for ( int y = y1; y <= y2; ++y ) { bool inRect = false; int rx0 = -1; - const uint *line = + const uint *line = reinterpret_cast ( image.scanLine( y ) ) + x1; - for ( int x = x1; x <= x2; x++ ) + for ( int x = x1; x <= x2; x++ ) { const bool on = ( ( *line++ >> 24 ) != 0 ); - if ( on != inRect ) + if ( on != inRect ) { - if ( inRect ) + if ( inRect ) { rect.setCoords( rx0, y, x - 1, y ); region += rect; - } - else + } + else { rx0 = x; } inRect = on; - } + } } - if ( inRect ) + if ( inRect ) { rect.setCoords( rx0, y, x2, y ); region = region.united( rect ); @@ -212,7 +211,7 @@ void QwtWidgetOverlay::updateMask() d_data->rgbaBuffer = ( uchar* )::calloc( width() * height(), 4 ); - QImage image( d_data->rgbaBuffer, + QImage image( d_data->rgbaBuffer, width(), height(), qwtMaskImageFormat() ); QPainter painter( &image ); @@ -249,7 +248,7 @@ void QwtWidgetOverlay::updateMask() */ void QwtWidgetOverlay::paintEvent( QPaintEvent* event ) { - const QRegion clipRegion = event->region(); + const QRegion &clipRegion = event->region(); QPainter painter( this ); @@ -266,7 +265,7 @@ void QwtWidgetOverlay::paintEvent( QPaintEvent* event ) if ( d_data->rgbaBuffer && useRgbaBuffer ) { - const QImage image( d_data->rgbaBuffer, + const QImage image( d_data->rgbaBuffer, width(), height(), qwtMaskImageFormat() ); QVector rects; diff --git a/qwtdemo/qwt/qwt_widget_overlay.h b/qwtdemo/qwt/qwt_widget_overlay.h index 40d4551..e1b2560 100644 --- a/qwtdemo/qwt/qwt_widget_overlay.h +++ b/qwtdemo/qwt/qwt_widget_overlay.h @@ -22,8 +22,8 @@ class QPainter; The main use case of an widget overlay is to avoid heavy repaint operation of the widget below. - F.e. in combination with the plot canvas an overlay - avoid replots as the content of the canvas can be restored from + F.e. in combination with the plot canvas an overlay + avoid replots as the content of the canvas can be restored from its backing store. QwtWidgetOverlay is an abstract base class. Deriving classes are @@ -32,7 +32,7 @@ class QPainter; - drawOverlay() - maskHint() - Internally QwtPlotPicker uses overlays for displaying + Internally QwtPlotPicker uses overlays for displaying the rubber band and the tracker text. \sa QwtPlotCanvas::BackingStore @@ -46,11 +46,11 @@ public: When using masks the widget below gets paint events for the masked regions of the overlay only. Otherwise Qt triggers full repaints. On less powerful hardware - ( f.e embedded systems ) - or when using the raster paint + ( f.e embedded systems ) - or when using the raster paint engine on a remote desktop - bit blitting is a noticeable operation, that needs to be avoided. - - If and how to mask depends on how expensive the calculation + + If and how to mask depends on how expensive the calculation of the mask is and how many pixels can be excluded by the mask. The default setting is MaskHint. @@ -65,7 +65,7 @@ public: /*! \brief Use maskHint() as mask - For many situations a fast approximation is good enough + For many situations a fast approximation is good enough and it is not necessary to build a more detailed mask ( f.e the bounding rectangle of a text ). */ @@ -77,7 +77,7 @@ public: Sometimes it is not possible to give a fast approximation and the mask needs to be calculated by drawing the overlay and testing the result. - + When a valid maskHint() is available only pixels inside this approximation are checked. */ diff --git a/savelog/savelog.cpp b/savelog/savelog.cpp index f8201ad..4a0cd17 100644 --- a/savelog/savelog.cpp +++ b/savelog/savelog.cpp @@ -1,5 +1,6 @@ #include "savelog.h" #include "qmutex.h" +#include "qdir.h" #include "qfile.h" #include "qtcpsocket.h" #include "qtcpserver.h" diff --git a/saveruntime/saveruntime.cpp b/saveruntime/saveruntime.cpp index a7e210b..742d1cb 100644 --- a/saveruntime/saveruntime.cpp +++ b/saveruntime/saveruntime.cpp @@ -1,8 +1,9 @@ #include "saveruntime.h" #include "qmutex.h" +#include "qdir.h" +#include "qfile.h" #include "qapplication.h" #include "qtimer.h" -#include "qfile.h" #include "qtextstream.h" #include "qstringlist.h"