qwt_plot.h
/* -*- 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;
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:
enum Axis
{
yLeft,
yRight,
xBottom,
xTop,
axisCnt
};
enum LegendPosition
{
LeftLegend,
RightLegend,
BottomLegend,
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 & );
QwtText title() const;
QwtTextLabel *titleLabel();
const QwtTextLabel *titleLabel() const;
// Footer
void setFooter( const QString & );
void setFooter( const QwtText & );
QwtText footer() const;
QwtTextLabel *footerLabel();
const QwtTextLabel *footerLabel() const;
// Canvas
void setCanvas( QWidget * );
QWidget *canvas();
const QWidget *canvas() const;
void setCanvasBackground( const QBrush & );
QBrush canvasBackground() const;
virtual QwtScaleMap canvasMap( 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 & );
QFont axisFont( int axisId ) const;
void setAxisScale( int axisId, double min, double max, double stepSize = 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:
void itemAttached( QwtPlotItem *plotItem, bool on );
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> &legendData );
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
QwtTextLabel
A Widget which displays a QwtText.
Definition: qwt_text_label.h:25
QwtPlot::yRight
Y axis right of the canvas.
Definition: qwt_plot.h:100
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:45
QwtAbstractLegend
Abstract base class for legend widgets.
Definition: qwt_abstract_legend.h:34
QwtPlot::Axis
Axis
Axis index.
Definition: qwt_plot.h:94
QwtScaleDraw
A class for drawing scales.
Definition: qwt_scale_draw.h:31
QwtScaleWidget
A Widget which contains a scale.
Definition: qwt_scale_widget.h:33
QwtPlotItem
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:64
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:30
QwtPlotDict
A dictionary for plot items.
Definition: qwt_plot_dict.h:34
QwtPlot::BottomLegend
The legend will be below the footer.
Definition: qwt_plot.h:126
QwtPlot::LegendPosition
LegendPosition
Definition: qwt_plot.h:117
QwtPlot::xTop
X axis above the canvas.
Definition: qwt_plot.h:106
QwtPlot::LeftLegend
The legend will be left from the QwtPlot::yLeft axis.
Definition: qwt_plot.h:120
QwtPlot::xBottom
X axis below the canvas.
Definition: qwt_plot.h:103
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:36
QwtPlotLayout
Layout engine for QwtPlot.
Definition: qwt_plot_layout.h:26
QwtPlotItem::title
const QwtText & title() const
Definition: qwt_plot_item.cpp:199
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:26
QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:75
QwtPlot::yLeft
Y axis left of the canvas.
Definition: qwt_plot.h:97
QwtPlotItem::updateScaleDiv
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &)
Update the item to changes of the axes scale division.
Definition: qwt_plot_item.cpp:636
QwtPlot::RightLegend
The legend will be right from the QwtPlot::yRight axis.
Definition: qwt_plot.h:123