Moved headers to separate include directories
This commit is contained in:
parent
a94503cb82
commit
4c64008fa5
98 changed files with 0 additions and 0 deletions
71
include/qwt_abstract_legend.h
Normal file
71
include/qwt_abstract_legend.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_ABSTRACT_LEGEND_H
|
||||
#define QWT_ABSTRACT_LEGEND_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_legend_data.h"
|
||||
#include <qframe.h>
|
||||
#include <qlist.h>
|
||||
|
||||
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
|
105
include/qwt_abstract_scale.h
Normal file
105
include/qwt_abstract_scale.h
Normal file
|
@ -0,0 +1,105 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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:
|
||||
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:
|
||||
void rescale( double lowerBound,
|
||||
double upperBound, double stepSize );
|
||||
|
||||
void setAbstractScaleDraw( QwtAbstractScaleDraw * );
|
||||
|
||||
const QwtAbstractScaleDraw *abstractScaleDraw() const;
|
||||
QwtAbstractScaleDraw *abstractScaleDraw();
|
||||
|
||||
virtual void scaleChange();
|
||||
|
||||
private:
|
||||
void updateScaleDraw();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
141
include/qwt_abstract_scale_draw.h
Normal file
141
include/qwt_abstract_scale_draw.h
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_ABSTRACT_SCALE_DRAW_H
|
||||
#define QWT_ABSTRACT_SCALE_DRAW_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_scale_div.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
//! Scale components
|
||||
typedef QFlags<ScaleComponent> ScaleComponents;
|
||||
|
||||
QwtAbstractScaleDraw();
|
||||
virtual ~QwtAbstractScaleDraw();
|
||||
|
||||
void setScaleDiv( const QwtScaleDiv &s );
|
||||
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 margin );
|
||||
double spacing() const;
|
||||
|
||||
void setPenWidth( int width );
|
||||
int penWidth() 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;
|
||||
|
||||
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;
|
||||
|
||||
void invalidateCache();
|
||||
const QwtText &tickLabel( const QFont &, double value ) const;
|
||||
|
||||
private:
|
||||
QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
|
||||
QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents )
|
||||
|
||||
#endif
|
167
include/qwt_abstract_slider.h
Normal file
167
include/qwt_abstract_slider.h
Normal file
|
@ -0,0 +1,167 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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 )
|
||||
|
||||
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 val );
|
||||
|
||||
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 * );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * );
|
||||
virtual void mouseMoveEvent( QMouseEvent * );
|
||||
virtual void keyPressEvent( QKeyEvent * );
|
||||
virtual void wheelEvent( QWheelEvent * );
|
||||
|
||||
/*!
|
||||
\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 numSteps );
|
||||
|
||||
virtual void scaleChange();
|
||||
|
||||
protected:
|
||||
virtual void sliderChange();
|
||||
|
||||
double incrementedValue(
|
||||
double value, int stepCount ) const;
|
||||
|
||||
private:
|
||||
double alignedValue( double ) const;
|
||||
double boundedValue( double ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
93
include/qwt_analog_clock.h
Normal file
93
include/qwt_analog_clock.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_ANALOG_CLOCK_H
|
||||
#define QWT_ANALOG_CLOCK_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_dial.h"
|
||||
#include "qwt_dial_needle.h"
|
||||
#include <qdatetime.h>
|
||||
|
||||
/*!
|
||||
\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;
|
||||
|
||||
virtual void drawHand( QPainter *, Hand, const QPointF &,
|
||||
double radius, double direction, QPalette::ColorGroup ) const;
|
||||
|
||||
private:
|
||||
// use setHand instead
|
||||
void setNeedle( QwtDialNeedle * );
|
||||
|
||||
QwtDialNeedle *d_hand[NHands];
|
||||
};
|
||||
|
||||
#endif
|
52
include/qwt_arrow_button.h
Normal file
52
include/qwt_arrow_button.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent *event );
|
||||
|
||||
virtual void drawButtonLabel( QPainter *p );
|
||||
virtual void drawArrow( QPainter *,
|
||||
const QRect &, Qt::ArrowType ) const;
|
||||
virtual QRect labelRect() const;
|
||||
virtual QSize arrowSize( Qt::ArrowType,
|
||||
const QSize &boundingSize ) const;
|
||||
|
||||
virtual void keyPressEvent( QKeyEvent * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
40
include/qwt_clipper.h
Normal file
40
include/qwt_clipper.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_CLIPPER_H
|
||||
#define QWT_CLIPPER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qpolygon.h>
|
||||
#include <qvector.h>
|
||||
|
||||
class QRect;
|
||||
class QRectF;
|
||||
|
||||
/*!
|
||||
\brief Some clipping algorithms
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtClipper
|
||||
{
|
||||
public:
|
||||
static QPolygon clipPolygon( const QRect &,
|
||||
const QPolygon &, bool closePolygon = false );
|
||||
static QPolygon clipPolygon( const QRectF &,
|
||||
const QPolygon &, bool closePolygon = false );
|
||||
|
||||
static QPolygonF clipPolygonF( const QRectF &,
|
||||
const QPolygonF &, bool closePolygon = false );
|
||||
|
||||
static QVector<QwtInterval> clipCircle(
|
||||
const QRectF &, const QPointF &, double radius );
|
||||
};
|
||||
|
||||
#endif
|
200
include/qwt_color_map.h
Normal file
200
include/qwt_color_map.h
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_COLOR_MAP_H
|
||||
#define QWT_COLOR_MAP_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qcolor.h>
|
||||
#include <qvector.h>
|
||||
|
||||
/*!
|
||||
\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,
|
||||
|
||||
/*!
|
||||
The map is intended to map into 8 bit values, that
|
||||
are indices into the color table.
|
||||
*/
|
||||
Indexed
|
||||
};
|
||||
|
||||
QwtColorMap( Format = QwtColorMap::RGB );
|
||||
virtual ~QwtColorMap();
|
||||
|
||||
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;
|
||||
|
||||
/*!
|
||||
Map a value of a given interval into a color index
|
||||
|
||||
\param interval Range for the values
|
||||
\param value Value
|
||||
\return color index, corresponding to value
|
||||
*/
|
||||
virtual unsigned char colorIndex(
|
||||
const QwtInterval &interval, double value ) const = 0;
|
||||
|
||||
QColor color( const QwtInterval &, double value ) const;
|
||||
virtual QVector<QRgb> colorTable( const QwtInterval & ) const;
|
||||
|
||||
private:
|
||||
Format d_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
|
||||
};
|
||||
|
||||
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;
|
||||
virtual unsigned char colorIndex(
|
||||
const QwtInterval &, double value ) const;
|
||||
|
||||
class ColorStops;
|
||||
|
||||
private:
|
||||
// Disabled copy constructor and operator=
|
||||
QwtLinearColorMap( const QwtLinearColorMap & );
|
||||
QwtLinearColorMap &operator=( const QwtLinearColorMap & );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief QwtAlphaColorMap varies the alpha value of a color
|
||||
*/
|
||||
class QWT_EXPORT QwtAlphaColorMap: public QwtColorMap
|
||||
{
|
||||
public:
|
||||
QwtAlphaColorMap( const QColor & = QColor( Qt::gray ) );
|
||||
virtual ~QwtAlphaColorMap();
|
||||
|
||||
void setColor( const QColor & );
|
||||
QColor color() const;
|
||||
|
||||
virtual QRgb rgb( const QwtInterval &, double value ) const;
|
||||
|
||||
private:
|
||||
QwtAlphaColorMap( const QwtAlphaColorMap & );
|
||||
QwtAlphaColorMap &operator=( const QwtAlphaColorMap & );
|
||||
|
||||
virtual unsigned char colorIndex(
|
||||
const QwtInterval &, double value ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
Map a value into a color
|
||||
|
||||
\param interval Valid interval for values
|
||||
\param value Value
|
||||
|
||||
\return Color corresponding to value
|
||||
|
||||
\warning This method is slow for Indexed color maps. If it is
|
||||
necessary to map many values, its better to get the
|
||||
color table once and find the color using colorIndex().
|
||||
*/
|
||||
inline QColor QwtColorMap::color(
|
||||
const QwtInterval &interval, double value ) const
|
||||
{
|
||||
if ( d_format == RGB )
|
||||
{
|
||||
return QColor::fromRgba( rgb( interval, value ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned int index = colorIndex( interval, value );
|
||||
return colorTable( interval )[index]; // slow
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Intended format of the color map
|
||||
\sa Format
|
||||
*/
|
||||
inline QwtColorMap::Format QwtColorMap::format() const
|
||||
{
|
||||
return d_format;
|
||||
}
|
||||
|
||||
#endif
|
161
include/qwt_column_symbol.h
Normal file
161
include/qwt_column_symbol.h
Normal file
|
@ -0,0 +1,161 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_COLUMN_SYMBOL_H
|
||||
#define QWT_COLUMN_SYMBOL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qpen.h>
|
||||
#include <qsize.h>
|
||||
#include <qrect.h>
|
||||
|
||||
class QPainter;
|
||||
class QPalette;
|
||||
class QRect;
|
||||
class QwtText;
|
||||
|
||||
/*!
|
||||
\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
|
||||
{
|
||||
QRectF r( hInterval.minValue(), vInterval.minValue(),
|
||||
hInterval.maxValue() - hInterval.minValue(),
|
||||
vInterval.maxValue() - vInterval.minValue() );
|
||||
r = r.normalized();
|
||||
|
||||
if ( hInterval.borderFlags() & QwtInterval::ExcludeMinimum )
|
||||
r.adjust( 1, 0, 0, 0 );
|
||||
if ( hInterval.borderFlags() & QwtInterval::ExcludeMaximum )
|
||||
r.adjust( 0, 0, -1, 0 );
|
||||
if ( vInterval.borderFlags() & QwtInterval::ExcludeMinimum )
|
||||
r.adjust( 0, 1, 0, 0 );
|
||||
if ( vInterval.borderFlags() & QwtInterval::ExcludeMaximum )
|
||||
r.adjust( 0, 0, 0, -1 );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
//! \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:
|
||||
QwtColumnSymbol( Style = NoStyle );
|
||||
virtual ~QwtColumnSymbol();
|
||||
|
||||
void setFrameStyle( FrameStyle style );
|
||||
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:
|
||||
class PrivateData;
|
||||
PrivateData* d_data;
|
||||
};
|
||||
|
||||
#endif
|
83
include/qwt_compass.h
Normal file
83
include/qwt_compass.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_COMPASS_H
|
||||
#define QWT_COMPASS_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_dial.h"
|
||||
#include "qwt_round_scale_draw.h"
|
||||
#include <qstring.h>
|
||||
#include <qmap.h>
|
||||
|
||||
class QwtCompassRose;
|
||||
|
||||
/*!
|
||||
\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 );
|
||||
|
||||
void setLabelMap( const QMap<double, QString> &map );
|
||||
QMap<double, QString> labelMap() const;
|
||||
|
||||
virtual QwtText label( double value ) const;
|
||||
|
||||
private:
|
||||
QMap<double, QString> d_labelMap;
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 ¢er,
|
||||
double radius, double north, QPalette::ColorGroup ) const;
|
||||
|
||||
virtual void drawScaleContents( QPainter *,
|
||||
const QPointF ¢er, double radius ) const;
|
||||
|
||||
virtual void keyPressEvent( QKeyEvent * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
89
include/qwt_compass_rose.h
Normal file
89
include/qwt_compass_rose.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_COMPASS_ROSE_H
|
||||
#define QWT_COMPASS_ROSE_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpalette.h>
|
||||
|
||||
class QPainter;
|
||||
|
||||
/*!
|
||||
\brief Abstract base class for a compass rose
|
||||
*/
|
||||
class QWT_EXPORT QwtCompassRose
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~QwtCompassRose() {};
|
||||
|
||||
//! Assign a palette
|
||||
virtual void setPalette( const QPalette &p )
|
||||
{
|
||||
d_palette = p;
|
||||
}
|
||||
|
||||
//! \return Current palette
|
||||
const QPalette &palette() const
|
||||
{
|
||||
return d_palette;
|
||||
}
|
||||
|
||||
/*!
|
||||
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 ¢er, double radius, double north,
|
||||
QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0;
|
||||
|
||||
private:
|
||||
QPalette d_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 w );
|
||||
double width() const;
|
||||
|
||||
void setNumThorns( int count );
|
||||
int numThorns() const;
|
||||
|
||||
void setNumThornLevels( int count );
|
||||
int numThornLevels() const;
|
||||
|
||||
void setShrinkFactor( double factor );
|
||||
double shrinkFactor() const;
|
||||
|
||||
virtual void draw( QPainter *, const QPointF ¢er, double radius,
|
||||
double north, QPalette::ColorGroup = QPalette::Active ) const;
|
||||
|
||||
static void drawRose( QPainter *, const QPalette &,
|
||||
const QPointF ¢er, double radius, double origin, double width,
|
||||
int numThorns, int numThornLevels, double shrinkFactor );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
161
include/qwt_counter.h
Normal file
161
include/qwt_counter.h
Normal file
|
@ -0,0 +1,161 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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 )
|
||||
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 n );
|
||||
int numButtons() const;
|
||||
|
||||
void setIncSteps( QwtCounter::Button btn, int nSteps );
|
||||
int incSteps( QwtCounter::Button btn ) const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
double singleStep() const;
|
||||
void setSingleStep( double s );
|
||||
|
||||
void setRange( double min, double max );
|
||||
|
||||
double minimum() const;
|
||||
void setMinimum( double min );
|
||||
|
||||
double maximum() const;
|
||||
void setMaximum( double max );
|
||||
|
||||
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 * );
|
||||
virtual void wheelEvent( QWheelEvent * );
|
||||
virtual void keyPressEvent( QKeyEvent * );
|
||||
|
||||
private Q_SLOTS:
|
||||
void btnReleased();
|
||||
void btnClicked();
|
||||
void textChanged();
|
||||
|
||||
private:
|
||||
void incrementValue( int numSteps );
|
||||
void initCounter();
|
||||
void updateButtons();
|
||||
void showNumber( double );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
139
include/qwt_curve_fitter.h
Normal file
139
include/qwt_curve_fitter.h
Normal file
|
@ -0,0 +1,139 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_CURVE_FITTER_H
|
||||
#define QWT_CURVE_FITTER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpolygon.h>
|
||||
#include <qrect.h>
|
||||
|
||||
class QwtSpline;
|
||||
|
||||
/*!
|
||||
\brief Abstract base class for a curve fitter
|
||||
*/
|
||||
class QWT_EXPORT QwtCurveFitter
|
||||
{
|
||||
public:
|
||||
virtual ~QwtCurveFitter();
|
||||
|
||||
/*!
|
||||
Find a curve which has the best fit to a series of data points
|
||||
|
||||
\param polygon Series of data points
|
||||
\return Curve points
|
||||
*/
|
||||
virtual QPolygonF fitCurve( const QPolygonF &polygon ) const = 0;
|
||||
|
||||
protected:
|
||||
QwtCurveFitter();
|
||||
|
||||
private:
|
||||
QwtCurveFitter( const QwtCurveFitter & );
|
||||
QwtCurveFitter &operator=( const QwtCurveFitter & );
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief A curve fitter using cubic splines
|
||||
*/
|
||||
class QWT_EXPORT QwtSplineCurveFitter: public QwtCurveFitter
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Spline type
|
||||
The default setting is Auto
|
||||
\sa setFitMode(), FitMode()
|
||||
*/
|
||||
enum FitMode
|
||||
{
|
||||
/*!
|
||||
Use the default spline algorithm for polygons with
|
||||
increasing x values ( p[i-1] < p[i] ), otherwise use
|
||||
a parametric spline algorithm.
|
||||
*/
|
||||
Auto,
|
||||
|
||||
//! Use a default spline algorithm
|
||||
Spline,
|
||||
|
||||
//! Use a parametric spline algorithm
|
||||
ParametricSpline
|
||||
};
|
||||
|
||||
QwtSplineCurveFitter();
|
||||
virtual ~QwtSplineCurveFitter();
|
||||
|
||||
void setFitMode( FitMode );
|
||||
FitMode fitMode() const;
|
||||
|
||||
void setSpline( const QwtSpline& );
|
||||
const QwtSpline &spline() const;
|
||||
QwtSpline &spline();
|
||||
|
||||
void setSplineSize( int size );
|
||||
int splineSize() const;
|
||||
|
||||
virtual QPolygonF fitCurve( const QPolygonF & ) const;
|
||||
|
||||
private:
|
||||
QPolygonF fitSpline( const QPolygonF & ) const;
|
||||
QPolygonF fitParametric( const QPolygonF & ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief A curve fitter implementing Douglas and Peucker algorithm
|
||||
|
||||
The purpose of the Douglas and Peucker algorithm is that given a 'curve'
|
||||
composed of line segments to find a curve not too dissimilar but that
|
||||
has fewer points. The algorithm defines 'too dissimilar' based on the
|
||||
maximum distance (tolerance) between the original curve and the
|
||||
smoothed curve.
|
||||
|
||||
The runtime of the algorithm increases non linear ( worst case O( n*n ) )
|
||||
and might be very slow for huge polygons. To avoid performance issues
|
||||
it might be useful to split the polygon ( setChunkSize() ) and to run the algorithm
|
||||
for these smaller parts. The disadvantage of having no interpolation
|
||||
at the borders is for most use cases irrelevant.
|
||||
|
||||
The smoothed curve consists of a subset of the points that defined the
|
||||
original curve.
|
||||
|
||||
In opposite to QwtSplineCurveFitter the Douglas and Peucker algorithm reduces
|
||||
the number of points. By adjusting the tolerance parameter according to the
|
||||
axis scales QwtSplineCurveFitter can be used to implement different
|
||||
level of details to speed up painting of curves of many points.
|
||||
*/
|
||||
class QWT_EXPORT QwtWeedingCurveFitter: public QwtCurveFitter
|
||||
{
|
||||
public:
|
||||
QwtWeedingCurveFitter( double tolerance = 1.0 );
|
||||
virtual ~QwtWeedingCurveFitter();
|
||||
|
||||
void setTolerance( double );
|
||||
double tolerance() const;
|
||||
|
||||
void setChunkSize( uint );
|
||||
uint chunkSize() const;
|
||||
|
||||
virtual QPolygonF fitCurve( const QPolygonF & ) const;
|
||||
|
||||
private:
|
||||
virtual QPolygonF simplify( const QPolygonF & ) const;
|
||||
|
||||
class Line;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
128
include/qwt_date.h
Normal file
128
include/qwt_date.h
Normal file
|
@ -0,0 +1,128 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _QWT_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
|
86
include/qwt_date_scale_draw.h
Normal file
86
include/qwt_date_scale_draw.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _QWT_DATE_SCALE_DRAW_H_
|
||||
#define _QWT_DATE_SCALE_DRAW_H_ 1
|
||||
|
||||
#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:
|
||||
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;
|
||||
|
||||
QDateTime toDateTime( double ) const;
|
||||
|
||||
protected:
|
||||
virtual QwtDate::IntervalType
|
||||
intervalType( const QwtScaleDiv & ) const;
|
||||
|
||||
virtual QString dateFormatOfDate( const QDateTime &,
|
||||
QwtDate::IntervalType ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
86
include/qwt_date_scale_engine.h
Normal file
86
include/qwt_date_scale_engine.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _QWT_DATE_SCALE_ENGINE_H_
|
||||
#define _QWT_DATE_SCALE_ENGINE_H_ 1
|
||||
|
||||
#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:
|
||||
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;
|
||||
|
||||
virtual QwtScaleDiv divideScale(
|
||||
double x1, double x2,
|
||||
int maxMajorSteps, int maxMinorSteps,
|
||||
double stepSize = 0.0 ) const;
|
||||
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
#endif
|
168
include/qwt_dial.h
Normal file
168
include/qwt_dial.h
Normal file
|
@ -0,0 +1,168 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_DIAL_H
|
||||
#define QWT_DIAL_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_abstract_slider.h"
|
||||
#include "qwt_abstract_scale_draw.h"
|
||||
#include <qframe.h>
|
||||
#include <qpalette.h>
|
||||
|
||||
class QwtDialNeedle;
|
||||
class QwtRoundScaleDraw;
|
||||
|
||||
/*!
|
||||
\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 min, double max );
|
||||
|
||||
void setMinScaleArc( double min );
|
||||
double minScaleArc() const;
|
||||
|
||||
void setMaxScaleArc( double min );
|
||||
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;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
void setScaleDraw( QwtRoundScaleDraw * );
|
||||
|
||||
QwtRoundScaleDraw *scaleDraw();
|
||||
const QwtRoundScaleDraw *scaleDraw() const;
|
||||
|
||||
protected:
|
||||
virtual void wheelEvent( QWheelEvent * );
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void changeEvent( QEvent * );
|
||||
|
||||
virtual void drawFrame( QPainter *p );
|
||||
virtual void drawContents( QPainter * ) const;
|
||||
virtual void drawFocusIndicator( QPainter * ) const;
|
||||
|
||||
void invalidateCache();
|
||||
|
||||
virtual void drawScale( QPainter *,
|
||||
const QPointF ¢er, double radius ) const;
|
||||
|
||||
virtual void drawScaleContents( QPainter *painter,
|
||||
const QPointF ¢er, double radius ) const;
|
||||
|
||||
virtual void drawNeedle( QPainter *, const QPointF &,
|
||||
double radius, double direction, QPalette::ColorGroup ) const;
|
||||
|
||||
virtual double scrolledTo( const QPoint & ) const;
|
||||
virtual bool isScrollPosition( const QPoint & ) const;
|
||||
|
||||
virtual void sliderChange();
|
||||
virtual void scaleChange();
|
||||
|
||||
private:
|
||||
void setAngleRange( double angle, double span );
|
||||
void drawNeedle( QPainter * ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
187
include/qwt_dial_needle.h
Normal file
187
include/qwt_dial_needle.h
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_DIAL_NEEDLE_H
|
||||
#define QWT_DIAL_NEEDLE_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpalette.h>
|
||||
|
||||
class QPainter;
|
||||
class QPoint;
|
||||
|
||||
/*!
|
||||
\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 *painter, const QPointF ¢er,
|
||||
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:
|
||||
QPalette d_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;
|
||||
|
||||
private:
|
||||
Style d_style;
|
||||
bool d_hasKnob;
|
||||
double d_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;
|
||||
|
||||
private:
|
||||
Style d_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;
|
||||
|
||||
private:
|
||||
Style d_style;
|
||||
};
|
||||
|
||||
#endif
|
83
include/qwt_dyngrid_layout.h
Normal file
83
include/qwt_dyngrid_layout.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_DYNGRID_LAYOUT_H
|
||||
#define QWT_DYNGRID_LAYOUT_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qlayout.h>
|
||||
#include <qsize.h>
|
||||
#include <qlist.h>
|
||||
|
||||
/*!
|
||||
\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 space = -1 );
|
||||
explicit QwtDynGridLayout( int space = -1 );
|
||||
|
||||
virtual ~QwtDynGridLayout();
|
||||
|
||||
virtual void invalidate();
|
||||
|
||||
void setMaxColumns( uint maxCols );
|
||||
uint maxColumns() const;
|
||||
|
||||
uint numRows () const;
|
||||
uint numColumns () const;
|
||||
|
||||
virtual void addItem( QLayoutItem * );
|
||||
|
||||
virtual QLayoutItem *itemAt( int index ) const;
|
||||
virtual QLayoutItem *takeAt( int index );
|
||||
virtual int count() const;
|
||||
|
||||
void setExpandingDirections( Qt::Orientations );
|
||||
virtual Qt::Orientations expandingDirections() const;
|
||||
QList<QRect> layoutItems( const QRect &, uint numCols ) const;
|
||||
|
||||
virtual int maxItemWidth() const;
|
||||
|
||||
virtual void setGeometry( const QRect &rect );
|
||||
|
||||
virtual bool hasHeightForWidth() const;
|
||||
virtual int heightForWidth( int ) const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
virtual bool isEmpty() const;
|
||||
uint itemCount() const;
|
||||
|
||||
virtual uint columnsForWidth( int width ) const;
|
||||
|
||||
protected:
|
||||
|
||||
void layoutGrid( uint numCols,
|
||||
QVector<int>& rowHeight, QVector<int>& colWidth ) const;
|
||||
void stretchGrid( const QRect &rect, uint numCols,
|
||||
QVector<int>& rowHeight, QVector<int>& colWidth ) const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
int maxRowWidth( int numCols ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
240
include/qwt_event_pattern.h
Normal file
240
include/qwt_event_pattern.h
Normal file
|
@ -0,0 +1,240 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_EVENT_PATTERN
|
||||
#define QWT_EVENT_PATTERN 1
|
||||
|
||||
#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 keyCode,
|
||||
Qt::KeyboardModifiers modifierCodes = 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> d_mousePattern;
|
||||
QVector<KeyPattern> d_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
|
41
include/qwt_global.h
Normal file
41
include/qwt_global.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_GLOBAL_H
|
||||
#define QWT_GLOBAL_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
// QWT_VERSION is (major << 16) + (minor << 8) + patch.
|
||||
|
||||
#define QWT_VERSION 0x060103
|
||||
#define QWT_VERSION_STR "6.1.3"
|
||||
|
||||
#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
|
||||
|
||||
#endif
|
176
include/qwt_graphic.h
Normal file
176
include/qwt_graphic.h
Normal file
|
@ -0,0 +1,176 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_GRAPHIC_H
|
||||
#define QWT_GRAPHIC_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_null_paintdevice.h"
|
||||
#include <qmetatype.h>
|
||||
#include <qimage.h>
|
||||
#include <qpixmap.h>
|
||||
|
||||
class QwtPainterCommand;
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Render hints
|
||||
|
||||
The default setting is to disable all hints
|
||||
*/
|
||||
typedef QFlags<RenderHint> RenderHints;
|
||||
|
||||
QwtGraphic();
|
||||
QwtGraphic( const QwtGraphic & );
|
||||
|
||||
virtual ~QwtGraphic();
|
||||
|
||||
QwtGraphic& operator=( const QwtGraphic & );
|
||||
|
||||
void reset();
|
||||
|
||||
bool isNull() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
void render( QPainter * ) const;
|
||||
|
||||
void render( QPainter *, const QSizeF &,
|
||||
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
|
||||
|
||||
void render( QPainter *, const QRectF &,
|
||||
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
|
||||
|
||||
void render( QPainter *, const QPointF &,
|
||||
Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
|
||||
|
||||
QPixmap toPixmap() const;
|
||||
QPixmap toPixmap( const QSize &,
|
||||
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
|
||||
|
||||
QImage toImage() const;
|
||||
QImage toImage( const QSize &,
|
||||
Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
|
||||
|
||||
QRectF scaledBoundingRect( double sx, double sy ) const;
|
||||
|
||||
QRectF boundingRect() const;
|
||||
QRectF controlPointRect() const;
|
||||
|
||||
const QVector< QwtPainterCommand > &commands() const;
|
||||
void setCommands( QVector< QwtPainterCommand > & );
|
||||
|
||||
void setDefaultSize( const QSizeF & );
|
||||
QSizeF defaultSize() const;
|
||||
|
||||
void setRenderHint( RenderHint, bool on = true );
|
||||
bool testRenderHint( RenderHint ) const;
|
||||
|
||||
protected:
|
||||
virtual QSize sizeMetrics() const;
|
||||
|
||||
virtual void drawPath( const QPainterPath & );
|
||||
|
||||
virtual void drawPixmap( const QRectF &,
|
||||
const QPixmap &, const QRectF & );
|
||||
|
||||
virtual void drawImage( const QRectF &,
|
||||
const QImage &, const QRectF &, Qt::ImageConversionFlags );
|
||||
|
||||
virtual void updateState( const QPaintEngineState &state );
|
||||
|
||||
private:
|
||||
void updateBoundingRect( const QRectF & );
|
||||
void updateControlPointRect( const QRectF & );
|
||||
|
||||
class PathInfo;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
|
||||
Q_DECLARE_METATYPE( QwtGraphic )
|
||||
|
||||
#endif
|
320
include/qwt_interval.h
Normal file
320
include/qwt_interval.h
Normal file
|
@ -0,0 +1,320 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_INTERVAL_H
|
||||
#define QWT_INTERVAL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qmetatype.h>
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
#include <qdebug.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\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
|
||||
typedef QFlags<BorderFlag> BorderFlags;
|
||||
|
||||
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 minValue, double maxValue ) 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;
|
||||
|
||||
void setMinValue( double );
|
||||
void setMaxValue( double );
|
||||
|
||||
bool contains( double value ) 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 d_minValue;
|
||||
double d_maxValue;
|
||||
BorderFlags d_borderFlags;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(QwtInterval, Q_MOVABLE_TYPE);
|
||||
|
||||
/*!
|
||||
\brief Default Constructor
|
||||
|
||||
Creates an invalid interval [0.0, -1.0]
|
||||
\sa setInterval(), isValid()
|
||||
*/
|
||||
inline QwtInterval::QwtInterval():
|
||||
d_minValue( 0.0 ),
|
||||
d_maxValue( -1.0 ),
|
||||
d_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 ):
|
||||
d_minValue( minValue ),
|
||||
d_maxValue( maxValue ),
|
||||
d_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 )
|
||||
{
|
||||
d_minValue = minValue;
|
||||
d_maxValue = maxValue;
|
||||
d_borderFlags = borderFlags;
|
||||
}
|
||||
|
||||
/*!
|
||||
Change the border flags
|
||||
|
||||
\param borderFlags Or'd BorderMode flags
|
||||
\sa borderFlags()
|
||||
*/
|
||||
inline void QwtInterval::setBorderFlags( BorderFlags borderFlags )
|
||||
{
|
||||
d_borderFlags = borderFlags;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Border flags
|
||||
\sa setBorderFlags()
|
||||
*/
|
||||
inline QwtInterval::BorderFlags QwtInterval::borderFlags() const
|
||||
{
|
||||
return d_borderFlags;
|
||||
}
|
||||
|
||||
/*!
|
||||
Assign the lower limit of the interval
|
||||
|
||||
\param minValue Minimum value
|
||||
*/
|
||||
inline void QwtInterval::setMinValue( double minValue )
|
||||
{
|
||||
d_minValue = minValue;
|
||||
}
|
||||
|
||||
/*!
|
||||
Assign the upper limit of the interval
|
||||
|
||||
\param maxValue Maximum value
|
||||
*/
|
||||
inline void QwtInterval::setMaxValue( double maxValue )
|
||||
{
|
||||
d_maxValue = maxValue;
|
||||
}
|
||||
|
||||
//! \return Lower limit of the interval
|
||||
inline double QwtInterval::minValue() const
|
||||
{
|
||||
return d_minValue;
|
||||
}
|
||||
|
||||
//! \return Upper limit of the interval
|
||||
inline double QwtInterval::maxValue() const
|
||||
{
|
||||
return d_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 ( ( d_borderFlags & ExcludeBorders ) == 0 )
|
||||
return d_minValue <= d_maxValue;
|
||||
else
|
||||
return d_minValue < d_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() ? ( d_maxValue - d_minValue ) : 0.0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\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 ( d_minValue == other.d_minValue ) &&
|
||||
( d_maxValue == other.d_maxValue ) &&
|
||||
( d_borderFlags == other.d_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() && d_minValue >= d_maxValue;
|
||||
}
|
||||
|
||||
/*!
|
||||
Invalidate the interval
|
||||
|
||||
The limits are set to interval [0.0, -1.0]
|
||||
\sa isValid()
|
||||
*/
|
||||
inline void QwtInterval::invalidate()
|
||||
{
|
||||
d_minValue = 0.0;
|
||||
d_maxValue = -1.0;
|
||||
}
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags )
|
||||
Q_DECLARE_METATYPE( QwtInterval )
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QWT_EXPORT QDebug operator<<( QDebug, const QwtInterval & );
|
||||
#endif
|
||||
|
||||
#endif
|
87
include/qwt_interval_symbol.h
Normal file
87
include/qwt_interval_symbol.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_INTERVAL_SYMBOL_H
|
||||
#define QWT_INTERVAL_SYMBOL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpen.h>
|
||||
#include <qsize.h>
|
||||
|
||||
class QPainter;
|
||||
class QRect;
|
||||
class QPointF;
|
||||
|
||||
/*!
|
||||
\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:
|
||||
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& b );
|
||||
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* d_data;
|
||||
};
|
||||
|
||||
#endif
|
178
include/qwt_knob.h
Normal file
178
include/qwt_knob.h
Normal file
|
@ -0,0 +1,178 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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 bw );
|
||||
int borderWidth() const;
|
||||
|
||||
void setMarkerStyle( MarkerStyle );
|
||||
MarkerStyle markerStyle() const;
|
||||
|
||||
void setMarkerSize( int );
|
||||
int markerSize() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
void setScaleDraw( QwtRoundScaleDraw * );
|
||||
|
||||
const QwtRoundScaleDraw *scaleDraw() const;
|
||||
QwtRoundScaleDraw *scaleDraw();
|
||||
|
||||
QRect knobRect() const;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void changeEvent( QEvent * );
|
||||
|
||||
virtual void drawKnob( QPainter *, const QRectF & ) const;
|
||||
|
||||
virtual void drawFocusIndicator( QPainter * ) const;
|
||||
|
||||
virtual void drawMarker( QPainter *,
|
||||
const QRectF &, double arc ) const;
|
||||
|
||||
virtual double scrolledTo( const QPoint & ) const;
|
||||
virtual bool isScrollPosition( const QPoint & ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
117
include/qwt_legend.h
Normal file
117
include/qwt_legend.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_LEGEND_H
|
||||
#define QWT_LEGEND_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_abstract_legend.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 * );
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual int heightForWidth( int w ) const;
|
||||
|
||||
QScrollBar *horizontalScrollBar() const;
|
||||
QScrollBar *verticalScrollBar() const;
|
||||
|
||||
virtual void renderLegend( QPainter *,
|
||||
const QRectF &, bool fillBackground ) const;
|
||||
|
||||
virtual void renderItem( QPainter *,
|
||||
const QWidget *, const QRectF &, bool fillBackground ) const;
|
||||
|
||||
virtual bool isEmpty() const;
|
||||
virtual int scrollExtent( Qt::Orientation ) const;
|
||||
|
||||
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> & );
|
||||
|
||||
protected Q_SLOTS:
|
||||
void itemClicked();
|
||||
void itemChecked( bool );
|
||||
|
||||
protected:
|
||||
virtual QWidget *createWidget( const QwtLegendData & ) const;
|
||||
virtual void updateWidget( QWidget *widget, const QwtLegendData &data );
|
||||
|
||||
private:
|
||||
void updateTabOrder();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
87
include/qwt_legend_data.h
Normal file
87
include/qwt_legend_data.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_LEGEND_DATA_H
|
||||
#define QWT_LEGEND_DATA_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_graphic.h"
|
||||
#include <qvariant.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qmap.h>
|
||||
|
||||
/*!
|
||||
\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 interprete 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> d_map;
|
||||
};
|
||||
|
||||
#endif
|
80
include/qwt_legend_label.h
Normal file
80
include/qwt_legend_label.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_LEGEND_LABEL_H
|
||||
#define QWT_LEGEND_LABEL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_legend_data.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_text_label.h"
|
||||
#include <qpixmap.h>
|
||||
|
||||
class QwtLegendData;
|
||||
|
||||
/*!
|
||||
\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 & );
|
||||
|
||||
void setIcon( const QPixmap & );
|
||||
QPixmap icon() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
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 * );
|
||||
virtual void mousePressEvent( QMouseEvent * );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * );
|
||||
virtual void keyPressEvent( QKeyEvent * );
|
||||
virtual void keyReleaseEvent( QKeyEvent * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
86
include/qwt_magnifier.h
Normal file
86
include/qwt_magnifier.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_MAGNIFIER_H
|
||||
#define QWT_MAGNIFIER_H 1
|
||||
|
||||
#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 * );
|
||||
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
#endif
|
149
include/qwt_math.h
Normal file
149
include/qwt_math.h
Normal file
|
@ -0,0 +1,149 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_MATH_H
|
||||
#define QWT_MATH_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#define _USE_MATH_DEFINES 1
|
||||
#endif
|
||||
|
||||
#include <qmath.h>
|
||||
#include "qwt_global.h"
|
||||
|
||||
#ifndef M_PI_2
|
||||
// For Qt <= 4.8.4 M_PI_2 is not known by MinGW-w64
|
||||
// when compiling with -std=c++11
|
||||
#define M_PI_2 (1.57079632679489661923)
|
||||
#endif
|
||||
|
||||
#ifndef LOG_MIN
|
||||
//! Minimum value for logarithmic scales
|
||||
#define LOG_MIN 1.0e-100
|
||||
#endif
|
||||
|
||||
#ifndef LOG_MAX
|
||||
//! Maximum value for logarithmic scales
|
||||
#define LOG_MAX 1.0e100
|
||||
#endif
|
||||
|
||||
QWT_EXPORT double qwtGetMin( const double *array, int size );
|
||||
QWT_EXPORT double qwtGetMax( const double *array, int size );
|
||||
|
||||
QWT_EXPORT double qwtNormalizeRadians( double radians );
|
||||
QWT_EXPORT double qwtNormalizeDegrees( double degrees );
|
||||
|
||||
/*!
|
||||
\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;
|
||||
}
|
||||
|
||||
|
||||
inline bool qwtFuzzyGreaterOrEqual( double d1, double d2 )
|
||||
{
|
||||
return ( d1 >= d2 ) || qFuzzyCompare( d1, d2 );
|
||||
}
|
||||
|
||||
inline bool qwtFuzzyLessOrEqual( double d1, double d2 )
|
||||
{
|
||||
return ( d1 <= d2 ) || qFuzzyCompare( d1, d2 );
|
||||
}
|
||||
|
||||
//! 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;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
}
|
||||
|
||||
#endif
|
74
include/qwt_matrix_raster_data.h
Normal file
74
include/qwt_matrix_raster_data.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_MATRIX_RASTER_DATA_H
|
||||
#define QWT_MATRIX_RASTER_DATA_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_raster_data.h"
|
||||
#include <qvector.h>
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
QwtMatrixRasterData();
|
||||
virtual ~QwtMatrixRasterData();
|
||||
|
||||
void setResampleMode(ResampleMode mode);
|
||||
ResampleMode resampleMode() const;
|
||||
|
||||
virtual void setInterval( Qt::Axis, const QwtInterval & );
|
||||
|
||||
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;
|
||||
|
||||
virtual double value( double x, double y ) const;
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
126
include/qwt_null_paintdevice.h
Normal file
126
include/qwt_null_paintdevice.h
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_NULL_PAINT_DEVICE_H
|
||||
#define QWT_NULL_PAINT_DEVICE_H 1
|
||||
|
||||
#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;
|
||||
|
||||
virtual int metric( PaintDeviceMetric metric ) const;
|
||||
|
||||
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 &s);
|
||||
|
||||
virtual void drawImage(const QRectF &,
|
||||
const QImage &, const QRectF &, Qt::ImageConversionFlags );
|
||||
|
||||
virtual void updateState( const QPaintEngineState &state );
|
||||
|
||||
protected:
|
||||
//! \return Size needed to implement metric()
|
||||
virtual QSize sizeMetrics() const = 0;
|
||||
|
||||
private:
|
||||
class PaintEngine;
|
||||
PaintEngine *d_engine;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
188
include/qwt_painter.h
Normal file
188
include/qwt_painter.h
Normal file
|
@ -0,0 +1,188 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PAINTER_H
|
||||
#define QWT_PAINTER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
|
||||
#include <qpoint.h>
|
||||
#include <qrect.h>
|
||||
#include <qpen.h>
|
||||
#include <qline.h>
|
||||
#include <qpalette.h>
|
||||
|
||||
class QPainter;
|
||||
class QBrush;
|
||||
class QColor;
|
||||
class QWidget;
|
||||
class QPolygonF;
|
||||
class QRectF;
|
||||
class QImage;
|
||||
class QPixmap;
|
||||
class QwtScaleMap;
|
||||
class QwtColorMap;
|
||||
class QwtInterval;
|
||||
|
||||
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(QPainter *);
|
||||
|
||||
static void drawText( QPainter *, double x, double y, const QString & );
|
||||
static void drawText( QPainter *, const QPointF &, const QString & );
|
||||
static void drawText( QPainter *, double x, double y, double w, double h,
|
||||
int flags, const QString & );
|
||||
static void drawText( QPainter *, const QRectF &,
|
||||
int flags, const QString & );
|
||||
|
||||
#ifndef QT_NO_RICHTEXT
|
||||
static void drawSimpleRichText( QPainter *, const QRectF &,
|
||||
int flags, const QTextDocument & );
|
||||
#endif
|
||||
|
||||
static void drawRect( QPainter *, double x, double y, double w, double 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 *, double x1, double y1, double x2, double 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 *, double x, double 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 &, double xRadius, double yRadius,
|
||||
const QPalette &, int lineWidth, int frameStyle );
|
||||
|
||||
static void drawFrame( QPainter *, const QRectF &rect,
|
||||
const QPalette &palette, QPalette::ColorRole foregroundRole,
|
||||
int lineWidth, int midLineWidth, int frameStyle );
|
||||
|
||||
static void drawFocusRect( QPainter *, const QWidget * );
|
||||
static void drawFocusRect( QPainter *, const QWidget *, const QRect & );
|
||||
|
||||
static void drawColorBar( QPainter *painter,
|
||||
const QwtColorMap &, const QwtInterval &,
|
||||
const QwtScaleMap &, Qt::Orientation, const QRectF & );
|
||||
|
||||
static bool isAligning( QPainter *painter );
|
||||
static bool isX11GraphicsSystem();
|
||||
|
||||
static void fillPixmap( const QWidget *,
|
||||
QPixmap &, const QPoint &offset = QPoint() );
|
||||
|
||||
static void drawBackgound( QPainter *painter,
|
||||
const QRectF &rect, const QWidget *widget );
|
||||
|
||||
static QPixmap backingStore( QWidget *, const QSize & );
|
||||
|
||||
private:
|
||||
static bool d_polylineSplitting;
|
||||
static bool d_roundingAlignment;
|
||||
};
|
||||
|
||||
//! Wrapper for QPainter::drawPoint()
|
||||
inline void QwtPainter::drawPoint( QPainter *painter, double x, double 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,
|
||||
double x1, double y1, double x2, double 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 d_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 d_roundingAlignment;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return roundingAlignment() && isAligning(painter);
|
||||
\param painter Painter
|
||||
*/
|
||||
inline bool QwtPainter::roundingAlignment(QPainter *painter)
|
||||
{
|
||||
return d_roundingAlignment && isAligning(painter);
|
||||
}
|
||||
#endif
|
173
include/qwt_painter_command.h
Normal file
173
include/qwt_painter_command.h
Normal file
|
@ -0,0 +1,173 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PAINTER_COMMAND_H
|
||||
#define QWT_PAINTER_COMMAND_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpaintengine.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qimage.h>
|
||||
#include <qpolygon.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;
|
||||
QMatrix matrix;
|
||||
QTransform transform;
|
||||
|
||||
Qt::ClipOperation clipOperation;
|
||||
QRegion clipRegion;
|
||||
QPainterPath clipPath;
|
||||
bool isClipEnabled;
|
||||
|
||||
QPainter::RenderHints renderHints;
|
||||
QPainter::CompositionMode compositionMode;
|
||||
qreal opacity;
|
||||
};
|
||||
|
||||
QwtPainterCommand();
|
||||
QwtPainterCommand(const QwtPainterCommand &);
|
||||
|
||||
QwtPainterCommand( const QPainterPath & );
|
||||
|
||||
QwtPainterCommand( const QRectF &rect,
|
||||
const QPixmap &, const QRectF& subRect );
|
||||
|
||||
QwtPainterCommand( const QRectF &rect,
|
||||
const QImage &, const QRectF& subRect,
|
||||
Qt::ImageConversionFlags );
|
||||
|
||||
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 d_type;
|
||||
|
||||
union
|
||||
{
|
||||
QPainterPath *d_path;
|
||||
PixmapData *d_pixmapData;
|
||||
ImageData *d_imageData;
|
||||
StateData *d_stateData;
|
||||
};
|
||||
};
|
||||
|
||||
//! \return Type of the command
|
||||
inline QwtPainterCommand::Type QwtPainterCommand::type() const
|
||||
{
|
||||
return d_type;
|
||||
}
|
||||
|
||||
//! \return Painter path to be painted
|
||||
inline const QPainterPath *QwtPainterCommand::path() const
|
||||
{
|
||||
return d_path;
|
||||
}
|
||||
|
||||
//! \return Attributes how to paint a QPixmap
|
||||
inline const QwtPainterCommand::PixmapData*
|
||||
QwtPainterCommand::pixmapData() const
|
||||
{
|
||||
return d_pixmapData;
|
||||
}
|
||||
|
||||
//! \return Attributes how to paint a QImage
|
||||
inline const QwtPainterCommand::ImageData *
|
||||
QwtPainterCommand::imageData() const
|
||||
{
|
||||
return d_imageData;
|
||||
}
|
||||
|
||||
//! \return Attributes of a state change
|
||||
inline const QwtPainterCommand::StateData *
|
||||
QwtPainterCommand::stateData() const
|
||||
{
|
||||
return d_stateData;
|
||||
}
|
||||
|
||||
#endif
|
103
include/qwt_panner.h
Normal file
103
include/qwt_panner.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PANNER_H
|
||||
#define QWT_PANNER_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qwidget.h>
|
||||
#include <qpixmap.h>
|
||||
|
||||
class QCursor;
|
||||
|
||||
/*!
|
||||
\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:
|
||||
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 * );
|
||||
|
||||
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 * );
|
||||
|
||||
virtual QBitmap contentsMask() const;
|
||||
virtual QPixmap grab() const;
|
||||
|
||||
private:
|
||||
#ifndef QT_NO_CURSOR
|
||||
void showCursor( bool );
|
||||
#endif
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
329
include/qwt_picker.h
Normal file
329
include/qwt_picker.h
Normal file
|
@ -0,0 +1,329 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PICKER
|
||||
#define QWT_PICKER 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_event_pattern.h"
|
||||
#include <qobject.h>
|
||||
#include <qpen.h>
|
||||
#include <qfont.h>
|
||||
#include <qrect.h>
|
||||
#include <qpainterpath.h>
|
||||
|
||||
class QWidget;
|
||||
class QMouseEvent;
|
||||
class QWheelEvent;
|
||||
class QKeyEvent;
|
||||
class QwtPickerMachine;
|
||||
class QwtWidgetOverlay;
|
||||
|
||||
/*!
|
||||
\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
|
||||
\verbatim #include <qwt_picker.h>
|
||||
#include <qwt_picker_machine.h>
|
||||
|
||||
QwtPicker *picker = new QwtPicker(widget);
|
||||
picker->setStateMachine(new QwtPickerDragRectMachine);
|
||||
picker->setTrackerMode(QwtPicker::ActiveOnly);
|
||||
picker->setRubberBand(QwtPicker::RectRubberBand); \endverbatim\n
|
||||
|
||||
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 * );
|
||||
|
||||
QWidget *parentWidget();
|
||||
const QWidget *parentWidget() const;
|
||||
|
||||
virtual QPainterPath pickArea() const;
|
||||
|
||||
virtual void drawRubberBand( QPainter * ) const;
|
||||
virtual void drawTracker( QPainter * ) 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;
|
||||
|
||||
private:
|
||||
void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
|
||||
|
||||
void setMouseTracking( bool );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
214
include/qwt_picker_machine.h
Normal file
214
include/qwt_picker_machine.h
Normal file
|
@ -0,0 +1,214 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PICKER_MACHINE
|
||||
#define QWT_PICKER_MACHINE 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qlist.h>
|
||||
|
||||
class QEvent;
|
||||
class QwtEventPattern;
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
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 d_selectionType;
|
||||
int d_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 * );
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 * );
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 * );
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 * );
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 * );
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 * );
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 * );
|
||||
};
|
||||
|
||||
#endif
|
98
include/qwt_pixel_matrix.h
Normal file
98
include/qwt_pixel_matrix.h
Normal file
|
@ -0,0 +1,98 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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:
|
||||
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 d_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 - d_rect.x();
|
||||
if ( dx < 0 || dx >= d_rect.width() )
|
||||
return -1;
|
||||
|
||||
const int dy = y - d_rect.y();
|
||||
if ( dy < 0 || dy >= d_rect.height() )
|
||||
return -1;
|
||||
|
||||
return dy * d_rect.width() + dx;
|
||||
}
|
||||
|
||||
#endif
|
312
include/qwt_plot.h
Normal file
312
include/qwt_plot.h
Normal file
|
@ -0,0 +1,312 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_H
|
||||
#define QWT_PLOT_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_plot_dict.h"
|
||||
#include "qwt_scale_map.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qframe.h>
|
||||
#include <qlist.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
class QwtPlotLayout;
|
||||
class QwtAbstractLegend;
|
||||
class QwtScaleWidget;
|
||||
class QwtScaleEngine;
|
||||
class QwtScaleDiv;
|
||||
class QwtScaleDraw;
|
||||
class QwtTextLabel;
|
||||
|
||||
/*!
|
||||
\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.
|
||||
\verbatim
|
||||
#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();
|
||||
\endverbatim
|
||||
*/
|
||||
|
||||
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 )
|
||||
|
||||
#if 0
|
||||
// This property is intended to configure the plot
|
||||
// widget from a special dialog in the deigner plugin.
|
||||
// Disabled until such a dialog has been implemented.
|
||||
|
||||
Q_PROPERTY( QString propertiesDocument
|
||||
READ grabProperties WRITE applyProperties )
|
||||
#endif
|
||||
|
||||
public:
|
||||
//! \brief Axis index
|
||||
enum Axis
|
||||
{
|
||||
//! 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,
|
||||
|
||||
//! Number of axes
|
||||
axisCnt
|
||||
};
|
||||
|
||||
/*!
|
||||
Position of the legend, relative to the canvas.
|
||||
|
||||
\sa insertLegend()
|
||||
*/
|
||||
enum LegendPosition
|
||||
{
|
||||
//! The legend will be left from the QwtPlot::yLeft axis.
|
||||
LeftLegend,
|
||||
|
||||
//! The legend will be right from the QwtPlot::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 applyProperties( const QString & );
|
||||
QString grabProperties() const;
|
||||
|
||||
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 &t );
|
||||
QwtText title() const;
|
||||
|
||||
QwtTextLabel *titleLabel();
|
||||
const QwtTextLabel *titleLabel() const;
|
||||
|
||||
// Footer
|
||||
|
||||
void setFooter( const QString & );
|
||||
void setFooter( const QwtText &t );
|
||||
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( int axisId ) const;
|
||||
|
||||
double invTransform( int axisId, int pos ) const;
|
||||
double transform( int axisId, double value ) const;
|
||||
|
||||
// Axes
|
||||
|
||||
QwtScaleEngine *axisScaleEngine( int axisId );
|
||||
const QwtScaleEngine *axisScaleEngine( int axisId ) const;
|
||||
void setAxisScaleEngine( int axisId, QwtScaleEngine * );
|
||||
|
||||
void setAxisAutoScale( int axisId, bool on = true );
|
||||
bool axisAutoScale( int axisId ) const;
|
||||
|
||||
void enableAxis( int axisId, bool tf = true );
|
||||
bool axisEnabled( int axisId ) const;
|
||||
|
||||
void setAxisFont( int axisId, const QFont &f );
|
||||
QFont axisFont( int axisId ) const;
|
||||
|
||||
void setAxisScale( int axisId, double min, double max, double step = 0 );
|
||||
void setAxisScaleDiv( int axisId, const QwtScaleDiv & );
|
||||
void setAxisScaleDraw( int axisId, QwtScaleDraw * );
|
||||
|
||||
double axisStepSize( int axisId ) const;
|
||||
QwtInterval axisInterval( int axisId ) const;
|
||||
|
||||
const QwtScaleDiv &axisScaleDiv( int axisId ) const;
|
||||
|
||||
const QwtScaleDraw *axisScaleDraw( int axisId ) const;
|
||||
QwtScaleDraw *axisScaleDraw( int axisId );
|
||||
|
||||
const QwtScaleWidget *axisWidget( int axisId ) const;
|
||||
QwtScaleWidget *axisWidget( int axisId );
|
||||
|
||||
void setAxisLabelAlignment( int axisId, Qt::Alignment );
|
||||
void setAxisLabelRotation( int axisId, double rotation );
|
||||
|
||||
void setAxisTitle( int axisId, const QString & );
|
||||
void setAxisTitle( int axisId, const QwtText & );
|
||||
QwtText axisTitle( int axisId ) const;
|
||||
|
||||
void setAxisMaxMinor( int axisId, int maxMinor );
|
||||
int axisMaxMinor( int axisId ) const;
|
||||
|
||||
void setAxisMaxMajor( int axisId, int maxMajor );
|
||||
int axisMaxMajor( int axisId ) 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;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
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 * );
|
||||
virtual bool eventFilter( QObject *, QEvent * );
|
||||
|
||||
virtual void drawItems( QPainter *, const QRectF &,
|
||||
const QwtScaleMap maps[axisCnt] ) const;
|
||||
|
||||
virtual QVariant itemToInfo( QwtPlotItem * ) const;
|
||||
virtual QwtPlotItem *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( 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:
|
||||
static bool axisValid( int axisId );
|
||||
|
||||
virtual void resizeEvent( QResizeEvent *e );
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateLegendItems( const QVariant &itemInfo,
|
||||
const QList<QwtLegendData> &data );
|
||||
|
||||
private:
|
||||
friend class QwtPlotItem;
|
||||
void attachItem( QwtPlotItem *, bool );
|
||||
|
||||
void initAxesData();
|
||||
void deleteAxesData();
|
||||
void updateScaleDiv();
|
||||
|
||||
void initPlot( const QwtText &title );
|
||||
|
||||
class AxisData;
|
||||
AxisData *d_axisData[axisCnt];
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
97
include/qwt_plot_abstract_barchart.h
Normal file
97
include/qwt_plot_abstract_barchart.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_ABSTRACT_BAR_CHART_H
|
||||
#define QWT_PLOT_ABSTRACT_BAR_CHART_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_seriesitem.h"
|
||||
#include "qwt_series_data.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;
|
||||
|
||||
|
||||
protected:
|
||||
double sampleWidth( const QwtScaleMap &map,
|
||||
double canvasSize, double dataSize,
|
||||
double value ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
118
include/qwt_plot_barchart.h
Normal file
118
include/qwt_plot_barchart.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_BAR_CHART_H
|
||||
#define QWT_PLOT_BAR_CHART_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_abstract_barchart.h"
|
||||
#include "qwt_series_data.h"
|
||||
|
||||
class QwtColumnRect;
|
||||
class QwtColumnSymbol;
|
||||
|
||||
/*!
|
||||
\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::null );
|
||||
explicit QwtPlotBarChart( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotBarChart();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
void setSamples( const QVector<QPointF> & );
|
||||
void setSamples( const QVector<double> & );
|
||||
void setSamples( QwtSeriesData<QPointF> *series );
|
||||
|
||||
void setSymbol( QwtColumnSymbol * );
|
||||
const QwtColumnSymbol *symbol() const;
|
||||
|
||||
void setLegendMode( LegendMode );
|
||||
LegendMode legendMode() const;
|
||||
|
||||
virtual void drawSeries( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
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& point,
|
||||
const QwtColumnRect & ) const;
|
||||
|
||||
QList<QwtLegendData> legendData() const;
|
||||
QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
171
include/qwt_plot_canvas.h
Normal file
171
include/qwt_plot_canvas.h
Normal file
|
@ -0,0 +1,171 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_CANVAS_H
|
||||
#define QWT_PLOT_CANVAS_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qframe.h>
|
||||
#include <qpainterpath.h>
|
||||
|
||||
class QwtPlot;
|
||||
class QPixmap;
|
||||
|
||||
/*!
|
||||
\brief Canvas of a QwtPlot.
|
||||
|
||||
Canvas is the widget where all plot items are displayed
|
||||
|
||||
\sa QwtPlot::setCanvas(), QwtPlotGLCanvas
|
||||
*/
|
||||
class QWT_EXPORT QwtPlotCanvas : public QFrame
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
/*!
|
||||
\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 QwtPlotCanvas( QwtPlot * = NULL );
|
||||
virtual ~QwtPlotCanvas();
|
||||
|
||||
QwtPlot *plot();
|
||||
const QwtPlot *plot() const;
|
||||
|
||||
void setFocusIndicator( FocusIndicator );
|
||||
FocusIndicator focusIndicator() const;
|
||||
|
||||
void setBorderRadius( double );
|
||||
double borderRadius() const;
|
||||
|
||||
void setPaintAttribute( PaintAttribute, bool on = true );
|
||||
bool testPaintAttribute( PaintAttribute ) const;
|
||||
|
||||
const QPixmap *backingStore() const;
|
||||
void invalidateBackingStore();
|
||||
|
||||
virtual bool event( QEvent * );
|
||||
|
||||
Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void replot();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
virtual void drawFocusIndicator( QPainter * );
|
||||
virtual void drawBorder( QPainter * );
|
||||
|
||||
void updateStyleSheetInfo();
|
||||
|
||||
private:
|
||||
void drawCanvas( QPainter *, bool withBackground );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCanvas::PaintAttributes )
|
||||
|
||||
#endif
|
337
include/qwt_plot_curve.h
Normal file
337
include/qwt_plot_curve.h
Normal file
|
@ -0,0 +1,337 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_CURVE_H
|
||||
#define QWT_PLOT_CURVE_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_seriesitem.h"
|
||||
#include "qwt_series_data.h"
|
||||
#include "qwt_text.h"
|
||||
#include <qpen.h>
|
||||
#include <qstring.h>
|
||||
|
||||
class QPainter;
|
||||
class QPolygonF;
|
||||
class QwtScaleMap;
|
||||
class QwtSymbol;
|
||||
class QwtCurveFitter;
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
//! Curve attributes
|
||||
typedef QFlags<CurveAttribute> CurveAttributes;
|
||||
|
||||
/*!
|
||||
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
|
||||
};
|
||||
|
||||
//! Legend attributes
|
||||
typedef QFlags<LegendAttribute> LegendAttributes;
|
||||
|
||||
/*!
|
||||
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
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotCurve();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
void setPaintAttribute( PaintAttribute, bool on = true );
|
||||
bool testPaintAttribute( PaintAttribute ) const;
|
||||
|
||||
void setLegendAttribute( LegendAttribute, bool on = true );
|
||||
bool testLegendAttribute( LegendAttribute ) const;
|
||||
|
||||
#ifndef QWT_NO_COMPAT
|
||||
void setRawSamples( const double *xData, const double *yData, int size );
|
||||
void setSamples( const double *xData, const double *yData, int size );
|
||||
void setSamples( const QVector<double> &xData, const QVector<double> &yData );
|
||||
#endif
|
||||
void setSamples( const QVector<QPointF> & );
|
||||
void setSamples( QwtSeriesData<QPointF> * );
|
||||
|
||||
int closestPoint( const QPoint &pos, double *dist = NULL ) 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;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
protected:
|
||||
|
||||
void init();
|
||||
|
||||
virtual void drawCurve( QPainter *p, int style,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawSymbols( QPainter *p, const QwtSymbol &,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawLines( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawSticks( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawDots( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual void drawSteps( QPainter *p,
|
||||
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 *d_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
|
58
include/qwt_plot_dict.h
Normal file
58
include/qwt_plot_dict.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
/*! \file !*/
|
||||
#ifndef QWT_PLOT_DICT
|
||||
#define QWT_PLOT_DICT
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include <qlist.h>
|
||||
|
||||
/// \var typedef QList< QwtPlotItem *> QwtPlotItemList
|
||||
/// \brief See QT 4.x assistant documentation for QList
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
#endif
|
100
include/qwt_plot_directpainter.h
Normal file
100
include/qwt_plot_directpainter.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_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
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<Attribute> Attributes;
|
||||
|
||||
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 * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotDirectPainter::Attributes )
|
||||
|
||||
#endif
|
130
include/qwt_plot_glcanvas.h
Normal file
130
include/qwt_plot_glcanvas.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_GLCANVAS_H
|
||||
#define QWT_PLOT_GLCANVAS_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qframe.h>
|
||||
#include <qgl.h>
|
||||
|
||||
class QwtPlot;
|
||||
|
||||
/*!
|
||||
\brief An alternative canvas for a QwtPlot derived from QGLWidget
|
||||
|
||||
QwtPlotGLCanvas implements the very basics to act as canvas
|
||||
inside of a QwtPlot widget. It might be extended to a full
|
||||
featured alternative to QwtPlotCanvas in a future version of Qwt.
|
||||
|
||||
Even if QwtPlotGLCanvas is not derived from QFrame it imitates
|
||||
its API. When using style sheets it supports the box model - beside
|
||||
backgrounds with rounded borders.
|
||||
|
||||
\sa QwtPlot::setCanvas(), QwtPlotCanvas
|
||||
|
||||
\note With Qt4 you might want to use the QPaintEngine::OpenGL paint engine
|
||||
( see QGL::setPreferredPaintEngine() ). On a Linux test system
|
||||
QPaintEngine::OpenGL2 shows very basic problems like translated
|
||||
geometries.
|
||||
*/
|
||||
class QWT_EXPORT QwtPlotGLCanvas: public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS( Shape Shadow )
|
||||
|
||||
Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
|
||||
Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
|
||||
Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
|
||||
Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
|
||||
Q_PROPERTY( int frameWidth READ frameWidth )
|
||||
Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false )
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief Frame shadow
|
||||
|
||||
Unfortunately it is not possible to use QFrame::Shadow
|
||||
as a property of a widget that is not derived from QFrame.
|
||||
The following enum is made for the designer only. It is safe
|
||||
to use QFrame::Shadow instead.
|
||||
*/
|
||||
enum Shadow
|
||||
{
|
||||
//! QFrame::Plain
|
||||
Plain = QFrame::Plain,
|
||||
|
||||
//! QFrame::Raised
|
||||
Raised = QFrame::Raised,
|
||||
|
||||
//! QFrame::Sunken
|
||||
Sunken = QFrame::Sunken
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Frame shape
|
||||
|
||||
Unfortunately it is not possible to use QFrame::Shape
|
||||
as a property of a widget that is not derived from QFrame.
|
||||
The following enum is made for the designer only. It is safe
|
||||
to use QFrame::Shadow instead.
|
||||
|
||||
\note QFrame::StyledPanel and QFrame::WinPanel are unsuported
|
||||
and will be displayed as QFrame::Panel.
|
||||
*/
|
||||
enum Shape
|
||||
{
|
||||
NoFrame = QFrame::NoFrame,
|
||||
|
||||
Box = QFrame::Box,
|
||||
Panel = QFrame::Panel
|
||||
};
|
||||
|
||||
explicit QwtPlotGLCanvas( QwtPlot * = NULL );
|
||||
virtual ~QwtPlotGLCanvas();
|
||||
|
||||
void setFrameStyle( int style );
|
||||
int frameStyle() const;
|
||||
|
||||
void setFrameShadow( Shadow );
|
||||
Shadow frameShadow() const;
|
||||
|
||||
void setFrameShape( Shape );
|
||||
Shape frameShape() const;
|
||||
|
||||
void setLineWidth( int );
|
||||
int lineWidth() const;
|
||||
|
||||
void setMidLineWidth( int );
|
||||
int midLineWidth() const;
|
||||
|
||||
int frameWidth() const;
|
||||
QRect frameRect() const;
|
||||
|
||||
Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
|
||||
|
||||
virtual bool event( QEvent * );
|
||||
|
||||
public Q_SLOTS:
|
||||
void replot();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
|
||||
virtual void drawBackground( QPainter * );
|
||||
virtual void drawBorder( QPainter * );
|
||||
virtual void drawItems( QPainter * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
87
include/qwt_plot_grid.h
Normal file
87
include/qwt_plot_grid.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_GRID_H
|
||||
#define QWT_PLOT_GRID_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include "qwt_scale_div.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;
|
||||
|
||||
void enableX( bool tf );
|
||||
bool xEnabled() const;
|
||||
|
||||
void enableY( bool tf );
|
||||
bool yEnabled() const;
|
||||
|
||||
void enableXMin( bool tf );
|
||||
bool xMinEnabled() const;
|
||||
|
||||
void enableYMin( bool tf );
|
||||
bool yMinEnabled() const;
|
||||
|
||||
void setXDiv( const QwtScaleDiv &sx );
|
||||
const QwtScaleDiv &xScaleDiv() const;
|
||||
|
||||
void setYDiv( const QwtScaleDiv &sy );
|
||||
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 &p );
|
||||
const QPen& minorPen() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
virtual void updateScaleDiv(
|
||||
const QwtScaleDiv &xMap, const QwtScaleDiv &yMap );
|
||||
|
||||
private:
|
||||
void drawLines( QPainter *painter, const QRectF &,
|
||||
Qt::Orientation orientation, const QwtScaleMap &,
|
||||
const QList<double> & ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
139
include/qwt_plot_histogram.h
Normal file
139
include/qwt_plot_histogram.h
Normal file
|
@ -0,0 +1,139 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_HISTOGRAM_H
|
||||
#define QWT_PLOT_HISTOGRAM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_seriesitem.h"
|
||||
#include "qwt_column_symbol.h"
|
||||
#include <qcolor.h>
|
||||
#include <qvector.h>
|
||||
|
||||
class QwtIntervalData;
|
||||
class QString;
|
||||
class QPolygonF;
|
||||
|
||||
/*!
|
||||
\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::null );
|
||||
explicit QwtPlotHistogram( const QwtText &title );
|
||||
virtual ~QwtPlotHistogram();
|
||||
|
||||
virtual int rtti() 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 setSamples( const QVector<QwtIntervalSample> & );
|
||||
void setSamples( QwtSeriesData<QwtIntervalSample> * );
|
||||
|
||||
void setBaseline( double reference );
|
||||
double baseline() const;
|
||||
|
||||
void setStyle( HistogramStyle style );
|
||||
HistogramStyle style() const;
|
||||
|
||||
void setSymbol( const QwtColumnSymbol * );
|
||||
const QwtColumnSymbol *symbol() const;
|
||||
|
||||
virtual void drawSeries( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
#endif
|
132
include/qwt_plot_intervalcurve.h
Normal file
132
include/qwt_plot_intervalcurve.h
Normal file
|
@ -0,0 +1,132 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_INTERVAL_CURVE_H
|
||||
#define QWT_PLOT_INTERVAL_CURVE_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_seriesitem.h"
|
||||
#include "qwt_series_data.h"
|
||||
|
||||
class QwtIntervalSymbol;
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotIntervalCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotIntervalCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotIntervalCurve();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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 *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotIntervalCurve::PaintAttributes )
|
||||
|
||||
#endif
|
307
include/qwt_plot_item.h
Normal file
307
include/qwt_plot_item.h
Normal file
|
@ -0,0 +1,307 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_ITEM_H
|
||||
#define QWT_PLOT_ITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_legend_data.h"
|
||||
#include "qwt_graphic.h"
|
||||
#include <qrect.h>
|
||||
#include <qlist.h>
|
||||
#include <qmetatype.h>
|
||||
|
||||
class QPainter;
|
||||
class QwtScaleMap;
|
||||
class QwtScaleDiv;
|
||||
class QwtPlot;
|
||||
|
||||
/*!
|
||||
\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 QwtPlotSvgItem
|
||||
Rtti_PlotSVG,
|
||||
|
||||
//! For QwtPlotTradingCurve
|
||||
Rtti_PlotTradingCurve,
|
||||
|
||||
//! For QwtPlotBarChart
|
||||
Rtti_PlotBarChart,
|
||||
|
||||
//! For QwtPlotMultiBarChart
|
||||
Rtti_PlotMultiBarChart,
|
||||
|
||||
//! For QwtPlotShapeItem
|
||||
Rtti_PlotShape,
|
||||
|
||||
//! For QwtPlotTextLabel
|
||||
Rtti_PlotTextLabel,
|
||||
|
||||
//! For QwtPlotZoneItem
|
||||
Rtti_PlotZone,
|
||||
|
||||
/*!
|
||||
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
|
||||
};
|
||||
|
||||
//! Plot Item Attributes
|
||||
typedef QFlags<ItemAttribute> ItemAttributes;
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
//! Plot Item Interests
|
||||
typedef QFlags<ItemInterest> ItemInterests;
|
||||
|
||||
//! Render hints
|
||||
enum RenderHint
|
||||
{
|
||||
//! Enable antialiasing
|
||||
RenderAntialiased = 0x1
|
||||
};
|
||||
|
||||
//! Render hints
|
||||
typedef QFlags<RenderHint> RenderHints;
|
||||
|
||||
explicit QwtPlotItem( const QwtText &title = QwtText() );
|
||||
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( int xAxis, int yAxis );
|
||||
|
||||
void setXAxis( int axis );
|
||||
int xAxis() const;
|
||||
|
||||
void setYAxis( int axis );
|
||||
int 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 &canvasSize,
|
||||
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:
|
||||
// Disabled copy constructor and operator=
|
||||
QwtPlotItem( const QwtPlotItem & );
|
||||
QwtPlotItem &operator=( const QwtPlotItem & );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_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
|
122
include/qwt_plot_layout.h
Normal file
122
include/qwt_plot_layout.h
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_LAYOUT_H
|
||||
#define QWT_PLOT_LAYOUT_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot.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
|
||||
};
|
||||
|
||||
//! Layout options
|
||||
typedef QFlags<Option> Options;
|
||||
|
||||
explicit QwtPlotLayout();
|
||||
virtual ~QwtPlotLayout();
|
||||
|
||||
void setCanvasMargin( int margin, int axis = -1 );
|
||||
int canvasMargin( int axis ) 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 &rect, Options options = 0x00 );
|
||||
|
||||
virtual void invalidate();
|
||||
|
||||
QRectF titleRect() const;
|
||||
QRectF footerRect() const;
|
||||
QRectF legendRect() const;
|
||||
QRectF scaleRect( int axis ) const;
|
||||
QRectF canvasRect() const;
|
||||
|
||||
class LayoutData;
|
||||
|
||||
protected:
|
||||
|
||||
void setTitleRect( const QRectF & );
|
||||
void setFooterRect( const QRectF & );
|
||||
void setLegendRect( const QRectF & );
|
||||
void setScaleRect( int axis, const QRectF & );
|
||||
void setCanvasRect( const QRectF & );
|
||||
|
||||
QRectF layoutLegend( Options options, const QRectF & ) const;
|
||||
QRectF alignLegend( const QRectF &canvasRect,
|
||||
const QRectF &legendRect ) const;
|
||||
|
||||
void expandLineBreaks( Options options, const QRectF &rect,
|
||||
int &dimTitle, int &dimFooter, int dimAxes[QwtPlot::axisCnt] ) const;
|
||||
|
||||
void alignScales( Options options, QRectF &canvasRect,
|
||||
QRectF scaleRect[QwtPlot::axisCnt] ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotLayout::Options )
|
||||
|
||||
#endif
|
136
include/qwt_plot_legenditem.h
Normal file
136
include/qwt_plot_legenditem.h
Normal file
|
@ -0,0 +1,136 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_LEGEND_ITEM_H
|
||||
#define QWT_PLOT_LEGEND_ITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include "qwt_legend_data.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;
|
||||
|
||||
void setAlignment( Qt::Alignment );
|
||||
Qt::Alignment alignment() 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 setBorderDistance( int numPixels );
|
||||
int borderDistance() 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 *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
void clearLegend();
|
||||
|
||||
virtual void updateLegend( const QwtPlotItem *,
|
||||
const QList<QwtLegendData> & );
|
||||
|
||||
virtual QRect geometry( const QRectF &canvasRect ) const;
|
||||
|
||||
virtual QSize minimumSize( const QwtLegendData & ) const;
|
||||
virtual int heightForWidth( const QwtLegendData &, int w ) const;
|
||||
|
||||
QList< const QwtPlotItem * > plotItems() const;
|
||||
QList< QRect > legendGeometries( const QwtPlotItem * ) const;
|
||||
|
||||
protected:
|
||||
virtual void drawLegendData( QPainter *painter,
|
||||
const QwtPlotItem *, const QwtLegendData &, const QRectF & ) const;
|
||||
|
||||
virtual void drawBackground( QPainter *, const QRectF &rect ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
54
include/qwt_plot_magnifier.h
Normal file
54
include/qwt_plot_magnifier.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_MAGNIFIER_H
|
||||
#define QWT_PLOT_MAGNIFIER_H 1
|
||||
|
||||
#include "qwt_global.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( int axis, bool on );
|
||||
bool isAxisEnabled( int axis ) const;
|
||||
|
||||
QWidget *canvas();
|
||||
const QWidget *canvas() const;
|
||||
|
||||
QwtPlot *plot();
|
||||
const QwtPlot *plot() const;
|
||||
|
||||
protected:
|
||||
virtual void rescale( double factor );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
130
include/qwt_plot_marker.h
Normal file
130
include/qwt_plot_marker.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_MARKER_H
|
||||
#define QWT_PLOT_MARKER_H
|
||||
|
||||
#include <qpen.h>
|
||||
#include <qfont.h>
|
||||
#include <qstring.h>
|
||||
#include <qbrush.h>
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
|
||||
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( const QString &title = QString::null );
|
||||
explicit QwtPlotMarker( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotMarker();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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 st );
|
||||
LineStyle lineStyle() const;
|
||||
|
||||
void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
|
||||
void setLinePen( const QPen &p );
|
||||
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 *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF & ) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
protected:
|
||||
virtual void drawLines( QPainter *,
|
||||
const QRectF &, const QPointF & ) const;
|
||||
|
||||
virtual void drawLabel( QPainter *,
|
||||
const QRectF &, const QPointF & ) const;
|
||||
|
||||
private:
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
127
include/qwt_plot_multi_barchart.h
Normal file
127
include/qwt_plot_multi_barchart.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_MULTI_BAR_CHART_H
|
||||
#define QWT_PLOT_MULTI_BAR_CHART_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_abstract_barchart.h"
|
||||
#include "qwt_series_data.h"
|
||||
|
||||
class QwtColumnRect;
|
||||
class QwtColumnSymbol;
|
||||
|
||||
/*!
|
||||
\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::null );
|
||||
explicit QwtPlotMultiBarChart( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotMultiBarChart();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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 barIndex, QwtColumnSymbol *symbol );
|
||||
const QwtColumnSymbol *symbol( int barIndex ) const;
|
||||
|
||||
void resetSymbolMap();
|
||||
|
||||
virtual void drawSeries( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual QList<QwtLegendData> legendData() const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
protected:
|
||||
QwtColumnSymbol *symbol( int barIndex );
|
||||
|
||||
virtual QwtColumnSymbol *specialSymbol(
|
||||
int sampleIndex, int valueIndex ) const;
|
||||
|
||||
virtual void drawSample( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, const QwtInterval &boundingInterval,
|
||||
int index, const QwtSetSample& sample ) const;
|
||||
|
||||
virtual void drawBar( QPainter *, int sampleIndex,
|
||||
int barIndex, const QwtColumnRect & ) const;
|
||||
|
||||
void drawStackedBars( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int index,
|
||||
double sampleWidth, const QwtSetSample& sample ) const;
|
||||
|
||||
void drawGroupedBars( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int index,
|
||||
double sampleWidth, const QwtSetSample& sample ) const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
60
include/qwt_plot_panner.h
Normal file
60
include/qwt_plot_panner.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_PANNER_H
|
||||
#define QWT_PLOT_PANNER_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_panner.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( int axis, bool on );
|
||||
bool isAxisEnabled( int axis ) const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void moveCanvas( int dx, int dy );
|
||||
|
||||
protected:
|
||||
virtual QBitmap contentsMask() const;
|
||||
virtual QPixmap grab() const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
111
include/qwt_plot_picker.h
Normal file
111
include/qwt_plot_picker.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_PICKER_H
|
||||
#define QWT_PLOT_PICKER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_picker.h"
|
||||
#include <qvector.h>
|
||||
|
||||
class QwtPlot;
|
||||
|
||||
/*!
|
||||
\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( int xAxis, int yAxis, QWidget * );
|
||||
|
||||
explicit QwtPlotPicker( int xAxis, int yAxis,
|
||||
RubberBand rubberBand, DisplayMode trackerMode, QWidget * );
|
||||
|
||||
virtual void setAxis( int xAxis, int yAxis );
|
||||
|
||||
int xAxis() const;
|
||||
int 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;
|
||||
virtual QwtText trackerTextF( const QPointF & ) const;
|
||||
|
||||
virtual void move( const QPoint & );
|
||||
virtual void append( const QPoint & );
|
||||
virtual bool end( bool ok = true );
|
||||
|
||||
private:
|
||||
int d_xAxis;
|
||||
int d_yAxis;
|
||||
};
|
||||
|
||||
#endif
|
152
include/qwt_plot_rasteritem.h
Normal file
152
include/qwt_plot_rasteritem.h
Normal file
|
@ -0,0 +1,152 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_RASTERITEM_H
|
||||
#define QWT_PLOT_RASTERITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qglobal.h>
|
||||
#include <qstring.h>
|
||||
#include <qimage.h>
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotRasterItem( const QString& title = QString::null );
|
||||
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 *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
virtual QRectF pixelHint( const QRectF & ) const;
|
||||
|
||||
virtual QwtInterval interval(Qt::Axis) const;
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
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:
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRasterItem::PaintAttributes )
|
||||
|
||||
#endif
|
170
include/qwt_plot_renderer.h
Normal file
170
include/qwt_plot_renderer.h
Normal file
|
@ -0,0 +1,170 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_RENDERER_H
|
||||
#define QWT_PLOT_RENDERER_H
|
||||
|
||||
#include "qwt_global.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:
|
||||
//! Disard 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
|
||||
|
||||
};
|
||||
|
||||
//! Disard flags
|
||||
typedef QFlags<DiscardFlag> DiscardFlags;
|
||||
|
||||
/*!
|
||||
\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
|
||||
};
|
||||
|
||||
//! Layout flags
|
||||
typedef QFlags<LayoutFlag> LayoutFlags;
|
||||
|
||||
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
|
||||
#if QT_VERSION >= 0x040500
|
||||
void renderTo( QwtPlot *, QSvgGenerator & ) const;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void renderTo( QwtPlot *, QPrinter & ) const;
|
||||
#endif
|
||||
|
||||
void renderTo( QwtPlot *, QPaintDevice &p ) const;
|
||||
|
||||
virtual void render( QwtPlot *,
|
||||
QPainter *, const QRectF &rect ) const;
|
||||
|
||||
virtual void renderTitle( const QwtPlot *,
|
||||
QPainter *, const QRectF & ) const;
|
||||
|
||||
virtual void renderFooter( const QwtPlot *,
|
||||
QPainter *, const QRectF & ) const;
|
||||
|
||||
virtual void renderScale( const QwtPlot *, QPainter *,
|
||||
int axisId, int startDist, int endDist,
|
||||
int baseDist, const QRectF & ) const;
|
||||
|
||||
virtual void renderCanvas( const QwtPlot *,
|
||||
QPainter *, const QRectF &canvasRect,
|
||||
const QwtScaleMap* maps ) const;
|
||||
|
||||
virtual void renderLegend(
|
||||
const QwtPlot *, QPainter *, const QRectF & ) 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 *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
|
||||
|
||||
#endif
|
142
include/qwt_plot_rescaler.h
Normal file
142
include/qwt_plot_rescaler.h
Normal file
|
@ -0,0 +1,142 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_RESCALER_H
|
||||
#define QWT_PLOT_RESCALER_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_interval.h"
|
||||
#include "qwt_plot.h"
|
||||
#include <qobject.h>
|
||||
|
||||
class QwtPlot;
|
||||
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
|
||||
{
|
||||
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,
|
||||
int referenceAxis = QwtPlot::xBottom,
|
||||
RescalePolicy = Expanding );
|
||||
|
||||
virtual ~QwtPlotRescaler();
|
||||
|
||||
void setEnabled( bool );
|
||||
bool isEnabled() const;
|
||||
|
||||
void setRescalePolicy( RescalePolicy );
|
||||
RescalePolicy rescalePolicy() const;
|
||||
|
||||
void setExpandingDirection( ExpandingDirection );
|
||||
void setExpandingDirection( int axis, ExpandingDirection );
|
||||
ExpandingDirection expandingDirection( int axis ) const;
|
||||
|
||||
void setReferenceAxis( int axis );
|
||||
int referenceAxis() const;
|
||||
|
||||
void setAspectRatio( double ratio );
|
||||
void setAspectRatio( int axis, double ratio );
|
||||
double aspectRatio( int axis ) const;
|
||||
|
||||
void setIntervalHint( int axis, const QwtInterval& );
|
||||
QwtInterval intervalHint( int axis ) const;
|
||||
|
||||
QWidget *canvas();
|
||||
const QWidget *canvas() const;
|
||||
|
||||
QwtPlot *plot();
|
||||
const QwtPlot *plot() const;
|
||||
|
||||
virtual bool eventFilter( QObject *, QEvent * );
|
||||
|
||||
void rescale() const;
|
||||
|
||||
protected:
|
||||
virtual void canvasResizeEvent( QResizeEvent * );
|
||||
|
||||
virtual void rescale( const QSize &oldSize, const QSize &newSize ) const;
|
||||
virtual QwtInterval expandScale(
|
||||
int axis, const QSize &oldSize, const QSize &newSize ) const;
|
||||
|
||||
virtual QwtInterval syncScale(
|
||||
int axis, const QwtInterval& reference,
|
||||
const QSize &size ) const;
|
||||
|
||||
virtual void updateScales(
|
||||
QwtInterval intervals[QwtPlot::axisCnt] ) const;
|
||||
|
||||
Qt::Orientation orientation( int axis ) const;
|
||||
QwtInterval interval( int axis ) const;
|
||||
QwtInterval expandInterval( const QwtInterval &,
|
||||
double width, ExpandingDirection ) const;
|
||||
|
||||
private:
|
||||
double pixelDist( int axis, const QSize & ) const;
|
||||
|
||||
class AxisData;
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
94
include/qwt_plot_scaleitem.h
Normal file
94
include/qwt_plot_scaleitem.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_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.
|
||||
\verbatim
|
||||
QwtPlotScaleItem *scaleItem =
|
||||
new QwtPlotScaleItem(QwtScaleDraw::RightScale, 0.0);
|
||||
scaleItem->setFont(plot->axisWidget(QwtPlot::yLeft)->font());
|
||||
scaleItem->attach(plot);
|
||||
|
||||
plot->enableAxis(QwtPlot::yLeft, false);
|
||||
\endverbatim
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtPlotScaleItem: public QwtPlotItem
|
||||
{
|
||||
public:
|
||||
explicit QwtPlotScaleItem(
|
||||
QwtScaleDraw::Alignment = QwtScaleDraw::BottomScale,
|
||||
const double pos = 0.0 );
|
||||
|
||||
virtual ~QwtPlotScaleItem();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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 numPixels );
|
||||
int borderDistance() const;
|
||||
|
||||
void setAlignment( QwtScaleDraw::Alignment );
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
virtual void updateScaleDiv( const QwtScaleDiv &, const QwtScaleDiv & );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
66
include/qwt_plot_seriesitem.h
Normal file
66
include/qwt_plot_seriesitem.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_SERIES_ITEM_H
|
||||
#define QWT_PLOT_SERIES_ITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include "qwt_scale_div.h"
|
||||
#include "qwt_series_data.h"
|
||||
#include "qwt_series_store.h"
|
||||
|
||||
/*!
|
||||
\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::null );
|
||||
explicit QwtPlotSeriesItem( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotSeriesItem();
|
||||
|
||||
void setOrientation( Qt::Orientation );
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF & ) const;
|
||||
|
||||
/*!
|
||||
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;
|
||||
|
||||
virtual void updateScaleDiv(
|
||||
const QwtScaleDiv &, const QwtScaleDiv & );
|
||||
|
||||
protected:
|
||||
virtual void dataChanged();
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
111
include/qwt_plot_shapeitem.h
Normal file
111
include/qwt_plot_shapeitem.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_SHAPE_ITEM_H
|
||||
#define QWT_PLOT_SHAPE_ITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include <qpainterpath.h>
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
||||
\sa QwtPlotZone
|
||||
*/
|
||||
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,
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
//! 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::null );
|
||||
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;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
79
include/qwt_plot_spectrocurve.h
Normal file
79
include/qwt_plot_spectrocurve.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_CURVE_3D_H
|
||||
#define QWT_PLOT_CURVE_3D_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_seriesitem.h"
|
||||
#include "qwt_series_data.h"
|
||||
|
||||
class QwtSymbol;
|
||||
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, QwtSeriesStore<QwtPoint3D>
|
||||
{
|
||||
public:
|
||||
//! Paint attributes
|
||||
enum PaintAttribute
|
||||
{
|
||||
//! Clip points outside the canvas rectangle
|
||||
ClipPoints = 1
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotSpectroCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotSpectroCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotSpectroCurve();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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;
|
||||
|
||||
void setPenWidth(double width);
|
||||
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 *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectroCurve::PaintAttributes )
|
||||
|
||||
#endif
|
118
include/qwt_plot_spectrogram.h
Normal file
118
include/qwt_plot_spectrogram.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_SPECTROGRAM_H
|
||||
#define QWT_PLOT_SPECTROGRAM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_raster_data.h"
|
||||
#include "qwt_plot_rasteritem.h"
|
||||
#include <qlist.h>
|
||||
|
||||
class QwtColorMap;
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
||||
\image html spectrogram3.png
|
||||
|
||||
\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
|
||||
};
|
||||
|
||||
//! Display modes
|
||||
typedef QFlags<DisplayMode> DisplayModes;
|
||||
|
||||
explicit QwtPlotSpectrogram( const QString &title = QString::null );
|
||||
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;
|
||||
|
||||
virtual QwtInterval interval(Qt::Axis) const;
|
||||
virtual QRectF pixelHint( const QRectF & ) const;
|
||||
|
||||
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;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
protected:
|
||||
virtual QImage renderImage(
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &area, const QSize &imageSize ) const;
|
||||
|
||||
virtual QSize contourRasterSize(
|
||||
const QRectF &, const QRect & ) const;
|
||||
|
||||
virtual QwtRasterData::ContourLines renderContourLines(
|
||||
const QRectF &rect, const QSize &raster ) const;
|
||||
|
||||
virtual void drawContourLines( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QwtRasterData::ContourLines& lines ) const;
|
||||
|
||||
void renderTile( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRect &imageRect, QImage *image ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectrogram::DisplayModes )
|
||||
|
||||
#endif
|
61
include/qwt_plot_svgitem.h
Normal file
61
include/qwt_plot_svgitem.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_SVGITEM_H
|
||||
#define QWT_PLOT_SVGITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include <qstring.h>
|
||||
|
||||
class QSvgRenderer;
|
||||
class QByteArray;
|
||||
|
||||
/*!
|
||||
\brief A plot item, which displays
|
||||
data in Scalable Vector Graphics (SVG) format.
|
||||
|
||||
SVG images are often used to display maps
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtPlotSvgItem: public QwtPlotItem
|
||||
{
|
||||
public:
|
||||
explicit QwtPlotSvgItem( const QString& title = QString::null );
|
||||
explicit QwtPlotSvgItem( const QwtText& title );
|
||||
virtual ~QwtPlotSvgItem();
|
||||
|
||||
bool loadFile( const QRectF&, const QString &fileName );
|
||||
bool loadData( const QRectF&, const QByteArray & );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual void draw( QPainter *p,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
protected:
|
||||
const QSvgRenderer &renderer() const;
|
||||
QSvgRenderer &renderer();
|
||||
|
||||
void render( QPainter *painter,
|
||||
const QRectF &viewBox, const QRectF &rect ) const;
|
||||
|
||||
QRectF viewBox( const QRectF &area ) const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
75
include/qwt_plot_textlabel.h
Normal file
75
include/qwt_plot_textlabel.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_TEXT_LABEL_H
|
||||
#define QWT_PLOT_TEXT_LABEL_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
||||
\verbatim
|
||||
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( this );
|
||||
\endverbatim
|
||||
|
||||
\sa QwtPlotMarker
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtPlotTextLabel: public QwtPlotItem
|
||||
{
|
||||
public:
|
||||
QwtPlotTextLabel();
|
||||
virtual ~QwtPlotTextLabel();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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;
|
||||
|
||||
void invalidateCache();
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
174
include/qwt_plot_tradingcurve.h
Normal file
174
include/qwt_plot_tradingcurve.h
Normal file
|
@ -0,0 +1,174 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_TRADING_CURVE_H
|
||||
#define QWT_PLOT_TRADING_CURVE_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_seriesitem.h"
|
||||
#include "qwt_series_data.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, 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
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
explicit QwtPlotTradingCurve( const QString &title = QString::null );
|
||||
explicit QwtPlotTradingCurve( const QwtText &title );
|
||||
|
||||
virtual ~QwtPlotTradingCurve();
|
||||
|
||||
virtual int rtti() const;
|
||||
|
||||
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 width );
|
||||
double symbolExtent() const;
|
||||
|
||||
void setMinSymbolWidth( double );
|
||||
double minSymbolWidth() const;
|
||||
|
||||
void setMaxSymbolWidth( double );
|
||||
double maxSymbolWidth() const;
|
||||
|
||||
virtual void drawSeries( QPainter *painter,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to ) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
||||
|
||||
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 width ) const;
|
||||
|
||||
void drawBar( QPainter *painter, 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 *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotTradingCurve::PaintAttributes )
|
||||
|
||||
#endif
|
65
include/qwt_plot_zoneitem.h
Normal file
65
include/qwt_plot_zoneitem.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_ZONE_ITEM_H
|
||||
#define QWT_PLOT_ZONE_ITEM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_item.h"
|
||||
#include "qwt_interval.h"
|
||||
|
||||
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;
|
||||
|
||||
void setOrientation( Qt::Orientation );
|
||||
Qt::Orientation orientation();
|
||||
|
||||
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 &) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
140
include/qwt_plot_zoomer.h
Normal file
140
include/qwt_plot_zoomer.h
Normal file
|
@ -0,0 +1,140 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_PLOT_ZOOMER_H
|
||||
#define QWT_PLOT_ZOOMER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_plot_picker.h"
|
||||
#include <qstack.h>
|
||||
|
||||
/*!
|
||||
\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( int xAxis, int 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 setAxis( int xAxis, int yAxis );
|
||||
|
||||
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 x, double y );
|
||||
virtual void moveTo( const QPointF & );
|
||||
|
||||
virtual void zoom( const QRectF & );
|
||||
virtual void zoom( int up );
|
||||
|
||||
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 * );
|
||||
virtual void widgetKeyPressEvent( QKeyEvent * );
|
||||
|
||||
virtual void begin();
|
||||
virtual bool end( bool ok = true );
|
||||
virtual bool accept( QPolygon & ) const;
|
||||
|
||||
private:
|
||||
void init( bool doReplot );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
189
include/qwt_point_3d.h
Normal file
189
include/qwt_point_3d.h
Normal file
|
@ -0,0 +1,189 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
/*! \file */
|
||||
#ifndef QWT_POINT_3D_H
|
||||
#define QWT_POINT_3D_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpoint.h>
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
#include <qdebug.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\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 QwtPoint3D & );
|
||||
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 d_x;
|
||||
double d_y;
|
||||
double d_z;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(QwtPoint3D, Q_MOVABLE_TYPE);
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QWT_EXPORT QDebug operator<<( QDebug, const QwtPoint3D & );
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Constructs a null point.
|
||||
\sa isNull()
|
||||
*/
|
||||
inline QwtPoint3D::QwtPoint3D():
|
||||
d_x( 0.0 ),
|
||||
d_y( 0.0 ),
|
||||
d_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 ):
|
||||
d_x( x ),
|
||||
d_y( y ),
|
||||
d_z( z )
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Copy constructor.
|
||||
Constructs a point using the values of the point specified.
|
||||
*/
|
||||
inline QwtPoint3D::QwtPoint3D( const QwtPoint3D &other ):
|
||||
d_x( other.d_x ),
|
||||
d_y( other.d_y ),
|
||||
d_z( other.d_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 ):
|
||||
d_x( other.x() ),
|
||||
d_y( other.y() ),
|
||||
d_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 d_x == 0.0 && d_y == 0.0 && d_z == 0.0;
|
||||
}
|
||||
|
||||
//! \return The x-coordinate of the point.
|
||||
inline double QwtPoint3D::x() const
|
||||
{
|
||||
return d_x;
|
||||
}
|
||||
|
||||
//! \return The y-coordinate of the point.
|
||||
inline double QwtPoint3D::y() const
|
||||
{
|
||||
return d_y;
|
||||
}
|
||||
|
||||
//! \return The z-coordinate of the point.
|
||||
inline double QwtPoint3D::z() const
|
||||
{
|
||||
return d_z;
|
||||
}
|
||||
|
||||
//! \return A reference to the x-coordinate of the point.
|
||||
inline double &QwtPoint3D::rx()
|
||||
{
|
||||
return d_x;
|
||||
}
|
||||
|
||||
//! \return A reference to the y-coordinate of the point.
|
||||
inline double &QwtPoint3D::ry()
|
||||
{
|
||||
return d_y;
|
||||
}
|
||||
|
||||
//! \return A reference to the z-coordinate of the point.
|
||||
inline double &QwtPoint3D::rz()
|
||||
{
|
||||
return d_z;
|
||||
}
|
||||
|
||||
//! Sets the x-coordinate of the point to the value specified by x.
|
||||
inline void QwtPoint3D::setX( double x )
|
||||
{
|
||||
d_x = x;
|
||||
}
|
||||
|
||||
//! Sets the y-coordinate of the point to the value specified by y.
|
||||
inline void QwtPoint3D::setY( double y )
|
||||
{
|
||||
d_y = y;
|
||||
}
|
||||
|
||||
//! Sets the z-coordinate of the point to the value specified by z.
|
||||
inline void QwtPoint3D::setZ( double z )
|
||||
{
|
||||
d_z = z;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return 2D point, where the z coordinate is dropped.
|
||||
*/
|
||||
inline QPointF QwtPoint3D::toPoint() const
|
||||
{
|
||||
return QPointF( d_x, d_y );
|
||||
}
|
||||
|
||||
//! \return True, if this point and other are equal; otherwise returns false.
|
||||
inline bool QwtPoint3D::operator==( const QwtPoint3D &other ) const
|
||||
{
|
||||
return ( d_x == other.d_x ) && ( d_y == other.d_y ) && ( d_z == other.d_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
|
146
include/qwt_point_data.h
Normal file
146
include/qwt_point_data.h
Normal file
|
@ -0,0 +1,146 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_POINT_DATA_H
|
||||
#define QWT_POINT_DATA_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_series_data.h"
|
||||
|
||||
/*!
|
||||
\brief Interface for iterating over two QVector<double> objects.
|
||||
*/
|
||||
class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
|
||||
{
|
||||
public:
|
||||
QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
|
||||
QwtPointArrayData( const double *x, const double *y, size_t size );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual size_t size() const;
|
||||
virtual QPointF sample( size_t i ) const;
|
||||
|
||||
const QVector<double> &xData() const;
|
||||
const QVector<double> &yData() const;
|
||||
|
||||
private:
|
||||
QVector<double> d_x;
|
||||
QVector<double> d_y;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Data class containing two pointers to memory blocks of doubles.
|
||||
*/
|
||||
class QWT_EXPORT QwtCPointerData: public QwtSeriesData<QPointF>
|
||||
{
|
||||
public:
|
||||
QwtCPointerData( const double *x, const double *y, size_t size );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual size_t size() const;
|
||||
virtual QPointF sample( size_t i ) const;
|
||||
|
||||
const double *xData() const;
|
||||
const double *yData() const;
|
||||
|
||||
private:
|
||||
const double *d_x;
|
||||
const double *d_y;
|
||||
size_t d_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( QwtPlot::xBottom, 0.0, 10.0 );
|
||||
plot.setAxisScale( QwtPlot::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;
|
||||
|
||||
void setInterval( const QwtInterval& );
|
||||
QwtInterval interval() const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual QPointF sample( size_t i ) const;
|
||||
|
||||
/*!
|
||||
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 & );
|
||||
QRectF rectOfInterest() const;
|
||||
|
||||
private:
|
||||
size_t d_size;
|
||||
QwtInterval d_interval;
|
||||
QRectF d_rectOfInterest;
|
||||
QwtInterval d_intervalOfInterest;
|
||||
};
|
||||
|
||||
#endif
|
89
include/qwt_point_mapper.h
Normal file
89
include/qwt_point_mapper.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_POINT_MAPPER_H
|
||||
#define QWT_POINT_MAPPER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_series_data.h"
|
||||
#include <qimage.h>
|
||||
|
||||
class QwtScaleMap;
|
||||
class QPolygonF;
|
||||
class QPolygon;
|
||||
|
||||
/*!
|
||||
\brief A helper class for translating a series of points
|
||||
|
||||
QwtPointMapper is a collection of methods and optimizations
|
||||
for translating a series of points into paint device coordinates.
|
||||
It is used by QwtPlotCurve but might also be useful for
|
||||
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
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Flags affecting the transformation process
|
||||
\sa setFlag(), setFlags()
|
||||
*/
|
||||
typedef QFlags<TransformationFlag> TransformationFlags;
|
||||
|
||||
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:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPointMapper::TransformationFlags )
|
||||
|
||||
#endif
|
201
include/qwt_point_polar.h
Normal file
201
include/qwt_point_polar.h
Normal file
|
@ -0,0 +1,201 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
/*! \file */
|
||||
#ifndef _QWT_POINT_POLAR_H_
|
||||
#define _QWT_POINT_POLAR_H_ 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_math.h"
|
||||
#include <qpoint.h>
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
#include <qdebug.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\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 QwtPointPolar & );
|
||||
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 d_azimuth;
|
||||
double d_radius;
|
||||
};
|
||||
|
||||
/*!
|
||||
Constructs a null point, with a radius and azimuth set to 0.0.
|
||||
\sa QPointF::isNull()
|
||||
*/
|
||||
inline QwtPointPolar::QwtPointPolar():
|
||||
d_azimuth( 0.0 ),
|
||||
d_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 ):
|
||||
d_azimuth( azimuth ),
|
||||
d_radius( radius )
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a point using the values of the point specified.
|
||||
\param other Other point
|
||||
*/
|
||||
inline QwtPointPolar::QwtPointPolar( const QwtPointPolar &other ):
|
||||
d_azimuth( other.d_azimuth ),
|
||||
d_radius( other.d_radius )
|
||||
{
|
||||
}
|
||||
|
||||
//! Returns true if radius() >= 0.0
|
||||
inline bool QwtPointPolar::isValid() const
|
||||
{
|
||||
return d_radius >= 0.0;
|
||||
}
|
||||
|
||||
//! Returns true if radius() >= 0.0
|
||||
inline bool QwtPointPolar::isNull() const
|
||||
{
|
||||
return d_radius == 0.0;
|
||||
}
|
||||
|
||||
//! Returns the radius.
|
||||
inline double QwtPointPolar::radius() const
|
||||
{
|
||||
return d_radius;
|
||||
}
|
||||
|
||||
//! Returns the azimuth.
|
||||
inline double QwtPointPolar::azimuth() const
|
||||
{
|
||||
return d_azimuth;
|
||||
}
|
||||
|
||||
//! Returns the radius.
|
||||
inline double &QwtPointPolar::rRadius()
|
||||
{
|
||||
return d_radius;
|
||||
}
|
||||
|
||||
//! Returns the azimuth.
|
||||
inline double &QwtPointPolar::rAzimuth()
|
||||
{
|
||||
return d_azimuth;
|
||||
}
|
||||
|
||||
//! Sets the radius to radius.
|
||||
inline void QwtPointPolar::setRadius( double radius )
|
||||
{
|
||||
d_radius = radius;
|
||||
}
|
||||
|
||||
//! Sets the atimuth to atimuth.
|
||||
inline void QwtPointPolar::setAzimuth( double azimuth )
|
||||
{
|
||||
d_azimuth = azimuth;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QWT_EXPORT QDebug operator<<( QDebug, const QwtPointPolar & );
|
||||
#endif
|
||||
|
||||
inline QPoint qwtPolar2Pos( const QPoint &pole,
|
||||
double radius, double angle )
|
||||
{
|
||||
const double x = pole.x() + radius * qCos( angle );
|
||||
const double y = pole.y() - radius * qSin( 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 * qCos( angle );
|
||||
const double y = pole.y() - radius * qSin( 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 )
|
||||
{
|
||||
#if QT_VERSION < 0x040601
|
||||
const double x = pole.x() + radius * ::cos( angle );
|
||||
const double y = pole.y() - radius * ::sin( angle );
|
||||
#else
|
||||
const double x = pole.x() + radius * qFastCos( angle );
|
||||
const double y = pole.y() - radius * qFastSin( angle );
|
||||
#endif
|
||||
|
||||
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
|
95
include/qwt_raster_data.h
Normal file
95
include/qwt_raster_data.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_RASTER_DATA_H
|
||||
#define QWT_RASTER_DATA_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qmap.h>
|
||||
#include <qlist.h>
|
||||
#include <qpolygon.h>
|
||||
|
||||
class QwtScaleMap;
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
||||
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 ).
|
||||
*/
|
||||
class QWT_EXPORT QwtRasterData
|
||||
{
|
||||
public:
|
||||
//! Contour lines
|
||||
typedef QMap<double, QPolygonF> ContourLines;
|
||||
|
||||
//! 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
|
||||
};
|
||||
|
||||
//! Flags to modify the contour algorithm
|
||||
typedef QFlags<ConrecFlag> ConrecFlags;
|
||||
|
||||
QwtRasterData();
|
||||
virtual ~QwtRasterData();
|
||||
|
||||
virtual void setInterval( Qt::Axis, const QwtInterval & );
|
||||
const QwtInterval &interval(Qt::Axis) const;
|
||||
|
||||
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:
|
||||
// Disabled copy constructor and operator=
|
||||
QwtRasterData( const QwtRasterData & );
|
||||
QwtRasterData &operator=( const QwtRasterData & );
|
||||
|
||||
QwtInterval d_intervals[3];
|
||||
};
|
||||
|
||||
/*!
|
||||
\return Bounding interval for a axis
|
||||
\sa setInterval
|
||||
*/
|
||||
inline const QwtInterval &QwtRasterData::interval( Qt::Axis axis) const
|
||||
{
|
||||
return d_intervals[axis];
|
||||
}
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtRasterData::ConrecFlags )
|
||||
|
||||
#endif
|
66
include/qwt_round_scale_draw.h
Normal file
66
include/qwt_round_scale_draw.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_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;
|
||||
|
||||
protected:
|
||||
virtual void drawTick( QPainter *, double val, double len ) const;
|
||||
virtual void drawBackbone( QPainter * ) const;
|
||||
virtual void drawLabel( QPainter *, double val ) const;
|
||||
|
||||
private:
|
||||
QwtRoundScaleDraw( const QwtRoundScaleDraw & );
|
||||
QwtRoundScaleDraw &operator=( const QwtRoundScaleDraw &other );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_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
|
239
include/qwt_samples.h
Normal file
239
include/qwt_samples.h
Normal file
|
@ -0,0 +1,239 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SAMPLES_H
|
||||
#define QWT_SAMPLES_H 1
|
||||
|
||||
#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();
|
||||
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 );
|
||||
}
|
||||
|
||||
#endif
|
50
include/qwt_sampling_thread.h
Normal file
50
include/qwt_sampling_thread.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#ifndef _QWT_SAMPLING_THREAD_H_
|
||||
#define _QWT_SAMPLING_THREAD_H_
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qthread.h>
|
||||
|
||||
/*!
|
||||
\brief A thread collecting samples at regular intervals.
|
||||
|
||||
Continuous signals are converted into a discrete signal by
|
||||
collecting samples at regular intervals. A discrete signal
|
||||
can be displayed by a QwtPlotSeriesItem on a QwtPlot widget.
|
||||
|
||||
QwtSamplingThread starts a thread calling periodically sample(),
|
||||
to collect and store ( or emit ) a single sample.
|
||||
|
||||
\sa QwtPlotCurve, QwtPlotSeriesItem
|
||||
*/
|
||||
class QWT_EXPORT QwtSamplingThread: public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~QwtSamplingThread();
|
||||
|
||||
double interval() const;
|
||||
double elapsed() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setInterval( double interval );
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
explicit QwtSamplingThread( QObject *parent = NULL );
|
||||
|
||||
virtual void run();
|
||||
|
||||
/*!
|
||||
Collect a sample
|
||||
|
||||
\param elapsed Time since the thread was started in milliseconds
|
||||
*/
|
||||
virtual void sample( double elapsed ) = 0;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
110
include/qwt_scale_div.h
Normal file
110
include/qwt_scale_div.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SCALE_DIV_H
|
||||
#define QWT_SCALE_DIV_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_interval.h"
|
||||
#include <qlist.h>
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
#include <qdebug.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief A class representing a scale division
|
||||
|
||||
A Qwt scale is defined by its boundaries and 3 list
|
||||
for the positions of the major, medium and minor ticks.
|
||||
|
||||
The upperBound() might be smaller than the lowerBound()
|
||||
to indicate inverted scales.
|
||||
|
||||
Scale divisions can be calculated from a QwtScaleEngine.
|
||||
|
||||
\sa QwtScaleEngine::divideScale(), QwtPlot::setAxisScaleDiv(),
|
||||
QwtAbstractSlider::setScaleDiv()
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtScaleDiv
|
||||
{
|
||||
public:
|
||||
//! Scale tick types
|
||||
enum TickType
|
||||
{
|
||||
//! No ticks
|
||||
NoTick = -1,
|
||||
|
||||
//! Minor ticks
|
||||
MinorTick,
|
||||
|
||||
//! Medium ticks
|
||||
MediumTick,
|
||||
|
||||
//! Major ticks
|
||||
MajorTick,
|
||||
|
||||
//! Number of valid tick types
|
||||
NTickTypes
|
||||
};
|
||||
|
||||
explicit QwtScaleDiv( double lowerBound = 0.0,
|
||||
double upperBound = 0.0 );
|
||||
|
||||
explicit QwtScaleDiv( const QwtInterval &, QList<double>[NTickTypes] );
|
||||
|
||||
explicit QwtScaleDiv( double lowerBound, double upperBound,
|
||||
QList<double>[NTickTypes] );
|
||||
|
||||
explicit QwtScaleDiv( double lowerBound, double upperBound,
|
||||
const QList<double> &minorTicks, const QList<double> &mediumTicks,
|
||||
const QList<double> &majorTicks );
|
||||
|
||||
bool operator==( const QwtScaleDiv & ) const;
|
||||
bool operator!=( const QwtScaleDiv & ) const;
|
||||
|
||||
void setInterval( double lowerBound, double upperBound );
|
||||
void setInterval( const QwtInterval & );
|
||||
QwtInterval interval() const;
|
||||
|
||||
void setLowerBound( double );
|
||||
double lowerBound() const;
|
||||
|
||||
void setUpperBound( double );
|
||||
double upperBound() const;
|
||||
|
||||
double range() const;
|
||||
|
||||
bool contains( double value ) const;
|
||||
|
||||
void setTicks( int tickType, const QList<double> & );
|
||||
QList<double> ticks( int tickType ) const;
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isIncreasing() const;
|
||||
|
||||
void invert();
|
||||
QwtScaleDiv inverted() const;
|
||||
|
||||
QwtScaleDiv bounded( double lowerBound, double upperBound ) const;
|
||||
|
||||
private:
|
||||
double d_lowerBound;
|
||||
double d_upperBound;
|
||||
QList<double> d_ticks[NTickTypes];
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO( QwtScaleDiv, Q_MOVABLE_TYPE );
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleDiv & );
|
||||
#endif
|
||||
|
||||
#endif
|
120
include/qwt_scale_draw.h
Normal file
120
include/qwt_scale_draw.h
Normal file
|
@ -0,0 +1,120 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SCALE_DRAW_H
|
||||
#define QWT_SCALE_DRAW_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_abstract_scale_draw.h"
|
||||
#include <qpoint.h>
|
||||
#include <qrect.h>
|
||||
#include <qtransform.h>
|
||||
|
||||
/*!
|
||||
\brief A class for drawing scales
|
||||
|
||||
QwtScaleDraw can be used to draw linear or logarithmic scales.
|
||||
A scale has a position, an alignment and a length, which can be specified .
|
||||
The labels can be rotated and aligned
|
||||
to the ticks using setLabelRotation() and setLabelAlignment().
|
||||
|
||||
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 QwtScaleDraw: public QwtAbstractScaleDraw
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Alignment of the scale draw
|
||||
\sa setAlignment(), alignment()
|
||||
*/
|
||||
enum Alignment
|
||||
{
|
||||
//! The scale is below
|
||||
BottomScale,
|
||||
|
||||
//! The scale is above
|
||||
TopScale,
|
||||
|
||||
//! The scale is left
|
||||
LeftScale,
|
||||
|
||||
//! The scale is right
|
||||
RightScale
|
||||
};
|
||||
|
||||
QwtScaleDraw();
|
||||
virtual ~QwtScaleDraw();
|
||||
|
||||
void getBorderDistHint( const QFont &, int &start, int &end ) const;
|
||||
int minLabelDist( const QFont & ) const;
|
||||
|
||||
int minLength( const QFont & ) const;
|
||||
virtual double extent( const QFont & ) const;
|
||||
|
||||
void move( double x, double y );
|
||||
void move( const QPointF & );
|
||||
void setLength( double length );
|
||||
|
||||
Alignment alignment() const;
|
||||
void setAlignment( Alignment );
|
||||
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
QPointF pos() const;
|
||||
double length() const;
|
||||
|
||||
void setLabelAlignment( Qt::Alignment );
|
||||
Qt::Alignment labelAlignment() const;
|
||||
|
||||
void setLabelRotation( double rotation );
|
||||
double labelRotation() const;
|
||||
|
||||
int maxLabelHeight( const QFont & ) const;
|
||||
int maxLabelWidth( const QFont & ) const;
|
||||
|
||||
QPointF labelPosition( double val ) const;
|
||||
|
||||
QRectF labelRect( const QFont &, double val ) const;
|
||||
QSizeF labelSize( const QFont &, double val ) const;
|
||||
|
||||
QRect boundingLabelRect( const QFont &, double val ) const;
|
||||
|
||||
protected:
|
||||
QTransform labelTransformation( const QPointF &, const QSizeF & ) const;
|
||||
|
||||
virtual void drawTick( QPainter *, double val, double len ) const;
|
||||
virtual void drawBackbone( QPainter * ) const;
|
||||
virtual void drawLabel( QPainter *, double val ) const;
|
||||
|
||||
private:
|
||||
QwtScaleDraw( const QwtScaleDraw & );
|
||||
QwtScaleDraw &operator=( const QwtScaleDraw &other );
|
||||
|
||||
void updateMap();
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
/*!
|
||||
Move the position of the scale
|
||||
|
||||
\param x X coordinate
|
||||
\param y Y coordinate
|
||||
|
||||
\sa move(const QPointF &)
|
||||
*/
|
||||
inline void QwtScaleDraw::move( double x, double y )
|
||||
{
|
||||
move( QPointF( x, y ) );
|
||||
}
|
||||
|
||||
#endif
|
220
include/qwt_scale_engine.h
Normal file
220
include/qwt_scale_engine.h
Normal file
|
@ -0,0 +1,220 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SCALE_ENGINE_H
|
||||
#define QWT_SCALE_ENGINE_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_scale_div.h"
|
||||
#include "qwt_interval.h"
|
||||
|
||||
class QwtTransform;
|
||||
|
||||
/*!
|
||||
\brief Arithmetic including a tolerance
|
||||
*/
|
||||
class QWT_EXPORT QwtScaleArithmetic
|
||||
{
|
||||
public:
|
||||
static double ceilEps( double value, double intervalSize );
|
||||
static double floorEps( double value, double intervalSize );
|
||||
|
||||
static double divideEps( double interval, double steps );
|
||||
|
||||
static double divideInterval( double interval,
|
||||
int numSteps, uint base );
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Base class for scale engines.
|
||||
|
||||
A scale engine tries to find "reasonable" ranges and step sizes
|
||||
for scales.
|
||||
|
||||
The layout of the scale can be varied with setAttribute().
|
||||
|
||||
Qwt offers implementations for logarithmic and linear scales.
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtScaleEngine
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Layout attributes
|
||||
\sa setAttribute(), testAttribute(), reference(),
|
||||
lowerMargin(), upperMargin()
|
||||
*/
|
||||
|
||||
enum Attribute
|
||||
{
|
||||
//! No attributes
|
||||
NoAttribute = 0x00,
|
||||
|
||||
//! Build a scale which includes the reference() value.
|
||||
IncludeReference = 0x01,
|
||||
|
||||
//! Build a scale which is symmetric to the reference() value.
|
||||
Symmetric = 0x02,
|
||||
|
||||
/*!
|
||||
The endpoints of the scale are supposed to be equal the
|
||||
outmost included values plus the specified margins
|
||||
(see setMargins()).
|
||||
If this attribute is *not* set, the endpoints of the scale will
|
||||
be integer multiples of the step size.
|
||||
*/
|
||||
Floating = 0x04,
|
||||
|
||||
//! Turn the scale upside down.
|
||||
Inverted = 0x08
|
||||
};
|
||||
|
||||
//! Layout attributes
|
||||
typedef QFlags<Attribute> Attributes;
|
||||
|
||||
explicit QwtScaleEngine( uint base = 10 );
|
||||
virtual ~QwtScaleEngine();
|
||||
|
||||
void setBase( uint base );
|
||||
uint base() const;
|
||||
|
||||
void setAttribute( Attribute, bool on = true );
|
||||
bool testAttribute( Attribute ) const;
|
||||
|
||||
void setAttributes( Attributes );
|
||||
Attributes attributes() const;
|
||||
|
||||
void setReference( double reference );
|
||||
double reference() const;
|
||||
|
||||
void setMargins( double lower, double upper );
|
||||
double lowerMargin() const;
|
||||
double upperMargin() const;
|
||||
|
||||
/*!
|
||||
Align and divide an interval
|
||||
|
||||
\param maxNumSteps Max. number of steps
|
||||
\param x1 First limit of the interval (In/Out)
|
||||
\param x2 Second limit of the interval (In/Out)
|
||||
\param stepSize Step size (Return value)
|
||||
*/
|
||||
virtual void autoScale( int maxNumSteps,
|
||||
double &x1, double &x2, double &stepSize ) const = 0;
|
||||
|
||||
/*!
|
||||
\brief Calculate a scale division
|
||||
|
||||
\param x1 First interval limit
|
||||
\param x2 Second interval limit
|
||||
\param maxMajorSteps Maximum for the number of major steps
|
||||
\param maxMinorSteps Maximum number of minor steps
|
||||
\param stepSize Step size. If stepSize == 0.0, the scaleEngine
|
||||
calculates one.
|
||||
|
||||
\return Calculated scale division
|
||||
*/
|
||||
virtual QwtScaleDiv divideScale( double x1, double x2,
|
||||
int maxMajorSteps, int maxMinorSteps,
|
||||
double stepSize = 0.0 ) const = 0;
|
||||
|
||||
void setTransformation( QwtTransform * );
|
||||
QwtTransform *transformation() const;
|
||||
|
||||
protected:
|
||||
bool contains( const QwtInterval &, double val ) const;
|
||||
QList<double> strip( const QList<double>&, const QwtInterval & ) const;
|
||||
|
||||
double divideInterval( double interval, int numSteps ) const;
|
||||
|
||||
QwtInterval buildInterval( double v ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief A scale engine for linear scales
|
||||
|
||||
The step size will fit into the pattern
|
||||
\f$\left\{ 1,2,5\right\} \cdot 10^{n}\f$, where n is an integer.
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
|
||||
{
|
||||
public:
|
||||
QwtLinearScaleEngine( uint base = 10 );
|
||||
virtual ~QwtLinearScaleEngine();
|
||||
|
||||
virtual void autoScale( int maxSteps,
|
||||
double &x1, double &x2, double &stepSize ) const;
|
||||
|
||||
virtual QwtScaleDiv divideScale( double x1, double x2,
|
||||
int numMajorSteps, int numMinorSteps,
|
||||
double stepSize = 0.0 ) const;
|
||||
|
||||
|
||||
protected:
|
||||
QwtInterval align( const QwtInterval&, double stepSize ) const;
|
||||
|
||||
void buildTicks(
|
||||
const QwtInterval &, double stepSize, int maxMinSteps,
|
||||
QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
|
||||
|
||||
QList<double> buildMajorTicks(
|
||||
const QwtInterval &interval, double stepSize ) const;
|
||||
|
||||
void buildMinorTicks( const QList<double>& majorTicks,
|
||||
int maxMinorSteps, double stepSize,
|
||||
QList<double> &minorTicks, QList<double> &mediumTicks ) const;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief A scale engine for logarithmic scales
|
||||
|
||||
The step size is measured in *decades*
|
||||
and the major step size will be adjusted to fit the pattern
|
||||
\f$\left\{ 1,2,3,5\right\} \cdot 10^{n}\f$, where n is a natural number
|
||||
including zero.
|
||||
|
||||
\warning the step size as well as the margins are measured in *decades*.
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtLogScaleEngine: public QwtScaleEngine
|
||||
{
|
||||
public:
|
||||
QwtLogScaleEngine( uint base = 10 );
|
||||
virtual ~QwtLogScaleEngine();
|
||||
|
||||
virtual void autoScale( int maxSteps,
|
||||
double &x1, double &x2, double &stepSize ) const;
|
||||
|
||||
virtual QwtScaleDiv divideScale( double x1, double x2,
|
||||
int numMajorSteps, int numMinorSteps,
|
||||
double stepSize = 0.0 ) const;
|
||||
|
||||
protected:
|
||||
QwtInterval align( const QwtInterval&, double stepSize ) const;
|
||||
|
||||
void buildTicks(
|
||||
const QwtInterval &, double stepSize, int maxMinSteps,
|
||||
QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
|
||||
|
||||
QList<double> buildMajorTicks(
|
||||
const QwtInterval &interval, double stepSize ) const;
|
||||
|
||||
void buildMinorTicks( const QList<double>& majorTicks,
|
||||
int maxMinorSteps, double stepSize,
|
||||
QList<double> &minorTicks, QList<double> &mediumTicks ) const;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
|
||||
|
||||
#endif
|
175
include/qwt_scale_map.h
Normal file
175
include/qwt_scale_map.h
Normal file
|
@ -0,0 +1,175 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SCALE_MAP_H
|
||||
#define QWT_SCALE_MAP_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_transform.h"
|
||||
#include <qrect.h>
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
#include <qdebug.h>
|
||||
#endif
|
||||
|
||||
class QRectF;
|
||||
|
||||
/*!
|
||||
\brief A scale map
|
||||
|
||||
QwtScaleMap offers transformations from the coordinate system
|
||||
of a scale into the linear coordinate system of a paint device
|
||||
and vice versa.
|
||||
*/
|
||||
class QWT_EXPORT QwtScaleMap
|
||||
{
|
||||
public:
|
||||
QwtScaleMap();
|
||||
QwtScaleMap( const QwtScaleMap& );
|
||||
|
||||
~QwtScaleMap();
|
||||
|
||||
QwtScaleMap &operator=( const QwtScaleMap & );
|
||||
|
||||
void setTransformation( QwtTransform * );
|
||||
const QwtTransform *transformation() const;
|
||||
|
||||
void setPaintInterval( double p1, double p2 );
|
||||
void setScaleInterval( double s1, double s2 );
|
||||
|
||||
double transform( double s ) const;
|
||||
double invTransform( double p ) const;
|
||||
|
||||
double p1() const;
|
||||
double p2() const;
|
||||
|
||||
double s1() const;
|
||||
double s2() const;
|
||||
|
||||
double pDist() const;
|
||||
double sDist() const;
|
||||
|
||||
static QRectF transform( const QwtScaleMap &,
|
||||
const QwtScaleMap &, const QRectF & );
|
||||
static QRectF invTransform( const QwtScaleMap &,
|
||||
const QwtScaleMap &, const QRectF & );
|
||||
|
||||
static QPointF transform( const QwtScaleMap &,
|
||||
const QwtScaleMap &, const QPointF & );
|
||||
static QPointF invTransform( const QwtScaleMap &,
|
||||
const QwtScaleMap &, const QPointF & );
|
||||
|
||||
bool isInverting() const;
|
||||
|
||||
private:
|
||||
void updateFactor();
|
||||
|
||||
double d_s1, d_s2; // scale interval boundaries
|
||||
double d_p1, d_p2; // paint device interval boundaries
|
||||
|
||||
double d_cnv; // conversion factor
|
||||
double d_ts1;
|
||||
|
||||
QwtTransform *d_transform;
|
||||
};
|
||||
|
||||
/*!
|
||||
\return First border of the scale interval
|
||||
*/
|
||||
inline double QwtScaleMap::s1() const
|
||||
{
|
||||
return d_s1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Second border of the scale interval
|
||||
*/
|
||||
inline double QwtScaleMap::s2() const
|
||||
{
|
||||
return d_s2;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return First border of the paint interval
|
||||
*/
|
||||
inline double QwtScaleMap::p1() const
|
||||
{
|
||||
return d_p1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Second border of the paint interval
|
||||
*/
|
||||
inline double QwtScaleMap::p2() const
|
||||
{
|
||||
return d_p2;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return qwtAbs(p2() - p1())
|
||||
*/
|
||||
inline double QwtScaleMap::pDist() const
|
||||
{
|
||||
return qAbs( d_p2 - d_p1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
\return qwtAbs(s2() - s1())
|
||||
*/
|
||||
inline double QwtScaleMap::sDist() const
|
||||
{
|
||||
return qAbs( d_s2 - d_s1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
Transform a point related to the scale interval into an point
|
||||
related to the interval of the paint device
|
||||
|
||||
\param s Value relative to the coordinates of the scale
|
||||
\return Transformed value
|
||||
|
||||
\sa invTransform()
|
||||
*/
|
||||
inline double QwtScaleMap::transform( double s ) const
|
||||
{
|
||||
if ( d_transform )
|
||||
s = d_transform->transform( s );
|
||||
|
||||
return d_p1 + ( s - d_ts1 ) * d_cnv;
|
||||
}
|
||||
|
||||
/*!
|
||||
Transform an paint device value into a value in the
|
||||
interval of the scale.
|
||||
|
||||
\param p Value relative to the coordinates of the paint device
|
||||
\return Transformed value
|
||||
|
||||
\sa transform()
|
||||
*/
|
||||
inline double QwtScaleMap::invTransform( double p ) const
|
||||
{
|
||||
double s = d_ts1 + ( p - d_p1 ) / d_cnv;
|
||||
if ( d_transform )
|
||||
s = d_transform->invTransform( s );
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \return True, when ( p1() < p2() ) != ( s1() < s2() )
|
||||
inline bool QwtScaleMap::isInverting() const
|
||||
{
|
||||
return ( ( d_p1 < d_p2 ) != ( d_s1 < d_s2 ) );
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap & );
|
||||
#endif
|
||||
|
||||
#endif
|
136
include/qwt_scale_widget.h
Normal file
136
include/qwt_scale_widget.h
Normal file
|
@ -0,0 +1,136 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SCALE_WIDGET_H
|
||||
#define QWT_SCALE_WIDGET_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_scale_draw.h"
|
||||
#include <qwidget.h>
|
||||
#include <qfont.h>
|
||||
#include <qcolor.h>
|
||||
#include <qstring.h>
|
||||
|
||||
class QPainter;
|
||||
class QwtTransform;
|
||||
class QwtScaleDiv;
|
||||
class QwtColorMap;
|
||||
|
||||
/*!
|
||||
\brief A Widget which contains a scale
|
||||
|
||||
This Widget can be used to decorate composite widgets with
|
||||
a scale.
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtScaleWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Layout flags of the title
|
||||
enum LayoutFlag
|
||||
{
|
||||
/*!
|
||||
The title of vertical scales is painted from top to bottom.
|
||||
Otherwise it is painted from bottom to top.
|
||||
*/
|
||||
TitleInverted = 1
|
||||
};
|
||||
|
||||
//! Layout flags of the title
|
||||
typedef QFlags<LayoutFlag> LayoutFlags;
|
||||
|
||||
explicit QwtScaleWidget( QWidget *parent = NULL );
|
||||
explicit QwtScaleWidget( QwtScaleDraw::Alignment, QWidget *parent = NULL );
|
||||
virtual ~QwtScaleWidget();
|
||||
|
||||
Q_SIGNALS:
|
||||
//! Signal emitted, whenever the scale division changes
|
||||
void scaleDivChanged();
|
||||
|
||||
public:
|
||||
void setTitle( const QString &title );
|
||||
void setTitle( const QwtText &title );
|
||||
QwtText title() const;
|
||||
|
||||
void setLayoutFlag( LayoutFlag, bool on );
|
||||
bool testLayoutFlag( LayoutFlag ) const;
|
||||
|
||||
void setBorderDist( int start, int end );
|
||||
int startBorderDist() const;
|
||||
int endBorderDist() const;
|
||||
|
||||
void getBorderDistHint( int &start, int &end ) const;
|
||||
|
||||
void getMinBorderDist( int &start, int &end ) const;
|
||||
void setMinBorderDist( int start, int end );
|
||||
|
||||
void setMargin( int );
|
||||
int margin() const;
|
||||
|
||||
void setSpacing( int td );
|
||||
int spacing() const;
|
||||
|
||||
void setScaleDiv( const QwtScaleDiv &sd );
|
||||
void setTransformation( QwtTransform * );
|
||||
|
||||
void setScaleDraw( QwtScaleDraw * );
|
||||
const QwtScaleDraw *scaleDraw() const;
|
||||
QwtScaleDraw *scaleDraw();
|
||||
|
||||
void setLabelAlignment( Qt::Alignment );
|
||||
void setLabelRotation( double rotation );
|
||||
|
||||
void setColorBarEnabled( bool );
|
||||
bool isColorBarEnabled() const;
|
||||
|
||||
void setColorBarWidth( int );
|
||||
int colorBarWidth() const;
|
||||
|
||||
void setColorMap( const QwtInterval &, QwtColorMap * );
|
||||
|
||||
QwtInterval colorBarInterval() const;
|
||||
const QwtColorMap *colorMap() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
int titleHeightForWidth( int width ) const;
|
||||
int dimForLength( int length, const QFont &scaleFont ) const;
|
||||
|
||||
void drawColorBar( QPainter *painter, const QRectF & ) const;
|
||||
void drawTitle( QPainter *painter, QwtScaleDraw::Alignment,
|
||||
const QRectF &rect ) const;
|
||||
|
||||
void setAlignment( QwtScaleDraw::Alignment );
|
||||
QwtScaleDraw::Alignment alignment() const;
|
||||
|
||||
QRectF colorBarRect( const QRectF& ) const;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
void draw( QPainter *p ) const;
|
||||
|
||||
void scaleChange();
|
||||
void layoutScale( bool update = true );
|
||||
|
||||
private:
|
||||
void initScale( QwtScaleDraw::Alignment );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleWidget::LayoutFlags )
|
||||
|
||||
#endif
|
355
include/qwt_series_data.h
Normal file
355
include/qwt_series_data.h
Normal file
|
@ -0,0 +1,355 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SERIES_DATA_H
|
||||
#define QWT_SERIES_DATA_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_samples.h"
|
||||
#include "qwt_point_3d.h"
|
||||
#include "qwt_point_polar.h"
|
||||
#include <qvector.h>
|
||||
#include <qrect.h>
|
||||
|
||||
/*!
|
||||
\brief Abstract interface for iterating over samples
|
||||
|
||||
Qwt offers several implementations of the QwtSeriesData API,
|
||||
but in situations, where data of an application specific format
|
||||
needs to be displayed, without having to copy it, it is recommended
|
||||
to implement an individual data access.
|
||||
|
||||
A subclass of QwtSeriesData<QPointF> must implement:
|
||||
|
||||
- size()\n
|
||||
Should return number of data points.
|
||||
|
||||
- sample()\n
|
||||
Should return values x and y values of the sample at specific position
|
||||
as QPointF object.
|
||||
|
||||
- boundingRect()\n
|
||||
Should return the bounding rectangle of the data series.
|
||||
It is used for autoscaling and might help certain algorithms for displaying
|
||||
the data. You can use qwtBoundingRect() for an implementation
|
||||
but often it is possible to implement a more efficient algorithm
|
||||
depending on the characteristics of the series.
|
||||
The member d_boundingRect is intended for caching the calculated rectangle.
|
||||
|
||||
*/
|
||||
template <typename T>
|
||||
class QwtSeriesData
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
QwtSeriesData();
|
||||
|
||||
//! Destructor
|
||||
virtual ~QwtSeriesData();
|
||||
|
||||
//! \return Number of samples
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
/*!
|
||||
Return a sample
|
||||
\param i Index
|
||||
\return Sample at position i
|
||||
*/
|
||||
virtual T sample( size_t i ) const = 0;
|
||||
|
||||
/*!
|
||||
Calculate the bounding rect of all samples
|
||||
|
||||
The bounding rect is necessary for autoscaling and can be used
|
||||
for a couple of painting optimizations.
|
||||
|
||||
qwtBoundingRect(...) offers slow implementations iterating
|
||||
over the samples. For large sets it is recommended to implement
|
||||
something faster f.e. by caching the bounding rectangle.
|
||||
|
||||
\return Bounding rectangle
|
||||
*/
|
||||
virtual QRectF boundingRect() const = 0;
|
||||
|
||||
/*!
|
||||
Set a the "rect of interest"
|
||||
|
||||
QwtPlotSeriesItem defines the current area of the plot canvas
|
||||
as "rectangle of interest" ( QwtPlotSeriesItem::updateScaleDiv() ).
|
||||
It can be used to implement different levels of details.
|
||||
|
||||
The default implementation does nothing.
|
||||
|
||||
\param rect Rectangle of interest
|
||||
*/
|
||||
virtual void setRectOfInterest( const QRectF &rect );
|
||||
|
||||
protected:
|
||||
//! Can be used to cache a calculated bounding rectangle
|
||||
mutable QRectF d_boundingRect;
|
||||
|
||||
private:
|
||||
QwtSeriesData<T> &operator=( const QwtSeriesData<T> & );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
QwtSeriesData<T>::QwtSeriesData():
|
||||
d_boundingRect( 0.0, 0.0, -1.0, -1.0 )
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QwtSeriesData<T>::~QwtSeriesData()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QwtSeriesData<T>::setRectOfInterest( const QRectF & )
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Template class for data, that is organized as QVector
|
||||
|
||||
QVector uses implicit data sharing and can be
|
||||
passed around as argument efficiently.
|
||||
*/
|
||||
template <typename T>
|
||||
class QwtArraySeriesData: public QwtSeriesData<T>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
QwtArraySeriesData();
|
||||
|
||||
/*!
|
||||
Constructor
|
||||
\param samples Array of samples
|
||||
*/
|
||||
QwtArraySeriesData( const QVector<T> &samples );
|
||||
|
||||
/*!
|
||||
Assign an array of samples
|
||||
\param samples Array of samples
|
||||
*/
|
||||
void setSamples( const QVector<T> &samples );
|
||||
|
||||
//! \return Array of samples
|
||||
const QVector<T> samples() const;
|
||||
|
||||
//! \return Number of samples
|
||||
virtual size_t size() const;
|
||||
|
||||
/*!
|
||||
\return Sample at a specific position
|
||||
|
||||
\param index Index
|
||||
\return Sample at position index
|
||||
*/
|
||||
virtual T sample( size_t index ) const;
|
||||
|
||||
protected:
|
||||
//! Vector of samples
|
||||
QVector<T> d_samples;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
QwtArraySeriesData<T>::QwtArraySeriesData()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QwtArraySeriesData<T>::QwtArraySeriesData( const QVector<T> &samples ):
|
||||
d_samples( samples )
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QwtArraySeriesData<T>::setSamples( const QVector<T> &samples )
|
||||
{
|
||||
QwtSeriesData<T>::d_boundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 );
|
||||
d_samples = samples;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const QVector<T> QwtArraySeriesData<T>::samples() const
|
||||
{
|
||||
return d_samples;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t QwtArraySeriesData<T>::size() const
|
||||
{
|
||||
return d_samples.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T QwtArraySeriesData<T>::sample( size_t i ) const
|
||||
{
|
||||
return d_samples[ static_cast<int>( i ) ];
|
||||
}
|
||||
|
||||
//! Interface for iterating over an array of points
|
||||
class QWT_EXPORT QwtPointSeriesData: public QwtArraySeriesData<QPointF>
|
||||
{
|
||||
public:
|
||||
QwtPointSeriesData(
|
||||
const QVector<QPointF> & = QVector<QPointF>() );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
};
|
||||
|
||||
//! Interface for iterating over an array of 3D points
|
||||
class QWT_EXPORT QwtPoint3DSeriesData: public QwtArraySeriesData<QwtPoint3D>
|
||||
{
|
||||
public:
|
||||
QwtPoint3DSeriesData(
|
||||
const QVector<QwtPoint3D> & = QVector<QwtPoint3D>() );
|
||||
virtual QRectF boundingRect() const;
|
||||
};
|
||||
|
||||
//! Interface for iterating over an array of intervals
|
||||
class QWT_EXPORT QwtIntervalSeriesData: public QwtArraySeriesData<QwtIntervalSample>
|
||||
{
|
||||
public:
|
||||
QwtIntervalSeriesData(
|
||||
const QVector<QwtIntervalSample> & = QVector<QwtIntervalSample>() );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
};
|
||||
|
||||
//! Interface for iterating over an array of samples
|
||||
class QWT_EXPORT QwtSetSeriesData: public QwtArraySeriesData<QwtSetSample>
|
||||
{
|
||||
public:
|
||||
QwtSetSeriesData(
|
||||
const QVector<QwtSetSample> & = QVector<QwtSetSample>() );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
Interface for iterating over an array of OHLC samples
|
||||
*/
|
||||
class QWT_EXPORT QwtTradingChartData: public QwtArraySeriesData<QwtOHLCSample>
|
||||
{
|
||||
public:
|
||||
QwtTradingChartData(
|
||||
const QVector<QwtOHLCSample> & = QVector<QwtOHLCSample>() );
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
};
|
||||
|
||||
QWT_EXPORT QRectF qwtBoundingRect(
|
||||
const QwtSeriesData<QPointF> &, int from = 0, int to = -1 );
|
||||
|
||||
QWT_EXPORT QRectF qwtBoundingRect(
|
||||
const QwtSeriesData<QwtPoint3D> &, int from = 0, int to = -1 );
|
||||
|
||||
QWT_EXPORT QRectF qwtBoundingRect(
|
||||
const QwtSeriesData<QwtPointPolar> &, int from = 0, int to = -1 );
|
||||
|
||||
QWT_EXPORT QRectF qwtBoundingRect(
|
||||
const QwtSeriesData<QwtIntervalSample> &, int from = 0, int to = -1 );
|
||||
|
||||
QWT_EXPORT QRectF qwtBoundingRect(
|
||||
const QwtSeriesData<QwtSetSample> &, int from = 0, int to = -1 );
|
||||
|
||||
QWT_EXPORT QRectF qwtBoundingRect(
|
||||
const QwtSeriesData<QwtOHLCSample> &, int from = 0, int to = -1 );
|
||||
|
||||
/*!
|
||||
Binary search for a sorted series of samples
|
||||
|
||||
qwtUpperSampleIndex returns the index of sample that is the upper bound
|
||||
of value. Is the the value smaller than the smallest value the return
|
||||
value will be 0. Is the value greater or equal than the largest
|
||||
value the return value will be -1.
|
||||
|
||||
\par Example
|
||||
The following example shows finds a point of curve from an x
|
||||
coordinate
|
||||
|
||||
\verbatim
|
||||
#include <qwt_series_data.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
|
||||
struct compareX
|
||||
{
|
||||
inline bool operator()( const double x, const QPointF &pos ) const
|
||||
{
|
||||
return ( x < pos.x() );
|
||||
}
|
||||
};
|
||||
|
||||
QLineF curveLineAt( const QwtPlotCurve *curve, double x )
|
||||
{
|
||||
int index = qwtUpperSampleIndex<QPointF>(
|
||||
*curve->data(), x, compareX() );
|
||||
|
||||
if ( index == -1 &&
|
||||
x == curve->sample( curve->dataSize() - 1 ).x() )
|
||||
{
|
||||
// the last sample is excluded from qwtUpperSampleIndex
|
||||
index = curve->dataSize() - 1;
|
||||
}
|
||||
|
||||
QLineF line; // invalid
|
||||
if ( index > 0 )
|
||||
{
|
||||
line.setP1( curve->sample( index - 1 ) );
|
||||
line.setP2( curve->sample( index ) );
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
\endverbatim
|
||||
|
||||
|
||||
\param series Series of samples
|
||||
\param value Value
|
||||
\param lessThan Compare operation
|
||||
|
||||
\note The samples must be sorted according to the order specified
|
||||
by the lessThan object
|
||||
|
||||
of the range [begin, end) and returns the position of the one-past-the-last occurrence of value. If no such item is found, returns the position where the item should be inserted.
|
||||
*/
|
||||
template <typename T, typename LessThan>
|
||||
inline int qwtUpperSampleIndex( const QwtSeriesData<T> &series,
|
||||
double value, LessThan lessThan )
|
||||
{
|
||||
const int indexMax = series.size() - 1;
|
||||
|
||||
if ( indexMax < 0 || !lessThan( value, series.sample( indexMax ) ) )
|
||||
return -1;
|
||||
|
||||
int indexMin = 0;
|
||||
int n = indexMax;
|
||||
|
||||
while ( n > 0 )
|
||||
{
|
||||
const int half = n >> 1;
|
||||
const int indexMid = indexMin + half;
|
||||
|
||||
if ( lessThan( value, series.sample( indexMid ) ) )
|
||||
{
|
||||
n = half;
|
||||
}
|
||||
else
|
||||
{
|
||||
indexMin = indexMid + 1;
|
||||
n -= half + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return indexMin;
|
||||
}
|
||||
|
||||
#endif
|
199
include/qwt_series_store.h
Normal file
199
include/qwt_series_store.h
Normal file
|
@ -0,0 +1,199 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SERIES_STORE_H
|
||||
#define QWT_SERIES_STORE_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_series_data.h"
|
||||
|
||||
/*!
|
||||
\brief Bridge between QwtSeriesStore and QwtPlotSeriesItem
|
||||
|
||||
QwtAbstractSeriesStore is an abstract interface only
|
||||
to make it possible to isolate the template based methods ( QwtSeriesStore )
|
||||
from the regular methods ( QwtPlotSeriesItem ) to make it possible
|
||||
to derive from QwtPlotSeriesItem without any hassle with templates.
|
||||
*/
|
||||
class QwtAbstractSeriesStore
|
||||
{
|
||||
protected:
|
||||
//! Destructor
|
||||
virtual ~QwtAbstractSeriesStore() {}
|
||||
|
||||
//! dataChanged() indicates, that the series has been changed.
|
||||
virtual void dataChanged() = 0;
|
||||
|
||||
/*!
|
||||
Set a the "rectangle of interest" for the stored series
|
||||
\sa QwtSeriesData<T>::setRectOfInterest()
|
||||
*/
|
||||
virtual void setRectOfInterest( const QRectF & ) = 0;
|
||||
|
||||
//! \return Bounding rectangle of the stored series
|
||||
virtual QRectF dataRect() const = 0;
|
||||
|
||||
//! \return Number of samples
|
||||
virtual size_t dataSize() const = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Class storing a QwtSeriesData object
|
||||
|
||||
QwtSeriesStore and QwtPlotSeriesItem are intended as base classes for all
|
||||
plot items iterating over a series of samples. Both classes share
|
||||
a virtual base class ( QwtAbstractSeriesStore ) to bridge between them.
|
||||
|
||||
QwtSeriesStore offers the template based part for the plot item API, so
|
||||
that QwtPlotSeriesItem can be derived without any hassle with templates.
|
||||
*/
|
||||
template <typename T>
|
||||
class QwtSeriesStore: public virtual QwtAbstractSeriesStore
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
\brief Constructor
|
||||
The store contains no series
|
||||
*/
|
||||
explicit QwtSeriesStore<T>();
|
||||
|
||||
//! Destructor
|
||||
~QwtSeriesStore<T>();
|
||||
|
||||
/*!
|
||||
Assign a series of samples
|
||||
|
||||
\param series Data
|
||||
\warning The item takes ownership of the data object, deleting
|
||||
it when its not used anymore.
|
||||
*/
|
||||
void setData( QwtSeriesData<T> *series );
|
||||
|
||||
//! \return the the series data
|
||||
QwtSeriesData<T> *data();
|
||||
|
||||
//! \return the the series data
|
||||
const QwtSeriesData<T> *data() const;
|
||||
|
||||
/*!
|
||||
\param index Index
|
||||
\return Sample at position index
|
||||
*/
|
||||
T sample( int index ) const;
|
||||
|
||||
/*!
|
||||
\return Number of samples of the series
|
||||
\sa setData(), QwtSeriesData<T>::size()
|
||||
*/
|
||||
virtual size_t dataSize() const;
|
||||
|
||||
/*!
|
||||
\return Bounding rectangle of the series
|
||||
or an invalid rectangle, when no series is stored
|
||||
|
||||
\sa QwtSeriesData<T>::boundingRect()
|
||||
*/
|
||||
virtual QRectF dataRect() const;
|
||||
|
||||
/*!
|
||||
Set a the "rect of interest" for the series
|
||||
|
||||
\param rect Rectangle of interest
|
||||
\sa QwtSeriesData<T>::setRectOfInterest()
|
||||
*/
|
||||
virtual void setRectOfInterest( const QRectF &rect );
|
||||
|
||||
/*!
|
||||
Replace a series without deleting the previous one
|
||||
|
||||
\param series New series
|
||||
\return Previously assigned series
|
||||
*/
|
||||
QwtSeriesData<T> *swapData( QwtSeriesData<T> *series );
|
||||
|
||||
private:
|
||||
QwtSeriesData<T> *d_series;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
QwtSeriesStore<T>::QwtSeriesStore():
|
||||
d_series( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QwtSeriesStore<T>::~QwtSeriesStore()
|
||||
{
|
||||
delete d_series;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QwtSeriesData<T> *QwtSeriesStore<T>::data()
|
||||
{
|
||||
return d_series;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const QwtSeriesData<T> *QwtSeriesStore<T>::data() const
|
||||
{
|
||||
return d_series;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T QwtSeriesStore<T>::sample( int index ) const
|
||||
{
|
||||
return d_series ? d_series->sample( index ) : T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QwtSeriesStore<T>::setData( QwtSeriesData<T> *series )
|
||||
{
|
||||
if ( d_series != series )
|
||||
{
|
||||
delete d_series;
|
||||
d_series = series;
|
||||
dataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t QwtSeriesStore<T>::dataSize() const
|
||||
{
|
||||
if ( d_series == NULL )
|
||||
return 0;
|
||||
|
||||
return d_series->size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QRectF QwtSeriesStore<T>::dataRect() const
|
||||
{
|
||||
if ( d_series == NULL )
|
||||
return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
|
||||
|
||||
return d_series->boundingRect();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QwtSeriesStore<T>::setRectOfInterest( const QRectF &rect )
|
||||
{
|
||||
if ( d_series )
|
||||
d_series->setRectOfInterest( rect );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QwtSeriesData<T>* QwtSeriesStore<T>::swapData( QwtSeriesData<T> *series )
|
||||
{
|
||||
QwtSeriesData<T> * swappedSeries = d_series;
|
||||
d_series = series;
|
||||
|
||||
return swappedSeries;
|
||||
}
|
||||
|
||||
#endif
|
130
include/qwt_slider.h
Normal file
130
include/qwt_slider.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SLIDER_H
|
||||
#define QWT_SLIDER_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_abstract_slider.h"
|
||||
|
||||
class QwtScaleDraw;
|
||||
|
||||
/*!
|
||||
\brief The Slider Widget
|
||||
|
||||
QwtSlider is a slider widget which operates on an interval
|
||||
of type double. Its position is related to a scale showing
|
||||
the current value.
|
||||
|
||||
The slider can be customized by having a through, a groove - or both.
|
||||
|
||||
\image html sliders.png
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtSlider: public QwtAbstractSlider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS( ScalePosition BackgroundStyle )
|
||||
|
||||
Q_PROPERTY( Qt::Orientation orientation
|
||||
READ orientation WRITE setOrientation )
|
||||
Q_PROPERTY( ScalePosition scalePosition READ scalePosition
|
||||
WRITE setScalePosition )
|
||||
|
||||
Q_PROPERTY( bool trough READ hasTrough WRITE setTrough )
|
||||
Q_PROPERTY( bool groove READ hasGroove WRITE setGroove )
|
||||
|
||||
Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
|
||||
Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
|
||||
Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
Position of the scale
|
||||
\sa QwtSlider(), setScalePosition(), setOrientation()
|
||||
*/
|
||||
enum ScalePosition
|
||||
{
|
||||
//! The slider has no scale
|
||||
NoScale,
|
||||
|
||||
//! The scale is right of a vertical or below a horizontal slider
|
||||
LeadingScale,
|
||||
|
||||
//! The scale is left of a vertical or above a horizontal slider
|
||||
TrailingScale
|
||||
};
|
||||
|
||||
explicit QwtSlider( QWidget *parent = NULL );
|
||||
explicit QwtSlider( Qt::Orientation, QWidget *parent = NULL );
|
||||
|
||||
virtual ~QwtSlider();
|
||||
|
||||
void setOrientation( Qt::Orientation );
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
void setScalePosition( ScalePosition );
|
||||
ScalePosition scalePosition() const;
|
||||
|
||||
void setTrough( bool );
|
||||
bool hasTrough() const;
|
||||
|
||||
void setGroove( bool );
|
||||
bool hasGroove() const;
|
||||
|
||||
void setHandleSize( const QSize & );
|
||||
QSize handleSize() const;
|
||||
|
||||
void setBorderWidth( int bw );
|
||||
int borderWidth() const;
|
||||
|
||||
void setSpacing( int );
|
||||
int spacing() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
void setScaleDraw( QwtScaleDraw * );
|
||||
const QwtScaleDraw *scaleDraw() const;
|
||||
|
||||
void setUpdateInterval( int );
|
||||
int updateInterval() const;
|
||||
|
||||
protected:
|
||||
virtual double scrolledTo( const QPoint & ) const;
|
||||
virtual bool isScrollPosition( const QPoint & ) const;
|
||||
|
||||
virtual void drawSlider ( QPainter *, const QRect & ) const;
|
||||
virtual void drawHandle( QPainter *, const QRect &, int pos ) const;
|
||||
|
||||
virtual void mousePressEvent( QMouseEvent * );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * );
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
virtual void paintEvent ( QPaintEvent * );
|
||||
virtual void changeEvent( QEvent * );
|
||||
virtual void timerEvent( QTimerEvent * );
|
||||
|
||||
virtual void scaleChange();
|
||||
|
||||
QRect sliderRect() const;
|
||||
QRect handleRect() const;
|
||||
|
||||
private:
|
||||
QwtScaleDraw *scaleDraw();
|
||||
|
||||
void layoutSlider( bool );
|
||||
void initSlider( Qt::Orientation );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
101
include/qwt_spline.h
Normal file
101
include/qwt_spline.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SPLINE_H
|
||||
#define QWT_SPLINE_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpolygon.h>
|
||||
#include <qvector.h>
|
||||
|
||||
/*!
|
||||
\brief A class for spline interpolation
|
||||
|
||||
The QwtSpline class is used for cubical spline interpolation.
|
||||
Two types of splines, natural and periodic, are supported.
|
||||
|
||||
\par Usage:
|
||||
<ol>
|
||||
<li>First call setPoints() to determine the spline coefficients
|
||||
for a tabulated function y(x).
|
||||
<li>After the coefficients have been set up, the interpolated
|
||||
function value for an argument x can be determined by calling
|
||||
QwtSpline::value().
|
||||
</ol>
|
||||
|
||||
\par Example:
|
||||
\code
|
||||
#include <qwt_spline.h>
|
||||
|
||||
QPolygonF interpolate(const QPolygonF& points, int numValues)
|
||||
{
|
||||
QwtSpline spline;
|
||||
if ( !spline.setPoints(points) )
|
||||
return points;
|
||||
|
||||
QPolygonF interpolatedPoints(numValues);
|
||||
|
||||
const double delta =
|
||||
(points[numPoints - 1].x() - points[0].x()) / (points.size() - 1);
|
||||
for(i = 0; i < points.size(); i++) / interpolate
|
||||
{
|
||||
const double x = points[0].x() + i * delta;
|
||||
interpolatedPoints[i].setX(x);
|
||||
interpolatedPoints[i].setY(spline.value(x));
|
||||
}
|
||||
return interpolatedPoints;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtSpline
|
||||
{
|
||||
public:
|
||||
//! Spline type
|
||||
enum SplineType
|
||||
{
|
||||
//! A natural spline
|
||||
Natural,
|
||||
|
||||
//! A periodic spline
|
||||
Periodic
|
||||
};
|
||||
|
||||
QwtSpline();
|
||||
QwtSpline( const QwtSpline & );
|
||||
|
||||
~QwtSpline();
|
||||
|
||||
QwtSpline &operator=( const QwtSpline & );
|
||||
|
||||
void setSplineType( SplineType );
|
||||
SplineType splineType() const;
|
||||
|
||||
bool setPoints( const QPolygonF& points );
|
||||
QPolygonF points() const;
|
||||
|
||||
void reset();
|
||||
|
||||
bool isValid() const;
|
||||
double value( double x ) const;
|
||||
|
||||
const QVector<double> &coefficientsA() const;
|
||||
const QVector<double> &coefficientsB() const;
|
||||
const QVector<double> &coefficientsC() const;
|
||||
|
||||
protected:
|
||||
bool buildNaturalSpline( const QPolygonF & );
|
||||
bool buildPeriodicSpline( const QPolygonF & );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
258
include/qwt_symbol.h
Normal file
258
include/qwt_symbol.h
Normal file
|
@ -0,0 +1,258 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SYMBOL_H
|
||||
#define QWT_SYMBOL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qpolygon.h>
|
||||
|
||||
class QPainter;
|
||||
class QRect;
|
||||
class QSize;
|
||||
class QBrush;
|
||||
class QPen;
|
||||
class QColor;
|
||||
class QPointF;
|
||||
class QPolygonF;
|
||||
class QPainterPath;
|
||||
class QPixmap;
|
||||
class QByteArray;
|
||||
class QwtGraphic;
|
||||
|
||||
//! A class for drawing symbols
|
||||
class QWT_EXPORT QwtSymbol
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Symbol Style
|
||||
\sa setStyle(), style()
|
||||
*/
|
||||
enum Style
|
||||
{
|
||||
//! No Style. The symbol cannot be drawn.
|
||||
NoSymbol = -1,
|
||||
|
||||
//! Ellipse or circle
|
||||
Ellipse,
|
||||
|
||||
//! Rectangle
|
||||
Rect,
|
||||
|
||||
//! Diamond
|
||||
Diamond,
|
||||
|
||||
//! Triangle pointing upwards
|
||||
Triangle,
|
||||
|
||||
//! Triangle pointing downwards
|
||||
DTriangle,
|
||||
|
||||
//! Triangle pointing upwards
|
||||
UTriangle,
|
||||
|
||||
//! Triangle pointing left
|
||||
LTriangle,
|
||||
|
||||
//! Triangle pointing right
|
||||
RTriangle,
|
||||
|
||||
//! Cross (+)
|
||||
Cross,
|
||||
|
||||
//! Diagonal cross (X)
|
||||
XCross,
|
||||
|
||||
//! Horizontal line
|
||||
HLine,
|
||||
|
||||
//! Vertical line
|
||||
VLine,
|
||||
|
||||
//! X combined with +
|
||||
Star1,
|
||||
|
||||
//! Six-pointed star
|
||||
Star2,
|
||||
|
||||
//! Hexagon
|
||||
Hexagon,
|
||||
|
||||
/*!
|
||||
The symbol is represented by a painter path, where the
|
||||
origin ( 0, 0 ) of the path coordinate system is mapped to
|
||||
the position of the symbol.
|
||||
|
||||
\sa setPath(), path()
|
||||
*/
|
||||
Path,
|
||||
|
||||
/*!
|
||||
The symbol is represented by a pixmap. The pixmap is centered
|
||||
or aligned to its pin point.
|
||||
|
||||
\sa setPinPoint()
|
||||
*/
|
||||
Pixmap,
|
||||
|
||||
/*!
|
||||
The symbol is represented by a graphic. The graphic is centered
|
||||
or aligned to its pin point.
|
||||
|
||||
\sa setPinPoint()
|
||||
*/
|
||||
Graphic,
|
||||
|
||||
/*!
|
||||
The symbol is represented by a SVG graphic. The graphic is centered
|
||||
or aligned to its pin point.
|
||||
|
||||
\sa setPinPoint()
|
||||
*/
|
||||
SvgDocument,
|
||||
|
||||
/*!
|
||||
Styles >= QwtSymbol::UserSymbol are reserved for derived
|
||||
classes of QwtSymbol that overload drawSymbols() with
|
||||
additional application specific symbol types.
|
||||
*/
|
||||
UserStyle = 1000
|
||||
};
|
||||
|
||||
/*!
|
||||
Depending on the render engine and the complexity of the
|
||||
symbol shape it might be faster to render the symbol
|
||||
to a pixmap and to paint this pixmap.
|
||||
|
||||
F.e. the raster paint engine is a pure software renderer
|
||||
where in cache mode a draw operation usually ends in
|
||||
raster operation with the the backing store, that are usually
|
||||
faster, than the algorithms for rendering polygons.
|
||||
But the opposite can be expected for graphic pipelines
|
||||
that can make use of hardware acceleration.
|
||||
|
||||
The default setting is AutoCache
|
||||
|
||||
\sa setCachePolicy(), cachePolicy()
|
||||
|
||||
\note The policy has no effect, when the symbol is painted
|
||||
to a vector graphics format ( PDF, SVG ).
|
||||
\warning Since Qt 4.8 raster is the default backend on X11
|
||||
*/
|
||||
|
||||
enum CachePolicy
|
||||
{
|
||||
//! Don't use a pixmap cache
|
||||
NoCache,
|
||||
|
||||
//! Always use a pixmap cache
|
||||
Cache,
|
||||
|
||||
/*!
|
||||
Use a cache when one of the following conditions is true:
|
||||
|
||||
- The symbol is rendered with the software
|
||||
renderer ( QPaintEngine::Raster )
|
||||
*/
|
||||
AutoCache
|
||||
};
|
||||
|
||||
public:
|
||||
QwtSymbol( Style = NoSymbol );
|
||||
QwtSymbol( Style, const QBrush &, const QPen &, const QSize & );
|
||||
QwtSymbol( const QPainterPath &, const QBrush &, const QPen & );
|
||||
|
||||
virtual ~QwtSymbol();
|
||||
|
||||
void setCachePolicy( CachePolicy );
|
||||
CachePolicy cachePolicy() const;
|
||||
|
||||
void setSize( const QSize & );
|
||||
void setSize( int width, int height = -1 );
|
||||
const QSize& size() const;
|
||||
|
||||
void setPinPoint( const QPointF &pos, bool enable = true );
|
||||
QPointF pinPoint() const;
|
||||
|
||||
void setPinPointEnabled( bool );
|
||||
bool isPinPointEnabled() const;
|
||||
|
||||
virtual void setColor( const QColor & );
|
||||
|
||||
void setBrush( const QBrush& b );
|
||||
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;
|
||||
|
||||
void setPath( const QPainterPath & );
|
||||
const QPainterPath &path() const;
|
||||
|
||||
void setPixmap( const QPixmap & );
|
||||
const QPixmap &pixmap() const;
|
||||
|
||||
void setGraphic( const QwtGraphic & );
|
||||
const QwtGraphic &graphic() const;
|
||||
|
||||
#ifndef QWT_NO_SVG
|
||||
void setSvgDocument( const QByteArray & );
|
||||
#endif
|
||||
|
||||
void drawSymbol( QPainter *, const QRectF & ) const;
|
||||
void drawSymbol( QPainter *, const QPointF & ) const;
|
||||
void drawSymbols( QPainter *, const QPolygonF & ) const;
|
||||
void drawSymbols( QPainter *,
|
||||
const QPointF *, int numPoints ) const;
|
||||
|
||||
virtual QRect boundingRect() const;
|
||||
void invalidateCache();
|
||||
|
||||
protected:
|
||||
virtual void renderSymbols( QPainter *,
|
||||
const QPointF *, int numPoints ) const;
|
||||
|
||||
private:
|
||||
// Disabled copy constructor and operator=
|
||||
QwtSymbol( const QwtSymbol & );
|
||||
QwtSymbol &operator=( const QwtSymbol & );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Draw the symbol at a specified position
|
||||
|
||||
\param painter Painter
|
||||
\param pos Position of the symbol in screen coordinates
|
||||
*/
|
||||
inline void QwtSymbol::drawSymbol(
|
||||
QPainter *painter, const QPointF &pos ) const
|
||||
{
|
||||
drawSymbols( painter, &pos, 1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Draw symbols at the specified points
|
||||
|
||||
\param painter Painter
|
||||
\param points Positions of the symbols in screen coordinates
|
||||
*/
|
||||
|
||||
inline void QwtSymbol::drawSymbols(
|
||||
QPainter *painter, const QPolygonF &points ) const
|
||||
{
|
||||
drawSymbols( painter, points.data(), points.size() );
|
||||
}
|
||||
|
||||
#endif
|
47
include/qwt_system_clock.h
Normal file
47
include/qwt_system_clock.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_SYSTEM_CLOCK_H
|
||||
#define QWT_SYSTEM_CLOCK_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
|
||||
/*!
|
||||
\brief QwtSystemClock provides high resolution clock time functions.
|
||||
|
||||
Sometimes the resolution offered by QTime ( millisecond ) is not accurate
|
||||
enough for implementing time measurements ( f.e. sampling ).
|
||||
QwtSystemClock offers a subset of the QTime functionality using higher
|
||||
resolution timers ( if possible ).
|
||||
|
||||
Precision and time intervals are multiples of milliseconds (ms).
|
||||
|
||||
\note The implementation uses high-resolution performance counter on Windows,
|
||||
mach_absolute_time() on the Mac or POSIX timers on other systems.
|
||||
If none is available it falls back on QTimer.
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtSystemClock
|
||||
{
|
||||
public:
|
||||
QwtSystemClock();
|
||||
virtual ~QwtSystemClock();
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
void start();
|
||||
double restart();
|
||||
double elapsed() const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
223
include/qwt_text.h
Normal file
223
include/qwt_text.h
Normal file
|
@ -0,0 +1,223 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_TEXT_H
|
||||
#define QWT_TEXT_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qstring.h>
|
||||
#include <qsize.h>
|
||||
#include <qfont.h>
|
||||
#include <qmetatype.h>
|
||||
|
||||
class QColor;
|
||||
class QPen;
|
||||
class QBrush;
|
||||
class QRectF;
|
||||
class QPainter;
|
||||
class QwtTextEngine;
|
||||
|
||||
/*!
|
||||
\brief A class representing a text
|
||||
|
||||
A QwtText is a text including a set of attributes how to render it.
|
||||
|
||||
- Format\n
|
||||
A text might include control sequences (f.e tags) describing
|
||||
how to render it. Each format (f.e MathML, TeX, Qt Rich Text)
|
||||
has its own set of control sequences, that can be handles by
|
||||
a special QwtTextEngine for this format.
|
||||
- Background\n
|
||||
A text might have a background, defined by a QPen and QBrush
|
||||
to improve its visibility. The corners of the background might
|
||||
be rounded.
|
||||
- Font\n
|
||||
A text might have an individual font.
|
||||
- Color\n
|
||||
A text might have an individual color.
|
||||
- Render Flags\n
|
||||
Flags from Qt::AlignmentFlag and Qt::TextFlag used like in
|
||||
QPainter::drawText().
|
||||
|
||||
\sa QwtTextEngine, QwtTextLabel
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtText
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
\brief Text format
|
||||
|
||||
The text format defines the QwtTextEngine, that is used to render
|
||||
the text.
|
||||
|
||||
\sa QwtTextEngine, setTextEngine()
|
||||
*/
|
||||
|
||||
enum TextFormat
|
||||
{
|
||||
/*!
|
||||
The text format is determined using QwtTextEngine::mightRender() for
|
||||
all available text engines in increasing order > PlainText.
|
||||
If none of the text engines can render the text is rendered
|
||||
like QwtText::PlainText.
|
||||
*/
|
||||
AutoText = 0,
|
||||
|
||||
//! Draw the text as it is, using a QwtPlainTextEngine.
|
||||
PlainText,
|
||||
|
||||
//! Use the Scribe framework (Qt Rich Text) to render the text.
|
||||
RichText,
|
||||
|
||||
/*!
|
||||
Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine
|
||||
to display the text. The Qwt MathML extension offers such an engine
|
||||
based on the MathML renderer of the Qt solutions package.
|
||||
To enable MathML support the following code needs to be added to the
|
||||
application:
|
||||
\verbatim QwtText::setTextEngine(QwtText::MathMLText, new QwtMathMLTextEngine()); \endverbatim
|
||||
*/
|
||||
MathMLText,
|
||||
|
||||
/*!
|
||||
Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine
|
||||
to display the text ( not implemented yet ).
|
||||
*/
|
||||
TeXText,
|
||||
|
||||
/*!
|
||||
The number of text formats can be extended using setTextEngine.
|
||||
Formats >= QwtText::OtherFormat are not used by Qwt.
|
||||
*/
|
||||
OtherFormat = 100
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Paint Attributes
|
||||
|
||||
Font and color and background are optional attributes of a QwtText.
|
||||
The paint attributes hold the information, if they are set.
|
||||
*/
|
||||
enum PaintAttribute
|
||||
{
|
||||
//! The text has an individual font.
|
||||
PaintUsingTextFont = 0x01,
|
||||
|
||||
//! The text has an individual color.
|
||||
PaintUsingTextColor = 0x02,
|
||||
|
||||
//! The text has an individual background.
|
||||
PaintBackground = 0x04
|
||||
};
|
||||
|
||||
//! Paint attributes
|
||||
typedef QFlags<PaintAttribute> PaintAttributes;
|
||||
|
||||
/*!
|
||||
\brief Layout Attributes
|
||||
The layout attributes affects some aspects of the layout of the text.
|
||||
*/
|
||||
enum LayoutAttribute
|
||||
{
|
||||
/*!
|
||||
Layout the text without its margins. This mode is useful if a
|
||||
text needs to be aligned accurately, like the tick labels of a scale.
|
||||
If QwtTextEngine::textMargins is not implemented for the format
|
||||
of the text, MinimumLayout has no effect.
|
||||
*/
|
||||
MinimumLayout = 0x01
|
||||
};
|
||||
|
||||
//! Layout attributes
|
||||
typedef QFlags<LayoutAttribute> LayoutAttributes;
|
||||
|
||||
QwtText( const QString & = QString::null,
|
||||
TextFormat textFormat = AutoText );
|
||||
QwtText( const QwtText & );
|
||||
~QwtText();
|
||||
|
||||
QwtText &operator=( const QwtText & );
|
||||
|
||||
bool operator==( const QwtText & ) const;
|
||||
bool operator!=( const QwtText & ) const;
|
||||
|
||||
void setText( const QString &,
|
||||
QwtText::TextFormat textFormat = AutoText );
|
||||
QString text() const;
|
||||
|
||||
bool isNull() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
void setFont( const QFont & );
|
||||
QFont font() const;
|
||||
|
||||
QFont usedFont( const QFont & ) const;
|
||||
|
||||
void setRenderFlags( int flags );
|
||||
int renderFlags() const;
|
||||
|
||||
void setColor( const QColor & );
|
||||
QColor color() const;
|
||||
|
||||
QColor usedColor( const QColor & ) const;
|
||||
|
||||
void setBorderRadius( double );
|
||||
double borderRadius() const;
|
||||
|
||||
void setBorderPen( const QPen & );
|
||||
QPen borderPen() const;
|
||||
|
||||
void setBackgroundBrush( const QBrush & );
|
||||
QBrush backgroundBrush() const;
|
||||
|
||||
void setPaintAttribute( PaintAttribute, bool on = true );
|
||||
bool testPaintAttribute( PaintAttribute ) const;
|
||||
|
||||
void setLayoutAttribute( LayoutAttribute, bool on = true );
|
||||
bool testLayoutAttribute( LayoutAttribute ) const;
|
||||
|
||||
double heightForWidth( double width, const QFont & = QFont() ) const;
|
||||
QSizeF textSize( const QFont & = QFont() ) const;
|
||||
|
||||
void draw( QPainter *painter, const QRectF &rect ) const;
|
||||
|
||||
static const QwtTextEngine *textEngine(
|
||||
const QString &text, QwtText::TextFormat = AutoText );
|
||||
|
||||
static const QwtTextEngine *textEngine( QwtText::TextFormat );
|
||||
static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
|
||||
class LayoutCache;
|
||||
LayoutCache *d_layoutCache;
|
||||
};
|
||||
|
||||
//! \return text().isNull()
|
||||
inline bool QwtText::isNull() const
|
||||
{
|
||||
return text().isNull();
|
||||
}
|
||||
|
||||
//! \return text().isEmpty()
|
||||
inline bool QwtText::isEmpty() const
|
||||
{
|
||||
return text().isEmpty();
|
||||
}
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
|
||||
|
||||
Q_DECLARE_METATYPE( QwtText )
|
||||
|
||||
#endif
|
172
include/qwt_text_engine.h
Normal file
172
include/qwt_text_engine.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_TEXT_ENGINE_H
|
||||
#define QWT_TEXT_ENGINE_H 1
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qsize.h>
|
||||
|
||||
class QFont;
|
||||
class QRectF;
|
||||
class QString;
|
||||
class QPainter;
|
||||
|
||||
/*!
|
||||
\brief Abstract base class for rendering text strings
|
||||
|
||||
A text engine is responsible for rendering texts for a
|
||||
specific text format. They are used by QwtText to render a text.
|
||||
|
||||
QwtPlainTextEngine and QwtRichTextEngine are part of the Qwt library.
|
||||
The implementation of QwtMathMLTextEngine uses code from the
|
||||
Qt solution package. Because of license implications it is built into
|
||||
a separate library.
|
||||
|
||||
\sa QwtText::setTextEngine()
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtTextEngine
|
||||
{
|
||||
public:
|
||||
virtual ~QwtTextEngine();
|
||||
|
||||
/*!
|
||||
Find the height for a given width
|
||||
|
||||
\param font Font of the text
|
||||
\param flags Bitwise OR of the flags used like in QPainter::drawText
|
||||
\param text Text to be rendered
|
||||
\param width Width
|
||||
|
||||
\return Calculated height
|
||||
*/
|
||||
virtual double heightForWidth( const QFont &font, int flags,
|
||||
const QString &text, double width ) const = 0;
|
||||
|
||||
/*!
|
||||
Returns the size, that is needed to render text
|
||||
|
||||
\param font Font of the text
|
||||
\param flags Bitwise OR of the flags like in for QPainter::drawText
|
||||
\param text Text to be rendered
|
||||
|
||||
\return Calculated size
|
||||
*/
|
||||
virtual QSizeF textSize( const QFont &font, int flags,
|
||||
const QString &text ) const = 0;
|
||||
|
||||
/*!
|
||||
Test if a string can be rendered by this text engine
|
||||
|
||||
\param text Text to be tested
|
||||
\return true, if it can be rendered
|
||||
*/
|
||||
virtual bool mightRender( const QString &text ) const = 0;
|
||||
|
||||
/*!
|
||||
Return margins around the texts
|
||||
|
||||
The textSize might include margins around the
|
||||
text, like QFontMetrics::descent(). In situations
|
||||
where texts need to be aligned in detail, knowing
|
||||
these margins might improve the layout calculations.
|
||||
|
||||
\param font Font of the text
|
||||
\param text Text to be rendered
|
||||
\param left Return value for the left margin
|
||||
\param right Return value for the right margin
|
||||
\param top Return value for the top margin
|
||||
\param bottom Return value for the bottom margin
|
||||
*/
|
||||
virtual void textMargins( const QFont &font, const QString &text,
|
||||
double &left, double &right, double &top, double &bottom ) const = 0;
|
||||
|
||||
/*!
|
||||
Draw the text in a clipping rectangle
|
||||
|
||||
\param painter Painter
|
||||
\param rect Clipping rectangle
|
||||
\param flags Bitwise OR of the flags like in for QPainter::drawText()
|
||||
\param text Text to be rendered
|
||||
*/
|
||||
virtual void draw( QPainter *painter, const QRectF &rect,
|
||||
int flags, const QString &text ) const = 0;
|
||||
|
||||
protected:
|
||||
QwtTextEngine();
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\brief A text engine for plain texts
|
||||
|
||||
QwtPlainTextEngine renders texts using the basic Qt classes
|
||||
QPainter and QFontMetrics.
|
||||
*/
|
||||
class QWT_EXPORT QwtPlainTextEngine: public QwtTextEngine
|
||||
{
|
||||
public:
|
||||
QwtPlainTextEngine();
|
||||
virtual ~QwtPlainTextEngine();
|
||||
|
||||
virtual double heightForWidth( const QFont &font, int flags,
|
||||
const QString &text, double width ) const;
|
||||
|
||||
virtual QSizeF textSize( const QFont &font, int flags,
|
||||
const QString &text ) const;
|
||||
|
||||
virtual void draw( QPainter *painter, const QRectF &rect,
|
||||
int flags, const QString &text ) const;
|
||||
|
||||
virtual bool mightRender( const QString & ) const;
|
||||
|
||||
virtual void textMargins( const QFont &, const QString &,
|
||||
double &left, double &right, double &top, double &bottom ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
|
||||
#ifndef QT_NO_RICHTEXT
|
||||
|
||||
/*!
|
||||
\brief A text engine for Qt rich texts
|
||||
|
||||
QwtRichTextEngine renders Qt rich texts using the classes
|
||||
of the Scribe framework of Qt.
|
||||
*/
|
||||
class QWT_EXPORT QwtRichTextEngine: public QwtTextEngine
|
||||
{
|
||||
public:
|
||||
QwtRichTextEngine();
|
||||
|
||||
virtual double heightForWidth( const QFont &font, int flags,
|
||||
const QString &text, double width ) const;
|
||||
|
||||
virtual QSizeF textSize( const QFont &font, int flags,
|
||||
const QString &text ) const;
|
||||
|
||||
virtual void draw( QPainter *painter, const QRectF &rect,
|
||||
int flags, const QString &text ) const;
|
||||
|
||||
virtual bool mightRender( const QString & ) const;
|
||||
|
||||
virtual void textMargins( const QFont &, const QString &,
|
||||
double &left, double &right, double &top, double &bottom ) const;
|
||||
|
||||
private:
|
||||
QString taggedText( const QString &, int flags ) const;
|
||||
};
|
||||
|
||||
#endif // !QT_NO_RICHTEXT
|
||||
|
||||
#endif
|
77
include/qwt_text_label.h
Normal file
77
include/qwt_text_label.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_TEXT_LABEL_H
|
||||
#define QWT_TEXT_LABEL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_text.h"
|
||||
#include <qframe.h>
|
||||
|
||||
class QString;
|
||||
class QPaintEvent;
|
||||
class QPainter;
|
||||
|
||||
/*!
|
||||
\brief A Widget which displays a QwtText
|
||||
*/
|
||||
|
||||
class QWT_EXPORT QwtTextLabel : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( int indent READ indent WRITE setIndent )
|
||||
Q_PROPERTY( int margin READ margin WRITE setMargin )
|
||||
Q_PROPERTY( QString plainText READ plainText WRITE setPlainText )
|
||||
|
||||
public:
|
||||
explicit QwtTextLabel( QWidget *parent = NULL );
|
||||
explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
|
||||
virtual ~QwtTextLabel();
|
||||
|
||||
void setPlainText( const QString & );
|
||||
QString plainText() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setText( const QString &,
|
||||
QwtText::TextFormat textFormat = QwtText::AutoText );
|
||||
virtual void setText( const QwtText & );
|
||||
|
||||
void clear();
|
||||
|
||||
public:
|
||||
const QwtText &text() const;
|
||||
|
||||
int indent() const;
|
||||
void setIndent( int );
|
||||
|
||||
int margin() const;
|
||||
void setMargin( int );
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
virtual int heightForWidth( int ) const;
|
||||
|
||||
QRect textRect() const;
|
||||
|
||||
virtual void drawText( QPainter *, const QRectF & );
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent *e );
|
||||
virtual void drawContents( QPainter * );
|
||||
|
||||
private:
|
||||
void init();
|
||||
int defaultIndent() const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
178
include/qwt_thermo.h
Normal file
178
include/qwt_thermo.h
Normal file
|
@ -0,0 +1,178 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_THERMO_H
|
||||
#define QWT_THERMO_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include "qwt_abstract_scale.h"
|
||||
#include "qwt_interval.h"
|
||||
|
||||
class QwtScaleDraw;
|
||||
class QwtColorMap;
|
||||
|
||||
/*!
|
||||
\brief The Thermometer Widget
|
||||
|
||||
QwtThermo is a widget which displays a value in an interval. It supports:
|
||||
- a horizontal or vertical layout;
|
||||
- a range;
|
||||
- a scale;
|
||||
- an alarm level.
|
||||
|
||||
\image html sysinfo.png
|
||||
|
||||
The fill colors might be calculated from an optional color map
|
||||
If no color map has been assigned QwtThermo uses the
|
||||
following colors/brushes from the widget palette:
|
||||
|
||||
- QPalette::Base
|
||||
Background of the pipe
|
||||
- QPalette::ButtonText
|
||||
Fill brush below the alarm level
|
||||
- QPalette::Highlight
|
||||
Fill brush for the values above the alarm level
|
||||
- QPalette::WindowText
|
||||
For the axis of the scale
|
||||
- QPalette::Text
|
||||
For the labels of the scale
|
||||
*/
|
||||
class QWT_EXPORT QwtThermo: public QwtAbstractScale
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS( ScalePosition )
|
||||
Q_ENUMS( OriginMode )
|
||||
|
||||
Q_PROPERTY( Qt::Orientation orientation
|
||||
READ orientation WRITE setOrientation )
|
||||
Q_PROPERTY( ScalePosition scalePosition
|
||||
READ scalePosition WRITE setScalePosition )
|
||||
Q_PROPERTY( OriginMode originMode READ originMode WRITE setOriginMode )
|
||||
|
||||
Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
|
||||
Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
|
||||
Q_PROPERTY( double origin READ origin WRITE setOrigin )
|
||||
Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
|
||||
Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
|
||||
Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
|
||||
Q_PROPERTY( double value READ value WRITE setValue )
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
Position of the scale
|
||||
\sa setScalePosition(), setOrientation()
|
||||
*/
|
||||
enum ScalePosition
|
||||
{
|
||||
//! The slider has no scale
|
||||
NoScale,
|
||||
|
||||
//! The scale is right of a vertical or below of a horizontal slider
|
||||
LeadingScale,
|
||||
|
||||
//! The scale is left of a vertical or above of a horizontal slider
|
||||
TrailingScale
|
||||
};
|
||||
|
||||
/*!
|
||||
Origin mode. This property specifies where the beginning of the liquid
|
||||
is placed.
|
||||
|
||||
\sa setOriginMode(), setOrigin()
|
||||
*/
|
||||
enum OriginMode
|
||||
{
|
||||
//! The origin is the minimum of the scale
|
||||
OriginMinimum,
|
||||
|
||||
//! The origin is the maximum of the scale
|
||||
OriginMaximum,
|
||||
|
||||
//! The origin is specified using the origin() property
|
||||
OriginCustom
|
||||
};
|
||||
|
||||
explicit QwtThermo( QWidget *parent = NULL );
|
||||
virtual ~QwtThermo();
|
||||
|
||||
void setOrientation( Qt::Orientation );
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
void setScalePosition( ScalePosition );
|
||||
ScalePosition scalePosition() const;
|
||||
|
||||
void setSpacing( int );
|
||||
int spacing() const;
|
||||
|
||||
void setBorderWidth( int w );
|
||||
int borderWidth() const;
|
||||
|
||||
void setOriginMode( OriginMode );
|
||||
OriginMode originMode() const;
|
||||
|
||||
void setOrigin( double );
|
||||
double origin() const;
|
||||
|
||||
void setFillBrush( const QBrush &b );
|
||||
QBrush fillBrush() const;
|
||||
|
||||
void setAlarmBrush( const QBrush &b );
|
||||
QBrush alarmBrush() const;
|
||||
|
||||
void setAlarmLevel( double v );
|
||||
double alarmLevel() const;
|
||||
|
||||
void setAlarmEnabled( bool tf );
|
||||
bool alarmEnabled() const;
|
||||
|
||||
void setColorMap( QwtColorMap * );
|
||||
QwtColorMap *colorMap();
|
||||
const QwtColorMap *colorMap() const;
|
||||
|
||||
void setPipeWidth( int w );
|
||||
int pipeWidth() const;
|
||||
|
||||
void setRangeFlags( QwtInterval::BorderFlags );
|
||||
QwtInterval::BorderFlags rangeFlags() const;
|
||||
|
||||
double value() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
void setScaleDraw( QwtScaleDraw * );
|
||||
const QwtScaleDraw *scaleDraw() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setValue( double val );
|
||||
|
||||
protected:
|
||||
virtual void drawLiquid( QPainter *, const QRect & ) const;
|
||||
virtual void scaleChange();
|
||||
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
virtual void changeEvent( QEvent * );
|
||||
|
||||
QwtScaleDraw *scaleDraw();
|
||||
|
||||
QRect pipeRect() const;
|
||||
QRect fillRect( const QRect & ) const;
|
||||
QRect alarmRect( const QRect & ) const;
|
||||
|
||||
private:
|
||||
void layoutThermo( bool );
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
142
include/qwt_transform.h
Normal file
142
include/qwt_transform.h
Normal file
|
@ -0,0 +1,142 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_TRANSFORM_H
|
||||
#define QWT_TRANSFORM_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
|
||||
/*!
|
||||
\brief A transformation between coordinate systems
|
||||
|
||||
QwtTransform manipulates values, when being mapped between
|
||||
the scale and the paint device coordinate system.
|
||||
|
||||
A transformation consists of 2 methods:
|
||||
|
||||
- transform
|
||||
- invTransform
|
||||
|
||||
where one is is the inverse function of the other.
|
||||
|
||||
When p1, p2 are the boundaries of the paint device coordinates
|
||||
and s1, s2 the boundaries of the scale, QwtScaleMap uses the
|
||||
following calculations:
|
||||
|
||||
- p = p1 + ( p2 - p1 ) * ( T( s ) - T( s1 ) / ( T( s2 ) - T( s1 ) );
|
||||
- s = invT ( T( s1 ) + ( T( s2 ) - T( s1 ) ) * ( p - p1 ) / ( p2 - p1 ) );
|
||||
*/
|
||||
class QWT_EXPORT QwtTransform
|
||||
{
|
||||
public:
|
||||
QwtTransform();
|
||||
virtual ~QwtTransform();
|
||||
|
||||
/*!
|
||||
Modify value to be a valid value for the transformation.
|
||||
The default implementation does nothing.
|
||||
*/
|
||||
virtual double bounded( double value ) const;
|
||||
|
||||
/*!
|
||||
Transformation function
|
||||
|
||||
\param value Value
|
||||
\return Modified value
|
||||
|
||||
\sa invTransform()
|
||||
*/
|
||||
virtual double transform( double value ) const = 0;
|
||||
|
||||
/*!
|
||||
Inverse transformation function
|
||||
|
||||
\param value Value
|
||||
\return Modified value
|
||||
|
||||
\sa transform()
|
||||
*/
|
||||
virtual double invTransform( double value ) const = 0;
|
||||
|
||||
//! Virtualized copy operation
|
||||
virtual QwtTransform *copy() const = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Null transformation
|
||||
|
||||
QwtNullTransform returns the values unmodified.
|
||||
|
||||
*/
|
||||
class QWT_EXPORT QwtNullTransform: public QwtTransform
|
||||
{
|
||||
public:
|
||||
QwtNullTransform();
|
||||
virtual ~QwtNullTransform();
|
||||
|
||||
virtual double transform( double value ) const;
|
||||
virtual double invTransform( double value ) const;
|
||||
|
||||
virtual QwtTransform *copy() const;
|
||||
};
|
||||
/*!
|
||||
\brief Logarithmic transformation
|
||||
|
||||
QwtLogTransform modifies the values using log() and exp().
|
||||
|
||||
\note In the calculations of QwtScaleMap the base of the log function
|
||||
has no effect on the mapping. So QwtLogTransform can be used
|
||||
for log2(), log10() or any other logarithmic scale.
|
||||
*/
|
||||
class QWT_EXPORT QwtLogTransform: public QwtTransform
|
||||
{
|
||||
public:
|
||||
QwtLogTransform();
|
||||
virtual ~QwtLogTransform();
|
||||
|
||||
virtual double transform( double value ) const;
|
||||
virtual double invTransform( double value ) const;
|
||||
|
||||
virtual double bounded( double value ) const;
|
||||
|
||||
virtual QwtTransform *copy() const;
|
||||
|
||||
#if QT_VERSION >= 0x050400
|
||||
static const double LogMin;
|
||||
static const double LogMax;
|
||||
#else
|
||||
QT_STATIC_CONST double LogMin;
|
||||
QT_STATIC_CONST double LogMax;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief A transformation using pow()
|
||||
|
||||
QwtPowerTransform preserves the sign of a value.
|
||||
F.e. a transformation with a factor of 2
|
||||
transforms a value of -3 to -9 and v.v. Thus QwtPowerTransform
|
||||
can be used for scales including negative values.
|
||||
*/
|
||||
class QWT_EXPORT QwtPowerTransform: public QwtTransform
|
||||
{
|
||||
public:
|
||||
QwtPowerTransform( double exponent );
|
||||
virtual ~QwtPowerTransform();
|
||||
|
||||
virtual double transform( double value ) const;
|
||||
virtual double invTransform( double value ) const;
|
||||
|
||||
virtual QwtTransform *copy() const;
|
||||
|
||||
private:
|
||||
const double d_exponent;
|
||||
};
|
||||
|
||||
#endif
|
178
include/qwt_wheel.h
Normal file
178
include/qwt_wheel.h
Normal file
|
@ -0,0 +1,178 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_WHEEL_H
|
||||
#define QWT_WHEEL_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qwidget.h>
|
||||
|
||||
/*!
|
||||
\brief The Wheel Widget
|
||||
|
||||
The wheel widget can be used to change values over a very large range
|
||||
in very small steps. Using the setMass() member, it can be configured
|
||||
as a flying wheel.
|
||||
|
||||
The default range of the wheel is [0.0, 100.0]
|
||||
|
||||
\sa The radio example.
|
||||
*/
|
||||
class QWT_EXPORT QwtWheel: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( Qt::Orientation orientation
|
||||
READ orientation WRITE setOrientation )
|
||||
|
||||
Q_PROPERTY( double value READ value WRITE setValue )
|
||||
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 pageStepCount READ pageStepCount WRITE setPageStepCount )
|
||||
Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment )
|
||||
|
||||
Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
|
||||
Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
|
||||
Q_PROPERTY( bool inverted READ isInverted WRITE setInverted )
|
||||
|
||||
Q_PROPERTY( double mass READ mass WRITE setMass )
|
||||
Q_PROPERTY( int updateInterval READ updateInterval WRITE setUpdateInterval )
|
||||
|
||||
Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
|
||||
Q_PROPERTY( double viewAngle READ viewAngle WRITE setViewAngle )
|
||||
Q_PROPERTY( int tickCount READ tickCount WRITE setTickCount )
|
||||
Q_PROPERTY( int wheelWidth READ wheelWidth WRITE setWheelWidth )
|
||||
Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
|
||||
Q_PROPERTY( int wheelBorderWidth READ wheelBorderWidth WRITE setWheelBorderWidth )
|
||||
|
||||
public:
|
||||
explicit QwtWheel( QWidget *parent = NULL );
|
||||
virtual ~QwtWheel();
|
||||
|
||||
double value() const;
|
||||
|
||||
void setOrientation( Qt::Orientation );
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
double totalAngle() const;
|
||||
double viewAngle() const;
|
||||
|
||||
void setTickCount( int );
|
||||
int tickCount() const;
|
||||
|
||||
void setWheelWidth( int );
|
||||
int wheelWidth() const;
|
||||
|
||||
void setWheelBorderWidth( int );
|
||||
int wheelBorderWidth() const;
|
||||
|
||||
void setBorderWidth( int );
|
||||
int borderWidth() const;
|
||||
|
||||
void setInverted( bool tf );
|
||||
bool isInverted() const;
|
||||
|
||||
void setWrapping( bool tf );
|
||||
bool wrapping() const;
|
||||
|
||||
void setSingleStep( double );
|
||||
double singleStep() const;
|
||||
|
||||
void setPageStepCount( int );
|
||||
int pageStepCount() const;
|
||||
|
||||
void setStepAlignment( bool on );
|
||||
bool stepAlignment() const;
|
||||
|
||||
void setRange( double vmin, double vmax );
|
||||
|
||||
void setMinimum( double min );
|
||||
double minimum() const;
|
||||
|
||||
void setMaximum( double max );
|
||||
double maximum() const;
|
||||
|
||||
void setUpdateInterval( int );
|
||||
int updateInterval() const;
|
||||
|
||||
void setTracking( bool enable );
|
||||
bool isTracking() const;
|
||||
|
||||
double mass() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setValue( double );
|
||||
void setTotalAngle ( double );
|
||||
void setViewAngle( double );
|
||||
void setMass( double );
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
/*!
|
||||
\brief Notify a change of value.
|
||||
|
||||
When tracking is enabled this signal will be emitted every
|
||||
time the value changes.
|
||||
|
||||
\param value new value
|
||||
\sa setTracking()
|
||||
*/
|
||||
void valueChanged( double value );
|
||||
|
||||
/*!
|
||||
This signal is emitted when the user presses the
|
||||
the wheel with the mouse
|
||||
*/
|
||||
void wheelPressed();
|
||||
|
||||
/*!
|
||||
This signal is emitted when the user releases the mouse
|
||||
*/
|
||||
void wheelReleased();
|
||||
|
||||
/*!
|
||||
This signal is emitted when the user moves the
|
||||
wheel with the mouse.
|
||||
|
||||
\param value new value
|
||||
*/
|
||||
void wheelMoved( double value );
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void mousePressEvent( QMouseEvent * );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * );
|
||||
virtual void mouseMoveEvent( QMouseEvent * );
|
||||
virtual void keyPressEvent( QKeyEvent * );
|
||||
virtual void wheelEvent( QWheelEvent * );
|
||||
virtual void timerEvent( QTimerEvent * );
|
||||
|
||||
void stopFlying();
|
||||
|
||||
QRect wheelRect() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
virtual void drawTicks( QPainter *, const QRectF & );
|
||||
virtual void drawWheelBackground( QPainter *, const QRectF & );
|
||||
|
||||
virtual double valueAt( const QPoint & ) const;
|
||||
|
||||
private:
|
||||
double alignedValue( double ) const;
|
||||
double boundedValue( double ) const;
|
||||
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
148
include/qwt_widget_overlay.h
Normal file
148
include/qwt_widget_overlay.h
Normal file
|
@ -0,0 +1,148 @@
|
|||
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||||
* Qwt Widget Library
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QWT_WIDGET_OVERLAY_H
|
||||
#define QWT_WIDGET_OVERLAY_H
|
||||
|
||||
#include "qwt_global.h"
|
||||
#include <qwidget.h>
|
||||
#include <qregion.h>
|
||||
|
||||
class QPainter;
|
||||
|
||||
/*!
|
||||
\brief An overlay for a widget
|
||||
|
||||
The main use case of an widget overlay is to avoid
|
||||
heavy repaint operation of the widget below.
|
||||
|
||||
F.e. in combination with the plot canvas an overlay
|
||||
avoid replots as the content of the canvas can be restored from
|
||||
its backing store.
|
||||
|
||||
QwtWidgetOverlay is an abstract base class. Deriving classes are
|
||||
supposed to reimplement the following methods:
|
||||
|
||||
- drawOverlay()
|
||||
- maskHint()
|
||||
|
||||
Internally QwtPlotPicker uses overlays for displaying
|
||||
the rubber band and the tracker text.
|
||||
|
||||
\sa QwtPlotCanvas::BackingStore
|
||||
*/
|
||||
class QWT_EXPORT QwtWidgetOverlay: public QWidget
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
\brief Mask mode
|
||||
|
||||
When using masks the widget below gets paint events for
|
||||
the masked regions of the overlay only. Otherwise
|
||||
Qt triggers full repaints. On less powerful hardware
|
||||
( f.e embedded systems ) - or when using the raster paint
|
||||
engine on a remote desktop - bit blitting is a noticeable
|
||||
operation, that needs to be avoided.
|
||||
|
||||
If and how to mask depends on how expensive the calculation
|
||||
of the mask is and how many pixels can be excluded by the mask.
|
||||
|
||||
The default setting is MaskHint.
|
||||
|
||||
\sa setMaskMode(), maskMode()
|
||||
*/
|
||||
enum MaskMode
|
||||
{
|
||||
//! Don't use a mask.
|
||||
NoMask,
|
||||
|
||||
/*!
|
||||
\brief Use maskHint() as mask
|
||||
|
||||
For many situations a fast approximation is good enough
|
||||
and it is not necessary to build a more detailed mask
|
||||
( f.e the bounding rectangle of a text ).
|
||||
*/
|
||||
MaskHint,
|
||||
|
||||
/*!
|
||||
\brief Calculate a mask by checking the alpha values
|
||||
|
||||
Sometimes it is not possible to give a fast approximation
|
||||
and the mask needs to be calculated by drawing the overlay
|
||||
and testing the result.
|
||||
|
||||
When a valid maskHint() is available
|
||||
only pixels inside this approximation are checked.
|
||||
*/
|
||||
AlphaMask
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Render mode
|
||||
|
||||
For calculating the alpha mask the overlay has already
|
||||
been painted to a temporary QImage. Instead of rendering
|
||||
the overlay twice this buffer can be copied for drawing
|
||||
the overlay.
|
||||
|
||||
On graphic systems using the raster paint engine ( QWS, Windows )
|
||||
it means usually copying some memory only. On X11 it results in an
|
||||
expensive operation building a pixmap and for simple overlays
|
||||
it might not be recommended.
|
||||
|
||||
\note The render mode has no effect, when maskMode() != AlphaMask.
|
||||
*/
|
||||
enum RenderMode
|
||||
{
|
||||
//! Copy the buffer, when using the raster paint engine.
|
||||
AutoRenderMode,
|
||||
|
||||
//! Always copy the buffer
|
||||
CopyAlphaMask,
|
||||
|
||||
//! Never copy the buffer
|
||||
DrawOverlay
|
||||
};
|
||||
|
||||
QwtWidgetOverlay( QWidget* );
|
||||
virtual ~QwtWidgetOverlay();
|
||||
|
||||
void setMaskMode( MaskMode );
|
||||
MaskMode maskMode() const;
|
||||
|
||||
void setRenderMode( RenderMode );
|
||||
RenderMode renderMode() const;
|
||||
|
||||
void updateOverlay();
|
||||
|
||||
virtual bool eventFilter( QObject *, QEvent *);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent* event );
|
||||
virtual void resizeEvent( QResizeEvent* event );
|
||||
|
||||
virtual QRegion maskHint() const;
|
||||
|
||||
/*!
|
||||
Draw the widget overlay
|
||||
\param painter Painter
|
||||
*/
|
||||
virtual void drawOverlay( QPainter *painter ) const = 0;
|
||||
|
||||
private:
|
||||
void updateMask();
|
||||
void draw( QPainter * ) const;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d_data;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue