添加项目文件。

This commit is contained in:
ldh
2026-11-06 14:45:09 +08:00
parent fb76f2ed7d
commit 24cbecc2cc
3437 changed files with 895900 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
/******************************************************************************
* 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_H
#define QWT_H
#include "qwt_global.h"
class QSize;
/*!
Some constants for use within Qwt.
*/
namespace Qwt
{
}
QWT_EXPORT QSize qwtExpandedToGlobalStrut( const QSize& );
#endif
@@ -0,0 +1,71 @@
/******************************************************************************
* 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_ABSTRACT_LEGEND_H
#define QWT_ABSTRACT_LEGEND_H
#include "qwt_global.h"
#include <qframe.h>
class QwtLegendData;
template< typename T > class QList;
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.
\note Other type of legends can be implemented by connecting to
the QwtPlot::legendDataChanged() signal. But as these legends
are unknown to the plot layout system the layout code
( on screen and for QwtPlotRenderer ) need to be organized
in application code.
\sa QwtLegend
*/
class QWT_EXPORT QwtAbstractLegend : public QFrame
{
Q_OBJECT
public:
explicit QwtAbstractLegend( QWidget* parent = NULL );
virtual ~QwtAbstractLegend();
/*!
Render the legend into a given rectangle.
\param painter Painter
\param rect Bounding rectangle
\param fillBackground When true, fill rect with the widget background
\sa renderLegend() is used by QwtPlotRenderer
*/
virtual void renderLegend( QPainter* painter,
const QRectF& rect, bool fillBackground ) const = 0;
//! \return True, when no plot item is inserted
virtual bool isEmpty() const = 0;
virtual int scrollExtent( Qt::Orientation ) const;
public Q_SLOTS:
/*!
\brief Update the entries for a plot item
\param itemInfo Info about an item
\param data List of legend entry attributes for the item
*/
virtual void updateLegend( const QVariant& itemInfo,
const QList< QwtLegendData >& data ) = 0;
};
#endif
@@ -0,0 +1,106 @@
/******************************************************************************
* 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_ABSTRACT_SCALE_H
#define QWT_ABSTRACT_SCALE_H
#include "qwt_global.h"
#include <qwidget.h>
class QwtScaleEngine;
class QwtAbstractScaleDraw;
class QwtScaleDiv;
class QwtScaleMap;
class QwtInterval;
/*!
\brief An abstract base class for widgets having a scale
The scale of an QwtAbstractScale is determined by a QwtScaleDiv
definition, that contains the boundaries and the ticks of the scale.
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.
The scale engine also decides the type of transformation of the scale
( linear, logarithmic ... ).
*/
class QWT_EXPORT QwtAbstractScale : public QWidget
{
Q_OBJECT
Q_PROPERTY( double lowerBound READ lowerBound WRITE setLowerBound )
Q_PROPERTY( double upperBound READ upperBound WRITE setUpperBound )
Q_PROPERTY( int scaleMaxMajor READ scaleMaxMajor WRITE setScaleMaxMajor )
Q_PROPERTY( int scaleMaxMinor READ scaleMaxMinor WRITE setScaleMaxMinor )
Q_PROPERTY( double scaleStepSize READ scaleStepSize WRITE setScaleStepSize )
public:
explicit QwtAbstractScale( QWidget* parent = NULL );
virtual ~QwtAbstractScale();
void setScale( double lowerBound, double upperBound );
void setScale( const QwtInterval& );
void setScale( const QwtScaleDiv& );
const QwtScaleDiv& scaleDiv() const;
void setLowerBound( double value );
double lowerBound() const;
void setUpperBound( double value );
double upperBound() const;
void setScaleStepSize( double stepSize );
double scaleStepSize() const;
void setScaleMaxMajor( int ticks );
int scaleMaxMinor() const;
void setScaleMaxMinor( int ticks );
int scaleMaxMajor() const;
void setScaleEngine( QwtScaleEngine* );
const QwtScaleEngine* scaleEngine() const;
QwtScaleEngine* scaleEngine();
int transform( double ) const;
double invTransform( int ) const;
bool isInverted() const;
double minimum() const;
double maximum() const;
const QwtScaleMap& scaleMap() const;
protected:
virtual void changeEvent( QEvent* ) QWT_OVERRIDE;
void rescale( double lowerBound,
double upperBound, double stepSize );
void setAbstractScaleDraw( QwtAbstractScaleDraw* );
const QwtAbstractScaleDraw* abstractScaleDraw() const;
QwtAbstractScaleDraw* abstractScaleDraw();
void updateScaleDraw();
virtual void scaleChange();
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,140 @@
/******************************************************************************
* 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_ABSTRACT_SCALE_DRAW_H
#define QWT_ABSTRACT_SCALE_DRAW_H
#include "qwt_global.h"
#include "qwt_scale_div.h"
class QwtText;
class QPalette;
class QPainter;
class QFont;
class QwtTransform;
class QwtScaleMap;
/*!
\brief A abstract base class for drawing scales
QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.
After a scale division has been specified as a QwtScaleDiv object
using setScaleDiv(), the scale can be drawn with the draw() member.
*/
class QWT_EXPORT QwtAbstractScaleDraw
{
public:
/*!
Components of a scale
\sa enableComponent(), hasComponent
*/
enum ScaleComponent
{
//! Backbone = the line where the ticks are located
Backbone = 0x01,
//! Ticks
Ticks = 0x02,
//! Labels
Labels = 0x04
};
Q_DECLARE_FLAGS( ScaleComponents, ScaleComponent )
QwtAbstractScaleDraw();
virtual ~QwtAbstractScaleDraw();
void setScaleDiv( const QwtScaleDiv& );
const QwtScaleDiv& scaleDiv() const;
void setTransformation( QwtTransform* );
const QwtScaleMap& scaleMap() const;
QwtScaleMap& scaleMap();
void enableComponent( ScaleComponent, bool enable = true );
bool hasComponent( ScaleComponent ) const;
void setTickLength( QwtScaleDiv::TickType, double length );
double tickLength( QwtScaleDiv::TickType ) const;
double maxTickLength() const;
void setSpacing( double );
double spacing() const;
void setPenWidthF( qreal width );
qreal penWidthF() const;
virtual void draw( QPainter*, const QPalette& ) const;
virtual QwtText label( double ) const;
/*!
Calculate the extent
The extent is the distance from the baseline to the outermost
pixel of the scale draw in opposite to its orientation.
It is at least minimumExtent() pixels.
\param font Font used for drawing the tick labels
\return Number of pixels
\sa setMinimumExtent(), minimumExtent()
*/
virtual double extent( const QFont& font ) const = 0;
void setMinimumExtent( double );
double minimumExtent() const;
void invalidateCache();
protected:
/*!
Draw a tick
\param painter Painter
\param value Value of the tick
\param len Length of the tick
\sa drawBackbone(), drawLabel()
*/
virtual void drawTick( QPainter* painter, double value, double len ) const = 0;
/*!
Draws the baseline of the scale
\param painter Painter
\sa drawTick(), drawLabel()
*/
virtual void drawBackbone( QPainter* painter ) const = 0;
/*!
Draws the label for a major scale tick
\param painter Painter
\param value Value
\sa drawTick(), drawBackbone()
*/
virtual void drawLabel( QPainter* painter, double value ) const = 0;
const QwtText& tickLabel( const QFont&, double value ) const;
private:
Q_DISABLE_COPY(QwtAbstractScaleDraw)
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents )
#endif
@@ -0,0 +1,167 @@
/******************************************************************************
* 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_ABSTRACT_SLIDER_H
#define QWT_ABSTRACT_SLIDER_H
#include "qwt_global.h"
#include "qwt_abstract_scale.h"
/*!
\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
QwtKnob, QwtDial and QwtSlider.
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.
Only for linear scales the number of steps correspond with
a fixed step size.
*/
class QWT_EXPORT QwtAbstractSlider : public QwtAbstractScale
{
Q_OBJECT
Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true )
Q_PROPERTY( uint totalSteps READ totalSteps WRITE setTotalSteps )
Q_PROPERTY( uint singleSteps READ singleSteps WRITE setSingleSteps )
Q_PROPERTY( uint pageSteps READ pageSteps WRITE setPageSteps )
Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment )
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
Q_PROPERTY( bool invertedControls READ invertedControls WRITE setInvertedControls )
public:
explicit QwtAbstractSlider( QWidget* parent = NULL );
virtual ~QwtAbstractSlider();
void setValid( bool );
bool isValid() const;
double value() const;
void setWrapping( bool );
bool wrapping() const;
void setTotalSteps( uint );
uint totalSteps() const;
void setSingleSteps( uint );
uint singleSteps() const;
void setPageSteps( uint );
uint pageSteps() const;
void setStepAlignment( bool );
bool stepAlignment() const;
void setTracking( bool );
bool isTracking() const;
void setReadOnly( bool );
bool isReadOnly() const;
void setInvertedControls( bool );
bool invertedControls() const;
public Q_SLOTS:
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.
\param value New value
\sa setTracking(), sliderMoved()
*/
void valueChanged( double value );
/*!
This signal is emitted when the user presses the
movable part of the slider.
*/
void sliderPressed();
/*!
This signal is emitted when the user releases the
movable part of the slider.
*/
void sliderReleased();
/*!
This signal is emitted when the user moves the
slider with the mouse.
\param value New value
\sa valueChanged()
*/
void sliderMoved( double value );
protected:
virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE;
virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE;
virtual void mouseMoveEvent( QMouseEvent* ) QWT_OVERRIDE;
virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE;
/*!
\brief Determine what to do when the user presses a mouse button.
\param pos Mouse position
\retval True, when pos is a valid scroll position
\sa scrolledTo()
*/
virtual bool isScrollPosition( const QPoint& pos ) const = 0;
/*!
\brief Determine the value for a new position of the
movable part of the slider
\param pos Mouse position
\return Value for the mouse position
\sa isScrollPosition()
*/
virtual double scrolledTo( const QPoint& pos ) const = 0;
void incrementValue( int stepCount );
virtual void scaleChange() QWT_OVERRIDE;
protected:
virtual void sliderChange();
double incrementedValue(
double value, int stepCount ) const;
private:
double alignedValue( double ) const;
double boundedValue( double ) const;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,93 @@
/******************************************************************************
* 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_ANALOG_CLOCK_H
#define QWT_ANALOG_CLOCK_H
#include "qwt_global.h"
#include "qwt_dial.h"
class QwtDialNeedle;
/*!
\brief An analog clock
\image html analogclock.png
\par Example
\code
#include <qwt_analog_clock.h>
QwtAnalogClock *clock = new QwtAnalogClock(...);
clock->scaleDraw()->setPenWidth(3);
clock->setLineWidth(6);
clock->setFrameShadow(QwtDial::Sunken);
clock->setTime();
// update the clock every second
QTimer *timer = new QTimer(clock);
timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
timer->start(1000);
\endcode
\note The examples/dials example shows how to use QwtAnalogClock.
*/
class QWT_EXPORT QwtAnalogClock : public QwtDial
{
Q_OBJECT
public:
/*!
Hand type
\sa setHand(), hand()
*/
enum Hand
{
//! Needle displaying the seconds
SecondHand,
//! Needle displaying the minutes
MinuteHand,
//! Needle displaying the hours
HourHand,
//! Number of needles
NHands
};
explicit QwtAnalogClock( QWidget* parent = NULL );
virtual ~QwtAnalogClock();
void setHand( Hand, QwtDialNeedle* );
const QwtDialNeedle* hand( Hand ) const;
QwtDialNeedle* hand( Hand );
public Q_SLOTS:
void setCurrentTime();
void setTime( const QTime& );
protected:
virtual void drawNeedle( QPainter*, const QPointF&, double radius,
double direction, QPalette::ColorGroup ) const QWT_OVERRIDE;
virtual void drawHand( QPainter*, Hand, const QPointF&,
double radius, double direction, QPalette::ColorGroup ) const;
private:
// use setHand instead
void setNeedle( QwtDialNeedle* );
QwtDialNeedle* m_hand[NHands];
};
#endif
@@ -0,0 +1,51 @@
/******************************************************************************
* 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_ARROW_BUTTON_H
#define QWT_ARROW_BUTTON_H
#include "qwt_global.h"
#include <qpushbutton.h>
/*!
\brief Arrow Button
A push button with one or more filled triangles on its front.
An Arrow button can have 1 to 3 arrows in a row, pointing
up, down, left or right.
*/
class QWT_EXPORT QwtArrowButton : public QPushButton
{
public:
explicit QwtArrowButton ( int num, Qt::ArrowType, QWidget* parent = NULL );
virtual ~QwtArrowButton();
Qt::ArrowType arrowType() const;
int num() const;
virtual QSize sizeHint() const QWT_OVERRIDE;
virtual QSize minimumSizeHint() const QWT_OVERRIDE;
protected:
virtual void paintEvent( QPaintEvent*) QWT_OVERRIDE;
virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
virtual void drawButtonLabel( QPainter* );
virtual void drawArrow( QPainter*,
const QRect&, Qt::ArrowType ) const;
virtual QRect labelRect() const;
virtual QSize arrowSize( Qt::ArrowType,
const QSize& boundingSize ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+62
View File
@@ -0,0 +1,62 @@
/******************************************************************************
* 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_AXIS_H
#define QWT_AXIS_H
#include "qwt_global.h"
/*!
Enums and methods for axes
*/
namespace QwtAxis
{
//! \brief Axis position
enum Position
{
//! Y axis left of the canvas
YLeft,
//! Y axis right of the canvas
YRight,
//! X axis below the canvas
XBottom,
//! X axis above the canvas
XTop
};
//! \brief Number of axis positions
enum { AxisPositions = XTop + 1 };
bool isValid( int axisPos );
bool isYAxis( int axisPos );
bool isXAxis( int axisPos );
}
//! \return true, when axisPos is in the valid range [ YLeft, XTop ]
inline bool QwtAxis::isValid( int axisPos )
{
return ( axisPos >= 0 && axisPos < AxisPositions );
}
//! \return true, when axisPos is XBottom or XTop
inline bool QwtAxis::isXAxis( int axisPos )
{
return ( axisPos == XBottom ) || ( axisPos == XTop );
}
//! \return true, when axisPos is YLeft or YRight
inline bool QwtAxis::isYAxis( int axisPos )
{
return ( axisPos == YLeft ) || ( axisPos == YRight );
}
#endif
+28
View File
@@ -0,0 +1,28 @@
/******************************************************************************
* 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_AXIS_ID_H
#define QWT_AXIS_ID_H
#include "qwt_global.h"
#include "qwt_axis.h"
/*!
\brief Axis identifier
An axis id is one of values of QwtAxis::Position.
QwtAxisId is a placeholder for future releases ( -> multiaxes branch ),
where it is possible to have more than one axis at each side of a plot.
\sa QwtAxis
*/
typedef int QwtAxisId;
#endif
+61
View File
@@ -0,0 +1,61 @@
/******************************************************************************
* 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_BEZIER_H
#define QWT_BEZIER_H
#include "qwt_global.h"
class QPointF;
class QPolygonF;
/*!
\brief An implementation of the de Casteljau’s Algorithm for interpolating
Bézier curves
The flatness criterion for terminating the subdivision is based on
"Piecewise Linear Approximation of Bézier Curves" by
Roger Willcocks ( http://www.rops.org )
This article explains the maths behind in a very nice way:
https://jeremykun.com/2013/05/11/bezier-curves-and-picasso
*/
class QWT_EXPORT QwtBezier
{
public:
QwtBezier( double tolerance = 0.5 );
~QwtBezier();
void setTolerance( double tolerance );
double tolerance() const;
QPolygonF toPolygon( const QPointF& p1, const QPointF& cp1,
const QPointF& cp2, const QPointF& p2 ) const;
void appendToPolygon( const QPointF& p1, const QPointF& cp1,
const QPointF& cp2, const QPointF& p2, QPolygonF& polygon ) const;
static QPointF pointAt( const QPointF& p1, const QPointF& cp1,
const QPointF& cp2, const QPointF& p2, double t );
private:
double m_tolerance;
double m_flatness;
};
/*!
\return Tolerance, that is used as criterion for the subdivision
\sa setTolerance()
*/
inline double QwtBezier::tolerance() const
{
return m_tolerance;
}
#endif
+54
View File
@@ -0,0 +1,54 @@
/******************************************************************************
* 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_CLIPPER_H
#define QWT_CLIPPER_H
#include "qwt_global.h"
class QwtInterval;
class QPointF;
class QRect;
class QRectF;
class QPolygon;
class QPolygonF;
#if QT_VERSION < 0x060000
template< typename T > class QVector;
#endif
/*!
\brief Some clipping algorithms
*/
namespace QwtClipper
{
QWT_EXPORT void clipPolygon( const QRect&,
QPolygon&, bool closePolygon = false );
QWT_EXPORT void clipPolygon( const QRectF&,
QPolygon&, bool closePolygon = false );
QWT_EXPORT void clipPolygonF( const QRectF&,
QPolygonF&, bool closePolygon = false );
QWT_EXPORT QPolygon clippedPolygon( const QRect&,
const QPolygon&, bool closePolygon = false );
QWT_EXPORT QPolygon clippedPolygon( const QRectF&,
const QPolygon&, bool closePolygon = false );
QWT_EXPORT QPolygonF clippedPolygonF( const QRectF&,
const QPolygonF&, bool closePolygon = false );
QWT_EXPORT QVector< QwtInterval > clipCircle(
const QRectF&, const QPointF&, double radius );
};
#endif
+262
View File
@@ -0,0 +1,262 @@
/******************************************************************************
* 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_COLOR_MAP_H
#define QWT_COLOR_MAP_H
#include "qwt_global.h"
#include <qcolor.h>
class QwtInterval;
#if QT_VERSION < 0x060000
template< typename T > class QVector;
#endif
/*!
\brief QwtColorMap is used to map values into colors.
For displaying 3D data on a 2D plane the 3rd dimension is often
displayed using colors, like f.e in a spectrogram.
Each color map is optimized to return colors for only one of the
following image formats:
- QImage::Format_Indexed8\n
- QImage::Format_ARGB32\n
\sa QwtPlotSpectrogram, QwtScaleWidget
*/
class QWT_EXPORT QwtColorMap
{
public:
/*!
Format for color mapping
\sa rgb(), colorIndex(), colorTable()
*/
enum Format
{
//! The map is intended to map into RGB values.
RGB,
/*!
Map values into 8 bit values, that
are used as indexes into the color table.
Indexed color maps are used to generate QImage::Format_Indexed8
images. The calculation of the color index is usually faster
and the resulting image has a lower memory footprint.
\sa colorIndex(), colorTable()
*/
Indexed
};
explicit QwtColorMap( Format = QwtColorMap::RGB );
virtual ~QwtColorMap();
void setFormat( Format );
Format format() const;
/*!
Map a value of a given interval into a RGB value.
\param interval Range for the values
\param value Value
\return RGB value, corresponding to value
*/
virtual QRgb rgb( const QwtInterval& interval, double value ) const = 0;
virtual uint colorIndex( int numColors,
const QwtInterval& interval, double value ) const;
QColor color( const QwtInterval&, double value ) const;
virtual QVector< QRgb > colorTable( int numColors ) const;
virtual QVector< QRgb > colorTable256() const;
private:
Q_DISABLE_COPY(QwtColorMap)
Format m_format;
};
/*!
\brief QwtLinearColorMap builds a color map from color stops.
A color stop is a color at a specific position. The valid
range for the positions is [0.0, 1.0]. When mapping a value
into a color it is translated into this interval according to mode().
*/
class QWT_EXPORT QwtLinearColorMap : public QwtColorMap
{
public:
/*!
Mode of color map
\sa setMode(), mode()
*/
enum Mode
{
//! Return the color from the next lower color stop
FixedColors,
//! Interpolating the colors of the adjacent stops.
ScaledColors
};
explicit QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
QwtLinearColorMap( const QColor& from, const QColor& to,
QwtColorMap::Format = QwtColorMap::RGB );
virtual ~QwtLinearColorMap();
void setMode( Mode );
Mode mode() const;
void setColorInterval( const QColor& color1, const QColor& color2 );
void addColorStop( double value, const QColor& );
QVector< double > colorStops() const;
QColor color1() const;
QColor color2() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
virtual uint colorIndex( int numColors,
const QwtInterval&, double value ) const QWT_OVERRIDE;
class ColorStops;
private:
class PrivateData;
PrivateData* m_data;
};
/*!
\brief QwtAlphaColorMap varies the alpha value of a color
*/
class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap
{
public:
explicit QwtAlphaColorMap( const QColor& = QColor( Qt::gray ) );
virtual ~QwtAlphaColorMap();
void setAlphaInterval( int alpha1, int alpha2 );
int alpha1() const;
int alpha2() const;
void setColor( const QColor& );
QColor color() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
/*!
\brief QwtHueColorMap varies the hue value of the HSV color model.
QwtHueColorMap can be used to set up a color map easily, that runs cyclic over
all colors. Each cycle has 360 different steps.
The values for value and saturation are in the range of 0 to 255 and doesn't
depend on the data value to be mapped.
\sa QwtSaturationValueColorMap
*/
class QWT_EXPORT QwtHueColorMap : public QwtColorMap
{
public:
explicit QwtHueColorMap( QwtColorMap::Format = QwtColorMap::RGB );
virtual ~QwtHueColorMap();
void setHueInterval( int hue1, int hue2 ); // direction ?
void setSaturation( int saturation );
void setValue( int value );
void setAlpha( int alpha );
int hue1() const;
int hue2() const;
int saturation() const;
int value() const;
int alpha() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
/*!
\brief QwtSaturationValueColorMap varies the saturation and/or value for a given
hue in the HSV color model.
Value and saturation are in the range of 0 to 255 while hue is in the range
of 0 to 259.
\sa QwtHueColorMap
*/
class QWT_EXPORT QwtSaturationValueColorMap : public QwtColorMap
{
public:
QwtSaturationValueColorMap();
virtual ~QwtSaturationValueColorMap();
void setHue( int hue );
void setSaturationInterval( int sat1, int sat2 );
void setValueInterval( int value1, int value2 );
void setAlpha( int alpha );
int hue() const;
int saturation1() const;
int saturation2() const;
int value1() const;
int value2() const;
int alpha() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
/*!
Map a value into a color
\param interval Valid interval for values
\param value Value
\return Color corresponding to value
*/
inline QColor QwtColorMap::color( const QwtInterval& interval, double value ) const
{
return QColor::fromRgba( rgb( interval, value ) );
}
/*!
\return Intended format of the color map
\sa Format
*/
inline QwtColorMap::Format QwtColorMap::format() const
{
return m_format;
}
#endif
@@ -0,0 +1,144 @@
/******************************************************************************
* 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_COLUMN_SYMBOL_H
#define QWT_COLUMN_SYMBOL_H
#include "qwt_global.h"
#include "qwt_interval.h"
#include <qnamespace.h>
class QPainter;
class QPalette;
class QRectF;
/*!
\brief Directed rectangle representing bounding rectangle and orientation
of a column.
*/
class QWT_EXPORT QwtColumnRect
{
public:
//! Direction of the column
enum Direction
{
//! From left to right
LeftToRight,
//! From right to left
RightToLeft,
//! From bottom to top
BottomToTop,
//! From top to bottom
TopToBottom
};
//! Build an rectangle with invalid intervals directed BottomToTop.
QwtColumnRect()
: direction( BottomToTop )
{
}
//! \return A normalized QRect built from the intervals
QRectF toRect() const;
//! \return Orientation
Qt::Orientation orientation() const
{
if ( direction == LeftToRight || direction == RightToLeft )
return Qt::Horizontal;
return Qt::Vertical;
}
//! Interval for the horizontal coordinates
QwtInterval hInterval;
//! Interval for the vertical coordinates
QwtInterval vInterval;
//! Direction
Direction direction;
};
//! A drawing primitive for columns
class QWT_EXPORT QwtColumnSymbol
{
public:
/*!
Style
\sa setStyle(), style()
*/
enum Style
{
//! No Style, the symbol draws nothing
NoStyle = -1,
/*!
The column is painted with a frame depending on the frameStyle()
and lineWidth() using the palette().
*/
Box,
/*!
Styles >= QwtColumnSymbol::UserStyle are reserved for derived
classes of QwtColumnSymbol that overload draw() with
additional application specific symbol types.
*/
UserStyle = 1000
};
/*!
Frame Style used in Box style().
\sa Style, setFrameStyle(), frameStyle(), setStyle(), setPalette()
*/
enum FrameStyle
{
//! No frame
NoFrame,
//! A plain frame style
Plain,
//! A raised frame style
Raised
};
public:
explicit QwtColumnSymbol( Style = NoStyle );
virtual ~QwtColumnSymbol();
void setFrameStyle( FrameStyle );
FrameStyle frameStyle() const;
void setLineWidth( int width );
int lineWidth() const;
void setPalette( const QPalette& );
const QPalette& palette() const;
void setStyle( Style );
Style style() const;
virtual void draw( QPainter*, const QwtColumnRect& ) const;
protected:
void drawBox( QPainter*, const QwtColumnRect& ) const;
private:
Q_DISABLE_COPY(QwtColumnSymbol)
class PrivateData;
PrivateData* m_data;
};
#endif
+87
View File
@@ -0,0 +1,87 @@
/******************************************************************************
* 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_COMPASS_H
#define QWT_COMPASS_H
#include "qwt_global.h"
#include "qwt_dial.h"
#include "qwt_round_scale_draw.h"
class QwtCompassRose;
class QString;
template< class Key, class T > class QMap;
/*!
\brief A special scale draw made for QwtCompass
QwtCompassScaleDraw maps values to strings using
a special map, that can be modified by the application
The default map consists of the labels N, NE, E, SE, S, SW, W, NW.
\sa QwtCompass
*/
class QWT_EXPORT QwtCompassScaleDraw : public QwtRoundScaleDraw
{
public:
explicit QwtCompassScaleDraw();
explicit QwtCompassScaleDraw( const QMap< double, QString >& map );
virtual ~QwtCompassScaleDraw();
void setLabelMap( const QMap< double, QString >& map );
QMap< double, QString > labelMap() const;
virtual QwtText label( double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
/*!
\brief A Compass Widget
QwtCompass is a widget to display and enter directions. It consists
of a scale, an optional needle and rose.
\image html dials1.png
\note The examples/dials example shows how to use QwtCompass.
*/
class QWT_EXPORT QwtCompass : public QwtDial
{
Q_OBJECT
public:
explicit QwtCompass( QWidget* parent = NULL );
virtual ~QwtCompass();
void setRose( QwtCompassRose* rose );
const QwtCompassRose* rose() const;
QwtCompassRose* rose();
protected:
virtual void drawRose( QPainter*, const QPointF& center,
double radius, double north, QPalette::ColorGroup ) const;
virtual void drawScaleContents( QPainter*,
const QPointF& center, double radius ) const QWT_OVERRIDE;
virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,83 @@
/******************************************************************************
* 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_COMPASS_ROSE_H
#define QWT_COMPASS_ROSE_H
#include "qwt_global.h"
#include <qpalette.h>
class QPainter;
/*!
\brief Abstract base class for a compass rose
*/
class QWT_EXPORT QwtCompassRose
{
public:
QwtCompassRose();
virtual ~QwtCompassRose();
virtual void setPalette( const QPalette& );
const QPalette& palette() const;
/*!
Draw the rose
\param painter Painter
\param center Center point
\param radius Radius of the rose
\param north Position
\param colorGroup Color group
*/
virtual void draw( QPainter* painter,
const QPointF& center, double radius, double north,
QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0;
private:
Q_DISABLE_COPY(QwtCompassRose)
QPalette m_palette;
};
/*!
\brief A simple rose for QwtCompass
*/
class QWT_EXPORT QwtSimpleCompassRose : public QwtCompassRose
{
public:
QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 );
virtual ~QwtSimpleCompassRose();
void setWidth( double );
double width() const;
void setNumThorns( int );
int numThorns() const;
void setNumThornLevels( int );
int numThornLevels() const;
void setShrinkFactor( double factor );
double shrinkFactor() const;
virtual void draw( QPainter*,
const QPointF& center, double radius, double north,
QPalette::ColorGroup = QPalette::Active ) const QWT_OVERRIDE;
static void drawRose( QPainter*, const QPalette&,
const QPointF& center, double radius, double north, double width,
int numThorns, int numThornLevels, double shrinkFactor );
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+161
View File
@@ -0,0 +1,161 @@
/******************************************************************************
* 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_COUNTER_H
#define QWT_COUNTER_H
#include "qwt_global.h"
#include <qwidget.h>
/*!
\brief The Counter Widget
A Counter consists of a label displaying a number and
one ore more (up to three) push buttons on each side
of the label which can be used to increment or decrement
the counter's value.
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
changed with setNumButtons().
Example:
\code
#include <qwt_counter.h>
QwtCounter *counter = new QwtCounter(parent);
counter->setRange(0.0, 100.0); // From 0.0 to 100
counter->setSingleStep( 1.0 ); // Step size 1.0
counter->setNumButtons(2); // Two buttons each side
counter->setIncSteps(QwtCounter::Button1, 1); // Button 1 increments 1 step
counter->setIncSteps(QwtCounter::Button2, 20); // Button 2 increments 20 steps
connect(counter, SIGNAL(valueChanged(double)), myClass, SLOT(newValue(double)));
\endcode
*/
class QWT_EXPORT QwtCounter : public QWidget
{
Q_OBJECT
Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true )
Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons )
Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 )
Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 )
Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 )
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
public:
//! Button index
enum Button
{
//! Button intended for minor steps
Button1,
//! Button intended for medium steps
Button2,
//! Button intended for large steps
Button3,
//! Number of buttons
ButtonCnt
};
explicit QwtCounter( QWidget* parent = NULL );
virtual ~QwtCounter();
void setValid( bool );
bool isValid() const;
void setWrapping( bool );
bool wrapping() const;
bool isReadOnly() const;
void setReadOnly( bool );
void setNumButtons( int );
int numButtons() const;
void setIncSteps( QwtCounter::Button, int numSteps );
int incSteps( QwtCounter::Button ) const;
virtual QSize sizeHint() const QWT_OVERRIDE;
double singleStep() const;
void setSingleStep( double stepSize );
void setRange( double min, double max );
double minimum() const;
void setMinimum( double );
double maximum() const;
void setMaximum( double );
void setStepButton1( int nSteps );
int stepButton1() const;
void setStepButton2( int nSteps );
int stepButton2() const;
void setStepButton3( int nSteps );
int stepButton3() const;
double value() const;
public Q_SLOTS:
void setValue( double );
Q_SIGNALS:
/*!
This signal is emitted when a button has been released
\param value The new value
*/
void buttonReleased ( double value );
/*!
This signal is emitted when the counter's value has changed
\param value The new value
*/
void valueChanged ( double value );
protected:
virtual bool event( QEvent* ) QWT_OVERRIDE;
virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE;
virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
private Q_SLOTS:
void btnReleased();
void btnClicked();
void textChanged();
private:
void incrementValue( int numSteps );
void initCounter();
void updateButtons();
void showNumber( double );
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,84 @@
/******************************************************************************
* 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_CURVE_FITTER_H
#define QWT_CURVE_FITTER_H
#include "qwt_global.h"
class QPainterPath;
class QPolygonF;
/*!
\brief Abstract base class for a curve fitter
*/
class QWT_EXPORT QwtCurveFitter
{
public:
/*!
\brief Preferred mode of the fitting algorithm
Even if a QPainterPath can always be created from a QPolygonF
the overhead of the conversion can be avoided by indicating
the preference of the implementation to the application
code.
*/
enum Mode
{
/*!
The fitting algorithm creates a polygon - the implementation
of fitCurvePath() simply wraps the polygon into a path.
\sa QwtWeedingCurveFitter
*/
Polygon,
/*!
The fitting algorithm creates a painter path - the implementation
of fitCurve() extracts a polygon from the path.
\sa QwtSplineCurveFitter
*/
Path
};
virtual ~QwtCurveFitter();
Mode mode() const;
/*!
Find a curve which has the best fit to a series of data points
\param polygon Series of data points
\return Curve points
\sa fitCurvePath()
*/
virtual QPolygonF fitCurve( const QPolygonF& polygon ) const = 0;
/*!
Find a curve path which has the best fit to a series of data points
\param polygon Series of data points
\return Curve path
\sa fitCurve()
*/
virtual QPainterPath fitCurvePath( const QPolygonF& polygon ) const = 0;
protected:
explicit QwtCurveFitter( Mode mode );
private:
Q_DISABLE_COPY(QwtCurveFitter)
const Mode m_mode;
};
#endif
+128
View File
@@ -0,0 +1,128 @@
/******************************************************************************
* 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_DATE_H
#define QWT_DATE_H
#include "qwt_global.h"
#include <qdatetime.h>
/*!
\brief A collection of methods around date/time values
Qt offers convenient classes for dealing with date/time values,
but Qwt uses coordinate systems that are based on doubles.
QwtDate offers methods to translate from QDateTime to double and v.v.
A double is interpreted as the number of milliseconds since
1970-01-01T00:00:00 Universal Coordinated Time - also known
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.
An axis for a date/time interval is expected to be aligned
and divided in time/date units like seconds, minutes, ...
QwtDate offers several algorithms that are needed to
calculate these axes.
\sa QwtDateScaleEngine, QwtDateScaleDraw, QDate, QTime
*/
class QWT_EXPORT QwtDate
{
public:
/*!
How to identify the first week of year differs between
countries.
*/
enum Week0Type
{
/*!
According to ISO 8601 the first week of a year is defined
as "the week with the year's first Thursday in it".
FirstThursday corresponds to the numbering that is
implemented in QDate::weekNumber().
*/
FirstThursday,
/*!
"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
align and divide it.
*/
enum IntervalType
{
//! The interval is related to milliseconds
Millisecond,
//! The interval is related to seconds
Second,
//! The interval is related to minutes
Minute,
//! The interval is related to hours
Hour,
//! The interval is related to days
Day,
//! The interval is related to weeks
Week,
//! The interval is related to months
Month,
//! The interval is related to years
Year
};
enum
{
//! The Julian day of "The Epoch"
JulianDayForEpoch = 2440588
};
static QDate minDate();
static QDate maxDate();
static QDateTime toDateTime( double value,
Qt::TimeSpec = Qt::UTC );
static double toDouble( const QDateTime& );
static QDateTime ceil( const QDateTime&, IntervalType );
static QDateTime floor( const QDateTime&, IntervalType );
static QDate dateOfWeek0( int year, Week0Type );
static int weekNumber( const QDate&, Week0Type );
static int utcOffset( const QDateTime& );
static QString toString( const QDateTime&,
const QString& format, Week0Type );
};
#endif
@@ -0,0 +1,86 @@
/******************************************************************************
* 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_DATE_SCALE_DRAW_H
#define QWT_DATE_SCALE_DRAW_H
#include "qwt_global.h"
#include "qwt_scale_draw.h"
#include "qwt_date.h"
/*!
\brief A class for drawing datetime scales
QwtDateScaleDraw displays values as datetime labels.
The format of the labels depends on the alignment of
the major tick labels.
The default format strings are:
- Millisecond\n
"hh:mm:ss:zzz\nddd dd MMM yyyy"
- Second\n
"hh:mm:ss\nddd dd MMM yyyy"
- Minute\n
"hh:mm\nddd dd MMM yyyy"
- Hour\n
"hh:mm\nddd dd MMM yyyy"
- Day\n
"ddd dd MMM yyyy"
- Week\n
"Www yyyy"
- Month\n
"MMM yyyy"
- Year\n
"yyyy"
The format strings can be modified using setDateFormat()
or individually for each tick label by overloading dateFormatOfDate(),
Usually QwtDateScaleDraw is used in combination with
QwtDateScaleEngine, that calculates scales for datetime
intervals.
\sa QwtDateScaleEngine, QwtPlot::setAxisScaleDraw()
*/
class QWT_EXPORT QwtDateScaleDraw : public QwtScaleDraw
{
public:
explicit QwtDateScaleDraw( Qt::TimeSpec = Qt::LocalTime );
virtual ~QwtDateScaleDraw();
void setDateFormat( QwtDate::IntervalType, const QString& );
QString dateFormat( QwtDate::IntervalType ) const;
void setTimeSpec( Qt::TimeSpec );
Qt::TimeSpec timeSpec() const;
void setUtcOffset( int seconds );
int utcOffset() const;
void setWeek0Type( QwtDate::Week0Type );
QwtDate::Week0Type week0Type() const;
virtual QwtText label( double ) const QWT_OVERRIDE;
QDateTime toDateTime( double ) const;
protected:
virtual QwtDate::IntervalType
intervalType( const QwtScaleDiv& ) const;
virtual QString dateFormatOfDate( const QDateTime&,
QwtDate::IntervalType ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,88 @@
/******************************************************************************
* 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_DATE_SCALE_ENGINE_H
#define QWT_DATE_SCALE_ENGINE_H
#include "qwt_global.h"
#include "qwt_date.h"
#include "qwt_scale_engine.h"
/*!
\brief A scale engine for date/time values
QwtDateScaleEngine builds scales from a time intervals.
Together with QwtDateScaleDraw it can be used for
axes according to date/time values.
Years, months, weeks, days, hours and minutes are organized
in steps with non constant intervals. QwtDateScaleEngine
classifies intervals and aligns the boundaries and tick positions
according to this classification.
QwtDateScaleEngine supports representations depending
on Qt::TimeSpec specifications. The valid range for scales
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
QwtDate::toDateTime().
\sa QwtDate, QwtPlot::setAxisScaleEngine(),
QwtAbstractScale::setScaleEngine()
*/
class QWT_EXPORT QwtDateScaleEngine : public QwtLinearScaleEngine
{
public:
explicit QwtDateScaleEngine( Qt::TimeSpec = Qt::LocalTime );
virtual ~QwtDateScaleEngine();
void setTimeSpec( Qt::TimeSpec );
Qt::TimeSpec timeSpec() const;
void setUtcOffset( int seconds );
int utcOffset() const;
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 QWT_OVERRIDE;
virtual QwtScaleDiv divideScale(
double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const QWT_OVERRIDE;
virtual QwtDate::IntervalType intervalType(
const QDateTime&, const QDateTime&, int maxSteps ) const;
QDateTime toDateTime( double ) const;
protected:
virtual QDateTime alignDate( const QDateTime&, double stepSize,
QwtDate::IntervalType, bool up ) const;
private:
QwtScaleDiv buildScaleDiv( const QDateTime&, const QDateTime&,
int maxMajorSteps, int maxMinorSteps,
QwtDate::IntervalType ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+169
View File
@@ -0,0 +1,169 @@
/******************************************************************************
* 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_DIAL_H
#define QWT_DIAL_H
#include "qwt_global.h"
#include "qwt_abstract_slider.h"
#include <qframe.h>
#include <qpalette.h>
class QwtDialNeedle;
class QwtRoundScaleDraw;
class QwtAbstractScaleDraw;
/*!
\brief QwtDial class provides a rounded range control.
QwtDial is intended as base class for dial widgets like
speedometers, compass widgets, clocks ...
\image html dials2.png
A dial contains a scale and a needle indicating the current value
of the dial. Depending on Mode one of them is fixed and the
other is rotating. If not isReadOnly() the
dial can be rotated by dragging the mouse or using keyboard inputs
(see QwtAbstractSlider::keyPressEvent()). A dial might be wrapping, what means
a rotation below/above one limit continues on the other limit (f.e compass).
The scale might cover any arc of the dial, its values are related to
the origin() of the dial.
Often dials have to be updated very often according to values from external
devices. For these high refresh rates QwtDial caches as much as possible.
For derived classes it might be necessary to clear these caches manually
according to attribute changes using invalidateCache().
\sa QwtCompass, QwtAnalogClock, QwtDialNeedle
\note The controls and dials examples shows different types of dials.
\note QDial is more similar to QwtKnob than to QwtDial
*/
class QWT_EXPORT QwtDial : public QwtAbstractSlider
{
Q_OBJECT
Q_ENUMS( Shadow Mode Direction )
Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
Q_PROPERTY( Mode mode READ mode WRITE setMode )
Q_PROPERTY( double origin READ origin WRITE setOrigin )
Q_PROPERTY( double minScaleArc READ minScaleArc WRITE setMinScaleArc )
Q_PROPERTY( double maxScaleArc READ maxScaleArc WRITE setMaxScaleArc )
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
};
//! Mode controlling whether the needle or the scale is rotating
enum Mode
{
//! The needle is rotating
RotateNeedle,
//! The needle is fixed, the scales are rotating
RotateScale
};
explicit QwtDial( QWidget* parent = NULL );
virtual ~QwtDial();
void setFrameShadow( Shadow );
Shadow frameShadow() const;
void setLineWidth( int );
int lineWidth() const;
void setMode( Mode );
Mode mode() const;
void setScaleArc( double minArc, double maxArc );
void setMinScaleArc( double );
double minScaleArc() const;
void setMaxScaleArc( double );
double maxScaleArc() const;
virtual void setOrigin( double );
double origin() const;
void setNeedle( QwtDialNeedle* );
const QwtDialNeedle* needle() const;
QwtDialNeedle* needle();
QRect boundingRect() const;
QRect innerRect() const;
virtual QRect scaleInnerRect() const;
virtual QSize sizeHint() const QWT_OVERRIDE;
virtual QSize minimumSizeHint() const QWT_OVERRIDE;
void setScaleDraw( QwtRoundScaleDraw* );
QwtRoundScaleDraw* scaleDraw();
const QwtRoundScaleDraw* scaleDraw() const;
protected:
virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE;
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void changeEvent( QEvent* ) QWT_OVERRIDE;
virtual void drawFrame( QPainter* );
virtual void drawContents( QPainter* ) const;
virtual void drawFocusIndicator( QPainter* ) const;
void invalidateCache();
virtual void drawScale( QPainter*,
const QPointF& center, double radius ) const;
virtual void drawScaleContents( QPainter* painter,
const QPointF& center, double radius ) const;
virtual void drawNeedle( QPainter*, const QPointF&,
double radius, double direction, QPalette::ColorGroup ) const;
virtual double scrolledTo( const QPoint& ) const QWT_OVERRIDE;
virtual bool isScrollPosition( const QPoint& ) const QWT_OVERRIDE;
virtual void sliderChange() QWT_OVERRIDE;
virtual void scaleChange() QWT_OVERRIDE;
private:
void setAngleRange( double angle, double span );
void drawNeedle( QPainter* ) const;
class PrivateData;
PrivateData* m_data;
};
#endif
+188
View File
@@ -0,0 +1,188 @@
/******************************************************************************
* 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_DIAL_NEEDLE_H
#define QWT_DIAL_NEEDLE_H
#include "qwt_global.h"
#include <qpalette.h>
class QPainter;
/*!
\brief Base class for needles that can be used in a QwtDial.
QwtDialNeedle is a pointer that indicates a value by pointing
to a specific direction.
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtDialNeedle
{
public:
QwtDialNeedle();
virtual ~QwtDialNeedle();
virtual void setPalette( const QPalette& );
const QPalette& palette() const;
virtual void draw( QPainter*, const QPointF& center,
double length, double direction,
QPalette::ColorGroup = QPalette::Active ) const;
protected:
/*!
\brief Draw the needle
The origin of the needle is at position (0.0, 0.0 )
pointing in direction 0.0 ( = east ).
The painter is already initialized with translation and
rotation.
\param painter Painter
\param length Length of the needle
\param colorGroup Color group, used for painting
\sa setPalette(), palette()
*/
virtual void drawNeedle( QPainter* painter,
double length, QPalette::ColorGroup colorGroup ) const = 0;
virtual void drawKnob( QPainter*, double width,
const QBrush&, bool sunken ) const;
private:
Q_DISABLE_COPY(QwtDialNeedle)
QPalette m_palette;
};
/*!
\brief A needle for dial widgets
The following colors are used:
- QPalette::Mid\n
Pointer
- QPalette::Base\n
Knob
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtDialSimpleNeedle : public QwtDialNeedle
{
public:
//! Style of the needle
enum Style
{
//! Arrow
Arrow,
//! A straight line from the center
Ray
};
QwtDialSimpleNeedle( Style, bool hasKnob = true,
const QColor& mid = Qt::gray, const QColor& base = Qt::darkGray );
void setWidth( double width );
double width() const;
protected:
virtual void drawNeedle( QPainter*, double length,
QPalette::ColorGroup ) const QWT_OVERRIDE;
private:
Style m_style;
bool m_hasKnob;
double m_width;
};
/*!
\brief A magnet needle for compass widgets
A magnet needle points to two opposite directions indicating
north and south.
The following colors are used:
- QPalette::Light\n
Used for pointing south
- QPalette::Dark\n
Used for pointing north
- QPalette::Base\n
Knob (ThinStyle only)
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtCompassMagnetNeedle : public QwtDialNeedle
{
public:
//! Style of the needle
enum Style
{
//! A needle with a triangular shape
TriangleStyle,
//! A thin needle
ThinStyle
};
QwtCompassMagnetNeedle( Style = TriangleStyle,
const QColor& light = Qt::white, const QColor& dark = Qt::red );
protected:
virtual void drawNeedle( QPainter*,
double length, QPalette::ColorGroup ) const QWT_OVERRIDE;
private:
Style m_style;
};
/*!
\brief An indicator for the wind direction
QwtCompassWindArrow shows the direction where the wind comes from.
- QPalette::Light\n
Used for Style1, or the light half of Style2
- QPalette::Dark\n
Used for the dark half of Style2
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtCompassWindArrow : public QwtDialNeedle
{
public:
//! Style of the arrow
enum Style
{
//! A needle pointing to the center
Style1,
//! A needle pointing to the center
Style2
};
QwtCompassWindArrow( Style, const QColor& light = Qt::white,
const QColor& dark = Qt::gray );
protected:
virtual void drawNeedle( QPainter*,
double length, QPalette::ColorGroup ) const QWT_OVERRIDE;
private:
Style m_style;
};
#endif
@@ -0,0 +1,84 @@
/******************************************************************************
* 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_DYNGRID_LAYOUT_H
#define QWT_DYNGRID_LAYOUT_H
#include "qwt_global.h"
#include <qlayout.h>
template< typename T > class QList;
/*!
\brief The QwtDynGridLayout class lays out widgets in a grid,
adjusting the number of columns and rows to the current size.
QwtDynGridLayout takes the space it gets, divides it up into rows and
columns, and puts each of the widgets it manages into the correct cell(s).
It lays out as many number of columns as possible (limited by maxColumns()).
*/
class QWT_EXPORT QwtDynGridLayout : public QLayout
{
Q_OBJECT
public:
explicit QwtDynGridLayout( QWidget*, int margin = 0, int spacing = -1 );
explicit QwtDynGridLayout( int spacing = -1 );
virtual ~QwtDynGridLayout();
virtual void invalidate() QWT_OVERRIDE;
void setMaxColumns( uint maxColumns );
uint maxColumns() const;
uint numRows () const;
uint numColumns () const;
virtual void addItem( QLayoutItem* ) QWT_OVERRIDE;
virtual QLayoutItem* itemAt( int index ) const QWT_OVERRIDE;
virtual QLayoutItem* takeAt( int index ) QWT_OVERRIDE;
virtual int count() const QWT_OVERRIDE;
void setExpandingDirections( Qt::Orientations );
virtual Qt::Orientations expandingDirections() const QWT_OVERRIDE;
QList< QRect > layoutItems( const QRect&, uint numColumns ) const;
virtual int maxItemWidth() const;
virtual void setGeometry( const QRect& ) QWT_OVERRIDE;
virtual bool hasHeightForWidth() const QWT_OVERRIDE;
virtual int heightForWidth( int ) const QWT_OVERRIDE;
virtual QSize sizeHint() const QWT_OVERRIDE;
virtual bool isEmpty() const QWT_OVERRIDE;
uint itemCount() const;
virtual uint columnsForWidth( int width ) const;
protected:
void layoutGrid( uint numColumns,
QVector< int >& rowHeight, QVector< int >& colWidth ) const;
void stretchGrid( const QRect& rect, uint numColumns,
QVector< int >& rowHeight, QVector< int >& colWidth ) const;
private:
void init();
int maxRowWidth( int numColumns ) const;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,241 @@
/******************************************************************************
* 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_EVENT_PATTERN
#define QWT_EVENT_PATTERN
#include "qwt_global.h"
#include <qnamespace.h>
#include <qvector.h>
class QMouseEvent;
class QKeyEvent;
/*!
\brief A collection of event patterns
QwtEventPattern introduces an level of indirection for mouse and
keyboard inputs. Those are represented by symbolic names, so
the application code can be configured by individual mappings.
\sa QwtPicker, QwtPickerMachine, QwtPlotZoomer
*/
class QWT_EXPORT QwtEventPattern
{
public:
/*!
\brief Symbolic mouse input codes
QwtEventPattern implements 3 different settings for
mice with 1, 2, or 3 buttons that can be activated
using initMousePattern(). The default setting is for
3 button mice.
Individual settings can be configured using setMousePattern().
\sa initMousePattern(), setMousePattern(), setKeyPattern()
*/
enum MousePatternCode
{
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton
- Qt::LeftButton
- Qt::LeftButton
*/
MouseSelect1,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::ControlModifier
- Qt::RightButton
- Qt::RightButton
*/
MouseSelect2,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::AltModifier
- Qt::LeftButton + Qt::AltModifier
- Qt::MidButton
*/
MouseSelect3,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::ShiftModifier
- Qt::LeftButton + Qt::ShiftModifier
- Qt::LeftButton + Qt::ShiftModifier
*/
MouseSelect4,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::ControlButton | Qt::ShiftModifier
- Qt::RightButton + Qt::ShiftModifier
- Qt::RightButton + Qt::ShiftModifier
*/
MouseSelect5,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::AltModifier + Qt::ShiftModifier
- Qt::LeftButton + Qt::AltModifier | Qt::ShiftModifier
- Qt::MidButton + Qt::ShiftModifier
*/
MouseSelect6,
//! Number of mouse patterns
MousePatternCount
};
/*!
\brief Symbolic keyboard input codes
Individual settings can be configured using setKeyPattern()
\sa setKeyPattern(), setMousePattern()
*/
enum KeyPatternCode
{
//! Qt::Key_Return
KeySelect1,
//! Qt::Key_Space
KeySelect2,
//! Qt::Key_Escape
KeyAbort,
//! Qt::Key_Left
KeyLeft,
//! Qt::Key_Right
KeyRight,
//! Qt::Key_Up
KeyUp,
//! Qt::Key_Down
KeyDown,
//! Qt::Key_Plus
KeyRedo,
//! Qt::Key_Minus
KeyUndo,
//! Qt::Key_Escape
KeyHome,
//! Number of key patterns
KeyPatternCount
};
//! A pattern for mouse events
class MousePattern
{
public:
//! Constructor
MousePattern( Qt::MouseButton btn = Qt::NoButton,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
button( btn ),
modifiers( modifierCodes )
{
}
//! Button
Qt::MouseButton button;
//! Keyboard modifier
Qt::KeyboardModifiers modifiers;
};
//! A pattern for key events
class KeyPattern
{
public:
//! Constructor
KeyPattern( int keyCode = Qt::Key_unknown,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
key( keyCode ),
modifiers( modifierCodes )
{
}
//! Key code
int key;
//! Modifiers
Qt::KeyboardModifiers modifiers;
};
QwtEventPattern();
virtual ~QwtEventPattern();
void initMousePattern( int numButtons );
void initKeyPattern();
void setMousePattern( MousePatternCode, Qt::MouseButton button,
Qt::KeyboardModifiers = Qt::NoModifier );
void setKeyPattern( KeyPatternCode, int key,
Qt::KeyboardModifiers modifiers = Qt::NoModifier );
void setMousePattern( const QVector< MousePattern >& );
void setKeyPattern( const QVector< KeyPattern >& );
const QVector< MousePattern >& mousePattern() const;
const QVector< KeyPattern >& keyPattern() const;
QVector< MousePattern >& mousePattern();
QVector< KeyPattern >& keyPattern();
bool mouseMatch( MousePatternCode, const QMouseEvent* ) const;
bool keyMatch( KeyPatternCode, const QKeyEvent* ) const;
protected:
virtual bool mouseMatch( const MousePattern&, const QMouseEvent* ) const;
virtual bool keyMatch( const KeyPattern&, const QKeyEvent* ) const;
private:
#if defined( _MSC_VER )
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
QVector< MousePattern > m_mousePattern;
QVector< KeyPattern > m_keyPattern;
#if defined( _MSC_VER )
#pragma warning(pop)
#endif
};
//! Compare operator
inline bool operator==( QwtEventPattern::MousePattern b1,
QwtEventPattern::MousePattern b2 )
{
return b1.button == b2.button && b1.modifiers == b2.modifiers;
}
//! Compare operator
inline bool operator==( QwtEventPattern::KeyPattern b1,
QwtEventPattern::KeyPattern b2 )
{
return b1.key == b2.key && b1.modifiers == b2.modifiers;
}
#endif
+60
View File
@@ -0,0 +1,60 @@
/******************************************************************************
* 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_GLOBAL_H
#define QWT_GLOBAL_H
#include <qglobal.h>
// QWT_VERSION is (major << 16) + (minor << 8) + patch.
#define QWT_VERSION 0x060300
#define QWT_VERSION_STR "6.3.0"
#if defined( _MSC_VER ) /* MSVC Compiler */
/* template-class specialization 'identifier' is already instantiated */
#pragma warning(disable: 4660)
/* inherits via dominance */
#pragma warning(disable: 4250)
#endif // _MSC_VER
#ifdef QWT_DLL
#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
#endif
#endif // QWT_DLL
#ifndef QWT_EXPORT
#define QWT_EXPORT
#endif
#define QWT_CONSTEXPR Q_DECL_CONSTEXPR
#if QT_VERSION >= 0x050000
#define QWT_OVERRIDE Q_DECL_OVERRIDE
#define QWT_FINAL Q_DECL_FINAL
#endif
#ifndef QWT_CONSTEXPR
#define QWT_CONSTEXPR
#endif
#ifndef QWT_OVERRIDE
#define QWT_OVERRIDE
#endif
#ifndef QWT_FINAL
#define QWT_FINAL
#endif
#endif
+204
View File
@@ -0,0 +1,204 @@
/******************************************************************************
* 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_GRAPHIC_H
#define QWT_GRAPHIC_H
#include "qwt_global.h"
#include "qwt_null_paintdevice.h"
#include <qmetatype.h>
class QwtPainterCommand;
class QPixmap;
class QImage;
/*!
\brief A paint device for scalable graphics
QwtGraphic is the representation of a graphic that is tailored for
scalability. Like QPicture it will be initialized by QPainter
operations and can be replayed later to any target paint device.
While the usual image representations QImage and QPixmap are not
scalable Qt offers two paint devices, that might be candidates
for representing a vector graphic:
- QPicture\n
Unfortunately QPicture had been forgotten, when Qt4
introduced floating point based render engines. Its API
is still on integers, what make it unusable for proper scaling.
- 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
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
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
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
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
control point rectangle.
\sa 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
the controlPointRect() and the coordinates of the target rectangle
is set up internally in render().
When RenderPensUnscaled is set this specific scaling is applied
for the control points only, but not for the pens.
All other painter transformations ( set up by application code )
are supposed to work like usual.
\sa render();
*/
RenderPensUnscaled = 0x1
};
Q_DECLARE_FLAGS( RenderHints, RenderHint )
/*!
Indicator if the graphic contains a specific type of painter command
\sa CommandTypes, commandTypes();
*/
enum CommandType
{
//! The graphic contains scalable vector data
VectorData = 1 << 0,
//! The graphic contains raster data ( QPixmap or QImage )
RasterData = 1 << 1,
//! The graphic contains transformations beyond simple translations
Transformation = 1 << 2
};
Q_DECLARE_FLAGS( CommandTypes, CommandType )
QwtGraphic();
QwtGraphic( const QwtGraphic& );
virtual ~QwtGraphic();
QwtGraphic& operator=( const QwtGraphic& );
void reset();
bool isNull() const;
bool isEmpty() const;
CommandTypes commandTypes() const;
void render( QPainter* ) const;
void render( QPainter*, const QSizeF&,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
void render( QPainter*, const QPointF&,
Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
void render( QPainter*, const QRectF&,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
QPixmap toPixmap( qreal devicePixelRatio = 0.0 ) const;
QPixmap toPixmap( const QSize&,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
qreal devicePixelRatio = 0.0 ) const;
QImage toImage( qreal devicePixelRatio = 0.0 ) const;
QImage toImage( const QSize&,
Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
qreal devicePixelRatio = 0.0 ) const;
QRectF scaledBoundingRect( qreal sx, qreal sy ) const;
QRectF boundingRect() const;
QRectF controlPointRect() const;
const QVector< QwtPainterCommand >& commands() const;
void setCommands( const QVector< QwtPainterCommand >& );
void setDefaultSize( const QSizeF& );
QSizeF defaultSize() const;
qreal heightForWidth( qreal width ) const;
qreal widthForHeight( qreal height ) const;
void setRenderHint( RenderHint, bool on = true );
bool testRenderHint( RenderHint ) const;
RenderHints renderHints() const;
protected:
virtual QSize sizeMetrics() const QWT_OVERRIDE;
virtual void drawPath( const QPainterPath& ) QWT_OVERRIDE;
virtual void drawPixmap( const QRectF&,
const QPixmap&, const QRectF& ) QWT_OVERRIDE;
virtual void drawImage( const QRectF&, const QImage&,
const QRectF&, Qt::ImageConversionFlags ) QWT_OVERRIDE;
virtual void updateState( const QPaintEngineState& ) QWT_OVERRIDE;
private:
void renderGraphic( QPainter*, QTransform* ) const;
void updateBoundingRect( const QRectF& );
void updateControlPointRect( const QRectF& );
class PathInfo;
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::CommandTypes )
Q_DECLARE_METATYPE( QwtGraphic )
#endif
+335
View File
@@ -0,0 +1,335 @@
/******************************************************************************
* 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_INTERVAL_H
#define QWT_INTERVAL_H
#include "qwt_global.h"
#include <qmetatype.h>
/*!
\brief A class representing an interval
The interval is represented by 2 doubles, the lower and the upper limit.
*/
class QWT_EXPORT QwtInterval
{
public:
/*!
Flag indicating if a border is included or excluded
\sa setBorderFlags(), borderFlags()
*/
enum BorderFlag
{
//! Min/Max values are inside the interval
IncludeBorders = 0x00,
//! Min value is not included in the interval
ExcludeMinimum = 0x01,
//! Max value is not included in the interval
ExcludeMaximum = 0x02,
//! Min/Max values are not included in the interval
ExcludeBorders = ExcludeMinimum | ExcludeMaximum
};
//! Border flags
Q_DECLARE_FLAGS( BorderFlags, BorderFlag )
QwtInterval();
QwtInterval( double minValue, double maxValue,
BorderFlags = IncludeBorders );
void setInterval( double minValue, double maxValue,
BorderFlags = IncludeBorders );
QwtInterval normalized() const;
QwtInterval inverted() const;
QwtInterval limited( double lowerBound, double upperBound ) const;
bool operator==( const QwtInterval& ) const;
bool operator!=( const QwtInterval& ) const;
void setBorderFlags( BorderFlags );
BorderFlags borderFlags() const;
double minValue() const;
double maxValue() const;
double width() const;
long double widthL() const;
void setMinValue( double );
void setMaxValue( double );
bool contains( double value ) const;
bool contains( const QwtInterval& ) const;
bool intersects( const QwtInterval& ) const;
QwtInterval intersect( const QwtInterval& ) const;
QwtInterval unite( const QwtInterval& ) const;
QwtInterval operator|( const QwtInterval& ) const;
QwtInterval operator&( const QwtInterval& ) const;
QwtInterval& operator|=( const QwtInterval& );
QwtInterval& operator&=( const QwtInterval& );
QwtInterval extend( double value ) const;
QwtInterval operator|( double ) const;
QwtInterval& operator|=( double );
bool isValid() const;
bool isNull() const;
void invalidate();
QwtInterval symmetrize( double value ) const;
private:
double m_minValue;
double m_maxValue;
BorderFlags m_borderFlags;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags )
Q_DECLARE_METATYPE( QwtInterval )
Q_DECLARE_TYPEINFO( QwtInterval, Q_MOVABLE_TYPE );
/*!
\brief Default Constructor
Creates an invalid interval [0.0, -1.0]
\sa setInterval(), isValid()
*/
inline QwtInterval::QwtInterval()
: m_minValue( 0.0 )
, m_maxValue( -1.0 )
, m_borderFlags( IncludeBorders )
{
}
/*!
Constructor
Build an interval with from min/max values
\param minValue Minimum value
\param maxValue Maximum value
\param borderFlags Include/Exclude borders
*/
inline QwtInterval::QwtInterval(
double minValue, double maxValue, BorderFlags borderFlags )
: m_minValue( minValue )
, m_maxValue( maxValue )
, m_borderFlags( borderFlags )
{
}
/*!
Assign the limits of the interval
\param minValue Minimum value
\param maxValue Maximum value
\param borderFlags Include/Exclude borders
*/
inline void QwtInterval::setInterval(
double minValue, double maxValue, BorderFlags borderFlags )
{
m_minValue = minValue;
m_maxValue = maxValue;
m_borderFlags = borderFlags;
}
/*!
Change the border flags
\param borderFlags Or'd BorderMode flags
\sa borderFlags()
*/
inline void QwtInterval::setBorderFlags( BorderFlags borderFlags )
{
m_borderFlags = borderFlags;
}
/*!
\return Border flags
\sa setBorderFlags()
*/
inline QwtInterval::BorderFlags QwtInterval::borderFlags() const
{
return m_borderFlags;
}
/*!
Assign the lower limit of the interval
\param minValue Minimum value
*/
inline void QwtInterval::setMinValue( double minValue )
{
m_minValue = minValue;
}
/*!
Assign the upper limit of the interval
\param maxValue Maximum value
*/
inline void QwtInterval::setMaxValue( double maxValue )
{
m_maxValue = maxValue;
}
//! \return Lower limit of the interval
inline double QwtInterval::minValue() const
{
return m_minValue;
}
//! \return Upper limit of the interval
inline double QwtInterval::maxValue() const
{
return m_maxValue;
}
/*!
A interval is valid when minValue() <= maxValue().
In case of QwtInterval::ExcludeBorders it is true
when minValue() < maxValue()
\return True, when the interval is valid
*/
inline bool QwtInterval::isValid() const
{
if ( ( m_borderFlags & ExcludeBorders ) == 0 )
return m_minValue <= m_maxValue;
else
return m_minValue < m_maxValue;
}
/*!
\brief Return the width of an interval
The width of invalid intervals is 0.0, otherwise the result is
maxValue() - minValue().
\return Interval width
\sa isValid()
*/
inline double QwtInterval::width() const
{
return isValid() ? ( m_maxValue - m_minValue ) : 0.0;
}
/*!
\brief Return the width of an interval as long double
The width of invalid intervals is 0.0, otherwise the result is
maxValue() - minValue().
\return Interval width
\sa isValid()
*/
inline long double QwtInterval::widthL() const
{
if ( !isValid() )
return 0.0;
return static_cast< long double >( m_maxValue )
- static_cast< long double >( m_minValue );
}
/*!
\brief Intersection of two intervals
\param other Interval to intersect with
\return Intersection of this and other
\sa intersect()
*/
inline QwtInterval QwtInterval::operator&(
const QwtInterval& other ) const
{
return intersect( other );
}
/*!
Union of two intervals
\param other Interval to unite with
\return Union of this and other
\sa unite()
*/
inline QwtInterval QwtInterval::operator|(
const QwtInterval& other ) const
{
return unite( other );
}
/*!
\brief Compare two intervals
\param other Interval to compare with
\return True, when this and other are equal
*/
inline bool QwtInterval::operator==( const QwtInterval& other ) const
{
return ( m_minValue == other.m_minValue ) &&
( m_maxValue == other.m_maxValue ) &&
( m_borderFlags == other.m_borderFlags );
}
/*!
\brief Compare two intervals
\param other Interval to compare with
\return True, when this and other are not equal
*/
inline bool QwtInterval::operator!=( const QwtInterval& other ) const
{
return ( !( *this == other ) );
}
/*!
Extend an interval
\param value Value
\return Extended interval
\sa extend()
*/
inline QwtInterval QwtInterval::operator|( double value ) const
{
return extend( value );
}
//! \return true, if isValid() && (minValue() >= maxValue())
inline bool QwtInterval::isNull() const
{
return isValid() && m_minValue >= m_maxValue;
}
/*!
Invalidate the interval
The limits are set to interval [0.0, -1.0]
\sa isValid()
*/
inline void QwtInterval::invalidate()
{
m_minValue = 0.0;
m_maxValue = -1.0;
}
#ifndef QT_NO_DEBUG_STREAM
QWT_EXPORT QDebug operator<<( QDebug, const QwtInterval& );
#endif
#endif
@@ -0,0 +1,88 @@
/******************************************************************************
* 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_INTERVAL_SYMBOL_H
#define QWT_INTERVAL_SYMBOL_H
#include "qwt_global.h"
#include <qnamespace.h>
class QPainter;
class QPen;
class QBrush;
class QPointF;
class QColor;
/*!
\brief A drawing primitive for displaying an interval like an error bar
\sa QwtPlotIntervalCurve
*/
class QWT_EXPORT QwtIntervalSymbol
{
public:
//! Symbol style
enum Style
{
//! No Style. The symbol cannot be drawn.
NoSymbol = -1,
/*!
The symbol displays a line with caps at the beginning/end.
The size of the caps depends on the symbol width().
*/
Bar,
/*!
The symbol displays a plain rectangle using pen() and brush().
The size of the rectangle depends on the translated interval and
the width(),
*/
Box,
/*!
Styles >= UserSymbol are reserved for derived
classes of QwtIntervalSymbol that overload draw() with
additional application specific symbol types.
*/
UserSymbol = 1000
};
public:
explicit QwtIntervalSymbol( Style = NoSymbol );
QwtIntervalSymbol( const QwtIntervalSymbol& );
virtual ~QwtIntervalSymbol();
QwtIntervalSymbol& operator=( const QwtIntervalSymbol& );
bool operator==( const QwtIntervalSymbol& ) const;
bool operator!=( const QwtIntervalSymbol& ) const;
void setWidth( int );
int width() 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;
void setStyle( Style );
Style style() const;
virtual void draw( QPainter*, Qt::Orientation,
const QPointF& from, const QPointF& to ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+178
View File
@@ -0,0 +1,178 @@
/******************************************************************************
* 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_KNOB_H
#define QWT_KNOB_H
#include "qwt_global.h"
#include "qwt_abstract_slider.h"
class QwtRoundScaleDraw;
/*!
\brief The Knob Widget
The QwtKnob widget imitates look and behavior of a volume knob on a radio.
It looks similar to QDial - not to QwtDial.
The value range of a knob might be divided into several turns.
The layout of the knob depends on the knobWidth().
- width > 0
The diameter of the knob is fixed and the knob is aligned
according to the alignment() flags inside of the contentsRect().
- width <= 0
The knob is extended to the minimum of width/height of the contentsRect()
and aligned in the other direction according to alignment().
Setting a fixed knobWidth() is helpful to align several knobs with different
scale labels.
\image html knob.png
*/
class QWT_EXPORT QwtKnob : public QwtAbstractSlider
{
Q_OBJECT
Q_ENUMS ( KnobStyle MarkerStyle )
Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle )
Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment )
Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
Q_PROPERTY( int numTurns READ numTurns WRITE setNumTurns )
Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle )
Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize )
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
filled from the brushes of the widget palette().
\sa setKnobStyle(), knobStyle()
*/
enum KnobStyle
{
//! Fill the knob with a brush from QPalette::Button.
Flat,
//! 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.
*/
Styled
};
/*!
\brief Marker type
The marker indicates the current value on the knob
The default setting is a Notch marker.
\sa setMarkerStyle(), setMarkerSize()
*/
enum MarkerStyle
{
//! Don't paint any marker
NoMarker = -1,
//! Paint a single tick in QPalette::ButtonText color
Tick,
//! Paint a triangle in QPalette::ButtonText color
Triangle,
//! Paint a circle in QPalette::ButtonText color
Dot,
/*!
Draw a raised ellipse with a gradient build from
QPalette::Light and QPalette::Mid
*/
Nub,
/*!
Draw a sunken ellipse with a gradient build from
QPalette::Light and QPalette::Mid
*/
Notch
};
explicit QwtKnob( QWidget* parent = NULL );
virtual ~QwtKnob();
void setAlignment( Qt::Alignment );
Qt::Alignment alignment() const;
void setKnobWidth( int );
int knobWidth() const;
void setNumTurns( int );
int numTurns() const;
void setTotalAngle ( double angle );
double totalAngle() const;
void setKnobStyle( KnobStyle );
KnobStyle knobStyle() const;
void setBorderWidth( int );
int borderWidth() const;
void setMarkerStyle( MarkerStyle );
MarkerStyle markerStyle() const;
void setMarkerSize( int );
int markerSize() const;
virtual QSize sizeHint() const QWT_OVERRIDE;
virtual QSize minimumSizeHint() const QWT_OVERRIDE;
void setScaleDraw( QwtRoundScaleDraw* );
const QwtRoundScaleDraw* scaleDraw() const;
QwtRoundScaleDraw* scaleDraw();
QRect knobRect() const;
protected:
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void changeEvent( QEvent* ) QWT_OVERRIDE;
virtual void drawKnob( QPainter*, const QRectF& ) const;
virtual void drawFocusIndicator( QPainter* ) const;
virtual void drawMarker( QPainter*,
const QRectF&, double angle ) const;
virtual double scrolledTo( const QPoint& ) const QWT_OVERRIDE;
virtual bool isScrollPosition( const QPoint& ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+119
View File
@@ -0,0 +1,119 @@
/******************************************************************************
* 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_LEGEND_H
#define QWT_LEGEND_H
#include "qwt_global.h"
#include "qwt_abstract_legend.h"
#include "qwt_legend_data.h"
#include <qvariant.h>
class QScrollBar;
/*!
\brief The legend widget
The QwtLegend widget is a tabular arrangement of legend items. Legend
items might be any type of widget, but in general they will be
a QwtLegendLabel.
\sa QwtLegendLabel, QwtPlotItem, QwtPlot
*/
class QWT_EXPORT QwtLegend : public QwtAbstractLegend
{
Q_OBJECT
public:
explicit QwtLegend( QWidget* parent = NULL );
virtual ~QwtLegend();
void setMaxColumns( uint numColums );
uint maxColumns() const;
void setDefaultItemMode( QwtLegendData::Mode );
QwtLegendData::Mode defaultItemMode() const;
QWidget* contentsWidget();
const QWidget* contentsWidget() const;
QWidget* legendWidget( const QVariant& ) const;
QList< QWidget* > legendWidgets( const QVariant& ) const;
QVariant itemInfo( const QWidget* ) const;
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
virtual QSize sizeHint() const QWT_OVERRIDE;
virtual int heightForWidth( int w ) const QWT_OVERRIDE;
QScrollBar* horizontalScrollBar() const;
QScrollBar* verticalScrollBar() const;
virtual void renderLegend( QPainter*,
const QRectF&, bool fillBackground ) const QWT_OVERRIDE;
virtual void renderItem( QPainter*,
const QWidget*, const QRectF&, bool fillBackground ) const;
virtual bool isEmpty() const QWT_OVERRIDE;
virtual int scrollExtent( Qt::Orientation ) const QWT_OVERRIDE;
Q_SIGNALS:
/*!
A signal which is emitted when the user has clicked on
a legend label, which is in QwtLegendData::Clickable mode.
\param itemInfo Info for the item item of the
selected legend item
\param index Index of the legend label in the list of widgets
that are associated with the plot item
\note clicks are disabled as default
\sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
*/
void clicked( const QVariant& itemInfo, int index );
/*!
A signal which is emitted when the user has clicked on
a legend label, which is in QwtLegendData::Checkable mode
\param itemInfo Info for the item of the
selected legend label
\param index Index of the legend label in the list of widgets
that are associated with the plot item
\param on True when the legend label is checked
\note clicks are disabled as default
\sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
*/
void checked( const QVariant& itemInfo, bool on, int index );
public Q_SLOTS:
virtual void updateLegend( const QVariant&,
const QList< QwtLegendData >& ) QWT_OVERRIDE;
protected Q_SLOTS:
void itemClicked();
void itemChecked( bool );
protected:
virtual QWidget* createWidget( const QwtLegendData& ) const;
virtual void updateWidget( QWidget*, const QwtLegendData& );
private:
void updateTabOrder();
class PrivateData;
PrivateData* m_data;
};
#endif
+88
View File
@@ -0,0 +1,88 @@
/******************************************************************************
* 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_LEGEND_DATA_H
#define QWT_LEGEND_DATA_H
#include "qwt_global.h"
#include <qvariant.h>
#include <qmap.h>
class QwtText;
class QwtGraphic;
/*!
\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.
By overloading QwtPlotItem::legendData() any other set of attributes
could be used, that can be handled by a modified ( or completely
different ) implementation of a legend.
\sa QwtLegend, QwtPlotLegendItem
\note The stockchart example implements a legend as a tree
with checkable items
*/
class QWT_EXPORT QwtLegendData
{
public:
//! Mode defining how a legend entry interacts
enum Mode
{
//! The legend item is not interactive, like a label
ReadOnly,
//! The legend item is clickable, like a push button
Clickable,
//! The legend item is checkable, like a checkable button
Checkable
};
//! Identifier how to interpret a QVariant
enum Role
{
// The value is a Mode
ModeRole,
// The value is a title
TitleRole,
// The value is an icon
IconRole,
// Values < UserRole are reserved for internal use
UserRole = 32
};
QwtLegendData();
~QwtLegendData();
void setValues( const QMap< int, QVariant >& );
const QMap< int, QVariant >& values() const;
void setValue( int role, const QVariant& );
QVariant value( int role ) const;
bool hasRole( int role ) const;
bool isValid() const;
QwtGraphic icon() const;
QwtText title() const;
Mode mode() const;
private:
QMap< int, QVariant > m_map;
};
#endif
@@ -0,0 +1,78 @@
/******************************************************************************
* 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_LEGEND_LABEL_H
#define QWT_LEGEND_LABEL_H
#include "qwt_global.h"
#include "qwt_text_label.h"
#include "qwt_legend_data.h"
class QwtText;
/*!
\brief A widget representing something on a QwtLegend.
*/
class QWT_EXPORT QwtLegendLabel : public QwtTextLabel
{
Q_OBJECT
public:
explicit QwtLegendLabel( QWidget* parent = 0 );
virtual ~QwtLegendLabel();
void setData( const QwtLegendData& );
const QwtLegendData& data() const;
void setItemMode( QwtLegendData::Mode );
QwtLegendData::Mode itemMode() const;
void setSpacing( int spacing );
int spacing() const;
virtual void setText( const QwtText& ) QWT_OVERRIDE;
void setIcon( const QPixmap& );
QPixmap icon() const;
virtual QSize sizeHint() const QWT_OVERRIDE;
bool isChecked() const;
public Q_SLOTS:
void setChecked( bool on );
Q_SIGNALS:
//! Signal, when the legend item has been clicked
void clicked();
//! Signal, when the legend item has been pressed
void pressed();
//! Signal, when the legend item has been released
void released();
//! Signal, when the legend item has been toggled
void checked( bool );
protected:
void setDown( bool );
bool isDown() const;
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE;
virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE;
virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
virtual void keyReleaseEvent( QKeyEvent* ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+86
View File
@@ -0,0 +1,86 @@
/******************************************************************************
* 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_MAGNIFIER_H
#define QWT_MAGNIFIER_H
#include "qwt_global.h"
#include <qobject.h>
class QWidget;
class QMouseEvent;
class QWheelEvent;
class QKeyEvent;
/*!
\brief QwtMagnifier provides zooming, by magnifying in steps.
Using QwtMagnifier a plot can be zoomed in/out in steps using
keys, the mouse wheel or moving a mouse button in vertical direction.
*/
class QWT_EXPORT QwtMagnifier : public QObject
{
Q_OBJECT
public:
explicit QwtMagnifier( QWidget* );
virtual ~QwtMagnifier();
QWidget* parentWidget();
const QWidget* parentWidget() const;
void setEnabled( bool );
bool isEnabled() const;
// mouse
void setMouseFactor( double );
double mouseFactor() const;
void setMouseButton( Qt::MouseButton, Qt::KeyboardModifiers = Qt::NoModifier );
void getMouseButton( Qt::MouseButton&, Qt::KeyboardModifiers& ) const;
// mouse wheel
void setWheelFactor( double );
double wheelFactor() const;
void setWheelModifiers( Qt::KeyboardModifiers );
Qt::KeyboardModifiers wheelModifiers() const;
// keyboard
void setKeyFactor( double );
double keyFactor() const;
void setZoomInKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
void getZoomInKey( int& key, Qt::KeyboardModifiers& ) const;
void setZoomOutKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
void getZoomOutKey( int& key, Qt::KeyboardModifiers& ) const;
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
protected:
/*!
Rescale the parent widget
\param factor Scale factor
*/
virtual void rescale( double factor ) = 0;
virtual void widgetMousePressEvent( QMouseEvent* );
virtual void widgetMouseReleaseEvent( QMouseEvent* );
virtual void widgetMouseMoveEvent( QMouseEvent* );
virtual void widgetWheelEvent( QWheelEvent* );
virtual void widgetKeyPressEvent( QKeyEvent* );
virtual void widgetKeyReleaseEvent( QKeyEvent* );
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+281
View File
@@ -0,0 +1,281 @@
/******************************************************************************
* 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_MATH_H
#define QWT_MATH_H
#include "qwt_global.h"
/*
Microsoft says:
Define _USE_MATH_DEFINES before including math.h to expose these macro
definitions for common math constants. These are placed under an #ifdef
since these commonly-defined names are not part of the C/C++ standards.
*/
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#define undef_USE_MATH_DEFINES
#endif
#include <cmath>
#ifdef undef_USE_MATH_DEFINES
#undef _USE_MATH_DEFINES
#undef undef_USE_MATH_DEFINES
#endif
#ifndef M_E
#define M_E ( 2.7182818284590452354 )
#endif
#ifndef M_LOG2E
#define M_LOG2E ( 1.4426950408889634074 )
#endif
#ifndef M_LOG10E
#define M_LOG10E ( 0.43429448190325182765 )
#endif
#ifndef M_LN2
#define M_LN2 ( 0.69314718055994530942 )
#endif
#ifndef M_LN10
#define M_LN10 ( 2.30258509299404568402 )
#endif
#ifndef M_PI
#define M_PI ( 3.14159265358979323846 )
#endif
#ifndef M_PI_2
#define M_PI_2 ( 1.57079632679489661923 )
#endif
#ifndef M_PI_4
#define M_PI_4 ( 0.78539816339744830962 )
#endif
#ifndef M_1_PI
#define M_1_PI ( 0.31830988618379067154 )
#endif
#ifndef M_2_PI
#define M_2_PI ( 0.63661977236758134308 )
#endif
#ifndef M_2_SQRTPI
#define M_2_SQRTPI ( 1.12837916709551257390 )
#endif
#ifndef M_SQRT2
#define M_SQRT2 ( 1.41421356237309504880 )
#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 ( 0.70710678118654752440 )
#endif
#if defined( QT_WARNING_PUSH )
/*
early Qt versions not having QT_WARNING_PUSH is full of warnings
so that we do not care of suppressing those from below
*/
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
QT_WARNING_DISABLE_GCC("-Wdouble-promotion")
#endif
/*
On systems, where qreal is a float you often run into
compiler issues with qMin/qMax.
*/
//! \return Minimum of a and b.
QWT_CONSTEXPR inline float qwtMinF( float a, float b )
{
return ( a < b ) ? a : b;
}
//! \return Minimum of a and b.
QWT_CONSTEXPR inline double qwtMinF( double a, double b )
{
return ( a < b ) ? a : b;
}
//! \return Minimum of a and b.
QWT_CONSTEXPR inline qreal qwtMinF( float a, double b )
{
return ( a < b ) ? a : b;
}
//! \return Minimum of a and b.
QWT_CONSTEXPR inline qreal qwtMinF( double a, float b )
{
return ( a < b ) ? a : b;
}
//! \return Maximum of a and b.
QWT_CONSTEXPR inline float qwtMaxF( float a, float b )
{
return ( a < b ) ? b : a;
}
//! \return Maximum of a and b.
QWT_CONSTEXPR inline double qwtMaxF( double a, double b )
{
return ( a < b ) ? b : a;
}
//! \return Maximum of a and b.
QWT_CONSTEXPR inline qreal qwtMaxF( float a, double b )
{
return ( a < b ) ? b : a;
}
//! \return Maximum of a and b.
QWT_CONSTEXPR inline qreal qwtMaxF( double a, float b )
{
return ( a < b ) ? b : a;
}
#if defined( QT_WARNING_POP )
QT_WARNING_POP
#endif
QWT_EXPORT double qwtNormalizeRadians( double radians );
QWT_EXPORT double qwtNormalizeDegrees( double degrees );
QWT_EXPORT quint32 qwtRand();
/*!
\brief Compare 2 values, relative to an interval
Values are "equal", when :
\f$\cdot value2 - value1 <= abs(intervalSize * 10e^{-6})\f$
\param value1 First value to compare
\param value2 Second value to compare
\param intervalSize interval size
\return 0: if equal, -1: if value2 > value1, 1: if value1 > value2
*/
inline int qwtFuzzyCompare( double value1, double value2, double intervalSize )
{
const double eps = qAbs( 1.0e-6 * intervalSize );
if ( value2 - value1 > eps )
return -1;
if ( value1 - value2 > eps )
return 1;
return 0;
}
//! Return the sign
inline int qwtSign( double x )
{
if ( x > 0.0 )
return 1;
else if ( x < 0.0 )
return ( -1 );
else
return 0;
}
//! Return the square of a number
inline double qwtSqr( double x )
{
return x * x;
}
//! Approximation of arc tangent ( error below 0,005 radians )
inline double qwtFastAtan( double x )
{
if ( x < -1.0 )
return -M_PI_2 - x / ( x * x + 0.28 );
if ( x > 1.0 )
return M_PI_2 - x / ( x * x + 0.28 );
return x / ( 1.0 + x * x * 0.28 );
}
//! Approximation of arc tangent ( error below 0,005 radians )
inline double qwtFastAtan2( double y, double x )
{
if ( x > 0 )
return qwtFastAtan( y / x );
if ( x < 0 )
{
const double d = qwtFastAtan( y / x );
return ( y >= 0 ) ? d + M_PI : d - M_PI;
}
if ( y < 0.0 )
return -M_PI_2;
if ( y > 0.0 )
return M_PI_2;
return 0.0;
}
/* !
\brief Calculate a value of a cubic polynomial
\param x Value
\param a Cubic coefficient
\param b Quadratic coefficient
\param c Linear coefficient
\param d Constant offset
\return Value of the polyonom for x
*/
inline double qwtCubicPolynomial( double x,
double a, double b, double c, double d )
{
return ( ( ( a * x ) + b ) * x + c ) * x + d;
}
//! Translate degrees into radians
inline double qwtRadians( double degrees )
{
return degrees * M_PI / 180.0;
}
//! Translate radians into degrees
inline double qwtDegrees( double degrees )
{
return degrees * 180.0 / M_PI;
}
/*!
The same as qCeil, but avoids including qmath.h
\return Ceiling of value.
*/
inline int qwtCeil( qreal value )
{
using std::ceil;
return int( ceil( value ) );
}
/*!
The same as qFloor, but avoids including qmath.h
\return Floor of value.
*/
inline int qwtFloor( qreal value )
{
using std::floor;
return int( floor( value ) );
}
#endif
@@ -0,0 +1,84 @@
/******************************************************************************
* 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_MATRIX_RASTER_DATA_H
#define QWT_MATRIX_RASTER_DATA_H
#include "qwt_global.h"
#include "qwt_raster_data.h"
#if QT_VERSION < 0x060000
template< typename T > class QVector;
#endif
/*!
\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.
It implements a couple of resampling algorithms, to provide
values for positions, that or not on the value matrix.
*/
class QWT_EXPORT QwtMatrixRasterData : public QwtRasterData
{
public:
/*!
\brief Resampling algorithm
The default setting is NearestNeighbour;
*/
enum ResampleMode
{
/*!
Return the value from the matrix, that is nearest to the
the requested position.
*/
NearestNeighbour,
/*!
Interpolate the value from the distances and values of the
4 surrounding values in the matrix,
*/
BilinearInterpolation,
/*!
Interpolate the value from the 16 surrounding values in the
matrix using hermite bicubic interpolation
*/
BicubicInterpolation
};
QwtMatrixRasterData();
virtual ~QwtMatrixRasterData();
void setResampleMode(ResampleMode mode);
ResampleMode resampleMode() const;
void setInterval( Qt::Axis, const QwtInterval& );
virtual QwtInterval interval( Qt::Axis axis) const QWT_OVERRIDE QWT_FINAL;
void setValueMatrix( const QVector< double >& values, int numColumns );
const QVector< double > valueMatrix() const;
void setValue( int row, int col, double value );
int numColumns() const;
int numRows() const;
virtual QRectF pixelHint( const QRectF& ) const QWT_OVERRIDE;
virtual double value( double x, double y ) const QWT_OVERRIDE;
private:
void update();
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,127 @@
/******************************************************************************
* 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_NULL_PAINT_DEVICE_H
#define QWT_NULL_PAINT_DEVICE_H
#include "qwt_global.h"
#include <qpaintdevice.h>
#include <qpaintengine.h>
/*!
\brief A null paint device doing nothing
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
this information by analyzing the stream of paint primitives.
F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify
styled backgrounds with rounded corners.
*/
class QWT_EXPORT QwtNullPaintDevice : public QPaintDevice
{
public:
/*!
\brief Render mode
\sa setMode(), mode()
*/
enum Mode
{
/*!
All vector graphic primitives are painted by
the corresponding draw methods
*/
NormalMode,
/*!
Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath
and are painted by drawPath. In PathMode mode
only a few draw methods are called:
- drawPath()
- drawPixmap()
- drawImage()
- drawPolygon()
*/
PolygonPathMode,
/*!
Vector graphic primitives are mapped to a QPainterPath
and are painted by drawPath. In PathMode mode
only a few draw methods are called:
- drawPath()
- drawPixmap()
- drawImage()
*/
PathMode
};
QwtNullPaintDevice();
virtual ~QwtNullPaintDevice();
void setMode( Mode );
Mode mode() const;
virtual QPaintEngine* paintEngine() const QWT_OVERRIDE;
virtual int metric( PaintDeviceMetric ) const QWT_OVERRIDE;
virtual void drawRects(const QRect*, int );
virtual void drawRects(const QRectF*, int );
virtual void drawLines(const QLine*, int );
virtual void drawLines(const QLineF*, int );
virtual void drawEllipse(const QRectF&);
virtual void drawEllipse(const QRect&);
virtual void drawPath(const QPainterPath&);
virtual void drawPoints(const QPointF*, int );
virtual void drawPoints(const QPoint*, int );
virtual void drawPolygon( const QPointF*, int,
QPaintEngine::PolygonDrawMode );
virtual void drawPolygon( const QPoint*, int,
QPaintEngine::PolygonDrawMode );
virtual void drawPixmap(const QRectF&,
const QPixmap&, const QRectF&);
virtual void drawTextItem(const QPointF&, const QTextItem&);
virtual void drawTiledPixmap(const QRectF&,
const QPixmap&, const QPointF& );
virtual void drawImage(const QRectF&, const QImage&,
const QRectF&, Qt::ImageConversionFlags );
virtual void updateState( const QPaintEngineState& );
protected:
//! \return Size needed to implement metric()
virtual QSize sizeMetrics() const = 0;
private:
class PaintEngine;
PaintEngine* m_engine;
class PrivateData;
PrivateData* m_data;
};
#endif
+207
View File
@@ -0,0 +1,207 @@
/******************************************************************************
* 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_PAINTER_H
#define QWT_PAINTER_H
#include "qwt_global.h"
#include <qpalette.h>
#include <qpolygon.h>
#include <qpen.h>
class QwtScaleMap;
class QwtColorMap;
class QwtInterval;
class QPainter;
class QBrush;
class QWidget;
class QImage;
class QPixmap;
class QFontMetrics;
class QFontMetricsF;
class QTextDocument;
class QPainterPath;
/*!
\brief A collection of QPainter workarounds
*/
class QWT_EXPORT QwtPainter
{
public:
static void setPolylineSplitting( bool );
static bool polylineSplitting();
static void setRoundingAlignment( bool );
static bool roundingAlignment();
static bool roundingAlignment( const QPainter* );
static void drawText( QPainter*, qreal x, qreal y, const QString& );
static void drawText( QPainter*, const QPointF&, const QString& );
static void drawText( QPainter*, qreal x, qreal y, qreal w, qreal h,
int flags, const QString& );
static void drawText( QPainter*, const QRectF&,
int flags, const QString& );
#ifndef QT_NO_RICHTEXT
static void drawSimpleRichText( QPainter*, const QRectF&,
int flags, const QTextDocument& );
#endif
static void drawRect( QPainter*, qreal x, qreal y, qreal w, qreal h );
static void drawRect( QPainter*, const QRectF& rect );
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 drawLine( QPainter*, qreal x1, qreal y1, qreal x2, qreal y2 );
static void drawLine( QPainter*, const QPointF& p1, const QPointF& p2 );
static void drawLine( QPainter*, const QLineF& );
static void drawPolygon( QPainter*, const QPolygonF& );
static void drawPolyline( QPainter*, const QPolygonF& );
static void drawPolyline( QPainter*, const QPointF*, int pointCount );
static void drawPolygon( QPainter*, const QPolygon& );
static void drawPolyline( QPainter*, const QPolygon& );
static void drawPolyline( QPainter*, const QPoint*, int pointCount );
static void drawPoint( QPainter*, const QPoint& );
static void drawPoints( QPainter*, const QPolygon& );
static void drawPoints( QPainter*, const QPoint*, int pointCount );
static void drawPoint( QPainter*, qreal x, qreal y );
static void drawPoint( QPainter*, const QPointF& );
static void drawPoints( QPainter*, const QPolygonF& );
static void drawPoints( QPainter*, const QPointF*, int pointCount );
static void drawPath( QPainter*, const QPainterPath& );
static void drawImage( QPainter*, const QRectF&, const QImage& );
static void drawPixmap( QPainter*, const QRectF&, const QPixmap& );
static void drawRoundFrame( QPainter*,
const QRectF&, const QPalette&, int lineWidth, int frameStyle );
static void drawRoundedFrame( QPainter*,
const QRectF&, qreal xRadius, qreal 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 );
static void drawFocusRect( QPainter*, const QWidget* );
static void drawFocusRect( QPainter*, const QWidget*, const QRect& );
static void drawColorBar( QPainter*,
const QwtColorMap&, const QwtInterval&,
const QwtScaleMap&, Qt::Orientation, const QRectF& );
static bool isAligning( const QPainter*);
static bool isX11GraphicsSystem();
static void fillPixmap( const QWidget*,
QPixmap&, const QPoint& offset = QPoint() );
static void drawBackgound( QPainter*,
const QRectF&, const QWidget* );
static QPixmap backingStore( QWidget*, const QSize& );
static qreal devicePixelRatio( const QPaintDevice* );
static qreal effectivePenWidth( const QPen& );
static int horizontalAdvance( const QFontMetrics&, const QString& );
static qreal horizontalAdvance( const QFontMetricsF&, const QString& );
static int horizontalAdvance( const QFontMetrics&, QChar );
static qreal horizontalAdvance( const QFontMetricsF&, QChar );
static QFont scaledFont( const QFont&, const QPaintDevice* = NULL );
private:
static bool m_polylineSplitting;
static bool m_roundingAlignment;
};
//! Wrapper for QPainter::drawPoint()
inline void QwtPainter::drawPoint( QPainter* painter, qreal x, qreal y )
{
QwtPainter::drawPoint( painter, QPointF( x, y ) );
}
//! Wrapper for QPainter::drawPoints()
inline void QwtPainter::drawPoints( QPainter* painter, const QPolygon& polygon )
{
drawPoints( painter, polygon.data(), polygon.size() );
}
//! Wrapper for QPainter::drawPoints()
inline void QwtPainter::drawPoints( QPainter* painter, const QPolygonF& polygon )
{
drawPoints( painter, polygon.data(), polygon.size() );
}
//! Wrapper for QPainter::drawLine()
inline void QwtPainter::drawLine( QPainter* painter,
qreal x1, qreal y1, qreal x2, qreal y2 )
{
QwtPainter::drawLine( painter, QPointF( x1, y1 ), QPointF( x2, y2 ) );
}
//! Wrapper for QPainter::drawLine()
inline void QwtPainter::drawLine( QPainter* painter, const QLineF& line )
{
QwtPainter::drawLine( painter, line.p1(), line.p2() );
}
/*!
\return True, when line splitting for the raster paint engine is enabled.
\sa setPolylineSplitting()
*/
inline bool QwtPainter::polylineSplitting()
{
return m_polylineSplitting;
}
/*!
Check whether coordinates should be rounded, before they are painted
to a paint engine that rounds to integer values. For other paint engines
( PDF, SVG ), this flag has no effect.
\return True, when rounding is enabled
\sa setRoundingAlignment(), isAligning()
*/
inline bool QwtPainter::roundingAlignment()
{
return m_roundingAlignment;
}
/*!
\return roundingAlignment() && isAligning(painter);
\param painter Painter
*/
inline bool QwtPainter::roundingAlignment( const QPainter* painter )
{
return m_roundingAlignment && isAligning(painter);
}
/*!
\return pen.widthF() expanded to at least 1.0
\param pen Pen
*/
inline qreal QwtPainter::effectivePenWidth( const QPen& pen )
{
const qreal width = pen.widthF();
return ( width < 1.0 ) ? 1.0 : width;
}
#endif
@@ -0,0 +1,174 @@
/******************************************************************************
* 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_PAINTER_COMMAND_H
#define QWT_PAINTER_COMMAND_H
#include "qwt_global.h"
#include <qpaintengine.h>
#include <qpixmap.h>
#include <qimage.h>
#include <qpolygon.h>
#include <qpainterpath.h>
class QPainterPath;
/*!
QwtPainterCommand represents the attributes of a paint operation
how it is used between QPainter and QPaintDevice
It is used by QwtGraphic to record and replay paint operations
\sa QwtGraphic::commands()
*/
class QWT_EXPORT QwtPainterCommand
{
public:
//! Type of the paint command
enum Type
{
//! Invalid command
Invalid = -1,
//! Draw a QPainterPath
Path,
//! Draw a QPixmap
Pixmap,
//! Draw a QImage
Image,
//! QPainter state change
State
};
//! Attributes how to paint a QPixmap
struct PixmapData
{
QRectF rect;
QPixmap pixmap;
QRectF subRect;
};
//! Attributes how to paint a QImage
struct ImageData
{
QRectF rect;
QImage image;
QRectF subRect;
Qt::ImageConversionFlags flags;
};
//! Attributes of a state change
struct StateData
{
QPaintEngine::DirtyFlags flags;
QPen pen;
QBrush brush;
QPointF brushOrigin;
QBrush backgroundBrush;
Qt::BGMode backgroundMode;
QFont font;
QTransform transform;
Qt::ClipOperation clipOperation;
QRegion clipRegion;
QPainterPath clipPath;
bool isClipEnabled;
QPainter::RenderHints renderHints;
QPainter::CompositionMode compositionMode;
qreal opacity;
};
QwtPainterCommand();
QwtPainterCommand(const QwtPainterCommand&);
explicit QwtPainterCommand( const QPainterPath& );
QwtPainterCommand( const QRectF& rect,
const QPixmap&, const QRectF& subRect );
QwtPainterCommand( const QRectF& rect,
const QImage&, const QRectF& subRect,
Qt::ImageConversionFlags );
explicit QwtPainterCommand( const QPaintEngineState& );
~QwtPainterCommand();
QwtPainterCommand& operator=(const QwtPainterCommand& );
Type type() const;
QPainterPath* path();
const QPainterPath* path() const;
PixmapData* pixmapData();
const PixmapData* pixmapData() const;
ImageData* imageData();
const ImageData* imageData() const;
StateData* stateData();
const StateData* stateData() const;
private:
void copy( const QwtPainterCommand& );
void reset();
Type m_type;
union
{
QPainterPath* m_path;
PixmapData* m_pixmapData;
ImageData* m_imageData;
StateData* m_stateData;
};
};
//! \return Type of the command
inline QwtPainterCommand::Type QwtPainterCommand::type() const
{
return m_type;
}
//! \return Painter path to be painted
inline const QPainterPath* QwtPainterCommand::path() const
{
return m_path;
}
//! \return Attributes how to paint a QPixmap
inline const QwtPainterCommand::PixmapData*
QwtPainterCommand::pixmapData() const
{
return m_pixmapData;
}
//! \return Attributes how to paint a QImage
inline const QwtPainterCommand::ImageData*
QwtPainterCommand::imageData() const
{
return m_imageData;
}
//! \return Attributes of a state change
inline const QwtPainterCommand::StateData*
QwtPainterCommand::stateData() const
{
return m_stateData;
}
#endif
+103
View File
@@ -0,0 +1,103 @@
/******************************************************************************
* 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_PANNER_H
#define QWT_PANNER_H
#include "qwt_global.h"
#include <qwidget.h>
class QCursor;
class QPixmap;
/*!
\brief QwtPanner provides panning of a widget
QwtPanner grabs the contents of a widget, that can be dragged
in all directions. The offset between the start and the end position
is emitted by the panned signal.
QwtPanner grabs the content of the widget into a pixmap and moves
the pixmap around, without initiating any repaint events for the widget.
Areas, that are not part of content are not painted while panning.
This makes panning fast enough for widgets, where
repaints are too slow for mouse movements.
For widgets, where repaints are very fast it might be better to
implement panning manually by mapping mouse events into paint events.
*/
class QWT_EXPORT QwtPanner : public QWidget
{
Q_OBJECT
public:
explicit QwtPanner( QWidget* parent );
virtual ~QwtPanner();
void setEnabled( bool );
bool isEnabled() const;
void setMouseButton( Qt::MouseButton,
Qt::KeyboardModifiers = Qt::NoModifier );
void getMouseButton( Qt::MouseButton& button,
Qt::KeyboardModifiers& ) const;
void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
void getAbortKey( int& key, Qt::KeyboardModifiers& ) const;
void setCursor( const QCursor& );
const QCursor cursor() const;
void setOrientations( Qt::Orientations );
Qt::Orientations orientations() const;
bool isOrientationEnabled( Qt::Orientation ) const;
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
Q_SIGNALS:
/*!
Signal emitted, when panning is done
\param dx Offset in horizontal direction
\param dy Offset in vertical direction
*/
void panned( int dx, int dy );
/*!
Signal emitted, while the widget moved, but panning
is not finished.
\param dx Offset in horizontal direction
\param dy Offset in vertical direction
*/
void moved( int dx, int dy );
protected:
virtual void widgetMousePressEvent( QMouseEvent* );
virtual void widgetMouseReleaseEvent( QMouseEvent* );
virtual void widgetMouseMoveEvent( QMouseEvent* );
virtual void widgetKeyPressEvent( QKeyEvent* );
virtual void widgetKeyReleaseEvent( QKeyEvent* );
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual QBitmap contentsMask() const;
virtual QPixmap grab() const;
private:
#ifndef QT_NO_CURSOR
void showCursor( bool );
#endif
class PrivateData;
PrivateData* m_data;
};
#endif
+339
View File
@@ -0,0 +1,339 @@
/******************************************************************************
* 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_PICKER
#define QWT_PICKER
#include "qwt_global.h"
#include "qwt_event_pattern.h"
#include <qobject.h>
class QwtPickerMachine;
class QwtWidgetOverlay;
class QwtText;
class QWidget;
class QMouseEvent;
class QWheelEvent;
class QKeyEvent;
class QPainter;
class QPen;
class QFont;
class QRegion;
class QPainterPath;
class QPoint;
class QRect;
class QSize;
class QPolygon;
/*!
\brief QwtPicker provides selections on a widget
QwtPicker filters all enter, leave, mouse and keyboard events of a widget
and translates them into an array of selected points.
The way how the points are collected depends on type of state machine
that is connected to the picker. Qwt offers a couple of predefined
state machines for selecting:
- Nothing\n
QwtPickerTrackerMachine
- Single points\n
QwtPickerClickPointMachine, QwtPickerDragPointMachine
- Rectangles\n
QwtPickerClickRectMachine, QwtPickerDragRectMachine
- Polygons\n
QwtPickerPolygonMachine
While these state machines cover the most common ways to collect points
it is also possible to implement individual machines as well.
QwtPicker translates the picked points into a selection using the
adjustedPoints() method. adjustedPoints() is intended to be reimplemented
to fix up the selection according to application specific requirements.
(F.e. when an application accepts rectangles of a fixed aspect ratio only.)
Optionally QwtPicker support the process of collecting points by a
rubber band and tracker displaying a text for the current mouse
position.
\par Example
\code
#include <qwt_picker.h>
#include <qwt_picker_machine.h>
QwtPicker *picker = new QwtPicker(widget);
picker->setStateMachine(new QwtPickerDragRectMachine);
picker->setTrackerMode(QwtPicker::ActiveOnly);
picker->setRubberBand(QwtPicker::RectRubberBand);
\endcode
The state machine triggers the following commands:
- begin()\n
Activate/Initialize the selection.
- append()\n
Add a new point
- move() \n
Change the position of the last point.
- remove()\n
Remove the last point.
- end()\n
Terminate the selection and call accept to validate the picked points.
The picker is active (isActive()), between begin() and end().
In active state the rubber band is displayed, and the tracker is visible
in case of trackerMode is ActiveOnly or AlwaysOn.
The cursor can be moved using the arrow keys. All selections can be aborted
using the abort key. (QwtEventPattern::KeyPatternCode)
\warning In case of QWidget::NoFocus the focus policy of the observed
widget is set to QWidget::WheelFocus and mouse tracking
will be manipulated while the picker is active,
or if trackerMode() is AlwayOn.
*/
class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern
{
Q_OBJECT
Q_ENUMS( RubberBand DisplayMode ResizeMode )
Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode )
Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen )
Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont )
Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand )
Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
public:
/*!
Rubber band style
The default value is QwtPicker::NoRubberBand.
\sa setRubberBand(), rubberBand()
*/
enum RubberBand
{
//! No rubberband.
NoRubberBand = 0,
//! A horizontal line ( only for QwtPickerMachine::PointSelection )
HLineRubberBand,
//! A vertical line ( only for QwtPickerMachine::PointSelection )
VLineRubberBand,
//! A crosshair ( only for QwtPickerMachine::PointSelection )
CrossRubberBand,
//! A rectangle ( only for QwtPickerMachine::RectSelection )
RectRubberBand,
//! An ellipse ( only for QwtPickerMachine::RectSelection )
EllipseRubberBand,
//! A polygon ( only for QwtPickerMachine::PolygonSelection )
PolygonRubberBand,
/*!
Values >= UserRubberBand can be used to define additional
rubber bands.
*/
UserRubberBand = 100
};
/*!
\brief Display mode
\sa setTrackerMode(), trackerMode(), isActive()
*/
enum DisplayMode
{
//! Display never
AlwaysOff,
//! Display always
AlwaysOn,
//! Display only when the selection is active
ActiveOnly
};
/*!
Controls what to do with the selected points of an active
selection when the observed widget is resized.
The default value is QwtPicker::Stretch.
\sa setResizeMode()
*/
enum ResizeMode
{
//! All points are scaled according to the new size,
Stretch,
//! All points remain unchanged.
KeepSize
};
explicit QwtPicker( QWidget* parent );
explicit QwtPicker( RubberBand rubberBand,
DisplayMode trackerMode, QWidget* );
virtual ~QwtPicker();
void setStateMachine( QwtPickerMachine* );
const QwtPickerMachine* stateMachine() const;
QwtPickerMachine* stateMachine();
void setRubberBand( RubberBand );
RubberBand rubberBand() const;
void setTrackerMode( DisplayMode );
DisplayMode trackerMode() const;
void setResizeMode( ResizeMode );
ResizeMode resizeMode() const;
void setRubberBandPen( const QPen& );
QPen rubberBandPen() const;
void setTrackerPen( const QPen& );
QPen trackerPen() const;
void setTrackerFont( const QFont& );
QFont trackerFont() const;
bool isEnabled() const;
bool isActive() const;
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
QWidget* parentWidget();
const QWidget* parentWidget() const;
virtual QPainterPath pickArea() const;
virtual void drawRubberBand( QPainter* ) const;
virtual void drawTracker( QPainter* ) const;
virtual QRegion trackerMask() const;
virtual QRegion rubberBandMask() const;
virtual QwtText trackerText( const QPoint& pos ) const;
QPoint trackerPosition() const;
virtual QRect trackerRect( const QFont& ) const;
QPolygon selection() const;
public Q_SLOTS:
void setEnabled( bool );
Q_SIGNALS:
/*!
A signal indicating, when the picker has been activated.
Together with setEnabled() it can be used to implement
selections with more than one picker.
\param on True, when the picker has been activated
*/
void activated( bool on );
/*!
A signal emitting the selected points,
at the end of a selection.
\param polygon Selected points
*/
void selected( const QPolygon& polygon );
/*!
A signal emitted when a point has been appended to the selection
\param pos Position of the appended point.
\sa append(). moved()
*/
void appended( const QPoint& pos );
/*!
A signal emitted whenever the last appended point of the
selection has been moved.
\param pos Position of the moved last point of the selection.
\sa move(), appended()
*/
void moved( const QPoint& pos );
/*!
A signal emitted whenever the last appended point of the
selection has been removed.
\param pos Position of the point, that has been removed
\sa remove(), appended()
*/
void removed( const QPoint& pos );
/*!
A signal emitted when the active selection has been changed.
This might happen when the observed widget is resized.
\param selection Changed selection
\sa stretchSelection()
*/
void changed( const QPolygon& selection );
protected:
virtual QPolygon adjustedPoints( const QPolygon& ) const;
virtual void transition( const QEvent* );
virtual void begin();
virtual void append( const QPoint& );
virtual void move( const QPoint& );
virtual void remove();
virtual bool end( bool ok = true );
virtual bool accept( QPolygon& ) const;
virtual void reset();
virtual void widgetMousePressEvent( QMouseEvent* );
virtual void widgetMouseReleaseEvent( QMouseEvent* );
virtual void widgetMouseDoubleClickEvent( QMouseEvent* );
virtual void widgetMouseMoveEvent( QMouseEvent* );
virtual void widgetWheelEvent( QWheelEvent* );
virtual void widgetKeyPressEvent( QKeyEvent* );
virtual void widgetKeyReleaseEvent( QKeyEvent* );
virtual void widgetEnterEvent( QEvent* );
virtual void widgetLeaveEvent( QEvent* );
virtual void stretchSelection(
const QSize& oldSize, const QSize& newSize );
virtual void updateDisplay();
const QwtWidgetOverlay* rubberBandOverlay() const;
const QwtWidgetOverlay* trackerOverlay() const;
const QPolygon& pickedPoints() const;
QRect trackerRect( const QSize& ) const;
private:
void init( QWidget*, RubberBand rubberBand, DisplayMode trackerMode );
void setMouseTracking( bool );
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,214 @@
/******************************************************************************
* 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_PICKER_MACHINE
#define QWT_PICKER_MACHINE
#include "qwt_global.h"
class QwtEventPattern;
class QEvent;
template< typename T > class QList;
/*!
\brief A state machine for QwtPicker selections
QwtPickerMachine accepts key and mouse events and translates them
into selection commands.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/
class QWT_EXPORT QwtPickerMachine
{
public:
/*!
Type of a selection.
\sa selectionType()
*/
enum SelectionType
{
//! The state machine not usable for any type of selection.
NoSelection = -1,
//! The state machine is for selecting a single point.
PointSelection,
//! The state machine is for selecting a rectangle (2 points).
RectSelection,
//! The state machine is for selecting a polygon (many points).
PolygonSelection
};
//! Commands - the output of a state machine
enum Command
{
Begin,
Append,
Move,
Remove,
End
};
explicit QwtPickerMachine( SelectionType );
virtual ~QwtPickerMachine();
//! Transition
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) = 0;
void reset();
int state() const;
void setState( int );
SelectionType selectionType() const;
private:
const SelectionType m_selectionType;
int m_state;
};
/*!
\brief A state machine for indicating mouse movements
QwtPickerTrackerMachine supports displaying information
corresponding to mouse movements, but is not intended for
selecting anything. Begin/End are related to Enter/Leave events.
*/
class QWT_EXPORT QwtPickerTrackerMachine : public QwtPickerMachine
{
public:
QwtPickerTrackerMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
/*!
\brief A state machine for point selections
Pressing QwtEventPattern::MouseSelect1 or
QwtEventPattern::KeySelect1 selects a point.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/
class QWT_EXPORT QwtPickerClickPointMachine : public QwtPickerMachine
{
public:
QwtPickerClickPointMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
/*!
\brief A state machine for point selections
Pressing QwtEventPattern::MouseSelect1 or QwtEventPattern::KeySelect1
starts the selection, releasing QwtEventPattern::MouseSelect1 or
a second press of QwtEventPattern::KeySelect1 terminates it.
*/
class QWT_EXPORT QwtPickerDragPointMachine : public QwtPickerMachine
{
public:
QwtPickerDragPointMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
/*!
\brief A state machine for rectangle selections
Pressing QwtEventPattern::MouseSelect1 starts
the selection, releasing it selects the first point. Pressing it
again selects the second point and terminates the selection.
Pressing QwtEventPattern::KeySelect1 also starts the
selection, a second press selects the first point. A third one selects
the second point and terminates the selection.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/
class QWT_EXPORT QwtPickerClickRectMachine : public QwtPickerMachine
{
public:
QwtPickerClickRectMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
/*!
\brief A state machine for rectangle selections
Pressing QwtEventPattern::MouseSelect1 selects
the first point, releasing it the second point.
Pressing QwtEventPattern::KeySelect1 also selects the
first point, a second press selects the second point and terminates
the selection.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/
class QWT_EXPORT QwtPickerDragRectMachine : public QwtPickerMachine
{
public:
QwtPickerDragRectMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
/*!
\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
first point, a second press selects the second point and terminates
the selection.
A common use case of QwtPickerDragLineMachine are pickers for
distance measurements.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/
class QWT_EXPORT QwtPickerDragLineMachine : public QwtPickerMachine
{
public:
QwtPickerDragLineMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
/*!
\brief A state machine for polygon selections
Pressing QwtEventPattern::MouseSelect1 or QwtEventPattern::KeySelect1
starts the selection and selects the first point, or appends a point.
Pressing QwtEventPattern::MouseSelect2 or QwtEventPattern::KeySelect2
appends the last point and terminates the selection.
\sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
*/
class QWT_EXPORT QwtPickerPolygonMachine : public QwtPickerMachine
{
public:
QwtPickerPolygonMachine();
virtual QList< Command > transition(
const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE;
};
#endif
@@ -0,0 +1,99 @@
/******************************************************************************
* 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_PIXEL_MATRIX_H
#define QWT_PIXEL_MATRIX_H
#include "qwt_global.h"
#include <qbitarray.h>
#include <qrect.h>
/*!
\brief A bit field corresponding to the pixels of a rectangle
QwtPixelMatrix is intended to filter out duplicates in an
unsorted array of points.
*/
class QWT_EXPORT QwtPixelMatrix : public QBitArray
{
public:
explicit QwtPixelMatrix( const QRect& rect );
~QwtPixelMatrix();
void setRect( const QRect& rect );
QRect rect() const;
bool testPixel( int x, int y ) const;
bool testAndSetPixel( int x, int y, bool on );
int index( int x, int y ) const;
private:
QRect m_rect;
};
/*!
\brief Test if a pixel has been set
\param x X-coordinate
\param y Y-coordinate
\return true, when pos is outside of rect(), or when the pixel
has already been set.
*/
inline bool QwtPixelMatrix::testPixel( int x, int y ) const
{
const int idx = index( x, y );
return ( idx >= 0 ) ? testBit( idx ) : true;
}
/*!
\brief Set a pixel and test if a pixel has been set before
\param x X-coordinate
\param y Y-coordinate
\param on Set/Clear the pixel
\return true, when pos is outside of rect(), or when the pixel
was set before.
*/
inline bool QwtPixelMatrix::testAndSetPixel( int x, int y, bool on )
{
const int idx = index( x, y );
if ( idx < 0 )
return true;
const bool onBefore = testBit( idx );
setBit( idx, on );
return onBefore;
}
/*!
\brief Calculate the index in the bit field corresponding to a position
\param x X-coordinate
\param y Y-coordinate
\return Index, when rect() contains pos - otherwise -1.
*/
inline int QwtPixelMatrix::index( int x, int y ) const
{
const int dx = x - m_rect.x();
if ( dx < 0 || dx >= m_rect.width() )
return -1;
const int dy = y - m_rect.y();
if ( dy < 0 || dy >= m_rect.height() )
return -1;
return dy * m_rect.width() + dx;
}
#endif
+310
View File
@@ -0,0 +1,310 @@
/******************************************************************************
* 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_H
#define QWT_PLOT_H
#include "qwt_global.h"
#include "qwt_axis_id.h"
#include "qwt_plot_dict.h"
#include <qframe.h>
class QwtPlotLayout;
class QwtAbstractLegend;
class QwtScaleWidget;
class QwtScaleEngine;
class QwtScaleDiv;
class QwtScaleMap;
class QwtScaleDraw;
class QwtTextLabel;
class QwtInterval;
class QwtText;
template< typename T > class QList;
// 6.1 compatibility definitions
#define QWT_AXIS_COMPAT 1
/*!
\brief A 2-D plotting widget
QwtPlot is a widget for plotting two-dimensional graphs.
An unlimited number of plot items can be displayed on
its canvas. Plot items might be curves (QwtPlotCurve), markers
(QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived
from QwtPlotItem.
A plot can have up to four axes, with each plot item attached to an x- and
a y axis. The scales at the axes can be explicitly set (QwtScaleDiv), or
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
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.
\code
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
QwtPlot *myPlot = new QwtPlot( "Two Curves", parent );
// 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( ... );
curve1->attach( myPlot );
curve2->attach( myPlot );
// finally, refresh the plot
myPlot->replot();
\endcode
*/
class QWT_EXPORT QwtPlot : public QFrame, public QwtPlotDict
{
Q_OBJECT
Q_PROPERTY( QBrush canvasBackground
READ canvasBackground WRITE setCanvasBackground )
Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
public:
/*!
Position of the legend, relative to the canvas.
\sa insertLegend()
*/
enum LegendPosition
{
//! The legend will be left from the QwtAxis::YLeft axis.
LeftLegend,
//! The legend will be right from the QwtAxis::YRight axis.
RightLegend,
//! The legend will be below the footer
BottomLegend,
//! The legend will be above the title
TopLegend
};
explicit QwtPlot( QWidget* = NULL );
explicit QwtPlot( const QwtText& title, QWidget* = NULL );
virtual ~QwtPlot();
void setAutoReplot( bool = true );
bool autoReplot() const;
// Layout
void setPlotLayout( QwtPlotLayout* );
QwtPlotLayout* plotLayout();
const QwtPlotLayout* plotLayout() const;
// Title
void setTitle( const QString& );
void setTitle( const QwtText& );
QwtText title() const;
QwtTextLabel* titleLabel();
const QwtTextLabel* titleLabel() const;
// Footer
void setFooter( const QString& );
void setFooter( const QwtText& );
QwtText footer() const;
QwtTextLabel* footerLabel();
const QwtTextLabel* footerLabel() const;
// Canvas
void setCanvas( QWidget* );
QWidget* canvas();
const QWidget* canvas() const;
void setCanvasBackground( const QBrush& );
QBrush canvasBackground() const;
virtual QwtScaleMap canvasMap( QwtAxisId ) const;
double invTransform( QwtAxisId, double pos ) const;
double transform( QwtAxisId, double value ) const;
// Axes
bool isAxisValid( QwtAxisId ) const;
void setAxisVisible( QwtAxisId, bool on = true );
bool isAxisVisible( QwtAxisId ) const;
// Axes data
QwtScaleEngine* axisScaleEngine( QwtAxisId );
const QwtScaleEngine* axisScaleEngine( QwtAxisId ) const;
void setAxisScaleEngine( QwtAxisId, QwtScaleEngine* );
void setAxisAutoScale( QwtAxisId, bool on = true );
bool axisAutoScale( QwtAxisId ) const;
void setAxisFont( QwtAxisId, const QFont& );
QFont axisFont( QwtAxisId ) const;
void setAxisScale( QwtAxisId, double min, double max, double stepSize = 0 );
void setAxisScaleDiv( QwtAxisId, const QwtScaleDiv& );
void setAxisScaleDraw( QwtAxisId, QwtScaleDraw* );
double axisStepSize( QwtAxisId ) const;
QwtInterval axisInterval( QwtAxisId ) const;
const QwtScaleDiv& axisScaleDiv( QwtAxisId ) const;
const QwtScaleDraw* axisScaleDraw( QwtAxisId ) const;
QwtScaleDraw* axisScaleDraw( QwtAxisId );
const QwtScaleWidget* axisWidget( QwtAxisId ) const;
QwtScaleWidget* axisWidget( QwtAxisId );
void setAxisLabelAlignment( QwtAxisId, Qt::Alignment );
void setAxisLabelRotation( QwtAxisId, double rotation );
void setAxisTitle( QwtAxisId, const QString& );
void setAxisTitle( QwtAxisId, const QwtText& );
QwtText axisTitle( QwtAxisId ) const;
void setAxisMaxMinor( QwtAxisId, int maxMinor );
int axisMaxMinor( QwtAxisId ) const;
void setAxisMaxMajor( QwtAxisId, int maxMajor );
int axisMaxMajor( QwtAxisId ) const;
// Legend
void insertLegend( QwtAbstractLegend*,
LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
QwtAbstractLegend* legend();
const QwtAbstractLegend* legend() const;
void updateLegend();
void updateLegend( const QwtPlotItem* );
// Misc
virtual QSize sizeHint() const QWT_OVERRIDE;
virtual QSize minimumSizeHint() const QWT_OVERRIDE;
virtual void updateLayout();
virtual void drawCanvas( QPainter* );
void updateAxes();
void updateCanvasMargins();
virtual void getCanvasMarginsHint(
const QwtScaleMap maps[], const QRectF& canvasRect,
double& left, double& top, double& right, double& bottom) const;
virtual bool event( QEvent* ) QWT_OVERRIDE;
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
virtual void drawItems( QPainter*, const QRectF&,
const QwtScaleMap maps[ QwtAxis::AxisPositions ] ) const;
virtual QVariant itemToInfo( QwtPlotItem* ) const;
virtual QwtPlotItem* infoToItem( const QVariant& ) const;
#if QWT_AXIS_COMPAT
enum Axis
{
yLeft = QwtAxis::YLeft,
yRight = QwtAxis::YRight,
xBottom = QwtAxis::XBottom,
xTop = QwtAxis::XTop,
axisCnt = QwtAxis::AxisPositions
};
void enableAxis( int axisId, bool on = true )
{
setAxisVisible( axisId, on );
}
bool axisEnabled( int axisId ) const
{
return isAxisVisible( axisId );
}
#endif
Q_SIGNALS:
/*!
A signal indicating, that an item has been attached/detached
\param plotItem Plot item
\param on Attached/Detached
*/
void itemAttached( QwtPlotItem* plotItem, bool on );
/*!
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()
\param data Attributes of the entries ( usually <= 1 ) for
the plot item.
\sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
*/
void legendDataChanged( const QVariant& itemInfo,
const QList< QwtLegendData >& data );
public Q_SLOTS:
virtual void replot();
void autoRefresh();
protected:
virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
private Q_SLOTS:
void updateLegendItems( const QVariant& itemInfo,
const QList< QwtLegendData >& legendData );
private:
friend class QwtPlotItem;
void attachItem( QwtPlotItem*, bool );
void initAxesData();
void deleteAxesData();
void updateScaleDiv();
void initPlot( const QwtText& title );
class ScaleData;
ScaleData* m_scaleData;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,96 @@
/******************************************************************************
* 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_ABSTRACT_BAR_CHART_H
#define QWT_PLOT_ABSTRACT_BAR_CHART_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
/*!
\brief Abstract base class for bar chart items
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.
*/
class QWT_EXPORT QwtPlotAbstractBarChart : public QwtPlotSeriesItem
{
public:
/*!
\brief Mode how to calculate the bar width
setLayoutPolicy(), setLayoutHint(), barWidthHint()
*/
enum LayoutPolicy
{
/*!
The sample width is calculated by dividing the bounding rectangle
by the number of samples. The layoutHint() is used as a minimum width
in paint device coordinates.
\sa boundingRectangle()
*/
AutoAdjustSamples,
/*!
layoutHint() defines an interval in axis coordinates
*/
ScaleSamplesToAxes,
/*!
The bar width is calculated by multiplying layoutHint()
with the height or width of the canvas.
\sa boundingRectangle()
*/
ScaleSampleToCanvas,
/*!
layoutHint() defines a fixed width in paint device coordinates.
*/
FixedSampleSize
};
explicit QwtPlotAbstractBarChart( const QwtText& title );
virtual ~QwtPlotAbstractBarChart();
void setLayoutPolicy( LayoutPolicy );
LayoutPolicy layoutPolicy() const;
void setLayoutHint( double );
double layoutHint() const;
void setSpacing( int );
int spacing() const;
void setMargin( int );
int margin() const;
void setBaseline( double );
double baseline() const;
virtual void getCanvasMarginHint(
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, double& left, double& top,
double& right, double& bottom) const QWT_OVERRIDE;
protected:
double sampleWidth( const QwtScaleMap& map,
double canvasSize, double boundingSize,
double value ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,164 @@
/******************************************************************************
* 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_ABSTRACT_CANVAS_H
#define QWT_PLOT_ABSTRACT_CANVAS_H
#include "qwt_global.h"
#include <qframe.h>
class QwtPlot;
/*!
\brief Base class for all type of plot canvases
*/
class QWT_EXPORT QwtPlotAbstractCanvas
{
public:
/*!
\brief Focus indicator
The default setting is NoFocusIndicator
\sa setFocusIndicator(), focusIndicator(), drawFocusIndicator()
*/
enum FocusIndicator
{
//! Don't paint a focus indicator
NoFocusIndicator,
/*!
The focus is related to the complete canvas.
Paint the focus indicator using drawFocusIndicator()
*/
CanvasFocusIndicator,
/*!
The focus is related to an item (curve, point, ...) on
the canvas. It is up to the application to display a
focus indication using f.e. highlighting.
*/
ItemFocusIndicator
};
explicit QwtPlotAbstractCanvas( QWidget* canvasWidget );
virtual ~QwtPlotAbstractCanvas();
QwtPlot* plot();
const QwtPlot* plot() const;
void setFocusIndicator( FocusIndicator );
FocusIndicator focusIndicator() const;
void setBorderRadius( double );
double borderRadius() const;
protected:
QWidget* canvasWidget();
const QWidget* canvasWidget() const;
virtual void drawFocusIndicator( QPainter* );
virtual void drawBorder( QPainter* );
virtual void drawBackground( QPainter* );
void fillBackground( QPainter* );
void drawCanvas( QPainter* );
void drawStyled( QPainter*, bool );
void drawUnstyled( QPainter* );
QPainterPath canvasBorderPath( const QRect& rect ) const;
void updateStyleSheetInfo();
private:
Q_DISABLE_COPY(QwtPlotAbstractCanvas)
class PrivateData;
PrivateData* m_data;
};
/*!
\brief Base class of QwtPlotOpenGLCanvas and QwtPlotGLCanvas
*/
class QWT_EXPORT QwtPlotAbstractGLCanvas : public QwtPlotAbstractCanvas
{
public:
/*!
\brief Paint attributes
The default setting enables BackingStore and Opaque.
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
\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 ).
Disabling the cache might improve the performance for
incremental paints (using QwtPlotDirectPainter ).
\sa backingStore(), invalidateBackingStore()
*/
BackingStore = 1,
/*!
When ImmediatePaint is set replot() calls repaint()
instead of update().
\sa replot(), QWidget::repaint(), QWidget::update()
*/
ImmediatePaint = 8,
};
//! Paint attributes
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotAbstractGLCanvas( QWidget* canvasWidget );
virtual ~QwtPlotAbstractGLCanvas();
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setFrameStyle( int style );
int frameStyle() const;
void setFrameShadow( QFrame::Shadow );
QFrame::Shadow frameShadow() const;
void setFrameShape( QFrame::Shape );
QFrame::Shape frameShape() const;
void setLineWidth( int );
int lineWidth() const;
void setMidLineWidth( int );
int midLineWidth() const;
int frameWidth() const;
QRect frameRect() const;
//! Invalidate the internal backing store
virtual void invalidateBackingStore() = 0;
protected:
void replot();
void draw( QPainter* );
private:
virtual void clearBackingStore() = 0;
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotAbstractGLCanvas::PaintAttributes )
#endif
@@ -0,0 +1,124 @@
/******************************************************************************
* 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_BAR_CHART_H
#define QWT_PLOT_BAR_CHART_H
#include "qwt_global.h"
#include "qwt_plot_abstract_barchart.h"
class QwtColumnRect;
class QwtColumnSymbol;
template< typename T > class QwtSeriesData;
/*!
\brief QwtPlotBarChart displays a series of a values as bars.
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()
and the value.
By activating the LegendBarTitles mode each sample will have
its own entry on the legend.
The most common use case of a bar chart is to display a
list of y coordinates, where the x coordinate is simply the index
in the list. But for other situations ( f.e. when values are related
to dates ) it is also possible to set x coordinates explicitly.
\sa QwtPlotMultiBarChart, QwtPlotHistogram, QwtPlotCurve::Sticks,
QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
*/
class QWT_EXPORT QwtPlotBarChart
: public QwtPlotAbstractBarChart
, public QwtSeriesStore< QPointF >
{
public:
/*!
\brief Legend modes.
The default setting is QwtPlotBarChart::LegendChartTitle.
\sa setLegendMode(), legendMode()
*/
enum LegendMode
{
/*!
One entry on the legend showing the default symbol
and the title() of the chart
\sa QwtPlotItem::title()
*/
LegendChartTitle,
/*!
One entry for each value showing the individual symbol
of the corresponding bar and the bar title.
\sa specialSymbol(), barTitle()
*/
LegendBarTitles
};
explicit QwtPlotBarChart( const QString& title = QString() );
explicit QwtPlotBarChart( const QwtText& title );
virtual ~QwtPlotBarChart();
virtual int rtti() const QWT_OVERRIDE;
void setSamples( const QVector< QPointF >& );
void setSamples( const QVector< double >& );
void setSamples( QwtSeriesData< QPointF >* );
void setSymbol( QwtColumnSymbol* );
const QwtColumnSymbol* symbol() const;
void setLegendMode( LegendMode );
LegendMode legendMode() const;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QwtColumnSymbol* specialSymbol(
int sampleIndex, const QPointF& ) const;
virtual QwtText barTitle( int sampleIndex ) const;
protected:
virtual void drawSample( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, const QwtInterval& boundingInterval,
int index, const QPointF& sample ) const;
virtual void drawBar( QPainter*,
int sampleIndex, const QPointF& sample,
const QwtColumnRect& ) const;
QwtColumnRect columnRect(
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, const QwtInterval& boundingInterval,
const QPointF& sample ) const;
QList< QwtLegendData > legendData() const QWT_OVERRIDE;
QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE;
private:
void init();
class PrivateData;
PrivateData* m_data;
};
#endif
+133
View File
@@ -0,0 +1,133 @@
/******************************************************************************
* 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_CANVAS_H
#define QWT_PLOT_CANVAS_H
#include "qwt_global.h"
#include "qwt_plot_abstract_canvas.h"
#include <qframe.h>
class QwtPlot;
class QPixmap;
class QPainterPath;
/*!
\brief Canvas of a QwtPlot.
Canvas is the widget where all plot items are displayed
\sa QwtPlot::setCanvas(), QwtPlotGLCanvas, QwtPlotOpenGLCanvas
*/
class QWT_EXPORT QwtPlotCanvas : public QFrame, public QwtPlotAbstractCanvas
{
Q_OBJECT
Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius )
public:
/*!
\brief Paint attributes
The default setting enables BackingStore and Opaque.
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
\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 ).
Disabling the cache might improve the performance for
incremental paints (using QwtPlotDirectPainter ).
\sa backingStore(), invalidateBackingStore()
*/
BackingStore = 1,
/*!
\brief Try to fill the complete contents rectangle
of the plot canvas
When using styled backgrounds Qt assumes, that the
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.
\warning Will not work for semitransparent backgrounds
*/
Opaque = 2,
/*!
\brief Try to improve painting of styled backgrounds
QwtPlotCanvas supports the box model attributes for
customizing the layout with style sheets. Unfortunately
the design of Qt style sheets has no concept how to
handle backgrounds with rounded corners - beside of padding.
When HackStyledBackground is enabled the plot canvas tries
to separate the background from the background border
by reverse engineering to paint the background before and
the border after the plot items. In this order the border
gets perfectly antialiased and you can avoid some pixel
artifacts in the corners.
*/
HackStyledBackground = 4,
/*!
When ImmediatePaint is set replot() calls repaint()
instead of update().
\sa replot(), QWidget::repaint(), QWidget::update()
*/
ImmediatePaint = 8
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotCanvas( QwtPlot* = NULL );
virtual ~QwtPlotCanvas();
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
const QPixmap* backingStore() const;
Q_INVOKABLE void invalidateBackingStore();
virtual bool event( QEvent* ) QWT_OVERRIDE;
Q_INVOKABLE QPainterPath borderPath( const QRect& ) const;
public Q_SLOTS:
void replot();
protected:
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
virtual void drawBorder( QPainter* ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCanvas::PaintAttributes )
#endif
+379
View File
@@ -0,0 +1,379 @@
/******************************************************************************
* 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_CURVE_H
#define QWT_PLOT_CURVE_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
#include <qstring.h>
class QwtScaleMap;
class QwtSymbol;
class QwtCurveFitter;
template< typename T > class QwtSeriesData;
class QwtText;
class QPainter;
class QPolygonF;
class QPen;
/*!
\brief A plot item, that represents a series of points
A curve is the representation of a series of points in the x-y plane.
It supports different display styles, interpolation ( f.e. spline )
and symbols.
\par Usage
<dl><dt>a) Assign curve properties</dt>
<dd>When a curve is created, it is configured to draw black solid lines
with in QwtPlotCurve::Lines style and no symbols.
You can change this by calling
setPen(), setStyle() and setSymbol().</dd>
<dt>b) Connect/Assign data.</dt>
<dd>QwtPlotCurve gets its points using a QwtSeriesData object offering
a bridge to the real storage of the points ( like QAbstractItemModel ).
There are several convenience classes derived from QwtSeriesData, that also store
the points inside ( like QStandardItemModel ). QwtPlotCurve also offers
a couple of variations of setSamples(), that build QwtSeriesData objects from
arrays internally.</dd>
<dt>c) Attach the curve to a plot</dt>
<dd>See QwtPlotItem::attach()
</dd></dl>
\par Example:
see examples/bode
\sa QwtPointSeriesData, QwtSymbol, QwtScaleMap
*/
class QWT_EXPORT QwtPlotCurve
: public QwtPlotSeriesItem
, public QwtSeriesStore< QPointF >
{
public:
/*!
Curve styles.
\sa setStyle(), style()
*/
enum CurveStyle
{
/*!
Don't draw a curve. Note: This doesn't affect the symbols.
*/
NoCurve = -1,
/*!
Connect the points with straight lines. The lines might
be interpolated depending on the 'Fitted' attribute. Curve
fitting can be configured using setCurveFitter().
*/
Lines,
/*!
Draw vertical or horizontal sticks ( depending on the
orientation() ) from a baseline which is defined by setBaseline().
*/
Sticks,
/*!
Connect the points with a step function. The step function
is drawn from the left to the right or vice versa,
depending on the QwtPlotCurve::Inverted attribute.
*/
Steps,
/*!
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
painting a point.
*/
Dots,
/*!
Styles >= QwtPlotCurve::UserCurve are reserved for derived
classes of QwtPlotCurve that overload drawCurve() with
additional application specific curve types.
*/
UserCurve = 100
};
/*!
Attribute for drawing the curve
\sa setCurveAttribute(), testCurveAttribute(), curveFitter()
*/
enum CurveAttribute
{
/*!
For QwtPlotCurve::Steps only.
Draws a step function from the right to the left.
*/
Inverted = 0x01,
/*!
Only in combination with QwtPlotCurve::Lines
A QwtCurveFitter tries to
interpolate/smooth the curve, before it is painted.
\note Curve fitting requires temporary memory
for calculating coefficients and additional points.
If painting in QwtPlotCurve::Fitted mode is slow it might be better
to fit the points, before they are passed to QwtPlotCurve.
*/
Fitted = 0x02
};
Q_DECLARE_FLAGS( CurveAttributes, CurveAttribute )
/*!
Attributes how to represent the curve on the legend
\sa setLegendAttribute(), testLegendAttribute(),
QwtPlotItem::legendData(), legendIcon()
*/
enum LegendAttribute
{
/*!
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
is painted with the curve pen().
*/
LegendShowLine = 0x01,
/*!
If the curve has a valid symbol it is painted.
*/
LegendShowSymbol = 0x02,
/*!
If the curve has a brush a rectangle filled with the
curve brush() is painted.
*/
LegendShowBrush = 0x04
};
Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute )
/*!
Attributes to modify the drawing algorithm.
The default setting enables ClipPolygons | FilterPoints
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
Clip polygons before painting them. In situations, where points
are far outside the visible area (f.e when zooming deep) this
might be a substantial improvement for the painting performance
*/
ClipPolygons = 0x01,
/*!
Tries to reduce the data that has to be painted, by sorting out
duplicates, or paintings outside the visible area. Might have a
notable impact on curves with many close points.
Only a couple of very basic filtering algorithms are implemented.
*/
FilterPoints = 0x02,
/*!
Minimize memory usage that is temporarily needed for the
translated points, before they get painted.
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.
With a reasonable number of points QPainter::drawPoints()
will be faster.
*/
ImageBuffer = 0x08,
/*!
More aggressive point filtering trying to filter out
intermediate points, accepting minor visual differences.
Has only an effect, when drawing the curve to a paint device
in integer coordinates ( f.e. all widgets on screen ) using the fact,
that consecutive points are often mapped to the same x or y coordinate.
Each chunk of samples mapped to the same coordinate can be reduced to
4 points ( first, min, max last ).
In the worst case the polygon to be rendered will be 4 times the width
of the plot canvas.
The algorithm is very fast and effective for huge datasets, and can be used
inside a replot cycle.
\note Implemented for QwtPlotCurve::Lines only
\note As this algo replaces many small lines by a long one
a nasty bug of the raster paint engine ( Qt 4.8, Qt 5.1 - 5.3 )
becomes more dominant. For these versions the bug can be
worked around by enabling the QwtPainter::polylineSplitting() mode.
*/
FilterPointsAggressive = 0x10,
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotCurve( const QString& title = QString() );
explicit QwtPlotCurve( const QwtText& title );
virtual ~QwtPlotCurve();
virtual int rtti() const QWT_OVERRIDE;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setLegendAttribute( LegendAttribute, bool on = true );
bool testLegendAttribute( LegendAttribute ) const;
void setLegendAttributes( LegendAttributes );
LegendAttributes legendAttributes() const;
void setRawSamples( const double* xData, const double* yData, int size );
void setRawSamples( const float* xData, const float* yData, int size );
void setRawSamples( const double* yData, int size );
void setRawSamples( const float* yData, int size );
void setSamples( const double* xData, const double* yData, int size );
void setSamples( const float* xData, const float* yData, int size );
void setSamples( const double* yData, int size );
void setSamples( const float* yData, int size );
void setSamples( const QVector< double >& yData );
void setSamples( const QVector< float >& yData );
void setSamples( const QVector< double >& xData, const QVector< double >& yData );
void setSamples( const QVector< float >& xData, const QVector< float >& yData );
void setSamples( const QVector< QPointF >& );
void setSamples( QwtSeriesData< QPointF >* );
virtual int closestPoint( const QPointF& pos, double* dist = NULL ) const;
virtual int adjacentPoint( Qt::Orientation orientation, qreal value ) const;
qreal interpolatedValueAt( Qt::Orientation, double ) const;
double minXValue() const;
double maxXValue() const;
double minYValue() const;
double maxYValue() const;
void setCurveAttribute( CurveAttribute, bool on = true );
bool testCurveAttribute( CurveAttribute ) const;
void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen& );
const QPen& pen() const;
void setBrush( const QBrush& );
const QBrush& brush() const;
void setBaseline( double );
double baseline() const;
void setStyle( CurveStyle style );
CurveStyle style() const;
void setSymbol( QwtSymbol* );
const QwtSymbol* symbol() const;
void setCurveFitter( QwtCurveFitter* );
QwtCurveFitter* curveFitter() const;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
void init();
virtual void drawCurve( QPainter*, int style,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawSymbols( QPainter*, const QwtSymbol&,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawLines( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawSticks( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawDots( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
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 QRectF& canvasRect, QPolygonF& ) const;
void closePolyline( QPainter*,
const QwtScaleMap&, const QwtScaleMap&, QPolygonF& ) const;
private:
class PrivateData;
PrivateData* m_data;
};
//! boundingRect().left()
inline double QwtPlotCurve::minXValue() const
{
return boundingRect().left();
}
//! boundingRect().right()
inline double QwtPlotCurve::maxXValue() const
{
return boundingRect().right();
}
//! boundingRect().top()
inline double QwtPlotCurve::minYValue() const
{
return boundingRect().top();
}
//! boundingRect().bottom()
inline double QwtPlotCurve::maxYValue() const
{
return boundingRect().bottom();
}
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
#endif
+56
View File
@@ -0,0 +1,56 @@
/******************************************************************************
* 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_DICT
#define QWT_PLOT_DICT
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include <qlist.h>
typedef QList< QwtPlotItem* > QwtPlotItemList;
typedef QList< QwtPlotItem* >::ConstIterator QwtPlotItemIterator;
/*!
\brief A dictionary for plot items
QwtPlotDict organizes plot items in increasing z-order.
If autoDelete() is enabled, all attached items will be deleted
in the destructor of the dictionary.
QwtPlotDict can be used to get access to all QwtPlotItem items - or all
items of a specific type - that are currently on the plot.
\sa QwtPlotItem::attach(), QwtPlotItem::detach(), QwtPlotItem::z()
*/
class QWT_EXPORT QwtPlotDict
{
public:
explicit QwtPlotDict();
virtual ~QwtPlotDict();
void setAutoDelete( bool );
bool autoDelete() const;
const QwtPlotItemList& itemList() const;
QwtPlotItemList itemList( int rtti ) const;
void detachItems( int rtti = QwtPlotItem::Rtti_PlotItem,
bool autoDelete = true );
protected:
void insertItem( QwtPlotItem* );
void removeItem( QwtPlotItem* );
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,99 @@
/******************************************************************************
* 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_DIRECT_PAINTER_H
#define QWT_PLOT_DIRECT_PAINTER_H
#include "qwt_global.h"
#include <qobject.h>
class QRegion;
class QwtPlotSeriesItem;
/*!
\brief Painter object trying to paint incrementally
Often applications want to display samples while they are
collected. When there are too many samples complete replots
will be expensive to be processed in a collection cycle.
QwtPlotDirectPainter offers an API to paint
subsets ( f.e all additions points ) without erasing/repainting
the plot canvas.
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 )
frame buffer.
\warning Incremental painting will only help when no replot is triggered
by another operation ( like changing scales ) and nothing needs
to be erased.
*/
class QWT_EXPORT QwtPlotDirectPainter : public QObject
{
public:
/*!
\brief Paint attributes
\sa setAttribute(), testAttribute(), drawSeries()
*/
enum Attribute
{
/*!
Initializing a QPainter is an expensive operation.
When AtomicPainter is set each call of drawSeries() opens/closes
a temporary QPainter. Otherwise QwtPlotDirectPainter tries to
use the same QPainter as long as possible.
*/
AtomicPainter = 0x01,
/*!
When FullRepaint is set the plot canvas is explicitly repainted
after the samples have been rendered.
*/
FullRepaint = 0x02,
/*!
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
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.
*/
CopyBackingStore = 0x04
};
Q_DECLARE_FLAGS( Attributes, Attribute )
explicit QwtPlotDirectPainter( QObject* parent = NULL );
virtual ~QwtPlotDirectPainter();
void setAttribute( Attribute, bool on );
bool testAttribute( Attribute ) const;
void setClipping( bool );
bool hasClipping() const;
void setClipRegion( const QRegion& );
QRegion clipRegion() const;
void drawSeries( QwtPlotSeriesItem*, int from, int to );
void reset();
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotDirectPainter::Attributes )
#endif
@@ -0,0 +1,86 @@
/******************************************************************************
* 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 "qwt_plot_abstract_canvas.h"
#include <qgl.h>
class QwtPlot;
/*!
\brief An alternative canvas for a QwtPlot derived from QGLWidget
QwtPlotGLCanvas implements the very basics to act as canvas
inside of a QwtPlot widget. It might be extended to a full
featured alternative to QwtPlotCanvas in a future version of Qwt.
Even if QwtPlotGLCanvas is not derived from QFrame it imitates
its API. When using style sheets it supports the box model - beside
backgrounds with rounded borders.
Since Qt 5.4 QOpenGLWidget is available, that is used by QwtPlotOpenGLCanvas.
\sa QwtPlot::setCanvas(), QwtPlotCanvas, QwtPlotOpenGLCanvas
\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.
\note Another way for getting hardware accelerated graphics is using
an OpenGL offscreen buffer ( QwtPlotCanvas::OpenGLBuffer ) with QwtPlotCanvas.
Performance is worse, than rendering straight to a QGLWidget, but is usually
better integrated into a desktop application.
*/
class QWT_EXPORT QwtPlotGLCanvas : public QGLWidget, public QwtPlotAbstractGLCanvas
{
Q_OBJECT
Q_PROPERTY( QFrame::Shadow frameShadow READ frameShadow WRITE setFrameShadow )
Q_PROPERTY( QFrame::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 )
Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius )
public:
explicit QwtPlotGLCanvas( QwtPlot* = NULL );
explicit QwtPlotGLCanvas( const QGLFormat&, QwtPlot* = NULL );
virtual ~QwtPlotGLCanvas();
Q_INVOKABLE virtual void invalidateBackingStore() QWT_OVERRIDE;
Q_INVOKABLE QPainterPath borderPath( const QRect& ) const;
virtual bool event( QEvent* ) QWT_OVERRIDE;
public Q_SLOTS:
void replot();
protected:
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void initializeGL() QWT_OVERRIDE;
virtual void paintGL() QWT_OVERRIDE;
virtual void resizeGL( int width, int height ) QWT_OVERRIDE;
private:
void init();
virtual void clearBackingStore() QWT_OVERRIDE;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,55 @@
/******************************************************************************
* 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_GRAPHIC_ITEM_H
#define QWT_PLOT_GRAPHIC_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include <qstring.h>
/*!
\brief A plot item, which displays
a recorded sequence of QPainter commands
QwtPlotGraphicItem renders a sequence of recorded painter commands
into a specific plot area. Recording of painter commands can be
done manually by QPainter or e.g. QSvgRenderer.
\sa QwtPlotShapeItem, QwtPlotSvgItem
*/
class QWT_EXPORT QwtPlotGraphicItem : public QwtPlotItem
{
public:
explicit QwtPlotGraphicItem( const QString& title = QString() );
explicit QwtPlotGraphicItem( const QwtText& title );
virtual ~QwtPlotGraphicItem();
void setGraphic( const QRectF& rect, const QwtGraphic& );
QwtGraphic graphic() const;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual int rtti() const QWT_OVERRIDE;
private:
void init();
class PrivateData;
PrivateData* m_data;
};
#endif
+90
View File
@@ -0,0 +1,90 @@
/******************************************************************************
* 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_GRID_H
#define QWT_PLOT_GRID_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
class QPainter;
class QPen;
class QwtScaleMap;
class QwtScaleDiv;
/*!
\brief A class which draws a coordinate grid
The QwtPlotGrid class can be used to draw a coordinate grid.
A coordinate grid consists of major and minor vertical
and horizontal grid lines. The locations of the grid lines
are determined by the X and Y scale divisions which can
be assigned with setXDiv() and setYDiv().
The draw() member draws the grid within a bounding
rectangle.
*/
class QWT_EXPORT QwtPlotGrid : public QwtPlotItem
{
public:
explicit QwtPlotGrid();
virtual ~QwtPlotGrid();
virtual int rtti() const QWT_OVERRIDE;
void enableX( bool );
bool xEnabled() const;
void enableY( bool );
bool yEnabled() const;
void enableXMin( bool );
bool xMinEnabled() const;
void enableYMin( bool );
bool yMinEnabled() const;
void setXDiv( const QwtScaleDiv& );
const QwtScaleDiv& xScaleDiv() const;
void setYDiv( const QwtScaleDiv& );
const QwtScaleDiv& yScaleDiv() const;
void setPen( const QColor&,
qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen& );
void setMajorPen( const QColor&,
qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setMajorPen( const QPen& );
const QPen& majorPen() const;
void setMinorPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setMinorPen( const QPen& );
const QPen& minorPen() const;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual void updateScaleDiv(
const QwtScaleDiv& xScaleDiv, const QwtScaleDiv& yScaleDiv ) QWT_OVERRIDE;
private:
void drawLines( QPainter*, const QRectF&,
Qt::Orientation, const QwtScaleMap&,
const QList< double >& ) const;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,145 @@
/******************************************************************************
* 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_HISTOGRAM_H
#define QWT_PLOT_HISTOGRAM_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
class QwtColumnSymbol;
class QwtColumnRect;
class QColor;
class QPolygonF;
#if QT_VERSION < 0x060000
template< typename T > class QVector;
#endif
/*!
\brief QwtPlotHistogram represents a series of samples, where an interval
is associated with a value ( \f$y = f([x1,x2])\f$ ).
The representation depends on the style() and an optional symbol()
that is displayed for each interval.
\note The term "histogram" is used in a different way in the areas of
digital image processing and statistics. Wikipedia introduces the
terms "image histogram" and "color histogram" to avoid confusions.
While "image histograms" can be displayed by a QwtPlotCurve there
is no applicable plot item for a "color histogram" yet.
\sa QwtPlotBarChart, QwtPlotMultiBarChart
*/
class QWT_EXPORT QwtPlotHistogram
: public QwtPlotSeriesItem
, public QwtSeriesStore< QwtIntervalSample >
{
public:
/*!
Histogram styles.
The default style is QwtPlotHistogram::Columns.
\sa setStyle(), style(), setSymbol(), symbol(), setBaseline()
*/
enum HistogramStyle
{
/*!
Draw an outline around the area, that is build by all intervals
using the pen() and fill it with the brush(). The outline style
requires, that the intervals are in increasing order and
not overlapping.
*/
Outline,
/*!
Draw a column for each interval. When a symbol() has been set
the symbol is used otherwise the column is displayed as
plain rectangle using pen() and brush().
*/
Columns,
/*!
Draw a simple line using the pen() for each interval.
*/
Lines,
/*!
Styles >= UserStyle are reserved for derived
classes that overload drawSeries() with
additional application specific ways to display a histogram.
*/
UserStyle = 100
};
explicit QwtPlotHistogram( const QString& title = QString() );
explicit QwtPlotHistogram( const QwtText& title );
virtual ~QwtPlotHistogram();
virtual int rtti() const QWT_OVERRIDE;
void setPen( const QColor&,
qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen& );
const QPen& pen() const;
void setBrush( const QBrush& );
const QBrush& brush() const;
void setSamples( const QVector< QwtIntervalSample >& );
void setSamples( QwtSeriesData< QwtIntervalSample >* );
void setBaseline( double );
double baseline() const;
void setStyle( HistogramStyle style );
HistogramStyle style() const;
void setSymbol( const QwtColumnSymbol* );
const QwtColumnSymbol* symbol() const;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QwtGraphic legendIcon(
int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
virtual QwtColumnRect columnRect( const QwtIntervalSample&,
const QwtScaleMap&, const QwtScaleMap& ) const;
virtual void drawColumn( QPainter*, const QwtColumnRect&,
const QwtIntervalSample& ) const;
void drawColumns( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
int from, int to ) const;
void drawOutline( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
int from, int to ) const;
void drawLines( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
int from, int to ) const;
private:
void init();
void flushPolygon( QPainter*, double baseLine, QPolygonF& ) const;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,156 @@
/******************************************************************************
* 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_INTERVAL_CURVE_H
#define QWT_PLOT_INTERVAL_CURVE_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
class QwtIntervalSymbol;
template< typename T > class QwtSeriesData;
/*!
\brief QwtPlotIntervalCurve represents a series of samples, where each value
is associated with an interval ( \f$[y1,y2] = f(x)\f$ ).
The representation depends on the style() and an optional symbol()
that is displayed for each interval. QwtPlotIntervalCurve might be used
to display error bars or the area between 2 curves.
*/
class QWT_EXPORT QwtPlotIntervalCurve
: public QwtPlotSeriesItem
, public QwtSeriesStore< QwtIntervalSample >
{
public:
/*!
\brief Curve styles.
The default setting is QwtPlotIntervalCurve::Tube.
\sa setStyle(), style()
*/
enum CurveStyle
{
/*!
Don't draw a curve. Note: This doesn't affect the symbols.
*/
NoCurve,
/*!
Build 2 curves from the upper and lower limits of the intervals
and draw them with the pen(). The area between the curves is
filled with the brush().
*/
Tube,
/*!
Styles >= QwtPlotIntervalCurve::UserCurve are reserved for derived
classes that overload drawSeries() with
additional application specific curve types.
*/
UserCurve = 100
};
/*!
Attributes to modify the drawing algorithm.
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
Clip polygons before painting them. In situations, where points
are far outside the visible area (f.e when zooming deep) this
might be a substantial improvement for the painting performance.
*/
ClipPolygons = 0x01,
//! Check if a symbol is on the plot canvas before painting it.
ClipSymbol = 0x02,
/*!
Fill the tube with horizontal or vertical lines and unite
overlapping border lines. This attribute is useful for large
data sets, where consecutive samples are often mapped to the same
coordinate.
Beside other minor visual differences the filling is always
monochrome - using brush().color().
This algorithm is very fast and effective and can be used inside
a replot cycle. In the worst case the number of lines to be rendered
will be 5 times the ( width/height - depending on the orientation() )
of the plot canvas.
\note Has only an effect, when drawing to a paint device
in integer coordinates ( f.e. all widgets on screen ).
\sa QwtPlotCurve::FilterPointsAggressive
*/
TubeAsLines = 0x10
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotIntervalCurve( const QString& title = QString() );
explicit QwtPlotIntervalCurve( const QwtText& title );
virtual ~QwtPlotIntervalCurve();
virtual int rtti() const QWT_OVERRIDE;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setSamples( const QVector< QwtIntervalSample >& );
void setSamples( QwtSeriesData< QwtIntervalSample >* );
void setPen( const QColor&,
qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen& );
const QPen& pen() const;
void setBrush( const QBrush& );
const QBrush& brush() const;
void setStyle( CurveStyle style );
CurveStyle style() const;
void setSymbol( const QwtIntervalSymbol* );
const QwtIntervalSymbol* symbol() const;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QwtGraphic legendIcon(
int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
void init();
virtual void drawTube( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawSymbols( QPainter*, const QwtIntervalSymbol&,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotIntervalCurve::PaintAttributes )
#endif
+310
View File
@@ -0,0 +1,310 @@
/******************************************************************************
* 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_ITEM_H
#define QWT_PLOT_ITEM_H
#include "qwt_global.h"
#include "qwt_axis_id.h"
#include <qmetatype.h>
class QwtScaleMap;
class QwtScaleDiv;
class QwtPlot;
class QwtText;
class QwtGraphic;
class QwtLegendData;
class QRectF;
class QPainter;
class QString;
template< typename T > class QList;
/*!
\brief Base class for items on the plot canvas
A plot item is "something", that can be painted on the plot canvas,
or only affects the scales of the plot widget. They can be categorized as:
- Representator\n
A "Representator" is an item that represents some sort of data
on the plot canvas. The different representator classes are organized
according to the characteristics of the data:
- QwtPlotMarker
Represents a point or a horizontal/vertical coordinate
- QwtPlotCurve
Represents a series of points
- QwtPlotSpectrogram ( QwtPlotRasterItem )
Represents raster data
- ...
- Decorators\n
A "Decorator" is an item, that displays additional information, that
is not related to any data:
- QwtPlotGrid
- QwtPlotScaleItem
- QwtPlotSvgItem
- ...
Depending on the QwtPlotItem::ItemAttribute flags, an item is included
into autoscaling or has an entry on the legend.
Before misusing the existing item classes it might be better to
implement a new type of plot item
( don't implement a watermark as spectrogram ).
Deriving a new type of QwtPlotItem primarily means to implement
the YourPlotItem::draw() method.
\sa The cpuplot example shows the implementation of additional plot items.
*/
class QWT_EXPORT QwtPlotItem
{
public:
/*!
\brief Runtime type information
RttiValues is used to cast plot items, without
having to enable runtime type information of the compiler.
*/
enum RttiValues
{
//! Unspecific value, that can be used, when it doesn't matter
Rtti_PlotItem = 0,
//! For QwtPlotGrid
Rtti_PlotGrid,
//! For QwtPlotScaleItem
Rtti_PlotScale,
//! For QwtPlotLegendItem
Rtti_PlotLegend,
//! For QwtPlotMarker
Rtti_PlotMarker,
//! For QwtPlotCurve
Rtti_PlotCurve,
//! For QwtPlotSpectroCurve
Rtti_PlotSpectroCurve,
//! For QwtPlotIntervalCurve
Rtti_PlotIntervalCurve,
//! For QwtPlotHistogram
Rtti_PlotHistogram,
//! For QwtPlotSpectrogram
Rtti_PlotSpectrogram,
//! For QwtPlotGraphicItem, QwtPlotSvgItem
Rtti_PlotGraphic,
//! For QwtPlotTradingCurve
Rtti_PlotTradingCurve,
//! For QwtPlotBarChart
Rtti_PlotBarChart,
//! For QwtPlotMultiBarChart
Rtti_PlotMultiBarChart,
//! For QwtPlotShapeItem
Rtti_PlotShape,
//! For QwtPlotTextLabel
Rtti_PlotTextLabel,
//! For QwtPlotZoneItem
Rtti_PlotZone,
//! For QwtPlotVectorField
Rtti_PlotVectorField,
/*!
Values >= Rtti_PlotUserItem are reserved for plot items
not implemented in the Qwt library.
*/
Rtti_PlotUserItem = 1000
};
/*!
\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
participates in these updates depends on its attributes.
\sa setItemAttribute(), testItemAttribute(), ItemInterest
*/
enum ItemAttribute
{
//! The item is represented on the legend.
Legend = 0x01,
/*!
The boundingRect() of the item is included in the
autoscaling calculation as long as its width or height
is >= 0.0.
*/
AutoScale = 0x02,
/*!
The item needs extra space to display something outside
its bounding rectangle.
\sa getCanvasMarginHint()
*/
Margins = 0x04
};
Q_DECLARE_FLAGS( ItemAttributes, ItemAttribute )
/*!
\brief Plot Item Interests
Plot items might depend on the situation of the corresponding
plot widget. By enabling an interest the plot item will be
notified, when the corresponding attribute of the plot widgets
has changed.
\sa setItemAttribute(), testItemAttribute(), ItemInterest
*/
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.
\note If the plot item wants to be represented on a legend
enable QwtPlotItem::Legend instead.
\sa updateLegend()
*/
LegendInterest = 0x02
};
Q_DECLARE_FLAGS( ItemInterests, ItemInterest )
//! Render hints
enum RenderHint
{
//! Enable antialiasing
RenderAntialiased = 0x1
};
Q_DECLARE_FLAGS( RenderHints, RenderHint )
explicit QwtPlotItem();
explicit QwtPlotItem( const QString& title );
explicit QwtPlotItem( const QwtText& title );
virtual ~QwtPlotItem();
void attach( QwtPlot* plot );
void detach();
QwtPlot* plot() const;
void setTitle( const QString& title );
void setTitle( const QwtText& title );
const QwtText& title() const;
virtual int rtti() const;
void setItemAttribute( ItemAttribute, bool on = true );
bool testItemAttribute( ItemAttribute ) const;
void setItemInterest( ItemInterest, bool on = true );
bool testItemInterest( ItemInterest ) const;
void setRenderHint( RenderHint, bool on = true );
bool testRenderHint( RenderHint ) const;
void setRenderThreadCount( uint numThreads );
uint renderThreadCount() const;
void setLegendIconSize( const QSize& );
QSize legendIconSize() const;
double z() const;
void setZ( double z );
void show();
void hide();
virtual void setVisible( bool );
bool isVisible () const;
void setAxes( QwtAxisId xAxis, QwtAxisId yAxis );
void setXAxis( QwtAxisId );
QwtAxisId xAxis() const;
void setYAxis( QwtAxisId );
QwtAxisId yAxis() const;
virtual void itemChanged();
virtual void legendChanged();
/*!
\brief Draw the item
\param painter Painter
\param xMap Maps x-values into pixel coordinates.
\param yMap Maps y-values into pixel coordinates.
\param canvasRect Contents rect of the canvas in painter coordinates
*/
virtual void draw( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const = 0;
virtual QRectF boundingRect() const;
virtual void getCanvasMarginHint(
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect,
double& left, double& top, double& right, double& bottom) const;
virtual void updateScaleDiv(
const QwtScaleDiv&, const QwtScaleDiv& );
virtual void updateLegend( const QwtPlotItem*,
const QList< QwtLegendData >& );
QRectF scaleRect( const QwtScaleMap&, const QwtScaleMap& ) const;
QRectF paintRect( const QwtScaleMap&, const QwtScaleMap& ) const;
virtual QList< QwtLegendData > legendData() const;
virtual QwtGraphic legendIcon( int index, const QSizeF& ) const;
protected:
QwtGraphic defaultIcon( const QBrush&, const QSizeF& ) const;
private:
Q_DISABLE_COPY(QwtPlotItem)
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
Q_DECLARE_METATYPE( QwtPlotItem* )
#endif
+111
View File
@@ -0,0 +1,111 @@
/******************************************************************************
* 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_LAYOUT_H
#define QWT_PLOT_LAYOUT_H
#include "qwt_global.h"
#include "qwt_plot.h"
#include "qwt_axis_id.h"
/*!
\brief Layout engine for QwtPlot.
It is used by the QwtPlot widget to organize its internal widgets
or by QwtPlot::print() to render its content to a QPaintDevice like
a QPrinter, QPixmap/QImage or QSvgRenderer.
\sa QwtPlot::setPlotLayout()
*/
class QWT_EXPORT QwtPlotLayout
{
public:
/*!
Options to configure the plot layout engine
\sa activate(), QwtPlotRenderer
*/
enum Option
{
//! Unused
AlignScales = 0x01,
/*!
Ignore the dimension of the scrollbars. There are no
scrollbars, when the plot is not rendered to widgets.
*/
IgnoreScrollbars = 0x02,
//! Ignore all frames.
IgnoreFrames = 0x04,
//! Ignore the legend.
IgnoreLegend = 0x08,
//! Ignore the title.
IgnoreTitle = 0x10,
//! Ignore the footer.
IgnoreFooter = 0x20
};
Q_DECLARE_FLAGS( Options, Option )
explicit QwtPlotLayout();
virtual ~QwtPlotLayout();
void setCanvasMargin( int margin, int axis = -1 );
int canvasMargin( int axisId ) const;
void setAlignCanvasToScales( bool );
void setAlignCanvasToScale( int axisId, bool );
bool alignCanvasToScale( int axisId ) const;
void setSpacing( int );
int spacing() const;
void setLegendPosition( QwtPlot::LegendPosition pos, double ratio );
void setLegendPosition( QwtPlot::LegendPosition pos );
QwtPlot::LegendPosition legendPosition() const;
void setLegendRatio( double ratio );
double legendRatio() const;
virtual QSize minimumSizeHint( const QwtPlot* ) const;
virtual void activate( const QwtPlot*,
const QRectF& plotRect, Options options = Options() );
virtual void invalidate();
QRectF titleRect() const;
QRectF footerRect() const;
QRectF legendRect() const;
QRectF scaleRect( QwtAxisId ) const;
QRectF canvasRect() const;
protected:
void setTitleRect( const QRectF& );
void setFooterRect( const QRectF& );
void setLegendRect( const QRectF& );
void setScaleRect( QwtAxisId, const QRectF& );
void setCanvasRect( const QRectF& );
private:
Q_DISABLE_COPY(QwtPlotLayout)
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotLayout::Options )
#endif
@@ -0,0 +1,135 @@
/******************************************************************************
* 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_LEGEND_ITEM_H
#define QWT_PLOT_LEGEND_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
class QFont;
/*!
\brief A class which draws a legend inside the plot canvas
QwtPlotLegendItem can be used to draw a inside the plot canvas.
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.
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
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
with a similar effect.
*/
class QWT_EXPORT QwtPlotLegendItem : public QwtPlotItem
{
public:
/*!
\brief Background mode
Depending on the mode the complete legend or each item
might have an background.
The default setting is LegendBackground.
\sa setBackgroundMode(), setBackgroundBrush(), drawBackground()
*/
enum BackgroundMode
{
//! The legend has a background
LegendBackground,
//! Each item has a background
ItemBackground
};
explicit QwtPlotLegendItem();
virtual ~QwtPlotLegendItem();
virtual int rtti() const QWT_OVERRIDE;
void setAlignmentInCanvas( Qt::Alignment );
Qt::Alignment alignmentInCanvas() const;
void setOffsetInCanvas( Qt::Orientations, int numPixels );
int offsetInCanvas( Qt::Orientation ) const;
void setMaxColumns( uint );
uint maxColumns() const;
void setMargin( int );
int margin() const;
void setSpacing( int );
int spacing() const;
void setItemMargin( int );
int itemMargin() const;
void setItemSpacing( int );
int itemSpacing() const;
void setFont( const QFont& );
QFont font() const;
void setBorderRadius( double );
double borderRadius() const;
void setBorderPen( const QPen& );
QPen borderPen() const;
void setBackgroundBrush( const QBrush& );
QBrush backgroundBrush() const;
void setBackgroundMode( BackgroundMode );
BackgroundMode backgroundMode() const;
void setTextPen( const QPen& );
QPen textPen() const;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
void clearLegend();
virtual void updateLegend( const QwtPlotItem*,
const QList< QwtLegendData >& ) QWT_OVERRIDE;
virtual QRect geometry( const QRectF& canvasRect ) const;
virtual QSize minimumSize( const QwtLegendData& ) 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*,
const QwtPlotItem*, const QwtLegendData&, const QRectF& ) const;
virtual void drawBackground( QPainter*, const QRectF& rect ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,55 @@
/******************************************************************************
* 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_MAGNIFIER_H
#define QWT_PLOT_MAGNIFIER_H
#include "qwt_global.h"
#include "qwt_axis_id.h"
#include "qwt_magnifier.h"
class QwtPlot;
/*!
\brief QwtPlotMagnifier provides zooming, by magnifying in steps.
Using QwtPlotMagnifier a plot can be zoomed in/out in steps using
keys, the mouse wheel or moving a mouse button in vertical direction.
Together with QwtPlotZoomer and QwtPlotPanner it is possible to implement
individual and powerful navigation of the plot canvas.
\sa QwtPlotZoomer, QwtPlotPanner, QwtPlot
*/
class QWT_EXPORT QwtPlotMagnifier : public QwtMagnifier
{
Q_OBJECT
public:
explicit QwtPlotMagnifier( QWidget* );
virtual ~QwtPlotMagnifier();
void setAxisEnabled( QwtAxisId, bool on );
bool isAxisEnabled( QwtAxisId ) const;
QWidget* canvas();
const QWidget* canvas() const;
QwtPlot* plot();
const QwtPlot* plot() const;
public Q_SLOTS:
virtual void rescale( double factor ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+132
View File
@@ -0,0 +1,132 @@
/******************************************************************************
* 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_MARKER_H
#define QWT_PLOT_MARKER_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
class QString;
class QRectF;
class QwtText;
class QwtSymbol;
/*!
\brief A class for drawing markers
A marker can be a horizontal line, a vertical line,
a symbol, a label or any combination of them, which can
be drawn around a center point inside a bounding rectangle.
The setSymbol() member assigns a symbol to the marker.
The symbol is drawn at the specified point.
With setLabel(), a label can be assigned to the marker.
The setLabelAlignment() member specifies where the label is
drawn. All the Align*-constants in Qt::AlignmentFlags (see Qt documentation)
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
Qt::AlignLeft | Qt::AlignTop.
\note QwtPlotTextLabel is intended to align a text label
according to the geometry of canvas
( unrelated to plot coordinates )
*/
class QWT_EXPORT QwtPlotMarker : public QwtPlotItem
{
public:
/*!
Line styles.
\sa setLineStyle(), lineStyle()
*/
enum LineStyle
{
//! No line
NoLine,
//! A horizontal line
HLine,
//! A vertical line
VLine,
//! A crosshair
Cross
};
explicit QwtPlotMarker();
explicit QwtPlotMarker( const QString& title );
explicit QwtPlotMarker( const QwtText& title );
virtual ~QwtPlotMarker();
virtual int rtti() const QWT_OVERRIDE;
double xValue() const;
double yValue() const;
QPointF value() const;
void setXValue( double );
void setYValue( double );
void setValue( double, double );
void setValue( const QPointF& );
void setLineStyle( LineStyle );
LineStyle lineStyle() const;
void setLinePen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setLinePen( const QPen& );
const QPen& linePen() const;
void setSymbol( const QwtSymbol* );
const QwtSymbol* symbol() const;
void setLabel( const QwtText& );
QwtText label() const;
void setLabelAlignment( Qt::Alignment );
Qt::Alignment labelAlignment() const;
void setLabelOrientation( Qt::Orientation );
Qt::Orientation labelOrientation() const;
void setSpacing( int );
int spacing() const;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QwtGraphic legendIcon(
int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
virtual void drawLines( QPainter*,
const QRectF&, const QPointF& ) const;
virtual void drawSymbol( QPainter*,
const QRectF&, const QPointF& ) const;
virtual void drawLabel( QPainter*,
const QRectF&, const QPointF& ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,129 @@
/******************************************************************************
* 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_MULTI_BAR_CHART_H
#define QWT_PLOT_MULTI_BAR_CHART_H
#include "qwt_global.h"
#include "qwt_plot_abstract_barchart.h"
class QwtColumnRect;
class QwtColumnSymbol;
template< typename T > class QwtSeriesData;
/*!
\brief QwtPlotMultiBarChart displays a series of a samples that consist
each of a set of values.
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()
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
: public QwtPlotAbstractBarChart
, public QwtSeriesStore< QwtSetSample >
{
public:
/*!
\brief Chart styles.
The default setting is QwtPlotMultiBarChart::Grouped.
\sa setStyle(), style()
*/
enum ChartStyle
{
//! The bars of a set are displayed side by side
Grouped,
/*!
The bars are displayed on top of each other accumulating
to a single bar. All values of a set need to have the same
sign.
*/
Stacked
};
explicit QwtPlotMultiBarChart( const QString& title = QString() );
explicit QwtPlotMultiBarChart( const QwtText& title );
virtual ~QwtPlotMultiBarChart();
virtual int rtti() const QWT_OVERRIDE;
void setBarTitles( const QList< QwtText >& );
QList< QwtText > barTitles() const;
void setSamples( const QVector< QwtSetSample >& );
void setSamples( const QVector< QVector< double > >& );
void setSamples( QwtSeriesData< QwtSetSample >* );
void setStyle( ChartStyle style );
ChartStyle style() const;
void setSymbol( int valueIndex, QwtColumnSymbol* );
const QwtColumnSymbol* symbol( int valueIndex ) const;
void resetSymbolMap();
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QList< QwtLegendData > legendData() const QWT_OVERRIDE;
virtual QwtGraphic legendIcon(
int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
QwtColumnSymbol* symbol( int valueIndex );
virtual QwtColumnSymbol* specialSymbol(
int sampleIndex, int valueIndex ) const;
virtual void drawSample( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, const QwtInterval& boundingInterval,
int index, const QwtSetSample& ) const;
virtual void drawBar( QPainter*, int sampleIndex,
int valueIndex, const QwtColumnRect& ) const;
void drawStackedBars( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int index,
double sampleWidth, const QwtSetSample& ) const;
void drawGroupedBars( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int index,
double sampleWidth, const QwtSetSample& ) const;
private:
void init();
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,75 @@
/******************************************************************************
* 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_OPENGL_CANVAS_H
#define QWT_PLOT_OPENGL_CANVAS_H
#include "qwt_global.h"
#include "qwt_plot_abstract_canvas.h"
#include <qopenglwidget.h>
class QwtPlot;
/*!
\brief An alternative canvas for a QwtPlot derived from QOpenGLWidget
Even if QwtPlotOpenGLCanvas 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, QwtPlotCanvas::OpenGLBuffer
\note Another way for getting hardware accelerated graphics is using
an OpenGL offscreen buffer ( QwtPlotCanvas::OpenGLBuffer ) with QwtPlotCanvas.
Performance is worse, than rendering straight to a QOpenGLWidget, but is usually
better integrated into a desktop application.
*/
class QWT_EXPORT QwtPlotOpenGLCanvas : public QOpenGLWidget, public QwtPlotAbstractGLCanvas
{
Q_OBJECT
Q_PROPERTY( QFrame::Shadow frameShadow READ frameShadow WRITE setFrameShadow )
Q_PROPERTY( QFrame::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 )
Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius )
public:
explicit QwtPlotOpenGLCanvas( QwtPlot* = NULL );
explicit QwtPlotOpenGLCanvas( int samples, QwtPlot* = NULL);
virtual ~QwtPlotOpenGLCanvas();
Q_INVOKABLE virtual void invalidateBackingStore() QWT_OVERRIDE;
Q_INVOKABLE QPainterPath borderPath( const QRect& ) const;
virtual bool event( QEvent* ) QWT_OVERRIDE;
public Q_SLOTS:
void replot();
protected:
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void initializeGL() QWT_OVERRIDE;
virtual void paintGL() QWT_OVERRIDE;
virtual void resizeGL( int width, int height ) QWT_OVERRIDE;
private:
void init();
virtual void clearBackingStore() QWT_OVERRIDE;
class PrivateData;
PrivateData* m_data;
};
#endif
+61
View File
@@ -0,0 +1,61 @@
/******************************************************************************
* 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_PANNER_H
#define QWT_PLOT_PANNER_H
#include "qwt_global.h"
#include "qwt_panner.h"
#include "qwt_axis_id.h"
class QwtPlot;
/*!
\brief QwtPlotPanner provides panning of a plot canvas
QwtPlotPanner is a panner for a plot canvas, that
adjusts the scales of the axes after dropping
the canvas on its new position.
Together with QwtPlotZoomer and QwtPlotMagnifier powerful ways
of navigating on a QwtPlot widget can be implemented easily.
\note The axes are not updated, while dragging the canvas
\sa QwtPlotZoomer, QwtPlotMagnifier
*/
class QWT_EXPORT QwtPlotPanner : public QwtPanner
{
Q_OBJECT
public:
explicit QwtPlotPanner( QWidget* );
virtual ~QwtPlotPanner();
QWidget* canvas();
const QWidget* canvas() const;
QwtPlot* plot();
const QwtPlot* plot() const;
void setAxisEnabled( QwtAxisId axisId, bool on );
bool isAxisEnabled( QwtAxisId ) const;
public Q_SLOTS:
virtual void moveCanvas( int dx, int dy );
protected:
virtual QBitmap contentsMask() const QWT_OVERRIDE;
virtual QPixmap grab() const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+117
View File
@@ -0,0 +1,117 @@
/******************************************************************************
* 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_PICKER_H
#define QWT_PLOT_PICKER_H
#include "qwt_global.h"
#include "qwt_picker.h"
#include "qwt_axis_id.h"
class QwtPlot;
class QPointF;
class QRectF;
#if QT_VERSION < 0x060000
template< typename T > class QVector;
#endif
/*!
\brief QwtPlotPicker provides selections on a plot canvas
QwtPlotPicker is a QwtPicker tailored for selections on
a plot canvas. It is set to a x-Axis and y-Axis and
translates all pixel coordinates into this coordinate system.
*/
class QWT_EXPORT QwtPlotPicker : public QwtPicker
{
Q_OBJECT
public:
explicit QwtPlotPicker( QWidget* canvas );
virtual ~QwtPlotPicker();
explicit QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget* );
explicit QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId,
RubberBand rubberBand, DisplayMode trackerMode, QWidget* );
virtual void setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId );
QwtAxisId xAxis() const;
QwtAxisId yAxis() const;
QwtPlot* plot();
const QwtPlot* plot() const;
QWidget* canvas();
const QWidget* canvas() const;
Q_SIGNALS:
/*!
A signal emitted in case of QwtPickerMachine::PointSelection.
\param pos Selected point
*/
void selected( const QPointF& pos );
/*!
A signal emitted in case of QwtPickerMachine::RectSelection.
\param rect Selected rectangle
*/
void selected( const QRectF& rect );
/*!
A signal emitting the selected points,
at the end of a selection.
\param pa Selected points
*/
void selected( const QVector< QPointF >& pa );
/*!
A signal emitted when a point has been appended to the selection
\param pos Position of the appended point.
\sa append(). moved()
*/
void appended( const QPointF& pos );
/*!
A signal emitted whenever the last appended point of the
selection has been moved.
\param pos Position of the moved last point of the selection.
\sa move(), appended()
*/
void moved( const QPointF& pos );
protected:
QRectF scaleRect() const;
QRectF invTransform( const QRect& ) const;
QRect transform( const QRectF& ) const;
QPointF invTransform( const QPoint& ) const;
QPoint transform( const QPointF& ) const;
virtual QwtText trackerText( const QPoint& ) const QWT_OVERRIDE;
virtual QwtText trackerTextF( const QPointF& ) const;
virtual void move( const QPoint& ) QWT_OVERRIDE;
virtual void append( const QPoint& ) QWT_OVERRIDE;
virtual bool end( bool ok = true ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,151 @@
/******************************************************************************
* 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_RASTERITEM_H
#define QWT_PLOT_RASTERITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include <qstring.h>
class QwtInterval;
/*!
\brief A class, which displays raster data
Raster data is a grid of pixel values, that can be represented
as a QImage. It is used for many types of information like
spectrograms, cartograms, geographical maps ...
Often a plot has several types of raster data organized in layers.
( f.e a geographical map, with weather statistics ).
Using setAlpha() raster items can be stacked easily.
QwtPlotRasterItem is only implemented for images of the following formats:
QImage::Format_Indexed8, QImage::Format_ARGB32.
\sa QwtPlotSpectrogram
*/
class QWT_EXPORT QwtPlotRasterItem : public QwtPlotItem
{
public:
/*!
\brief Cache policy
The default policy is NoCache
*/
enum CachePolicy
{
/*!
renderImage() is called each time the item has to be repainted
*/
NoCache,
/*!
renderImage() is called, whenever the image cache is not valid,
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.
All other situations are handled by the canvas backing store.
*/
PaintCache
};
/*!
Attributes to modify the drawing algorithm.
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
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
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
document/file. If this is possible for a document format
depends on the implementation of the specific QPaintEngine.
*/
PaintInDeviceResolution = 1
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotRasterItem( const QString& title = QString() );
explicit QwtPlotRasterItem( const QwtText& title );
virtual ~QwtPlotRasterItem();
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setAlpha( int alpha );
int alpha() const;
void setCachePolicy( CachePolicy );
CachePolicy cachePolicy() const;
void invalidateCache();
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual QRectF pixelHint( const QRectF& ) const;
virtual QwtInterval interval(Qt::Axis) const;
virtual QRectF boundingRect() const QWT_OVERRIDE;
protected:
/*!
\brief Render an image
An implementation of render() might iterate over all
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.
\param xMap X-Scale Map
\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,
const QwtScaleMap& yMap, const QRectF& area,
const QSize& imageSize ) const = 0;
virtual QwtScaleMap imageMap( Qt::Orientation,
const QwtScaleMap& map, const QRectF& area,
const QSize& imageSize, double pixelSize) const;
private:
explicit QwtPlotRasterItem( const QwtPlotRasterItem& );
QwtPlotRasterItem& operator=( const QwtPlotRasterItem& );
void init();
QImage compose( const QwtScaleMap&, const QwtScaleMap&,
const QRectF& imageArea, const QRectF& paintRect,
const QSize& imageSize, bool doCache) const;
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRasterItem::PaintAttributes )
#endif
@@ -0,0 +1,168 @@
/******************************************************************************
* 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_RENDERER_H
#define QWT_PLOT_RENDERER_H
#include "qwt_global.h"
#include "qwt_axis_id.h"
#include <qobject.h>
#include <qsize.h>
class QwtPlot;
class QwtScaleMap;
class QRectF;
class QPainter;
class QPaintDevice;
#ifndef QT_NO_PRINTER
class QPrinter;
#endif
#ifndef QWT_NO_SVG
#ifdef QT_SVG_LIB
class QSvgGenerator;
#endif
#endif
/*!
\brief Renderer for exporting a plot to a document, a printer
or anything else, that is supported by QPainter/QPaintDevice
*/
class QWT_EXPORT QwtPlotRenderer : public QObject
{
Q_OBJECT
public:
//! Discard flags
enum DiscardFlag
{
//! Render all components of the plot
DiscardNone = 0x00,
//! Don't render the background of the plot
DiscardBackground = 0x01,
//! Don't render the title of the plot
DiscardTitle = 0x02,
//! Don't render the legend of the plot
DiscardLegend = 0x04,
//! Don't render the background of the canvas
DiscardCanvasBackground = 0x08,
//! 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
style sheets, where the frame is part
of the background
*/
DiscardCanvasFrame = 0x20
};
Q_DECLARE_FLAGS( DiscardFlags, DiscardFlag )
/*!
\brief Layout flags
\sa setLayoutFlag(), testLayoutFlag()
*/
enum LayoutFlag
{
//! Use the default layout as on screen
DefaultLayout = 0x00,
/*!
Instead of the scales a box is painted around the plot canvas,
where the scale ticks are aligned to.
*/
FrameWithScales = 0x01
};
Q_DECLARE_FLAGS( LayoutFlags, LayoutFlag )
explicit QwtPlotRenderer( QObject* = NULL );
virtual ~QwtPlotRenderer();
void setDiscardFlag( DiscardFlag flag, bool on = true );
bool testDiscardFlag( DiscardFlag flag ) const;
void setDiscardFlags( DiscardFlags flags );
DiscardFlags discardFlags() const;
void setLayoutFlag( LayoutFlag flag, bool on = true );
bool testLayoutFlag( LayoutFlag flag ) const;
void setLayoutFlags( LayoutFlags flags );
LayoutFlags layoutFlags() const;
void renderDocument( QwtPlot*, const QString& fileName,
const QSizeF& sizeMM, int resolution = 85 );
void renderDocument( QwtPlot*,
const QString& fileName, const QString& format,
const QSizeF& sizeMM, int resolution = 85 );
#ifndef QWT_NO_SVG
#ifdef QT_SVG_LIB
void renderTo( QwtPlot*, QSvgGenerator& ) const;
#endif
#endif
#ifndef QT_NO_PRINTER
void renderTo( QwtPlot*, QPrinter& ) const;
#endif
void renderTo( QwtPlot*, QPaintDevice& ) const;
virtual void render( QwtPlot*,
QPainter*, const QRectF& plotRect ) const;
virtual void renderTitle( const QwtPlot*,
QPainter*, const QRectF& titleRect ) const;
virtual void renderFooter( const QwtPlot*,
QPainter*, const QRectF& footerRect ) const;
virtual void renderScale( const QwtPlot*, QPainter*,
QwtAxisId, int startDist, int endDist,
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& legendRect ) const;
bool exportTo( QwtPlot*, const QString& documentName,
const QSizeF& sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
private:
void buildCanvasMaps( const QwtPlot*,
const QRectF&, QwtScaleMap maps[] ) const;
bool updateCanvasMargins( QwtPlot*,
const QRectF&, const QwtScaleMap maps[] ) const;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
#endif
@@ -0,0 +1,144 @@
/******************************************************************************
* 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_RESCALER_H
#define QWT_PLOT_RESCALER_H
#include "qwt_global.h"
#include "qwt_plot.h"
#include <qobject.h>
class QwtPlot;
class QwtInterval;
class QResizeEvent;
/*!
\brief QwtPlotRescaler takes care of fixed aspect ratios for plot scales
QwtPlotRescaler auto adjusts the axes of a QwtPlot according
to fixed aspect ratios.
*/
class QWT_EXPORT QwtPlotRescaler : public QObject
{
Q_OBJECT
public:
/*!
The rescale policy defines how to rescale the reference axis and
their depending axes.
\sa ExpandingDirection, setIntervalHint()
*/
enum RescalePolicy
{
/*!
The interval of the reference axis remains unchanged, when the
geometry of the canvas changes. All other axes
will be adjusted according to their aspect ratio.
*/
Fixed,
/*!
The interval of the reference axis will be shrunk/expanded,
when the geometry of the canvas changes. All other axes
will be adjusted according to their aspect ratio.
The interval, that is represented by one pixel is fixed.
*/
Expanding,
/*!
The intervals of the axes are calculated, so that all axes include
their interval hint.
*/
Fitting
};
/*!
When rescalePolicy() is set to Expanding its direction depends
on ExpandingDirection
*/
enum ExpandingDirection
{
//! The upper limit of the scale is adjusted
ExpandUp,
//! The lower limit of the scale is adjusted
ExpandDown,
//! Both limits of the scale are adjusted
ExpandBoth
};
explicit QwtPlotRescaler( QWidget* canvas,
QwtAxisId referenceAxis = QwtAxis::XBottom,
RescalePolicy = Expanding );
virtual ~QwtPlotRescaler();
void setEnabled( bool );
bool isEnabled() const;
void setRescalePolicy( RescalePolicy );
RescalePolicy rescalePolicy() const;
void setExpandingDirection( ExpandingDirection );
void setExpandingDirection( QwtAxisId, ExpandingDirection );
ExpandingDirection expandingDirection( QwtAxisId ) const;
void setReferenceAxis( QwtAxisId );
QwtAxisId referenceAxis() const;
void setAspectRatio( double ratio );
void setAspectRatio( QwtAxisId, double ratio );
double aspectRatio( QwtAxisId ) const;
void setIntervalHint( QwtAxisId, const QwtInterval& );
QwtInterval intervalHint( QwtAxisId ) const;
QWidget* canvas();
const QWidget* canvas() const;
QwtPlot* plot();
const QwtPlot* plot() const;
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
void rescale() const;
protected:
virtual void canvasResizeEvent( QResizeEvent* );
virtual void rescale( const QSize& oldSize, const QSize& newSize ) const;
virtual QwtInterval expandScale(
QwtAxisId, const QSize& oldSize, const QSize& newSize ) const;
virtual QwtInterval syncScale(
QwtAxisId, const QwtInterval& reference, const QSize& size ) const;
virtual void updateScales(
QwtInterval intervals[QwtAxis::AxisPositions] ) const;
Qt::Orientation orientation( QwtAxisId ) const;
QwtInterval interval( QwtAxisId ) const;
QwtInterval expandInterval( const QwtInterval&,
double width, ExpandingDirection ) const;
private:
double pixelDist( QwtAxisId, const QSize& ) const;
class AxisData;
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,94 @@
/******************************************************************************
* 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_SCALE_ITEM_H
#define QWT_PLOT_SCALE_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include "qwt_scale_draw.h"
class QPalette;
/*!
\brief A class which draws a scale inside the plot canvas
QwtPlotScaleItem can be used to draw an axis inside the plot canvas.
It might by synchronized to one of the axis of the plot, but can
also display its own ticks and labels.
It is allowed to synchronize the scale item with a disabled axis.
In plots with vertical and horizontal scale items, it might be
necessary to remove ticks at the intersections, by overloading
updateScaleDiv().
The scale might be at a specific position (f.e 0.0) or it might be
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.
\code
QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem( QwtScaleDraw::RightScale, 0.0 );
scaleItem->setFont( plot->axisWidget( QwtAxis::YLeft )->font() );
scaleItem->attach(plot);
plot->setAxisVisible( QwtAxis::YLeft, false );
\endcode
*/
class QWT_EXPORT QwtPlotScaleItem : public QwtPlotItem
{
public:
explicit QwtPlotScaleItem(
QwtScaleDraw::Alignment = QwtScaleDraw::BottomScale,
const double pos = 0.0 );
virtual ~QwtPlotScaleItem();
virtual int rtti() const QWT_OVERRIDE;
void setScaleDiv( const QwtScaleDiv& );
const QwtScaleDiv& scaleDiv() const;
void setScaleDivFromAxis( bool on );
bool isScaleDivFromAxis() const;
void setPalette( const QPalette& );
QPalette palette() const;
void setFont( const QFont& );
QFont font() const;
void setScaleDraw( QwtScaleDraw* );
const QwtScaleDraw* scaleDraw() const;
QwtScaleDraw* scaleDraw();
void setPosition( double pos );
double position() const;
void setBorderDistance( int );
int borderDistance() const;
void setAlignment( QwtScaleDraw::Alignment );
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual void updateScaleDiv(
const QwtScaleDiv&, const QwtScaleDiv& ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,68 @@
/******************************************************************************
* 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_SERIES_ITEM_H
#define QWT_PLOT_SERIES_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include "qwt_series_store.h"
#include <qstring.h>
class QwtScaleDiv;
/*!
\brief Base class for plot items representing a series of samples
*/
class QWT_EXPORT QwtPlotSeriesItem : public QwtPlotItem,
public virtual QwtAbstractSeriesStore
{
public:
explicit QwtPlotSeriesItem( const QString& title = QString() );
explicit QwtPlotSeriesItem( const QwtText& title );
virtual ~QwtPlotSeriesItem();
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
/*!
Draw a subset of the samples
\param painter Painter
\param xMap Maps x-values into pixel coordinates.
\param yMap Maps y-values into pixel coordinates.
\param canvasRect Contents rectangle of the canvas
\param from Index of the first point to be painted
\param to Index of the last point to be painted. If to < 0 the
curve will be painted to its last point.
*/
virtual void drawSeries( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const = 0;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual void updateScaleDiv(
const QwtScaleDiv&, const QwtScaleDiv& ) QWT_OVERRIDE;
protected:
virtual void dataChanged() QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,118 @@
/******************************************************************************
* 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_SHAPE_ITEM_H
#define QWT_PLOT_SHAPE_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include <qstring.h>
class QPainterPath;
class QPolygonF;
/*!
\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
regions, rectangles, ellipses or irregular areas defined by lines, and curves.
QwtPlotShapeItem displays a shape with a pen and brush.
QwtPlotShapeItem offers a couple of optimizations like clipping or weeding.
These algorithms need to convert the painter path into polygons that might be
less performant for paths built from curves and ellipses.
More complex shapes, that can't be expressed by a QPainterPath can be displayed
using QwtPlotGraphicItem.
\sa QwtPlotZone, QwtPlotGraphicItem
*/
class QWT_EXPORT QwtPlotShapeItem : public QwtPlotItem
{
public:
/*!
Attributes to modify the drawing algorithm.
The default disables all attributes
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
Clip polygons before painting them. In situations, where points
are far outside the visible area (f.e when zooming deep) this
might be a substantial improvement for the painting performance
But polygon clipping will convert the painter path into
polygons what might introduce a negative impact on the
performance of paths composed from curves or ellipses.
*/
ClipPolygons = 0x01,
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
//! Mode how to display the item on the legend
enum LegendMode
{
//! Display a scaled down version of the shape
LegendShape,
//! Display a filled rectangle
LegendColor
};
explicit QwtPlotShapeItem( const QString& title = QString() );
explicit QwtPlotShapeItem( const QwtText& title );
virtual ~QwtPlotShapeItem();
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setLegendMode( LegendMode );
LegendMode legendMode() const;
void setRect( const QRectF& );
void setPolygon( const QPolygonF& );
void setShape( const QPainterPath& );
QPainterPath shape() const;
void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen& );
QPen pen() const;
void setBrush( const QBrush& );
QBrush brush() const;
void setRenderTolerance( double );
double renderTolerance() const;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual QwtGraphic legendIcon(
int index, const QSizeF& ) const QWT_OVERRIDE;
virtual int rtti() const QWT_OVERRIDE;
private:
void init();
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,77 @@
/******************************************************************************
* 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_CURVE_3D_H
#define QWT_PLOT_CURVE_3D_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
class QwtColorMap;
/*!
\brief Curve that displays 3D points as dots, where the z coordinate is
mapped to a color.
*/
class QWT_EXPORT QwtPlotSpectroCurve
: public QwtPlotSeriesItem
, public QwtSeriesStore< QwtPoint3D >
{
public:
//! Paint attributes
enum PaintAttribute
{
//! Clip points outside the canvas rectangle
ClipPoints = 1
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotSpectroCurve( const QString& title = QString() );
explicit QwtPlotSpectroCurve( const QwtText& title );
virtual ~QwtPlotSpectroCurve();
virtual int rtti() const QWT_OVERRIDE;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setSamples( const QVector< QwtPoint3D >& );
void setSamples( QwtSeriesData< QwtPoint3D >* );
void setColorMap( QwtColorMap* );
const QwtColorMap* colorMap() const;
void setColorRange( const QwtInterval& );
QwtInterval& colorRange() const;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
void setPenWidth( double );
double penWidth() const;
protected:
virtual void drawDots( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
private:
void init();
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectroCurve::PaintAttributes )
#endif
@@ -0,0 +1,118 @@
/******************************************************************************
* 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_SPECTROGRAM_H
#define QWT_PLOT_SPECTROGRAM_H
#include "qwt_global.h"
#include "qwt_raster_data.h"
#include "qwt_plot_rasteritem.h"
class QwtColorMap;
template< typename T > class QList;
/*!
\brief A plot item, which displays a spectrogram
A spectrogram displays 3-dimensional data, where the 3rd dimension
( the intensity ) is displayed using colors. The colors are calculated
from the values using a color map.
On multi-core systems the performance of the image composition
can often be improved by dividing the area into tiles - each of them
rendered in a different thread ( see QwtPlotItem::setRenderThreadCount() ).
In ContourMode contour lines are painted for the contour levels.
\sa QwtRasterData, QwtColorMap, QwtPlotItem::setRenderThreadCount()
*/
class QWT_EXPORT QwtPlotSpectrogram : public QwtPlotRasterItem
{
public:
/*!
The display mode controls how the raster data will be represented.
\sa setDisplayMode(), testDisplayMode()
*/
enum DisplayMode
{
//! The values are mapped to colors using a color map.
ImageMode = 0x01,
//! The data is displayed using contour lines
ContourMode = 0x02
};
Q_DECLARE_FLAGS( DisplayModes, DisplayMode )
explicit QwtPlotSpectrogram( const QString& title = QString() );
virtual ~QwtPlotSpectrogram();
void setDisplayMode( DisplayMode, bool on = true );
bool testDisplayMode( DisplayMode ) const;
void setData( QwtRasterData* data );
const QwtRasterData* data() const;
QwtRasterData* data();
void setColorMap( QwtColorMap* );
const QwtColorMap* colorMap() const;
void setColorTableSize( int numColors );
int colorTableSize() const;
virtual QwtInterval interval( Qt::Axis ) const QWT_OVERRIDE;
virtual QRectF pixelHint( const QRectF& ) const QWT_OVERRIDE;
void setDefaultContourPen( const QColor&,
qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setDefaultContourPen( const QPen& );
QPen defaultContourPen() const;
virtual QPen contourPen( double level ) const;
void setConrecFlag( QwtRasterData::ConrecFlag, bool on );
bool testConrecFlag( QwtRasterData::ConrecFlag ) const;
void setContourLevels( const QList< double >& );
QList< double > contourLevels() const;
virtual int rtti() const QWT_OVERRIDE;
virtual void draw( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const QWT_OVERRIDE;
protected:
virtual QImage renderImage(
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& area, const QSize& imageSize ) const QWT_OVERRIDE;
virtual QSize contourRasterSize(
const QRectF&, const QRect& ) const;
virtual QwtRasterData::ContourLines renderContourLines(
const QRectF& rect, const QSize& raster ) const;
virtual void drawContourLines( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QwtRasterData::ContourLines& ) const;
void renderTile( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRect& tile, QImage* ) const;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectrogram::DisplayModes )
#endif
@@ -0,0 +1,39 @@
/******************************************************************************
* 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_SVG_ITEM_H
#define QWT_PLOT_SVG_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_graphicitem.h"
class QByteArray;
/*!
\brief A plot item, which displays
data in Scalable Vector Graphics (SVG) format.
SVG images are often used to display maps
QwtPlotSvgItem is only a small convenience wrapper class for
QwtPlotGraphicItem, that creates a QwtGraphic from SVG data.
*/
class QWT_EXPORT QwtPlotSvgItem : public QwtPlotGraphicItem
{
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& );
};
#endif
@@ -0,0 +1,75 @@
/******************************************************************************
* 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_TEXT_LABEL_H
#define QWT_PLOT_TEXT_LABEL_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
class QwtText;
/*!
\brief A plot item, which displays a text label
QwtPlotTextLabel displays a text label aligned to the plot canvas.
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.
\code
QwtText title( "Plot Title" );
title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
QFont font;
font.setBold( true );
title.setFont( font );
QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
titleItem->setText( title );
titleItem->attach( plot );
\endcode
\sa QwtPlotMarker
*/
class QWT_EXPORT QwtPlotTextLabel : public QwtPlotItem
{
public:
QwtPlotTextLabel();
virtual ~QwtPlotTextLabel();
virtual int rtti() const QWT_OVERRIDE;
void setText( const QwtText& );
QwtText text() const;
void setMargin( int margin );
int margin() const;
virtual QRectF textRect( const QRectF&, const QSizeF& ) const;
protected:
virtual void draw( QPainter*,
const QwtScaleMap&, const QwtScaleMap&,
const QRectF&) const QWT_OVERRIDE;
void invalidateCache();
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,173 @@
/******************************************************************************
* 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_TRADING_CURVE_H
#define QWT_PLOT_TRADING_CURVE_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
/*!
\brief QwtPlotTradingCurve illustrates movements in the price of a
financial instrument over time.
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() )
of each symbol depends on the corresponding OHLC sample the size
of the other dimension can be controlled using:
- setSymbolExtent()
- setSymbolMinWidth()
- setSymbolMaxWidth()
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.
*/
class QWT_EXPORT QwtPlotTradingCurve
: public QwtPlotSeriesItem
, public QwtSeriesStore< QwtOHLCSample >
{
public:
/*!
\brief Symbol styles.
The default setting is QwtPlotSeriesItem::CandleStick.
\sa setSymbolStyle(), symbolStyle()
*/
enum SymbolStyle
{
//! Nothing is displayed
NoSymbol = -1,
/*!
A line on the chart shows the price range (the highest and lowest
prices) over one unit of time, e.g. one day or one hour.
Tick marks project from each side of the line indicating the
opening and closing price.
*/
Bar,
/*!
The range between opening/closing price are displayed as
a filled box. The fill brush depends on the direction of the
price movement. The box is connected to the highest/lowest
values by lines.
*/
CandleStick,
/*!
SymbolTypes >= UserSymbol are displayed by drawUserSymbol(),
that needs to be overloaded and implemented in derived
curve classes.
\sa drawUserSymbol()
*/
UserSymbol = 100
};
/*!
\brief Direction of a price movement
*/
enum Direction
{
//! The closing price is higher than the opening price
Increasing,
//! The closing price is lower than the opening price
Decreasing
};
/*!
Attributes to modify the drawing algorithm.
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
//! Check if a symbol is on the plot canvas before painting it.
ClipSymbols = 0x01
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPlotTradingCurve( const QString& title = QString() );
explicit QwtPlotTradingCurve( const QwtText& title );
virtual ~QwtPlotTradingCurve();
virtual int rtti() const QWT_OVERRIDE;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setSamples( const QVector< QwtOHLCSample >& );
void setSamples( QwtSeriesData< QwtOHLCSample >* );
void setSymbolStyle( SymbolStyle style );
SymbolStyle symbolStyle() const;
void setSymbolPen( const QColor&,
qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setSymbolPen( const QPen& );
QPen symbolPen() const;
void setSymbolBrush( Direction, const QBrush& );
QBrush symbolBrush( Direction ) const;
void setSymbolExtent( double );
double symbolExtent() const;
void setMinSymbolWidth( double );
double minSymbolWidth() const;
void setMaxSymbolWidth( double );
double maxSymbolWidth() const;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
void init();
virtual void drawSymbols( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawUserSymbol( QPainter*,
SymbolStyle, const QwtOHLCSample&,
Qt::Orientation, bool inverted, double symbolWidth ) const;
void drawBar( QPainter*, const QwtOHLCSample&,
Qt::Orientation, bool inverted, double width ) const;
void drawCandleStick( QPainter*, const QwtOHLCSample&,
Qt::Orientation, double width ) const;
virtual double scaledSymbolWidth(
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect ) const;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotTradingCurve::PaintAttributes )
#endif
@@ -0,0 +1,169 @@
/******************************************************************************
* 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_VECTOR_FIELD_H
#define QWT_PLOT_VECTOR_FIELD_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
class QwtVectorFieldSymbol;
class QwtColorMap;
class QPen;
class QBrush;
/*!
\brief A plot item, that represents a vector field
A vector field is a representation of a points with a given magnitude and direction
as arrows. While the direction affects the direction of the arrow, the magnitude
might be represented as a color or by the length of the arrow.
\sa QwtVectorFieldSymbol, QwtVectorFieldSample
*/
class QWT_EXPORT QwtPlotVectorField
: public QwtPlotSeriesItem
, public QwtSeriesStore< QwtVectorFieldSample >
{
public:
/*!
Depending on the origin the indicator symbol ( usually an arrow )
will be to the position of the corresponding sample.
*/
enum IndicatorOrigin
{
//! symbol points to the sample position
OriginHead,
//! The arrow starts at the sample position
OriginTail,
//! The arrow is centered at the sample position
OriginCenter
};
/*!
Attributes to modify the rendering
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*
FilterVectors calculates an average sample from all samples
that lie in the same cell of a grid that is determined by
setting the rasterSize().
\sa setRasterSize()
*/
FilterVectors = 0x01
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
/*!
Depending on the MagnitudeMode the magnitude component will have
an impact on the attributes of the symbol/arrow.
\sa setMagnitudeMode()
*/
enum MagnitudeMode
{
/*!
The magnitude will be mapped to a color using a color map
\sa magnitudeRange(), colorMap()
*/
MagnitudeAsColor = 0x01,
/*!
The magnitude will have an impact on the length of the arrow/symbol
\sa arrowLength(), magnitudeScaleFactor()
*/
MagnitudeAsLength = 0x02
};
Q_DECLARE_FLAGS( MagnitudeModes, MagnitudeMode )
explicit QwtPlotVectorField( const QString& title = QString() );
explicit QwtPlotVectorField( const QwtText& title );
virtual ~QwtPlotVectorField();
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setMagnitudeMode( MagnitudeMode, bool on = true );
bool testMagnitudeMode( MagnitudeMode ) const;
void setSymbol( QwtVectorFieldSymbol* );
const QwtVectorFieldSymbol* symbol() const;
void setPen( const QPen& );
QPen pen() const;
void setBrush( const QBrush& );
QBrush brush() const;
void setRasterSize( const QSizeF& );
QSizeF rasterSize() const;
void setIndicatorOrigin( IndicatorOrigin );
IndicatorOrigin indicatorOrigin() const;
void setSamples( const QVector< QwtVectorFieldSample >& );
void setSamples( QwtVectorFieldData* );
void setColorMap( QwtColorMap* );
const QwtColorMap* colorMap() const;
void setMagnitudeRange( const QwtInterval& );
QwtInterval magnitudeRange() const;
void setMinArrowLength( double );
double minArrowLength() const;
void setMaxArrowLength( double );
double maxArrowLength() const;
virtual double arrowLength( double magnitude ) const;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual void drawSeries( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
virtual int rtti() const QWT_OVERRIDE;
virtual QwtGraphic legendIcon(
int index, const QSizeF& ) const QWT_OVERRIDE;
void setMagnitudeScaleFactor( double factor );
double magnitudeScaleFactor() const;
protected:
virtual void drawSymbols( QPainter*,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const;
virtual void drawSymbol( QPainter*,
double x, double y, double vx, double vy ) const;
virtual void dataChanged() QWT_OVERRIDE;
private:
void init();
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotVectorField::PaintAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotVectorField::MagnitudeModes )
#endif
@@ -0,0 +1,67 @@
/******************************************************************************
* 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_ZONE_ITEM_H
#define QWT_PLOT_ZONE_ITEM_H
#include "qwt_global.h"
#include "qwt_plot_item.h"
#include <qnamespace.h>
class QwtInterval;
class QPen;
class QBrush;
/*!
\brief A plot item, which displays a zone
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.
\note For displaying an area that is bounded for x and y coordinates
use QwtPlotShapeItem
*/
class QWT_EXPORT QwtPlotZoneItem :
public QwtPlotItem
{
public:
explicit QwtPlotZoneItem();
virtual ~QwtPlotZoneItem();
virtual int rtti() const QWT_OVERRIDE;
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
void setInterval( double min, double max );
void setInterval( const QwtInterval& );
QwtInterval interval() const;
void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen& );
const QPen& pen() const;
void setBrush( const QBrush& );
const QBrush& brush() const;
virtual void draw( QPainter*,
const QwtScaleMap&, const QwtScaleMap&,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual QRectF boundingRect() const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+142
View File
@@ -0,0 +1,142 @@
/******************************************************************************
* 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_ZOOMER_H
#define QWT_PLOT_ZOOMER_H
#include "qwt_global.h"
#include "qwt_plot_picker.h"
class QSizeF;
template< typename T > class QStack;
/*!
\brief QwtPlotZoomer provides stacked zooming for a plot widget
QwtPlotZoomer selects rectangles from user inputs ( mouse or keyboard )
translates them into plot coordinates and adjusts the axes to them.
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
maxStackDepth() or minZoomSize(). Each rectangle is pushed on a stack.
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 second point from the position, where the mouse is released.
- QwtEventPattern::KeySelect1\n
The first key press selects the first, the second key press
selects the second point.
- QwtEventPattern::KeyAbort\n
Discard the selection in the state, where the first point
is selected.
To traverse the zoom stack the following bindings are used:
- 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
- QwtEventPattern::MouseSelect2, QwtEventPattern::KeyHome\n
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
"unzoom" the plot.
\code
zoomer = new QwtPlotZoomer( plot );
zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );
\endcode
QwtPlotZoomer is tailored for plots with one x and y axis, but it is
allowed to attach a second QwtPlotZoomer ( without rubber band and tracker )
for the other axes.
\note The realtime example includes an derived zoomer class that adds
scrollbars to the plot canvas.
\sa QwtPlotPanner, QwtPlotMagnifier
*/
class QWT_EXPORT QwtPlotZoomer : public QwtPlotPicker
{
Q_OBJECT
public:
explicit QwtPlotZoomer( QWidget*, bool doReplot = true );
explicit QwtPlotZoomer( QwtAxisId xAxis, QwtAxisId yAxis,
QWidget*, bool doReplot = true );
virtual ~QwtPlotZoomer();
virtual void setZoomBase( bool doReplot = true );
virtual void setZoomBase( const QRectF& );
QRectF zoomBase() const;
QRectF zoomRect() const;
virtual void setAxes( QwtAxisId xAxis, QwtAxisId yAxis ) QWT_OVERRIDE;
void setMaxStackDepth( int );
int maxStackDepth() const;
const QStack< QRectF >& zoomStack() const;
void setZoomStack( const QStack< QRectF >&,
int zoomRectIndex = -1 );
uint zoomRectIndex() const;
public Q_SLOTS:
void moveBy( double dx, double dy );
virtual void moveTo( const QPointF& );
virtual void zoom( const QRectF& );
virtual void zoom( int offset );
Q_SIGNALS:
/*!
A signal emitting the zoomRect(), when the plot has been
zoomed in or out.
\param rect Current zoom rectangle.
*/
void zoomed( const QRectF& rect );
protected:
virtual void rescale();
virtual QSizeF minZoomSize() const;
virtual void widgetMouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE;
virtual void widgetKeyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
virtual void begin() QWT_OVERRIDE;
virtual bool end( bool ok = true ) QWT_OVERRIDE;
virtual bool accept( QPolygon& ) const QWT_OVERRIDE;
private:
void init( bool doReplot );
class PrivateData;
PrivateData* m_data;
};
#endif
+176
View File
@@ -0,0 +1,176 @@
/******************************************************************************
* 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
*****************************************************************************/
/*! \file */
#ifndef QWT_POINT_3D_H
#define QWT_POINT_3D_H
#include "qwt_global.h"
#include <qpoint.h>
#include <qmetatype.h>
/*!
\brief QwtPoint3D class defines a 3D point in double coordinates
*/
class QWT_EXPORT QwtPoint3D
{
public:
QwtPoint3D();
QwtPoint3D( double x, double y, double z );
QwtPoint3D( const QPointF& );
bool isNull() const;
double x() const;
double y() const;
double z() const;
double& rx();
double& ry();
double& rz();
void setX( double x );
void setY( double y );
void setZ( double y );
QPointF toPoint() const;
bool operator==( const QwtPoint3D& ) const;
bool operator!=( const QwtPoint3D& ) const;
private:
double m_x;
double m_y;
double m_z;
};
Q_DECLARE_TYPEINFO( QwtPoint3D, Q_MOVABLE_TYPE );
Q_DECLARE_METATYPE( QwtPoint3D )
#ifndef QT_NO_DEBUG_STREAM
QWT_EXPORT QDebug operator<<( QDebug, const QwtPoint3D& );
#endif
/*!
Constructs a null point.
\sa isNull()
*/
inline QwtPoint3D::QwtPoint3D()
: m_x( 0.0 )
, m_y( 0.0 )
, m_z( 0.0 )
{
}
//! Constructs a point with coordinates specified by x, y and z.
inline QwtPoint3D::QwtPoint3D( double x, double y, double z = 0.0 )
: m_x( x )
, m_y( y )
, m_z( z )
{
}
/*!
Constructs a point with x and y coordinates from a 2D point,
and a z coordinate of 0.
*/
inline QwtPoint3D::QwtPoint3D( const QPointF& other )
: m_x( other.x() )
, m_y( other.y() )
, m_z( 0.0 )
{
}
/*!
\return True if the point is null; otherwise returns false.
A point is considered to be null if x, y and z-coordinates
are equal to zero.
*/
inline bool QwtPoint3D::isNull() const
{
return m_x == 0.0 && m_y == 0.0 && m_z == 0.0;
}
//! \return The x-coordinate of the point.
inline double QwtPoint3D::x() const
{
return m_x;
}
//! \return The y-coordinate of the point.
inline double QwtPoint3D::y() const
{
return m_y;
}
//! \return The z-coordinate of the point.
inline double QwtPoint3D::z() const
{
return m_z;
}
//! \return A reference to the x-coordinate of the point.
inline double& QwtPoint3D::rx()
{
return m_x;
}
//! \return A reference to the y-coordinate of the point.
inline double& QwtPoint3D::ry()
{
return m_y;
}
//! \return A reference to the z-coordinate of the point.
inline double& QwtPoint3D::rz()
{
return m_z;
}
//! Sets the x-coordinate of the point to the value specified by x.
inline void QwtPoint3D::setX( double x )
{
m_x = x;
}
//! Sets the y-coordinate of the point to the value specified by y.
inline void QwtPoint3D::setY( double y )
{
m_y = y;
}
//! Sets the z-coordinate of the point to the value specified by z.
inline void QwtPoint3D::setZ( double z )
{
m_z = z;
}
/*!
\return 2D point, where the z coordinate is dropped.
*/
inline QPointF QwtPoint3D::toPoint() const
{
return QPointF( m_x, m_y );
}
//! \return True, if this point and other are equal; otherwise returns false.
inline bool QwtPoint3D::operator==( const QwtPoint3D& other ) const
{
return ( m_x == other.m_x ) && ( m_y == other.m_y ) && ( m_z == other.m_z );
}
//! \return True if this rect and other are different; otherwise returns false.
inline bool QwtPoint3D::operator!=( const QwtPoint3D& other ) const
{
return !operator==( other );
}
#endif
+412
View File
@@ -0,0 +1,412 @@
/******************************************************************************
* 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_POINT_DATA_H
#define QWT_POINT_DATA_H
#include "qwt_global.h"
#include "qwt_series_data.h"
#include <cstring>
/*!
\brief Interface for iterating over two QVector<T> objects.
*/
template< typename T >
class QwtPointArrayData : public QwtSeriesData< QPointF >
{
public:
QwtPointArrayData( const QVector< T >& x, const QVector< T >& y );
QwtPointArrayData( const T* x, const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const QVector< T >& xData() const;
const QVector< T >& yData() const;
private:
QVector< T > m_x;
QVector< T > m_y;
};
/*!
\brief Data class containing two pointers to memory blocks of T.
*/
template< typename T >
class QwtCPointerData : public QwtSeriesData< QPointF >
{
public:
QwtCPointerData( const T* x, const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const T* xData() const;
const T* yData() const;
private:
const T* m_x;
const T* m_y;
size_t m_size;
};
/*!
\brief Interface for iterating over a QVector<T>.
The memory contains the y coordinates, while the index is
interpreted as x coordinate.
*/
template< typename T >
class QwtValuePointData : public QwtSeriesData< QPointF >
{
public:
QwtValuePointData( const QVector< T >& y );
QwtValuePointData( const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const QVector< T >& yData() const;
private:
QVector< T > m_y;
};
/*!
\brief Data class containing a pointer to memory of y coordinates
The memory contains the y coordinates, while the index is
interpreted as x coordinate.
*/
template< typename T >
class QwtCPointerValueData : public QwtSeriesData< QPointF >
{
public:
QwtCPointerValueData( const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const T* yData() const;
private:
const T* m_y;
size_t m_size;
};
/*!
\brief Synthetic point data
QwtSyntheticPointData provides a fixed number of points for an interval.
The points are calculated in equidistant steps in x-direction.
If the interval is invalid, the points are calculated for
the "rectangle of interest", what normally is the displayed area on the
plot canvas. In this mode you get different levels of detail, when
zooming in/out.
\par Example
The following example shows how to implement a sinus curve.
\code
#include <cmath>
#include <qwt_series_data.h>
#include <qwt_plot_curve.h>
#include <qwt_plot.h>
#include <qapplication.h>
class SinusData: public QwtSyntheticPointData
{
public:
SinusData():
QwtSyntheticPointData( 100 )
{
}
virtual double y( double x ) const
{
return qSin( x );
}
};
int main(int argc, char **argv)
{
QApplication a( argc, argv );
QwtPlot plot;
plot.setAxisScale( QwtAxis::XBottom, 0.0, 10.0 );
plot.setAxisScale( QwtAxis::YLeft, -1.0, 1.0 );
QwtPlotCurve *curve = new QwtPlotCurve( "y = sin(x)" );
curve->setData( new SinusData() );
curve->attach( &plot );
plot.show();
return a.exec();
}
\endcode
*/
class QWT_EXPORT QwtSyntheticPointData : public QwtSeriesData< QPointF >
{
public:
QwtSyntheticPointData( size_t size,
const QwtInterval& = QwtInterval() );
void setSize( size_t size );
virtual size_t size() const QWT_OVERRIDE;
void setInterval( const QwtInterval& );
QwtInterval interval() const;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
/*!
Calculate a y value for a x value
\param x x value
\return Corresponding y value
*/
virtual double y( double x ) const = 0;
virtual double x( uint index ) const;
virtual void setRectOfInterest( const QRectF& ) QWT_OVERRIDE;
QRectF rectOfInterest() const;
private:
size_t m_size;
QwtInterval m_interval;
QRectF m_rectOfInterest;
QwtInterval m_intervalOfInterest;
};
/*!
Constructor
\param x Array of x values
\param y Array of y values
\sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
*/
template< typename T >
QwtPointArrayData< T >::QwtPointArrayData(
const QVector< T >& x, const QVector< T >& y )
: m_x( x )
, m_y( y )
{
}
/*!
Constructor
\param x Array of x values
\param y Array of y values
\param size Size of the x and y arrays
\sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
*/
template< typename T >
QwtPointArrayData< T >::QwtPointArrayData( const T* x, const T* y, size_t size )
{
m_x.resize( size );
std::memcpy( m_x.data(), x, size * sizeof( T ) );
m_y.resize( size );
std::memcpy( m_y.data(), y, size * sizeof( T ) );
}
//! \return Size of the data set
template< typename T >
size_t QwtPointArrayData< T >::size() const
{
return qMin( m_x.size(), m_y.size() );
}
/*!
Return the sample at position i
\param index Index
\return Sample at position i
*/
template< typename T >
QPointF QwtPointArrayData< T >::sample( size_t index ) const
{
return QPointF( m_x[int( index )], m_y[int( index )] );
}
//! \return Array of the x-values
template< typename T >
const QVector< T >& QwtPointArrayData< T >::xData() const
{
return m_x;
}
//! \return Array of the y-values
template< typename T >
const QVector< T >& QwtPointArrayData< T >::yData() const
{
return m_y;
}
/*!
Constructor
\param y Array of y values
\sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
*/
template< typename T >
QwtValuePointData< T >::QwtValuePointData( const QVector< T >& y )
: m_y( y )
{
}
/*!
Constructor
\param y Array of y values
\param size Size of the x and y arrays
\sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
*/
template< typename T >
QwtValuePointData< T >::QwtValuePointData( const T* y, size_t size )
{
m_y.resize( size );
std::memcpy( m_y.data(), y, size * sizeof( T ) );
}
//! \return Size of the data set
template< typename T >
size_t QwtValuePointData< T >::size() const
{
return m_y.size();
}
/*!
Return the sample at position i
\param index Index
\return Sample at position i
*/
template< typename T >
QPointF QwtValuePointData< T >::sample( size_t index ) const
{
return QPointF( index, m_y[int( index )] );
}
//! \return Array of the y-values
template< typename T >
const QVector< T >& QwtValuePointData< T >::yData() const
{
return m_y;
}
/*!
Constructor
\param x Array of x values
\param y Array of y values
\param size Size of the x and y arrays
\warning The programmer must assure that the memory blocks referenced
by the pointers remain valid during the lifetime of the
QwtPlotCPointer object.
\sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
*/
template< typename T >
QwtCPointerData< T >::QwtCPointerData( const T* x, const T* y, size_t size )
: m_x( x )
, m_y( y )
, m_size( size )
{
}
//! \return Size of the data set
template< typename T >
size_t QwtCPointerData< T >::size() const
{
return m_size;
}
/*!
Return the sample at position i
\param index Index
\return Sample at position i
*/
template< typename T >
QPointF QwtCPointerData< T >::sample( size_t index ) const
{
return QPointF( m_x[int( index )], m_y[int( index )] );
}
//! \return Array of the x-values
template< typename T >
const T* QwtCPointerData< T >::xData() const
{
return m_x;
}
//! \return Array of the y-values
template< typename T >
const T* QwtCPointerData< T >::yData() const
{
return m_y;
}
/*!
Constructor
\param y Array of y values
\param size Size of the x and y arrays
\warning The programmer must assure that the memory blocks referenced
by the pointers remain valid during the lifetime of the
QwtCPointerValueData object.
\sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
*/
template< typename T >
QwtCPointerValueData< T >::QwtCPointerValueData( const T* y, size_t size )
: m_y( y )
, m_size( size )
{
}
//! \return Size of the data set
template< typename T >
size_t QwtCPointerValueData< T >::size() const
{
return m_size;
}
/*!
Return the sample at position i
\param index Index
\return Sample at position i
*/
template< typename T >
QPointF QwtCPointerValueData< T >::sample( size_t index ) const
{
return QPointF( index, m_y[ int( index ) ] );
}
//! \return Array of the y-values
template< typename T >
const T* QwtCPointerValueData< T >::yData() const
{
return m_y;
}
#endif
+110
View File
@@ -0,0 +1,110 @@
/******************************************************************************
* 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_POINT_MAPPER_H
#define QWT_POINT_MAPPER_H
#include "qwt_global.h"
class QwtScaleMap;
template< typename T > class QwtSeriesData;
class QPolygonF;
class QPointF;
class QRectF;
class QPolygon;
class QPen;
class QImage;
/*!
\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
similar plot items displaying a QwtSeriesData<QPointF>.
*/
class QWT_EXPORT QwtPointMapper
{
public:
/*!
\brief Flags affecting the transformation process
\sa setFlag(), setFlags()
*/
enum TransformationFlag
{
//! Round points to integer values
RoundPoints = 0x01,
/*!
Try to remove points, that are translated to the
same position.
*/
WeedOutPoints = 0x02,
/*!
An even more aggressive weeding algorithm, that
can be used in toPolygon().
A consecutive chunk of points being mapped to the
same x coordinate is reduced to 4 points:
- first point
- point with the minimum y coordinate
- point with the maximum y coordinate
- last point
In the worst case ( first and last points are never one of the extremes )
the number of points will be 4 times the width.
As the algorithm is fast it can be used inside of
a polyline render cycle.
*/
WeedOutIntermediatePoints = 0x04
};
Q_DECLARE_FLAGS( TransformationFlags, TransformationFlag )
QwtPointMapper();
~QwtPointMapper();
void setFlags( TransformationFlags );
TransformationFlags flags() const;
void setFlag( TransformationFlag, bool on = true );
bool testFlag( TransformationFlag ) const;
void setBoundingRect( const QRectF& );
QRectF boundingRect() const;
QPolygonF toPolygonF( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QwtSeriesData< QPointF >* series, int from, int to ) const;
QPolygon toPolygon( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QwtSeriesData< QPointF >* series, int from, int to ) const;
QPolygon toPoints( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QwtSeriesData< QPointF >* series, int from, int to ) const;
QPolygonF toPointsF( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QwtSeriesData< QPointF >* series, int from, int to ) const;
QImage toImage( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QwtSeriesData< QPointF >* series, int from, int to,
const QPen&, bool antialiased, uint numThreads ) const;
private:
Q_DISABLE_COPY(QwtPointMapper)
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPointMapper::TransformationFlags )
#endif
+188
View File
@@ -0,0 +1,188 @@
/******************************************************************************
* 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
*****************************************************************************/
/*! \file */
#ifndef QWT_POINT_POLAR_H
#define QWT_POINT_POLAR_H
#include "qwt_global.h"
#include "qwt_math.h"
#include <qpoint.h>
#include <qmetatype.h>
#include <qmath.h>
/*!
\brief A point in polar coordinates
In polar coordinates a point is determined by an angle and a distance.
See http://en.wikipedia.org/wiki/Polar_coordinate_system
*/
class QWT_EXPORT QwtPointPolar
{
public:
QwtPointPolar();
QwtPointPolar( double azimuth, double radius );
QwtPointPolar( const QPointF& );
void setPoint( const QPointF& );
QPointF toPoint() const;
bool isValid() const;
bool isNull() const;
double radius() const;
double azimuth() const;
double& rRadius();
double& rAzimuth();
void setRadius( double );
void setAzimuth( double );
bool operator==( const QwtPointPolar& ) const;
bool operator!=( const QwtPointPolar& ) const;
QwtPointPolar normalized() const;
private:
double m_azimuth;
double m_radius;
};
Q_DECLARE_TYPEINFO( QwtPointPolar, Q_MOVABLE_TYPE );
Q_DECLARE_METATYPE( QwtPointPolar )
#ifndef QT_NO_DEBUG_STREAM
QWT_EXPORT QDebug operator<<( QDebug, const QwtPointPolar& );
#endif
/*!
Constructs a null point, with a radius and azimuth set to 0.0.
\sa QPointF::isNull()
*/
inline QwtPointPolar::QwtPointPolar()
: m_azimuth( 0.0 )
, m_radius( 0.0 )
{
}
/*!
Constructs a point with coordinates specified by radius and azimuth.
\param azimuth Azimuth
\param radius Radius
*/
inline QwtPointPolar::QwtPointPolar( double azimuth, double radius )
: m_azimuth( azimuth )
, m_radius( radius )
{
}
//! Returns true if radius() >= 0.0
inline bool QwtPointPolar::isValid() const
{
return m_radius >= 0.0;
}
//! Returns true if radius() >= 0.0
inline bool QwtPointPolar::isNull() const
{
return m_radius == 0.0;
}
//! Returns the radius.
inline double QwtPointPolar::radius() const
{
return m_radius;
}
//! Returns the azimuth.
inline double QwtPointPolar::azimuth() const
{
return m_azimuth;
}
//! Returns the radius.
inline double& QwtPointPolar::rRadius()
{
return m_radius;
}
//! Returns the azimuth.
inline double& QwtPointPolar::rAzimuth()
{
return m_azimuth;
}
//! Sets the radius to radius.
inline void QwtPointPolar::setRadius( double radius )
{
m_radius = radius;
}
//! Sets the azimuth to azimuth.
inline void QwtPointPolar::setAzimuth( double azimuth )
{
m_azimuth = azimuth;
}
inline QPoint qwtPolar2Pos( const QPoint& pole,
double radius, double angle )
{
const double x = pole.x() + radius * std::cos( angle );
const double y = pole.y() - radius * std::sin( angle );
return QPoint( qRound( x ), qRound( y ) );
}
inline QPoint qwtDegree2Pos( const QPoint& pole,
double radius, double angle )
{
return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI );
}
inline QPointF qwtPolar2Pos( const QPointF& pole,
double radius, double angle )
{
const double x = pole.x() + radius * std::cos( angle );
const double y = pole.y() - radius * std::sin( angle );
return QPointF( x, y);
}
inline QPointF qwtDegree2Pos( const QPointF& pole,
double radius, double angle )
{
return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI );
}
inline QPointF qwtFastPolar2Pos( const QPointF& pole,
double radius, double angle )
{
const double x = pole.x() + radius * qFastCos( angle );
const double y = pole.y() - radius * qFastSin( angle );
return QPointF( x, y);
}
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 )
{
return QwtPointPolar( qwtFastAtan2( pos.y(), pos.x() ),
qSqrt( qwtSqr( pos.x() ) + qwtSqr( pos.y() ) ) );
}
#endif
+84
View File
@@ -0,0 +1,84 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_H
#define QWT_POLAR_H
#include "qwt_polar.h"
namespace QwtPolar
{
//! Unit of an angle
enum AngleUnit
{
//! 0.0 -> 2_M_PI
Radians,
//! 0.0 -> 360.0
Degrees,
//! 0.0 - 400.0
Gradians,
//! 0.0 - 1.0
Turns
};
//! An enum, that identifies the type of a coordinate
enum Coordinate
{
//! Azimuth
Azimuth,
//! Radius
Radius
};
/*!
Indices used to identify an axis.
\sa Scale
*/
enum Axis
{
//! Azimuth axis
AxisAzimuth,
//! Left axis
AxisLeft,
//! Right axis
AxisRight,
//! Top axis
AxisTop,
//! Bottom axis
AxisBottom,
//! Number of available axis
AxesCount
};
/*!
Indices used to identify a scale.
\sa Axis
*/
enum Scale
{
//! Azimuth scale
ScaleAzimuth = Azimuth,
//! Radial scale
ScaleRadius = Radius,
//! Number of scales
ScaleCount
};
}
#endif
@@ -0,0 +1,78 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_CANVAS_H
#define QWT_POLAR_CANVAS_H
#include "qwt_global.h"
#include "qwt_point_polar.h"
#include <qframe.h>
class QPainter;
class QwtPolarPlot;
/*!
\brief Canvas of a QwtPolarPlot.
The canvas is the widget, where all polar items are painted to.
\note In opposite to QwtPlot all axes are painted on the canvas.
\sa QwtPolarPlot
*/
class QWT_EXPORT QwtPolarCanvas : public QFrame
{
Q_OBJECT
public:
/*!
\brief Paint attributes
The default setting enables BackingStore
\sa setPaintAttribute(), testPaintAttribute(), backingStore()
*/
enum PaintAttribute
{
/*!
Paint double buffered and reuse the content of the pixmap buffer
for some spontaneous repaints that happen when a plot gets unhidden,
deiconified or changes the focus.
*/
BackingStore = 0x01
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPolarCanvas( QwtPolarPlot* );
virtual ~QwtPolarCanvas();
QwtPolarPlot* plot();
const QwtPolarPlot* plot() const;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
const QPixmap* backingStore() const;
void invalidateBackingStore();
QwtPointPolar invTransform( const QPoint& ) const;
QPoint transform( const QwtPointPolar& ) const;
protected:
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCanvas::PaintAttributes )
#endif
+160
View File
@@ -0,0 +1,160 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_CURVE_H
#define QWT_POLAR_CURVE_H
#include "qwt_global.h"
#include "qwt_polar_item.h"
#include "qwt_point_polar.h"
#include "qwt_series_data.h"
class QPainter;
class QwtSymbol;
class QwtCurveFitter;
/*!
\brief An item, that represents a series of points
A curve is the representation of a series of points in polar coordinates.
The points are connected to the curve using the abstract QwtData interface.
\sa QwtPolarPlot, QwtSymbol, QwtScaleMap
*/
class QWT_EXPORT QwtPolarCurve : public QwtPolarItem
{
public:
/*!
Curve styles.
\sa setStyle(), style()
*/
enum CurveStyle
{
//! Don't draw a curve. Note: This doesn't affect the symbols.
NoCurve,
/*!
Connect the points with straight lines. The lines might
be interpolated depending on the 'Fitted' attribute. Curve
fitting can be configured using setCurveFitter().
*/
Lines,
//! Values > 100 are reserved for user specific curve styles
UserCurve = 100
};
/*!
\brief Attributes how to represent the curve on the legend
If none of the flags is activated QwtPlotCurve tries to find
a color representing the curve and paints a rectangle with it.
In the default setting all attributes are off.
\sa setLegendAttribute(), testLegendAttribute()
*/
enum LegendAttribute
{
/*!
If the curveStyle() is not NoCurve a line is painted with the
curvePen().
*/
LegendShowLine = 0x01,
//! If the curve has a valid symbol it is painted.
LegendShowSymbol = 0x02
};
Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute )
explicit QwtPolarCurve();
explicit QwtPolarCurve( const QwtText& title );
explicit QwtPolarCurve( const QString& title );
virtual ~QwtPolarCurve();
virtual int rtti() const QWT_OVERRIDE;
void setLegendAttribute( LegendAttribute, bool on = true );
bool testLegendAttribute( LegendAttribute ) const;
void setData( QwtSeriesData< QwtPointPolar >* data );
const QwtSeriesData< QwtPointPolar >* data() const;
size_t dataSize() const;
QwtPointPolar sample( int i ) const;
void setPen( const QPen& );
const QPen& pen() const;
void setStyle( CurveStyle style );
CurveStyle style() const;
void setSymbol( QwtSymbol* );
const QwtSymbol* symbol() const;
void setCurveFitter( QwtCurveFitter* );
QwtCurveFitter* curveFitter() const;
virtual void draw( QPainter* p,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, double radius,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual void draw( QPainter* p,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, int from, int to ) const;
virtual QwtInterval boundingInterval( int scaleId ) const QWT_OVERRIDE;
virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE;
protected:
void init();
virtual void drawCurve( QPainter*, int style,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, int from, int to ) const;
virtual void drawSymbols( QPainter*, const QwtSymbol&,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, int from, int to ) const;
void drawLines( QPainter*,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, int from, int to ) const;
private:
QwtSeriesData< QwtPointPolar >* m_series;
class PrivateData;
PrivateData* m_data;
};
//! \return the the curve data
inline const QwtSeriesData< QwtPointPolar >* QwtPolarCurve::data() const
{
return m_series;
}
/*!
\param i index
\return point at position i
*/
inline QwtPointPolar QwtPolarCurve::sample( int i ) const
{
return m_series->sample( i );
}
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCurve::LegendAttributes )
#endif
@@ -0,0 +1,41 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_FITTER_H
#define QWT_POLAR_FITTER_H
#include "qwt_global.h"
#include "qwt_curve_fitter.h"
/*!
\brief A simple curve fitter for polar points
QwtPolarFitter adds equidistant points between 2 curve points,
so that the connection gets rounded according to the nature of
a polar plot.
\sa QwtPolarCurve::setCurveFitter()
*/
class QWT_EXPORT QwtPolarFitter : public QwtCurveFitter
{
public:
QwtPolarFitter( int stepCount = 5 );
virtual ~QwtPolarFitter();
void setStepCount( int size );
int stepCount() const;
virtual QPolygonF fitCurve( const QPolygonF& ) const QWT_OVERRIDE;
virtual QPainterPath fitCurvePath( const QPolygonF& ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
+183
View File
@@ -0,0 +1,183 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_GRID_H
#define QWT_POLAR_GRID_H
#include "qwt_global.h"
#include "qwt_polar.h"
#include "qwt_polar_item.h"
#include "qwt_polar_plot.h"
class QPainter;
class QPen;
class QwtScaleMap;
class QwtScaleDiv;
class QwtRoundScaleDraw;
class QwtScaleDraw;
/*!
\brief An item which draws scales and grid lines on a polar plot.
The QwtPolarGrid class can be used to draw a coordinate grid.
A coordinate grid consists of major and minor gridlines.
The locations of the gridlines are determined by the azimuth and radial
scale divisions.
QwtPolarGrid is also responsible for drawing the axis representing the
scales. It is possible to display 4 radial and one azimuth axis.
Whenever the scale divisions of the plot widget changes the grid
is synchronized by updateScaleDiv().
\sa QwtPolarPlot, QwtPolar::Axis
*/
class QWT_EXPORT QwtPolarGrid : public QwtPolarItem
{
public:
/*!
Mysterious flags trying to avoid conflicts, when painting the
scales and grid lines.
The default setting enables all flags.
\sa setDisplayFlag(), testDisplayFlag()
*/
enum DisplayFlag
{
/*!
Try to avoid situations, where the label of the origin is
painted over another axis.
*/
SmartOriginLabel = 1,
/*!
Often the outermost tick of the radial scale is close to the
canvas border. With HideMaxRadiusLabel enabled it is not painted.
*/
HideMaxRadiusLabel = 2,
/*!
The tick labels of the radial scales might be hard to read, when
they are painted on top of the radial grid lines ( or on top
of a curve/spectrogram ). When ClipAxisBackground the bounding rect
of each label is added to the clip region.
*/
ClipAxisBackground = 4,
/*!
Don't paint the backbone of the radial axes, when they are very close
to a line of the azimuth grid.
*/
SmartScaleDraw = 8,
/*!
All grid lines are clipped against the plot area before being painted.
When the plot is zoomed in this will have an significant impact
on the performance of the painting code.
*/
ClipGridLines = 16
};
Q_DECLARE_FLAGS( DisplayFlags, DisplayFlag )
/*!
\brief Grid attributes
\sa setGridAttributes(), testGridAttributes()
*/
enum GridAttribute
{
/*!
When AutoScaling is enabled, the radial axes will be adjusted
to the interval, that is currently visible on the canvas plot.
*/
AutoScaling = 0x01
};
Q_DECLARE_FLAGS( GridAttributes, GridAttribute )
explicit QwtPolarGrid();
virtual ~QwtPolarGrid();
virtual int rtti() const QWT_OVERRIDE;
void setDisplayFlag( DisplayFlag, bool on = true );
bool testDisplayFlag( DisplayFlag ) const;
void setGridAttribute( GridAttribute, bool on = true );
bool testGridAttribute( GridAttribute ) const;
void showGrid( int scaleId, bool show = true );
bool isGridVisible( int scaleId ) const;
void showMinorGrid( int scaleId, bool show = true );
bool isMinorGridVisible( int scaleId ) const;
void showAxis( int axisId, bool show = true );
bool isAxisVisible( int axisId ) const;
void setPen( const QPen& p );
void setFont( const QFont& );
void setMajorGridPen( const QPen& p );
void setMajorGridPen( int scaleId, const QPen& p );
QPen majorGridPen( int scaleId ) const;
void setMinorGridPen( const QPen& p );
void setMinorGridPen( int scaleId, const QPen& p );
QPen minorGridPen( int scaleId ) const;
void setAxisPen( int axisId, const QPen& p );
QPen axisPen( int axisId ) const;
void setAxisFont( int axisId, const QFont& p );
QFont axisFont( int axisId ) const;
void setScaleDraw( int axisId, QwtScaleDraw* );
const QwtScaleDraw* scaleDraw( int axisId ) const;
QwtScaleDraw* scaleDraw( int axisId );
void setAzimuthScaleDraw( QwtRoundScaleDraw* );
const QwtRoundScaleDraw* azimuthScaleDraw() const;
QwtRoundScaleDraw* azimuthScaleDraw();
virtual void draw( QPainter* p,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, double radius,
const QRectF& rect ) const QWT_OVERRIDE;
virtual void updateScaleDiv( const QwtScaleDiv& azimuthMap,
const QwtScaleDiv& radialMap, const QwtInterval& ) QWT_OVERRIDE;
virtual int marginHint() const QWT_OVERRIDE;
protected:
void drawRays( QPainter*, const QRectF&,
const QPointF& pole, double radius,
const QwtScaleMap& azimuthMap, const QList< double >& ) const;
void drawCircles( QPainter*, const QRectF&,
const QPointF& pole, const QwtScaleMap& radialMap,
const QList< double >& ) const;
void drawAxis( QPainter*, int axisId ) const;
private:
void updateScaleDraws(
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, const double radius ) const;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::DisplayFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::GridAttributes )
#endif
+174
View File
@@ -0,0 +1,174 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_ITEM_H
#define QWT_POLAR_ITEM_H
#include "qwt_global.h"
#include "qwt_text.h"
#include "qwt_legend_data.h"
#include "qwt_graphic.h"
#include "qwt_interval.h"
class QString;
class QRect;
class QPointF;
class QPainter;
class QwtPolarPlot;
class QwtScaleMap;
class QwtScaleDiv;
/*!
\brief Base class for items on a polar plot
A QwtPolarItem is "something that can be painted on the canvas".
It is connected to the QwtPolar framework by a couple of virtual
methods, that are individually implemented in derived item classes.
QwtPolar offers an implementation of the most common types of items,
but deriving from QwtPolarItem makes it easy to implement additional
types of items.
*/
class QWT_EXPORT QwtPolarItem
{
public:
/*!
\brief Runtime type information
RttiValues is used to cast plot items, without
having to enable runtime type information of the compiler.
*/
enum RttiValues
{
//! Unspecific value, that can be used, when it doesn't matter
Rtti_PolarItem = 0,
//! For QwtPolarGrid
Rtti_PolarGrid,
//! For QwtPolarMarker
Rtti_PolarMarker,
//! For QwtPolarCurve
Rtti_PolarCurve,
//! For QwtPolarSpectrogram
Rtti_PolarSpectrogram,
/*!
Values >= Rtti_PolarUserItem are reserved for plot items
not implemented in the QwtPolar library.
*/
Rtti_PolarUserItem = 1000
};
/*!
\brief Plot Item Attributes
\sa setItemAttribute(), testItemAttribute()
*/
enum ItemAttribute
{
//! The item is represented on the legend.
Legend = 0x01,
/*!
The boundingRect() of the item is included in the
autoscaling calculation.
*/
AutoScale = 0x02
};
Q_DECLARE_FLAGS( ItemAttributes, ItemAttribute )
/*!
\brief Render hints
\sa setRenderHint(), testRenderHint()
*/
enum RenderHint
{
//! Enable antialiasing
RenderAntialiased = 0x01
};
Q_DECLARE_FLAGS( RenderHints, RenderHint )
explicit QwtPolarItem( const QwtText& title = QwtText() );
virtual ~QwtPolarItem();
void attach( QwtPolarPlot* plot );
void detach();
QwtPolarPlot* plot() const;
void setTitle( const QString& title );
void setTitle( const QwtText& title );
const QwtText& title() const;
virtual int rtti() const;
void setItemAttribute( ItemAttribute, bool on = true );
bool testItemAttribute( ItemAttribute ) const;
void setRenderHint( RenderHint, bool on = true );
bool testRenderHint( RenderHint ) const;
void setRenderThreadCount( uint numThreads );
uint renderThreadCount() const;
double z() const;
void setZ( double z );
void show();
void hide();
virtual void setVisible( bool );
bool isVisible () const;
virtual void itemChanged();
virtual void legendChanged();
/*!
\brief Draw the item
\param painter Painter
\param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
\param radialMap Maps radius values into painter coordinates.
\param pole Position of the pole in painter coordinates
\param radius Radius of the complete plot area in painter coordinates
\param canvasRect Contents rect of the canvas in painter coordinates
*/
virtual void draw( QPainter* painter,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, double radius,
const QRectF& canvasRect ) const = 0;
virtual QwtInterval boundingInterval( int scaleId ) const;
virtual void updateScaleDiv( const QwtScaleDiv&,
const QwtScaleDiv&, const QwtInterval& );
virtual int marginHint() const;
void setLegendIconSize( const QSize& );
QSize legendIconSize() const;
virtual QList< QwtLegendData > legendData() const;
virtual QwtGraphic legendIcon( int index, const QSizeF& ) const;
private:
Q_DISABLE_COPY( QwtPolarItem )
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::ItemAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
Q_DECLARE_METATYPE( QwtPolarItem* )
#endif
@@ -0,0 +1,51 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_ITEMDICT_H
#define QWT_POLAR_ITEMDICT_H
#include "qwt_global.h"
#include "qwt_polar_item.h"
#include <qlist.h>
typedef QList< QwtPolarItem* >::ConstIterator QwtPolarItemIterator;
typedef QList< QwtPolarItem* > QwtPolarItemList;
/*!
\brief A dictionary for polar plot items
QwtPolarItemDict organizes polar plot items in increasing z-order.
If autoDelete() is enabled, all attached items will be deleted
in the destructor of the dictionary.
\sa QwtPolarItem::attach(), QwtPolarItem::detach(), QwtPolarItem::z()
*/
class QWT_EXPORT QwtPolarItemDict
{
public:
explicit QwtPolarItemDict();
~QwtPolarItemDict();
void setAutoDelete( bool );
bool autoDelete() const;
const QwtPolarItemList& itemList() const;
void detachItems( int rtti = QwtPolarItem::Rtti_PolarItem,
bool autoDelete = true );
protected:
void insertItem( QwtPolarItem* );
void removeItem( QwtPolarItem* );
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,76 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_LAYOUT_H
#define QWT_POLAR_LAYOUT_H
#include "qwt_global.h"
#include "qwt_polar_plot.h"
/*!
\brief Layout class for QwtPolarPlot.
Organizes the geometry for the different QwtPolarPlot components.
It is used by the QwtPolar widget to organize its internal widgets
or by QwtPolarRnderer to render its content to a QPaintDevice like
a QPrinter, QPixmap/QImage or QSvgRenderer.
*/
class QWT_EXPORT QwtPolarLayout
{
public:
//! \brief Options to configure the plot layout engine
enum Option
{
//! Ignore the dimension of the scrollbars.
IgnoreScrollbars = 0x01,
//! Ignore all frames.
IgnoreFrames = 0x02,
//! Ignore the title.
IgnoreTitle = 0x04,
//! Ignore the legend.
IgnoreLegend = 0x08
};
Q_DECLARE_FLAGS( Options, Option )
explicit QwtPolarLayout();
virtual ~QwtPolarLayout();
void setLegendPosition( QwtPolarPlot::LegendPosition pos, double ratio );
void setLegendPosition( QwtPolarPlot::LegendPosition pos );
QwtPolarPlot::LegendPosition legendPosition() const;
void setLegendRatio( double ratio );
double legendRatio() const;
virtual void activate( const QwtPolarPlot*,
const QRectF& rect, Options options = Options() );
virtual void invalidate();
const QRectF& titleRect() const;
const QRectF& legendRect() const;
const QRectF& canvasRect() const;
class LayoutData;
protected:
QRectF layoutLegend( Options options, QRectF& ) const;
private:
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarLayout::Options )
#endif
@@ -0,0 +1,59 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_MAGNIFIER_H
#define QWT_POLAR_MAGNIFIER_H
#include "qwt_global.h"
#include "qwt_magnifier.h"
class QwtPolarPlot;
class QwtPolarCanvas;
/*!
\brief QwtPolarMagnifier provides zooming, by magnifying in steps.
Using QwtPlotMagnifier a plot can be zoomed in/out in steps using
keys, the mouse wheel or moving a mouse button in vertical direction.
Together with QwtPolarPanner it is possible to implement
an individual navigation of the plot canvas.
\sa QwtPolarPanner, QwtPolarPlot, QwtPolarCanvas
*/
class QWT_EXPORT QwtPolarMagnifier : public QwtMagnifier
{
Q_OBJECT
public:
explicit QwtPolarMagnifier( QwtPolarCanvas* );
virtual ~QwtPolarMagnifier();
void setUnzoomKey( int key, int modifiers );
void getUnzoomKey( int& key, int& modifiers ) const;
QwtPolarPlot* plot();
const QwtPolarPlot* plot() const;
QwtPolarCanvas* canvas();
const QwtPolarCanvas* canvas() const;
public Q_SLOTS:
virtual void rescale( double factor ) QWT_OVERRIDE;
void unzoom();
protected:
virtual void widgetKeyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,68 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_MARKER_H
#define QWT_POLAR_MARKER_H
#include "qwt_global.h"
#include "qwt_polar_item.h"
#include "qwt_point_polar.h"
class QRect;
class QwtText;
class QwtSymbol;
/*!
\brief A class for drawing markers
A marker can be a a symbol, a label or a combination of them, which can
be drawn around a center point inside a bounding rectangle.
The setSymbol() member assigns a symbol to the marker.
The symbol is drawn at the specified point.
With setLabel(), a label can be assigned to the marker.
The setLabelAlignment() member specifies where the label is
drawn. All the Align*-constants in Qt::AlignmentFlags (see Qt documentation)
are valid. The alignment refers to the center point of
the marker, which means, for example, that the label would be painted
left above the center point if the alignment was set to AlignLeft|AlignTop.
*/
class QWT_EXPORT QwtPolarMarker : public QwtPolarItem
{
public:
explicit QwtPolarMarker();
virtual ~QwtPolarMarker();
virtual int rtti() const QWT_OVERRIDE;
void setPosition( const QwtPointPolar& );
QwtPointPolar position() const;
void setSymbol( const QwtSymbol* s );
const QwtSymbol* symbol() const;
void setLabel( const QwtText& );
QwtText label() const;
void setLabelAlignment( Qt::Alignment );
Qt::Alignment labelAlignment() const;
virtual void draw( QPainter* painter,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, double radius,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual QwtInterval boundingInterval( int scaleId ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,51 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_PANNER_H
#define QWT_POLAR_PANNER_H
#include "qwt_global.h"
#include "qwt_panner.h"
class QwtPolarPlot;
class QwtPolarCanvas;
/*!
\brief QwtPolarPanner provides panning of a polar plot canvas
QwtPolarPanner is a panner for a QwtPolarCanvas, that
adjusts the visible area after dropping
the canvas on its new position.
Together with QwtPolarMagnifier individual ways
of navigating on a QwtPolarPlot widget can be implemented easily.
\sa QwtPolarMagnifier
*/
class QWT_EXPORT QwtPolarPanner : public QwtPanner
{
Q_OBJECT
public:
explicit QwtPolarPanner( QwtPolarCanvas* );
virtual ~QwtPolarPanner();
QwtPolarPlot* plot();
const QwtPolarPlot* plot() const;
QwtPolarCanvas* canvas();
const QwtPolarCanvas* canvas() const;
public Q_SLOTS:
virtual void movePlot( int dx, int dy );
protected:
virtual void widgetMousePressEvent( QMouseEvent* ) QWT_OVERRIDE;
};
#endif
@@ -0,0 +1,98 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_PICKER_H
#define QWT_POLAR_PICKER_H
#include "qwt_global.h"
#include "qwt_picker.h"
#include <qvector.h>
#include <qpainterpath.h>
class QwtPolarPlot;
class QwtPolarCanvas;
class QwtPointPolar;
/*!
\brief QwtPolarPicker provides selections on a plot canvas
QwtPolarPicker is a QwtPicker tailored for selections on
a polar plot canvas.
*/
class QWT_EXPORT QwtPolarPicker : public QwtPicker
{
Q_OBJECT
public:
explicit QwtPolarPicker( QwtPolarCanvas* );
virtual ~QwtPolarPicker();
explicit QwtPolarPicker(
RubberBand rubberBand, DisplayMode trackerMode,
QwtPolarCanvas* );
QwtPolarPlot* plot();
const QwtPolarPlot* plot() const;
QwtPolarCanvas* canvas();
const QwtPolarCanvas* canvas() const;
virtual QRect pickRect() const;
Q_SIGNALS:
/*!
A signal emitted in case of selectionFlags() & PointSelection.
\param pos Selected point
*/
void selected( const QwtPointPolar& pos );
/*!
A signal emitting the selected points,
at the end of a selection.
\param points Selected points
*/
void selected( const QVector< QwtPointPolar >& points );
/*!
A signal emitted when a point has been appended to the selection
\param pos Position of the appended point.
\sa append(). moved()
*/
void appended( const QwtPointPolar& pos );
/*!
A signal emitted whenever the last appended point of the
selection has been moved.
\param pos Position of the moved last point of the selection.
\sa move(), appended()
*/
void moved( const QwtPointPolar& pos );
protected:
QwtPointPolar invTransform( const QPoint& ) const;
virtual QwtText trackerText( const QPoint& ) const QWT_OVERRIDE;
virtual QwtText trackerTextPolar( const QwtPointPolar& ) const;
virtual void move( const QPoint& ) QWT_OVERRIDE;
virtual void append( const QPoint& ) QWT_OVERRIDE;
virtual bool end( bool ok = true ) QWT_OVERRIDE;
private:
virtual QPainterPath pickArea() const QWT_OVERRIDE;
class PrivateData;
PrivateData* m_data;
};
#endif
+219
View File
@@ -0,0 +1,219 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_PLOT_H
#define QWT_POLAR_PLOT_H
#include "qwt_global.h"
#include "qwt_polar.h"
#include "qwt_polar_itemdict.h"
#include "qwt_interval.h"
#include "qwt_scale_map.h"
#include "qwt_point_polar.h"
#include <qframe.h>
class QwtRoundScaleDraw;
class QwtScaleEngine;
class QwtScaleDiv;
class QwtTextLabel;
class QwtPolarCanvas;
class QwtPolarLayout;
class QwtAbstractLegend;
/*!
\brief A plotting widget, displaying a polar coordinate system
An unlimited number of plot items can be displayed on
its canvas. Plot items might be curves (QwtPolarCurve), markers
(QwtPolarMarker), the grid (QwtPolarGrid), or anything else derived
from QwtPolarItem.
The coordinate system is defined by a radial and a azimuth scale.
The scales at the axes can be explicitly set (QwtScaleDiv), or
are calculated from the plot items, using algorithms (QwtScaleEngine) which
can be configured separately for each axis. Autoscaling is supported
for the radial scale.
In opposite to QwtPlot the scales might be different from the
view, that is displayed on the canvas. The view can be changed by
zooming - f.e. by using QwtPolarPanner or QwtPolarMaginfier.
*/
class QWT_EXPORT QwtPolarPlot : public QFrame, public QwtPolarItemDict
{
Q_OBJECT
Q_PROPERTY( QBrush plotBackground READ plotBackground WRITE setPlotBackground )
Q_PROPERTY( double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin )
public:
/*!
Position of the legend, relative to the canvas.
\sa insertLegend()
*/
enum LegendPosition
{
//! The legend will be left from the canvas.
LeftLegend,
//! The legend will be right from the canvas.
RightLegend,
//! The legend will be below the canvas.
BottomLegend,
//! The legend will be between canvas and title.
TopLegend,
/*!
External means that only the content of the legend
will be handled by QwtPlot, but not its geometry.
This might be interesting if an application wants to
have a legend in an external window ( or on the canvas ).
\note The legend is not painted by QwtPolarRenderer
*/
ExternalLegend
};
explicit QwtPolarPlot( QWidget* parent = NULL );
QwtPolarPlot( const QwtText& title, QWidget* parent = NULL );
virtual ~QwtPolarPlot();
void setTitle( const QString& );
void setTitle( const QwtText& );
QwtText title() const;
QwtTextLabel* titleLabel();
const QwtTextLabel* titleLabel() const;
void setAutoReplot( bool tf = true );
bool autoReplot() const;
void setAutoScale( int scaleId );
bool hasAutoScale( int scaleId ) const;
void setScaleMaxMinor( int scaleId, int maxMinor );
int scaleMaxMinor( int scaleId ) const;
int scaleMaxMajor( int scaleId ) const;
void setScaleMaxMajor( int scaleId, int maxMajor );
QwtScaleEngine* scaleEngine( int scaleId );
const QwtScaleEngine* scaleEngine( int scaleId ) const;
void setScaleEngine( int scaleId, QwtScaleEngine* );
void setScale( int scaleId, double min, double max, double step = 0 );
void setScaleDiv( int scaleId, const QwtScaleDiv& );
const QwtScaleDiv* scaleDiv( int scaleId ) const;
QwtScaleDiv* scaleDiv( int scaleId );
QwtScaleMap scaleMap( int scaleId, double radius ) const;
QwtScaleMap scaleMap( int scaleId ) const;
void updateScale( int scaleId );
double azimuthOrigin() const;
void zoom( const QwtPointPolar&, double factor );
void unzoom();
QwtPointPolar zoomPos() const;
double zoomFactor() const;
// Canvas
QwtPolarCanvas* canvas();
const QwtPolarCanvas* canvas() const;
void setPlotBackground ( const QBrush& c );
const QBrush& plotBackground() const;
virtual void drawCanvas( QPainter*, const QRectF& ) const;
// Legend
void insertLegend( QwtAbstractLegend*,
LegendPosition = RightLegend, double ratio = -1.0 );
QwtAbstractLegend* legend();
const QwtAbstractLegend* legend() const;
void updateLegend();
void updateLegend( const QwtPolarItem* );
// Layout
QwtPolarLayout* plotLayout();
const QwtPolarLayout* plotLayout() const;
QwtInterval visibleInterval() const;
QRectF plotRect() const;
QRectF plotRect( const QRectF& ) const;
int plotMarginHint() const;
virtual QVariant itemToInfo( QwtPolarItem* ) const;
virtual QwtPolarItem* infoToItem( const QVariant& ) const;
Q_SIGNALS:
/*!
A signal indicating, that an item has been attached/detached
\param plotItem Plot item
\param on Attached/Detached
*/
void itemAttached( QwtPolarItem* plotItem, bool on );
/*!
A signal with the attributes how to update
the legend entries for a plot item.
\param itemInfo Info about a plot, build from itemToInfo()
\param data Attributes of the entries ( usually <= 1 ) for the plot item.
\sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
*/
void legendDataChanged( const QVariant& itemInfo,
const QList< QwtLegendData >& data );
/*!
A signal that is emitted, whenever the layout of the plot
has been recalculated.
*/
void layoutChanged();
public Q_SLOTS:
virtual void replot();
void autoRefresh();
void setAzimuthOrigin( double );
protected:
virtual bool event( QEvent* ) QWT_OVERRIDE;
virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
virtual void updateLayout();
virtual void drawItems( QPainter* painter,
const QwtScaleMap& radialMap, const QwtScaleMap& azimuthMap,
const QPointF& pole, double radius,
const QRectF& canvasRect ) const;
private:
friend class QwtPolarItem;
void attachItem( QwtPolarItem*, bool );
void initPlot( const QwtText& );
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,78 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_RENDERER_H
#define QWT_POLAR_RENDERER_H
#include "qwt_global.h"
#include <qobject.h>
#include <qsize.h>
class QwtPolarPlot;
class QRectF;
class QPainter;
class QPaintDevice;
#ifndef QT_NO_PRINTER
class QPrinter;
#endif
#ifndef QWT_NO_SVG
#ifdef QT_SVG_LIB
class QSvgGenerator;
#endif
#endif
/*!
\brief Renderer for exporting a polar plot to a document, a printer
or anything else, that is supported by QPainter/QPaintDevice
*/
class QWT_EXPORT QwtPolarRenderer : public QObject
{
Q_OBJECT
public:
explicit QwtPolarRenderer( QObject* parent = NULL );
virtual ~QwtPolarRenderer();
void renderDocument( QwtPolarPlot*, const QString& format,
const QSizeF& sizeMM, int resolution = 85 );
void renderDocument( QwtPolarPlot*,
const QString& title, const QString& format,
const QSizeF& sizeMM, int resolution = 85 );
#ifndef QWT_NO_SVG
#ifdef QT_SVG_LIB
void renderTo( QwtPolarPlot*, QSvgGenerator& ) const;
#endif
#endif
#ifndef QT_NO_PRINTER
void renderTo( QwtPolarPlot*, QPrinter& ) const;
#endif
void renderTo( QwtPolarPlot*, QPaintDevice& ) const;
virtual void render( QwtPolarPlot*,
QPainter*, const QRectF& rect ) const;
bool exportTo( QwtPolarPlot*, const QString& documentName,
const QSizeF& sizeMM = QSizeF( 200, 200 ), int resolution = 85 );
virtual void renderTitle( QPainter*, const QRectF& ) const;
virtual void renderLegend(
const QwtPolarPlot*, QPainter*, const QRectF& ) const;
private:
class PrivateData;
PrivateData* m_data;
};
#endif
@@ -0,0 +1,91 @@
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 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_POLAR_SPECTROGRAM_H
#define QWT_POLAR_SPECTROGRAM_H
#include "qwt_global.h"
#include "qwt_polar_item.h"
#include <qimage.h>
class QwtRasterData;
class QwtColorMap;
/*!
\brief An item, which displays a spectrogram
A spectrogram displays 3-dimensional data, where the 3rd dimension
( the intensity ) is displayed using colors. The colors are calculated
from the values using a color map.
\sa QwtRasterData, QwtColorMap
*/
class QWT_EXPORT QwtPolarSpectrogram : public QwtPolarItem
{
public:
/*!
Attributes to modify the drawing algorithm.
The default setting disables ApproximatedAtan
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
Use qwtFastAtan2 instead of atan2 for translating
widget into polar coordinates.
*/
ApproximatedAtan = 0x01
};
Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
explicit QwtPolarSpectrogram();
virtual ~QwtPolarSpectrogram();
void setData( QwtRasterData* data );
const QwtRasterData* data() const;
void setColorMap( QwtColorMap* );
const QwtColorMap* colorMap() const;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
virtual int rtti() const QWT_OVERRIDE;
virtual void draw( QPainter* painter,
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, double radius,
const QRectF& canvasRect ) const QWT_OVERRIDE;
virtual QwtInterval boundingInterval( int scaleId ) const QWT_OVERRIDE;
protected:
virtual QImage renderImage(
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, const QRect& rect ) const;
virtual void renderTile(
const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
const QPointF& pole, const QPoint& imagePos,
const QRect& tile, QImage* image ) const;
private:
class TileInfo;
void renderTileInfo( const QwtScaleMap&, const QwtScaleMap&,
const QPointF& pole, TileInfo* ) const;
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarSpectrogram::PaintAttributes )
#endif
+129
View File
@@ -0,0 +1,129 @@
/******************************************************************************
* 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_RASTER_DATA_H
#define QWT_RASTER_DATA_H
#include "qwt_global.h"
#include <qnamespace.h>
class QwtInterval;
class QPolygonF;
class QRectF;
class QSize;
template< typename T > class QList;
template< class Key, class T > class QMap;
/*!
\brief QwtRasterData defines an interface to any type of raster data.
QwtRasterData is an abstract interface, that is used by
QwtPlotRasterItem to find the values at the pixels of its raster.
Gaps inside the bounding rectangle of the data can be indicated by NaN
values ( when WithoutGaps is disabled ).
Often a raster item is used to display values from a matrix. Then the
derived raster data class needs to implement some sort of resampling,
that maps the raster of the matrix into the requested raster of
the raster item ( depending on resolution and scales of the canvas ).
QwtMatrixRasterData implements raster data, that returns values from
a given 2D matrix.
\sa QwtMatrixRasterData
*/
class QWT_EXPORT QwtRasterData
{
public:
//! Contour lines
typedef QMap< double, QPolygonF > ContourLines;
/*!
\brief Raster data attributes
Additional information that is used to improve processing
of the data.
*/
enum Attribute
{
/*!
The bounding rectangle of the data is spanned by
the interval(Qt::XAxis) and interval(Qt::YAxis).
WithoutGaps indicates, that the data has no gaps
( unknown values ) in this area and the result of
value() does not need to be checked for NaN values.
Enabling this flag will have an positive effect on
the performance of rendering a QwtPlotSpectrogram.
The default setting is false.
\note NaN values indicate an undefined value
*/
WithoutGaps = 0x01
};
Q_DECLARE_FLAGS( Attributes, Attribute )
//! Flags to modify the contour algorithm
enum ConrecFlag
{
//! Ignore all vertices on the same level
IgnoreAllVerticesOnLevel = 0x01,
//! Ignore all values, that are out of range
IgnoreOutOfRange = 0x02
};
Q_DECLARE_FLAGS( ConrecFlags, ConrecFlag )
QwtRasterData();
virtual ~QwtRasterData();
void setAttribute( Attribute, bool on = true );
bool testAttribute( Attribute ) const;
/*!
\return Bounding interval for an axis
\sa setInterval
*/
virtual QwtInterval interval( Qt::Axis ) const = 0;
virtual QRectF pixelHint( const QRectF& ) const;
virtual void initRaster( const QRectF&, const QSize& raster );
virtual void discardRaster();
/*!
\return the value at a raster position
\param x X value in plot coordinates
\param y Y value in plot coordinates
*/
virtual double value( double x, double y ) const = 0;
virtual ContourLines contourLines( const QRectF& rect,
const QSize& raster, const QList< double >& levels,
ConrecFlags ) const;
class Contour3DPoint;
class ContourPlane;
private:
Q_DISABLE_COPY(QwtRasterData)
class PrivateData;
PrivateData* m_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtRasterData::ConrecFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtRasterData::Attributes )
#endif
@@ -0,0 +1,69 @@
/******************************************************************************
* 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_ROUND_SCALE_DRAW_H
#define QWT_ROUND_SCALE_DRAW_H
#include "qwt_global.h"
#include "qwt_abstract_scale_draw.h"
#include <qpoint.h>
/*!
\brief A class for drawing round scales
QwtRoundScaleDraw can be used to draw round scales.
The circle segment can be adjusted by setAngleRange().
The geometry of the scale can be specified with
moveCenter() and setRadius().
After a scale division has been specified as a QwtScaleDiv object
using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s),
the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
*/
class QWT_EXPORT QwtRoundScaleDraw : public QwtAbstractScaleDraw
{
public:
QwtRoundScaleDraw();
virtual ~QwtRoundScaleDraw();
void setRadius( double radius );
double radius() const;
void moveCenter( double x, double y );
void moveCenter( const QPointF& );
QPointF center() const;
void setAngleRange( double angle1, double angle2 );
virtual double extent( const QFont& ) const QWT_OVERRIDE;
protected:
virtual void drawTick( QPainter*,
double value, double len ) const QWT_OVERRIDE;
virtual void drawBackbone(
QPainter* ) const QWT_OVERRIDE;
virtual void drawLabel(
QPainter*, double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
//! Move the center of the scale draw, leaving the radius unchanged
inline void QwtRoundScaleDraw::moveCenter( double x, double y )
{
moveCenter( QPointF( x, y ) );
}
#endif
+314
View File
@@ -0,0 +1,314 @@
/******************************************************************************
* 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_SAMPLES_H
#define QWT_SAMPLES_H
#include "qwt_global.h"
#include "qwt_interval.h"
#include <qvector.h>
#include <qrect.h>
//! \brief A sample of the types (x1-x2, y) or (x, y1-y2)
class QWT_EXPORT QwtIntervalSample
{
public:
QwtIntervalSample();
QwtIntervalSample( double, const QwtInterval& );
QwtIntervalSample( double value, double min, double max );
bool operator==( const QwtIntervalSample& ) const;
bool operator!=( const QwtIntervalSample& ) const;
//! Value
double value;
//! Interval
QwtInterval interval;
};
/*!
Constructor
The value is set to 0.0, the interval is invalid
*/
inline QwtIntervalSample::QwtIntervalSample()
: value( 0.0 )
{
}
//! Constructor
inline QwtIntervalSample::QwtIntervalSample( double v, const QwtInterval& intv )
: value( v )
, interval( intv )
{
}
//! Constructor
inline QwtIntervalSample::QwtIntervalSample( double v, double min, double max )
: value( v )
, interval( min, max )
{
}
//! Compare operator
inline bool QwtIntervalSample::operator==( const QwtIntervalSample& other ) const
{
return value == other.value && interval == other.interval;
}
//! Compare operator
inline bool QwtIntervalSample::operator!=( const QwtIntervalSample& other ) const
{
return !( *this == other );
}
//! \brief A sample of the types (x1...xn, y) or (x, y1..yn)
class QWT_EXPORT QwtSetSample
{
public:
QwtSetSample();
explicit QwtSetSample( double, const QVector< double >& = QVector< double >( ) );
bool operator==( const QwtSetSample& other ) const;
bool operator!=( const QwtSetSample& other ) const;
double added() const;
//! value
double value;
//! Vector of values associated to value
QVector< double > set;
};
/*!
Constructor
The value is set to 0.0
*/
inline QwtSetSample::QwtSetSample()
: value( 0.0 )
{
}
/*!
Constructor
\param v Value
\param s Set of values
*/
inline QwtSetSample::QwtSetSample( double v, const QVector< double >& s )
: value( v )
, set( s )
{
}
//! Compare operator
inline bool QwtSetSample::operator==( const QwtSetSample& other ) const
{
return value == other.value && set == other.set;
}
//! Compare operator
inline bool QwtSetSample::operator!=( const QwtSetSample& other ) const
{
return !( *this == other );
}
//! \return All values of the set added
inline double QwtSetSample::added() const
{
double y = 0.0;
for ( int i = 0; i < set.size(); i++ )
y += set[i];
return y;
}
/*!
\brief Open-High-Low-Close sample used in financial charts
In financial charts the movement of a price in a time interval is often
represented by the opening/closing prices and the lowest/highest prices
in this interval.
\sa QwtTradingChartData
*/
class QWT_EXPORT QwtOHLCSample
{
public:
QwtOHLCSample( double time = 0.0,
double open = 0.0, double high = 0.0,
double low = 0.0, double close = 0.0 );
QwtInterval boundingInterval() const;
bool isValid() const;
/*!
Time of the sample, usually a number representing
a specific interval - like a day.
*/
double time;
//! Opening price
double open;
//! Highest price
double high;
//! Lowest price
double low;
//! Closing price
double close;
};
/*!
Constructor
\param t Time value
\param o Open value
\param h High value
\param l Low value
\param c Close value
*/
inline QwtOHLCSample::QwtOHLCSample(
double t, double o, double h, double l, double c )
: time( t )
, open( o )
, high( h )
, low( l )
, close( c )
{
}
/*!
\brief Check if a sample is valid
A sample is valid, when all of the following checks are true:
- low <= high
- low <= open <= high
- low <= close <= high
\return True, when the sample is valid
*/
inline bool QwtOHLCSample::isValid() const
{
return ( low <= high )
&& ( open >= low )
&& ( open <= high )
&& ( close >= low )
&& ( close <= high );
}
/*!
\brief Calculate the bounding interval of the OHLC values
For valid samples the limits of this interval are always low/high.
\return Bounding interval
\sa isValid()
*/
inline QwtInterval QwtOHLCSample::boundingInterval() const
{
double minY = open;
minY = qMin( minY, high );
minY = qMin( minY, low );
minY = qMin( minY, close );
double maxY = open;
maxY = qMax( maxY, high );
maxY = qMax( maxY, low );
maxY = qMax( maxY, close );
return QwtInterval( minY, maxY );
}
/*!
\brief Sample used in vector fields
A vector field sample is a position and a vector - usually
representing some direction and magnitude - attached to this position.
\sa QwtVectorFieldData
*/
class QWT_EXPORT QwtVectorFieldSample
{
public:
QwtVectorFieldSample( double x = 0.0, double y = 0.0,
double vx = 0.0, double vy = 0.0 );
QwtVectorFieldSample( const QPointF& pos,
double vx = 0.0, double vy = 0.0 );
QPointF pos() const;
bool isNull() const;
//! x coordinate of the position
double x;
//! y coordinate of the position
double y;
//! x coordinate of the vector
double vx;
//! y coordinate of the vector
double vy;
};
/*!
\brief Constructor
\param posX x coordinate of the position
\param posY y coordinate of the position
\param vectorX x coordinate of the vector
\param vectorY y coordinate of the vector
*/
inline QwtVectorFieldSample::QwtVectorFieldSample(
double posX, double posY, double vectorX, double vectorY )
: x( posX )
, y( posY )
, vx( vectorX )
, vy( vectorY )
{
}
/*!
\brief Constructor
\param pos Position
\param vectorX x coordinate of the vector
\param vectorY y coordinate of the vector
*/
inline QwtVectorFieldSample::QwtVectorFieldSample(
const QPointF& pos, double vectorX, double vectorY )
: x( pos.x() )
, y( pos.y() )
, vx( vectorX )
, vy( vectorY )
{
}
//! \return x/y coordinates as QPointF
inline QPointF QwtVectorFieldSample::pos() const
{
return QPointF( x, y );
}
//! \return true, if vx and vy are 0
inline bool QwtVectorFieldSample::isNull() const
{
return ( vx == 0.0 ) && ( vy == 0.0 );
}
#endif

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