Commit c96458cf authored by Bryant's avatar Bryant

Update Qwt to 6.1.

We also document how we got the source code and keep our modifications out of the Qwt directory.
parent 2e4ac6be
This folder contains the various required libraries for QGC to compile. They are distributed with the codebase to ease development.
# Qwt
Qt Widgets for Technical Applications
Version: 6.1
Source obtained: `svn checkout svn://svn.code.sf.net/p/qwt/code/branches/qwt-6.1 qwt`
Contents of `/libs/qwt` is the contents of the `/src` directory from the Qwt repository.
qwt.pri file is custom made to compile all necessary Qwt code in with QGC.
######################################################################
# Automatically generated by qmake (2.01a) Wed Feb 10 11:43:43 2010
######################################################################
QWTSRCDIR = libs/qwt
DEPENDPATH += $$QWTSRCDIR
INCLUDEPATH += $$QWTSRCDIR
# Input
HEADERS += $$QWTSRCDIR/qwt.h \
$$QWTSRCDIR/qwt_abstract_legend.h \
$$QWTSRCDIR/qwt_abstract_scale.h \
$$QWTSRCDIR/qwt_abstract_scale_draw.h \
$$QWTSRCDIR/qwt_abstract_slider.h \
$$QWTSRCDIR/qwt_analog_clock.h \
$$QWTSRCDIR/qwt_arrow_button.h \
$$QWTSRCDIR/qwt_clipper.h \
$$QWTSRCDIR/qwt_color_map.h \
$$QWTSRCDIR/qwt_compass.h \
$$QWTSRCDIR/qwt_compass_rose.h \
$$QWTSRCDIR/qwt_counter.h \
$$QWTSRCDIR/qwt_curve_fitter.h \
$$QWTSRCDIR/qwt_dial.h \
$$QWTSRCDIR/qwt_dial_needle.h \
$$QWTSRCDIR/qwt_dyngrid_layout.h \
$$QWTSRCDIR/qwt_event_pattern.h \
$$QWTSRCDIR/qwt_global.h \
$$QWTSRCDIR/qwt_graphic.h \
$$QWTSRCDIR/qwt_interval.h \
$$QWTSRCDIR/qwt_knob.h \
$$QWTSRCDIR/qwt_legend.h \
$$QWTSRCDIR/qwt_legend_data.h \
$$QWTSRCDIR/qwt_legend_label.h \
$$QWTSRCDIR/qwt_magnifier.h \
$$QWTSRCDIR/qwt_math.h \
$$QWTSRCDIR/qwt_null_paintdevice.h \
$$QWTSRCDIR/qwt_painter.h \
$$QWTSRCDIR/qwt_painter_command.h \
$$QWTSRCDIR/qwt_panner.h \
$$QWTSRCDIR/qwt_picker.h \
$$QWTSRCDIR/qwt_picker_machine.h \
$$QWTSRCDIR/qwt_pixel_matrix.h \
$$QWTSRCDIR/qwt_plot.h \
$$QWTSRCDIR/qwt_plot_canvas.h \
$$QWTSRCDIR/qwt_plot_curve.h \
$$QWTSRCDIR/qwt_plot_dict.h \
$$QWTSRCDIR/qwt_plot_grid.h \
$$QWTSRCDIR/qwt_plot_item.h \
$$QWTSRCDIR/qwt_plot_layout.h \
$$QWTSRCDIR/qwt_plot_magnifier.h \
$$QWTSRCDIR/qwt_plot_marker.h \
$$QWTSRCDIR/qwt_plot_panner.h \
$$QWTSRCDIR/qwt_plot_picker.h \
$$QWTSRCDIR/qwt_plot_rasteritem.h \
$$QWTSRCDIR/qwt_plot_scaleitem.h \
$$QWTSRCDIR/qwt_plot_seriesitem.h \
$$QWTSRCDIR/qwt_plot_spectrogram.h \
$$QWTSRCDIR/qwt_plot_svgitem.h \
$$QWTSRCDIR/qwt_plot_zoomer.h \
$$QWTSRCDIR/qwt_point_mapper.h \
$$QWTSRCDIR/qwt_point_data.h \
$$QWTSRCDIR/qwt_raster_data.h \
$$QWTSRCDIR/qwt_round_scale_draw.h \
$$QWTSRCDIR/qwt_scale_div.h \
$$QWTSRCDIR/qwt_scale_draw.h \
$$QWTSRCDIR/qwt_scale_engine.h \
$$QWTSRCDIR/qwt_scale_map.h \
$$QWTSRCDIR/qwt_scale_widget.h \
$$QWTSRCDIR/qwt_series_data.h \
$$QWTSRCDIR/qwt_slider.h \
$$QWTSRCDIR/qwt_spline.h \
$$QWTSRCDIR/qwt_symbol.h \
$$QWTSRCDIR/qwt_text.h \
$$QWTSRCDIR/qwt_text_engine.h \
$$QWTSRCDIR/qwt_text_label.h \
$$QWTSRCDIR/qwt_thermo.h \
$$QWTSRCDIR/qwt_transform.h \
$$QWTSRCDIR/qwt_wheel.h \
$$QWTSRCDIR/qwt_widget_overlay.h
SOURCES += $$QWTSRCDIR/qwt_abstract_legend.cpp \
$$QWTSRCDIR/qwt_abstract_scale.cpp \
$$QWTSRCDIR/qwt_abstract_scale_draw.cpp \
$$QWTSRCDIR/qwt_abstract_slider.cpp \
$$QWTSRCDIR/qwt_analog_clock.cpp \
$$QWTSRCDIR/qwt_arrow_button.cpp \
$$QWTSRCDIR/qwt_clipper.cpp \
$$QWTSRCDIR/qwt_color_map.cpp \
$$QWTSRCDIR/qwt_compass.cpp \
$$QWTSRCDIR/qwt_compass_rose.cpp \
$$QWTSRCDIR/qwt_counter.cpp \
$$QWTSRCDIR/qwt_curve_fitter.cpp \
$$QWTSRCDIR/qwt_dial.cpp \
$$QWTSRCDIR/qwt_dial_needle.cpp \
$$QWTSRCDIR/qwt_dyngrid_layout.cpp \
$$QWTSRCDIR/qwt_event_pattern.cpp \
$$QWTSRCDIR/qwt_graphic.cpp \
$$QWTSRCDIR/qwt_interval.cpp \
$$QWTSRCDIR/qwt_knob.cpp \
$$QWTSRCDIR/qwt_legend.cpp \
$$QWTSRCDIR/qwt_legend_data.cpp \
$$QWTSRCDIR/qwt_legend_label.cpp \
$$QWTSRCDIR/qwt_magnifier.cpp \
$$QWTSRCDIR/qwt_math.cpp \
$$QWTSRCDIR/qwt_null_paintdevice.cpp \
$$QWTSRCDIR/qwt_painter.cpp \
$$QWTSRCDIR/qwt_painter_command.cpp \
$$QWTSRCDIR/qwt_panner.cpp \
$$QWTSRCDIR/qwt_picker.cpp \
$$QWTSRCDIR/qwt_picker_machine.cpp \
$$QWTSRCDIR/qwt_pixel_matrix.cpp \
$$QWTSRCDIR/qwt_plot.cpp \
$$QWTSRCDIR/qwt_plot_axis.cpp \
$$QWTSRCDIR/qwt_plot_canvas.cpp \
$$QWTSRCDIR/qwt_plot_curve.cpp \
$$QWTSRCDIR/qwt_plot_dict.cpp \
$$QWTSRCDIR/qwt_plot_grid.cpp \
$$QWTSRCDIR/qwt_plot_item.cpp \
$$QWTSRCDIR/qwt_plot_layout.cpp \
$$QWTSRCDIR/qwt_plot_magnifier.cpp \
$$QWTSRCDIR/qwt_plot_marker.cpp \
$$QWTSRCDIR/qwt_plot_panner.cpp \
$$QWTSRCDIR/qwt_plot_picker.cpp \
$$QWTSRCDIR/qwt_plot_rasteritem.cpp \
$$QWTSRCDIR/qwt_plot_scaleitem.cpp \
$$QWTSRCDIR/qwt_plot_seriesitem.cpp \
$$QWTSRCDIR/qwt_plot_spectrogram.cpp \
$$QWTSRCDIR/qwt_plot_svgitem.cpp \
$$QWTSRCDIR/qwt_plot_xml.cpp \
$$QWTSRCDIR/qwt_plot_zoomer.cpp \
$$QWTSRCDIR/qwt_point_mapper.cpp \
$$QWTSRCDIR/qwt_point_data.cpp \
$$QWTSRCDIR/qwt_raster_data.cpp \
$$QWTSRCDIR/qwt_round_scale_draw.cpp \
$$QWTSRCDIR/qwt_scale_div.cpp \
$$QWTSRCDIR/qwt_scale_draw.cpp \
$$QWTSRCDIR/qwt_scale_engine.cpp \
$$QWTSRCDIR/qwt_scale_map.cpp \
$$QWTSRCDIR/qwt_scale_widget.cpp \
$$QWTSRCDIR/qwt_series_data.cpp \
$$QWTSRCDIR/qwt_slider.cpp \
$$QWTSRCDIR/qwt_spline.cpp \
$$QWTSRCDIR/qwt_symbol.cpp \
$$QWTSRCDIR/qwt_text.cpp \
$$QWTSRCDIR/qwt_text_engine.cpp \
$$QWTSRCDIR/qwt_text_label.cpp \
$$QWTSRCDIR/qwt_thermo.cpp \
$$QWTSRCDIR/qwt_transform.cpp \
$$QWTSRCDIR/qwt_wheel.cpp \
$$QWTSRCDIR/qwt_widget_overlay.cpp
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_abstract_legend.h"
/*!
Constructor
\param parent Parent widget
*/
QwtAbstractLegend::QwtAbstractLegend( QWidget *parent ):
QFrame( parent )
{
}
//! Destructor
QwtAbstractLegend::~QwtAbstractLegend()
{
}
/*!
Return the extent, that is needed for elements to scroll
the legend ( usually scrollbars ),
\param orientation Orientation
\return Extent of the corresponding scroll element
*/
int QwtAbstractLegend::scrollExtent( Qt::Orientation orientation ) const
{
Q_UNUSED( orientation );
return 0;
}
/* -*- 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
This diff is collapsed.
...@@ -11,50 +11,85 @@ ...@@ -11,50 +11,85 @@
#define QWT_ABSTRACT_SCALE_H #define QWT_ABSTRACT_SCALE_H
#include "qwt_global.h" #include "qwt_global.h"
#include <qwidget.h>
class QwtScaleEngine; class QwtScaleEngine;
class QwtAbstractScaleDraw; class QwtAbstractScaleDraw;
class QwtScaleDiv; class QwtScaleDiv;
class QwtScaleMap; class QwtScaleMap;
class QwtDoubleInterval; class QwtInterval;
/*! /*!
\brief An abstract base class for classes containing a scale \brief An abstract base class for widgets having a scale
QwtAbstractScale is used to provide classes with a QwtScaleDraw, The scale of an QwtAbstractScale is determined by a QwtScaleDiv
and a QwtScaleDiv. The QwtScaleDiv might be set explicitely definition, that contains the boundaries and the ticks of the scale.
or calculated by a QwtScaleEngine. 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 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: public:
QwtAbstractScale(); QwtAbstractScale( QWidget *parent = NULL );
virtual ~QwtAbstractScale(); virtual ~QwtAbstractScale();
void setScale(double vmin, double vmax, double step = 0.0); void setScale( double lowerBound, double upperBound );
void setScale(const QwtDoubleInterval &, double step = 0.0); void setScale( const QwtInterval & );
void setScale(const QwtScaleDiv &s); void setScale( const QwtScaleDiv & );
const QwtScaleDiv& scaleDiv() const;
void setAutoScale(); void setLowerBound( double value );
bool autoScale() const; double lowerBound() const;
void setScaleMaxMajor( int ticks); void setUpperBound( double value );
double upperBound() const;
void setScaleStepSize( double stepSize );
double scaleStepSize() const;
void setScaleMaxMajor( int ticks );
int scaleMaxMinor() const; int scaleMaxMinor() const;
void setScaleMaxMinor( int ticks); void setScaleMaxMinor( int ticks );
int scaleMaxMajor() const; int scaleMaxMajor() const;
void setScaleEngine(QwtScaleEngine *); void setScaleEngine( QwtScaleEngine * );
const QwtScaleEngine *scaleEngine() const; const QwtScaleEngine *scaleEngine() const;
QwtScaleEngine *scaleEngine(); QwtScaleEngine *scaleEngine();
int transform( double ) const;
double invTransform( int ) const;
bool isInverted() const;
double minimum() const;
double maximum() const;
const QwtScaleMap &scaleMap() const; const QwtScaleMap &scaleMap() const;
protected: protected:
void rescale(double vmin, double vmax, double step = 0.0); void rescale( double lowerBound,
double upperBound, double stepSize );
void setAbstractScaleDraw( QwtAbstractScaleDraw * );
void setAbstractScaleDraw(QwtAbstractScaleDraw *);
const QwtAbstractScaleDraw *abstractScaleDraw() const; const QwtAbstractScaleDraw *abstractScaleDraw() const;
QwtAbstractScaleDraw *abstractScaleDraw(); QwtAbstractScaleDraw *abstractScaleDraw();
......
This diff is collapsed.
...@@ -14,15 +14,10 @@ ...@@ -14,15 +14,10 @@
#include "qwt_scale_div.h" #include "qwt_scale_div.h"
#include "qwt_text.h" #include "qwt_text.h"
#if QT_VERSION < 0x040000
class QColorGroup;
#else
class QPalette; class QPalette;
#endif
class QPainter; class QPainter;
class QFont; class QFont;
class QwtScaleTransformation; class QwtTransform;
class QwtScaleMap; class QwtScaleMap;
/*! /*!
...@@ -31,8 +26,7 @@ class QwtScaleMap; ...@@ -31,8 +26,7 @@ class QwtScaleMap;
QwtAbstractScaleDraw can be used to draw linear or logarithmic scales. QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.
After a scale division has been specified as a QwtScaleDiv object After a scale division has been specified as a QwtScaleDiv object
using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s), using setScaleDiv(), the scale can be drawn with the draw() member.
the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
*/ */
class QWT_EXPORT QwtAbstractScaleDraw class QWT_EXPORT QwtAbstractScaleDraw
{ {
...@@ -40,66 +34,66 @@ public: ...@@ -40,66 +34,66 @@ public:
/*! /*!
Components of a scale Components of a scale
\sa enableComponent(), hasComponent
*/
enum ScaleComponent
{
//! Backbone = the line where the ticks are located
Backbone = 0x01,
- Backbone //! Ticks
- Ticks Ticks = 0x02,
- Labels
\sa QwtAbstractScaleDraw::enableComponent,
QwtAbstractScaleDraw::hasComponent
*/
enum ScaleComponent { //! Labels
Backbone = 1, Labels = 0x04
Ticks = 2,
Labels = 4
}; };
//! Scale components
typedef QFlags<ScaleComponent> ScaleComponents;
QwtAbstractScaleDraw(); QwtAbstractScaleDraw();
QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
virtual ~QwtAbstractScaleDraw(); virtual ~QwtAbstractScaleDraw();
QwtAbstractScaleDraw &operator=(const QwtAbstractScaleDraw &); void setScaleDiv( const QwtScaleDiv &s );
void setScaleDiv(const QwtScaleDiv &s);
const QwtScaleDiv& scaleDiv() const; const QwtScaleDiv& scaleDiv() const;
void setTransformation(QwtScaleTransformation *); void setTransformation( QwtTransform * );
const QwtScaleMap &map() const; const QwtScaleMap &scaleMap() const;
QwtScaleMap &scaleMap();
void enableComponent(ScaleComponent, bool enable = true); void enableComponent( ScaleComponent, bool enable = true );
bool hasComponent(ScaleComponent) const; bool hasComponent( ScaleComponent ) const;
void setTickLength(QwtScaleDiv::TickType, int length); void setTickLength( QwtScaleDiv::TickType, double length );
int tickLength(QwtScaleDiv::TickType) const; double tickLength( QwtScaleDiv::TickType ) const;
int majTickLength() const; double maxTickLength() const;
void setSpacing(int margin); void setSpacing( double margin );
int spacing() const; double spacing() const;
#if QT_VERSION < 0x040000 void setPenWidth( int width );
virtual void draw(QPainter *, const QColorGroup &) const; int penWidth() const;
#else
virtual void draw(QPainter *, const QPalette &) const; virtual void draw( QPainter *, const QPalette & ) const;
#endif
virtual QwtText label(double) const; virtual QwtText label( double ) const;
/*! /*!
Calculate the extent Calculate the extent
The extent is the distcance from the baseline to the outermost The extent is the distance from the baseline to the outermost
pixel of the scale draw in opposite to its orientation. pixel of the scale draw in opposite to its orientation.
It is at least minimumExtent() pixels. It is at least minimumExtent() pixels.
\param font Font used for drawing the tick labels
\return Number of pixels
\sa setMinimumExtent(), minimumExtent() \sa setMinimumExtent(), minimumExtent()
*/ */
virtual int extent(const QPen &, const QFont &) const = 0; virtual double extent( const QFont &font ) const = 0;
void setMinimumExtent(int); void setMinimumExtent( double );
int minimumExtent() const; double minimumExtent() const;
QwtScaleMap &scaleMap();
protected: protected:
/*! /*!
...@@ -107,11 +101,11 @@ protected: ...@@ -107,11 +101,11 @@ protected:
\param painter Painter \param painter Painter
\param value Value of the tick \param value Value of the tick
\param len Lenght of the tick \param len Length of the tick
\sa drawBackbone(), drawLabel() \sa drawBackbone(), drawLabel()
*/ */
virtual void drawTick(QPainter *painter, double value, int len) const = 0; virtual void drawTick( QPainter *painter, double value, double len ) const = 0;
/*! /*!
Draws the baseline of the scale Draws the baseline of the scale
...@@ -119,7 +113,7 @@ protected: ...@@ -119,7 +113,7 @@ protected:
\sa drawTick(), drawLabel() \sa drawTick(), drawLabel()
*/ */
virtual void drawBackbone(QPainter *painter) const = 0; virtual void drawBackbone( QPainter *painter ) const = 0;
/*! /*!
Draws the label for a major scale tick Draws the label for a major scale tick
...@@ -127,19 +121,21 @@ protected: ...@@ -127,19 +121,21 @@ protected:
\param painter Painter \param painter Painter
\param value Value \param value Value
\sa drawTick, drawBackbone \sa drawTick(), drawBackbone()
*/ */
virtual void drawLabel(QPainter *painter, double value) const = 0; virtual void drawLabel( QPainter *painter, double value ) const = 0;
void invalidateCache(); void invalidateCache();
const QwtText &tickLabel(const QFont &, double value) const; const QwtText &tickLabel( const QFont &, double value ) const;
private: private:
int operator==(const QwtAbstractScaleDraw &) const; QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
int operator!=(const QwtAbstractScaleDraw &) const; QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & );
class PrivateData; class PrivateData;
PrivateData *d_data; PrivateData *d_data;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents )
#endif #endif
This diff is collapsed.
...@@ -10,112 +10,95 @@ ...@@ -10,112 +10,95 @@
#ifndef QWT_ABSTRACT_SLIDER_H #ifndef QWT_ABSTRACT_SLIDER_H
#define QWT_ABSTRACT_SLIDER_H #define QWT_ABSTRACT_SLIDER_H
#include <qwidget.h>
#include "qwt_global.h" #include "qwt_global.h"
#include "qwt_double_range.h" #include "qwt_abstract_scale.h"
/*! /*!
\brief An abstract base class for slider widgets \brief An abstract base class for slider widgets with a scale
QwtAbstractSlider is a base class for A slider widget displays a value according to a scale.
slider widgets. It handles mouse events The class is designed as a common super class for widgets like
and updates the slider's value accordingly. Derived classes QwtKnob, QwtDial and QwtSlider.
only have to implement the getValue() and
getScrollMode() members, and should react to a When the slider is nor readOnly() its value can be modified
valueChange(), which normally requires repainting. 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 QWidget, public QwtDoubleRange class QWT_EXPORT QwtAbstractSlider: public QwtAbstractScale
{ {
Q_OBJECT 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 readOnly READ isReadOnly WRITE setReadOnly )
Q_PROPERTY( bool valid READ isValid WRITE setValid ) Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
Q_PROPERTY( double mass READ mass WRITE setMass ) Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
#ifndef Q_MOC_RUN // Qt3 moc
#define QWT_PROPERTY Q_PROPERTY Q_PROPERTY( bool invertedControls READ invertedControls WRITE setInvertedControls )
Q_PROPERTY( Orientation orientation
READ orientation WRITE setOrientation )
#else // Qt4 moc
// MOC_SKIP_BEGIN
Q_PROPERTY( Qt::Orientation orientation
READ orientation WRITE setOrientation )
// MOC_SKIP_END
#endif
public: public:
/*! explicit QwtAbstractSlider( QWidget *parent = NULL );
Scroll mode
\sa getScrollMode()
*/
enum ScrollMode {
ScrNone,
ScrMouse,
ScrTimer,
ScrDirect,
ScrPage
};
explicit QwtAbstractSlider(Qt::Orientation, QWidget *parent = NULL);
virtual ~QwtAbstractSlider(); virtual ~QwtAbstractSlider();
void setUpdateTime(int t); void setValid( bool );
void stopMoving(); bool isValid() const;
void setTracking(bool enable);
virtual void setMass(double val); double value() const;
virtual double mass() const;
#if QT_VERSION >= 0x040000 void setWrapping( bool );
virtual void setOrientation(Qt::Orientation o); bool wrapping() const;
Qt::Orientation orientation() const;
#else
virtual void setOrientation(Orientation o);
Orientation orientation() const;
#endif
bool isReadOnly() const; void setTotalSteps( uint );
uint totalSteps() const;
/* void setSingleSteps( uint );
Wrappers for QwtDblRange::isValid/QwtDblRange::setValid made uint singleSteps() const;
to be available as Q_PROPERTY in the designer.
*/
/*! void setPageSteps( uint );
\sa QwtDblRange::isValid uint pageSteps() const;
*/
bool isValid() const {
return QwtDoubleRange::isValid();
}
/*! void setStepAlignment( bool );
\sa QwtDblRange::isValid bool stepAlignment() const;
*/
void setValid(bool valid) {
QwtDoubleRange::setValid(valid);
}
public slots: void setTracking( bool );
virtual void setValue(double val); bool isTracking() const;
virtual void fitValue(double val);
virtual void incValue(int steps); void setReadOnly( bool );
bool isReadOnly() const;
virtual void setReadOnly(bool); void setInvertedControls( bool );
bool invertedControls() const;
signals: public Q_SLOTS:
void setValue( double val );
Q_SIGNALS:
/*! /*!
\brief Notify a change of value. \brief Notify a change of value.
In the default setting When tracking is enabled (default setting),
(tracking enabled), this signal will be emitted every this signal will be emitted every time the value changes.
time the value changes ( see setTracking() ).
\param value new value \param value New value
\sa setTracking(), sliderMoved()
*/ */
void valueChanged(double value); void valueChanged( double value );
/*! /*!
This signal is emitted when the user presses the This signal is emitted when the user presses the
movable part of the slider (start ScrMouse Mode). movable part of the slider.
*/ */
void sliderPressed(); void sliderPressed();
...@@ -123,70 +106,59 @@ signals: ...@@ -123,70 +106,59 @@ signals:
This signal is emitted when the user releases the This signal is emitted when the user releases the
movable part of the slider. movable part of the slider.
*/ */
void sliderReleased(); void sliderReleased();
/*! /*!
This signal is emitted when the user moves the This signal is emitted when the user moves the
slider with the mouse. slider with the mouse.
\param value new value
\param value New value
\sa valueChanged()
*/ */
void sliderMoved(double value); void sliderMoved( double value );
protected: protected:
virtual void setPosition(const QPoint &); virtual void mousePressEvent( QMouseEvent * );
virtual void valueChange(); virtual void mouseReleaseEvent( QMouseEvent * );
virtual void mouseMoveEvent( QMouseEvent * );
virtual void timerEvent(QTimerEvent *e); virtual void keyPressEvent( QKeyEvent * );
virtual void mousePressEvent(QMouseEvent *e); virtual void wheelEvent( QWheelEvent * );
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void keyPressEvent(QKeyEvent *e);
virtual void wheelEvent(QWheelEvent *e);
/*! /*!
\brief Determine the value corresponding to a specified poind \brief Determine what to do when the user presses a mouse button.
\param pos Mouse position
This is an abstract virtual function which is called when \retval True, when pos is a valid scroll position
the user presses or releases a mouse button or moves the \sa scrolledTo()
mouse. It has to be implemented by the derived class.
\param p point
*/ */
virtual double getValue(const QPoint & p) = 0; virtual bool isScrollPosition( const QPoint &pos ) const = 0;
/*! /*!
\brief Determine what to do when the user presses a mouse button. \brief Determine the value for a new position of the
movable part of the slider
This function is abstract and has to be implemented by derived classes. \param pos Mouse position
It is called on a mousePress event. The derived class can determine
what should happen next in dependence of the position where the mouse \return Value for the mouse position
was pressed by returning scrolling mode and direction. QwtAbstractSlider \sa isScrollPosition()
knows the following modes:<dl>
<dt>QwtAbstractSlider::ScrNone
<dd>Scrolling switched off. Don't change the value.
<dt>QwtAbstractSlider::ScrMouse
<dd>Change the value while the user keeps the
button pressed and moves the mouse.
<dt>QwtAbstractSlider::ScrTimer
<dd>Automatic scrolling. Increment the value
in the specified direction as long as
the user keeps the button pressed.
<dt>QwtAbstractSlider::ScrPage
<dd>Automatic scrolling. Same as ScrTimer, but
increment by page size.</dl>
\param p point where the mouse was pressed
\retval scrollMode The scrolling mode
\retval direction direction: 1, 0, or -1.
*/ */
virtual void getScrollMode( const QPoint &p, virtual double scrolledTo( const QPoint &pos ) const = 0;
int &scrollMode, int &direction) = 0;
void incrementValue( int numSteps );
void setMouseOffset(double); virtual void scaleChange();
double mouseOffset() const;
protected:
virtual void sliderChange();
int scrollMode() const; double incrementedValue(
double value, int stepCount ) const;
private: private:
void buttonReleased(); double alignedValue( double ) const;
double boundedValue( double ) const;
class PrivateData; class PrivateData;
PrivateData *d_data; PrivateData *d_data;
......
...@@ -8,69 +8,94 @@ ...@@ -8,69 +8,94 @@
*****************************************************************************/ *****************************************************************************/
#include "qwt_analog_clock.h" #include "qwt_analog_clock.h"
#include "qwt_round_scale_draw.h"
#include <qmath.h>
#include <qlocale.h>
/*! class QwtAnalogClockScaleDraw: public QwtRoundScaleDraw
Constructor
\param parent Parent widget
*/
QwtAnalogClock::QwtAnalogClock(QWidget *parent):
QwtDial(parent)
{ {
initClock(); public:
} QwtAnalogClockScaleDraw()
{
setSpacing( 8 );
enableComponent( QwtAbstractScaleDraw::Backbone, false );
setTickLength( QwtScaleDiv::MinorTick, 2 );
setTickLength( QwtScaleDiv::MediumTick, 4 );
setTickLength( QwtScaleDiv::MajorTick, 8 );
setPenWidth( 1 );
}
virtual QwtText label( double value ) const
{
if ( qFuzzyCompare( value + 1.0, 1.0 ) )
value = 60.0 * 60.0 * 12.0;
return QLocale().toString( qRound( value / ( 60.0 * 60.0 ) ) );
}
};
#if QT_VERSION < 0x040000
/*! /*!
Constructor Constructor
\param parent Parent widget \param parent Parent widget
\param name Object name
*/ */
QwtAnalogClock::QwtAnalogClock(QWidget* parent, const char *name): QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
QwtDial(parent, name) QwtDial( parent )
{ {
initClock(); setWrapping( true );
} setReadOnly( true );
#endif
void QwtAnalogClock::initClock() setOrigin( 270.0 );
{ setScaleDraw( new QwtAnalogClockScaleDraw() );
setWrapping(true);
setReadOnly(true); setTotalSteps( 60 );
const int secondsPerHour = 60.0 * 60.0;
setOrigin(270.0); QList<double> majorTicks;
setRange(0.0, 60.0 * 60.0 * 12.0); // seconds QList<double> minorTicks;
setScale(-1, 5, 60.0 * 60.0);
setScaleOptions(ScaleTicks | ScaleLabel); for ( int i = 0; i < 12; i++ )
setScaleTicks(1, 0, 8); {
scaleDraw()->setSpacing(8); majorTicks += i * secondsPerHour;
QColor knobColor = for ( int j = 1; j < 5; j++ )
#if QT_VERSION < 0x040000 minorTicks += i * secondsPerHour + j * secondsPerHour / 5.0;
palette().color(QPalette::Active, QColorGroup::Text); }
#else
palette().color(QPalette::Active, QPalette::Text); QwtScaleDiv scaleDiv;
#endif scaleDiv.setInterval( 0.0, 12.0 * secondsPerHour );
knobColor = knobColor.dark(120); scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks );
setScale( scaleDiv );
QColor knobColor = palette().color( QPalette::Active, QPalette::Text );
knobColor = knobColor.dark( 120 );
QColor handColor; QColor handColor;
int width; int width;
for ( int i = 0; i < NHands; i++ ) { for ( int i = 0; i < NHands; i++ )
if ( i == SecondHand ) { {
if ( i == SecondHand )
{
width = 2; width = 2;
handColor = knobColor.dark(120); handColor = knobColor.dark( 120 );
} else { }
else
{
width = 8; width = 8;
handColor = knobColor; handColor = knobColor;
} }
QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle( QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
QwtDialSimpleNeedle::Arrow, true, handColor, knobColor); QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
hand->setWidth(width); hand->setWidth( width );
d_hand[i] = NULL; d_hand[i] = NULL;
setHand((Hand)i, hand); setHand( static_cast<Hand>( i ), hand );
} }
} }
...@@ -82,24 +107,25 @@ QwtAnalogClock::~QwtAnalogClock() ...@@ -82,24 +107,25 @@ QwtAnalogClock::~QwtAnalogClock()
} }
/*! /*!
Nop method, use setHand instead Nop method, use setHand() instead
\sa QwtAnalogClock::setHand \sa setHand()
*/ */
void QwtAnalogClock::setNeedle(QwtDialNeedle *) void QwtAnalogClock::setNeedle( QwtDialNeedle * )
{ {
// no op // no op
return; return;
} }
/*! /*!
Set a clockhand Set a clock hand
\param hand Specifies the type of hand \param hand Specifies the type of hand
\param needle Hand \param needle Hand
\sa QwtAnalogClock::hand() \sa hand()
*/ */
void QwtAnalogClock::setHand(Hand hand, QwtDialNeedle *needle) void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle *needle )
{ {
if ( hand >= 0 || hand < NHands ) { if ( hand >= 0 && hand < NHands )
{
delete d_hand[hand]; delete d_hand[hand];
d_hand[hand] = needle; d_hand[hand] = needle;
} }
...@@ -108,9 +134,9 @@ void QwtAnalogClock::setHand(Hand hand, QwtDialNeedle *needle) ...@@ -108,9 +134,9 @@ void QwtAnalogClock::setHand(Hand hand, QwtDialNeedle *needle)
/*! /*!
\return Clock hand \return Clock hand
\param hd Specifies the type of hand \param hd Specifies the type of hand
\sa QwtAnalogClock::setHand \sa setHand()
*/ */
QwtDialNeedle *QwtAnalogClock::hand(Hand hd) QwtDialNeedle *QwtAnalogClock::hand( Hand hd )
{ {
if ( hd < 0 || hd >= NHands ) if ( hd < 0 || hd >= NHands )
return NULL; return NULL;
...@@ -121,81 +147,75 @@ QwtDialNeedle *QwtAnalogClock::hand(Hand hd) ...@@ -121,81 +147,75 @@ QwtDialNeedle *QwtAnalogClock::hand(Hand hd)
/*! /*!
\return Clock hand \return Clock hand
\param hd Specifies the type of hand \param hd Specifies the type of hand
\sa QwtAnalogClock::setHand \sa setHand()
*/ */
const QwtDialNeedle *QwtAnalogClock::hand(Hand hd) const const QwtDialNeedle *QwtAnalogClock::hand( Hand hd ) const
{ {
return ((QwtAnalogClock *)this)->hand(hd); return const_cast<QwtAnalogClock *>( this )->hand( hd );
} }
/*! /*!
\brief Set the current time \brief Set the current time
This is the same as QwtAnalogClock::setTime(), but Qt < 3.0
can't handle default parameters for slots.
*/ */
void QwtAnalogClock::setCurrentTime() void QwtAnalogClock::setCurrentTime()
{ {
setTime(QTime::currentTime()); setTime( QTime::currentTime() );
} }
/*! /*!
Set a time Set a time
\param time Time to display \param time Time to display
*/ */
void QwtAnalogClock::setTime(const QTime &time) void QwtAnalogClock::setTime( const QTime &time )
{
if ( time.isValid() ) {
setValue((time.hour() % 12) * 60.0 * 60.0
+ time.minute() * 60.0 + time.second());
} else
setValid(false);
}
/*!
Find the scale label for a given value
\param value Value
\return Label
*/
QwtText QwtAnalogClock::scaleLabel(double value) const
{ {
if ( value == 0.0 ) if ( time.isValid() )
value = 60.0 * 60.0 * 12.0; {
setValue( ( time.hour() % 12 ) * 60.0 * 60.0
return QString::number(int(value / (60.0 * 60.0))); + time.minute() * 60.0 + time.second() );
}
else
setValid( false );
} }
/*! /*!
\brief Draw the needle \brief Draw the needle
A clock has no single needle but three hands instead. drawNeedle A clock has no single needle but three hands instead. drawNeedle()
translates value() into directions for the hands and calls translates value() into directions for the hands and calls
drawHand(). drawHand().
\param painter Painter \param painter Painter
\param center Center of the clock \param center Center of the clock
\param radius Maximum length for the hands \param radius Maximum length for the hands
\param direction Dummy, not used. \param dir Dummy, not used.
\param cg ColorGroup \param colorGroup ColorGroup
\sa QwtAnalogClock::drawHand() \sa drawHand()
*/ */
void QwtAnalogClock::drawNeedle(QPainter *painter, const QPoint &center, void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF &center,
int radius, double, QPalette::ColorGroup cg) const double radius, double dir, QPalette::ColorGroup colorGroup ) const
{ {
if ( isValid() ) { Q_UNUSED( dir );
const double hours = value() / (60.0 * 60.0);
const double minutes = (value() - (int)hours * 60.0 * 60.0) / 60.0; if ( isValid() )
const double seconds = value() - (int)hours * 60.0 * 60.0 {
- (int)minutes * 60.0; const double hours = value() / ( 60.0 * 60.0 );
const double minutes =
drawHand(painter, HourHand, center, radius, ( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0;
360.0 - (origin() + 360.0 * hours / 12.0), cg); const double seconds = value() - qFloor(hours) * 60.0 * 60.0
drawHand(painter, MinuteHand, center, radius, - qFloor(minutes) * 60.0;
360.0 - (origin() + 360.0 * minutes / 60.0), cg);
drawHand(painter, SecondHand, center, radius, double angle[NHands];
360.0 - (origin() + 360.0 * seconds / 60.0), cg); angle[HourHand] = 360.0 * hours / 12.0;
angle[MinuteHand] = 360.0 * minutes / 60.0;
angle[SecondHand] = 360.0 * seconds / 60.0;
for ( int hand = 0; hand < NHands; hand++ )
{
const double d = 360.0 - angle[hand] - origin();
drawHand( painter, static_cast<Hand>( hand ),
center, radius, d, colorGroup );
}
} }
} }
...@@ -209,15 +229,16 @@ void QwtAnalogClock::drawNeedle(QPainter *painter, const QPoint &center, ...@@ -209,15 +229,16 @@ void QwtAnalogClock::drawNeedle(QPainter *painter, const QPoint &center,
\param direction Direction of the hand in degrees, counter clockwise \param direction Direction of the hand in degrees, counter clockwise
\param cg ColorGroup \param cg ColorGroup
*/ */
void QwtAnalogClock::drawHand(QPainter *painter, Hand hd, void QwtAnalogClock::drawHand( QPainter *painter, Hand hd,
const QPoint &center, int radius, double direction, const QPointF &center, double radius, double direction,
QPalette::ColorGroup cg) const QPalette::ColorGroup cg ) const
{ {
const QwtDialNeedle *needle = hand(hd); const QwtDialNeedle *needle = hand( hd );
if ( needle ) { if ( needle )
{
if ( hd == HourHand ) if ( hd == HourHand )
radius = qRound(0.8 * radius); radius = qRound( 0.8 * radius );
needle->draw(painter, center, radius, direction, cg); needle->draw( painter, center, radius, direction, cg );
} }
} }
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#ifndef QWT_ANALOG_CLOCK_H #ifndef QWT_ANALOG_CLOCK_H
#define QWT_ANALOG_CLOCK_H #define QWT_ANALOG_CLOCK_H
#include <qdatetime.h>
#include "qwt_global.h" #include "qwt_global.h"
#include "qwt_dial.h" #include "qwt_dial.h"
#include "qwt_dial_needle.h" #include "qwt_dial_needle.h"
#include <qdatetime.h>
/*! /*!
\brief An analog clock \brief An analog clock
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
\image html analogclock.png \image html analogclock.png
\par Example \par Example
\verbatim #include <qwt_analog_clock.h> \code
#include <qwt_analog_clock.h>
QwtAnalogClock *clock = new QwtAnalogClock(...); QwtAnalogClock *clock = new QwtAnalogClock(...);
clock->scaleDraw()->setPenWidth(3); clock->scaleDraw()->setPenWidth(3);
...@@ -34,10 +35,7 @@ ...@@ -34,10 +35,7 @@
timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime())); timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
timer->start(1000); timer->start(1000);
\endverbatim \endcode
Qwt is missing a set of good looking hands.
Contributions are very welcome.
\note The examples/dials example shows how to use QwtAnalogClock. \note The examples/dials example shows how to use QwtAnalogClock.
*/ */
...@@ -51,41 +49,43 @@ public: ...@@ -51,41 +49,43 @@ public:
Hand type Hand type
\sa setHand(), hand() \sa setHand(), hand()
*/ */
enum Hand
enum Hand { {
//! Needle displaying the seconds
SecondHand, SecondHand,
//! Needle displaying the minutes
MinuteHand, MinuteHand,
//! Needle displaying the hours
HourHand, HourHand,
//! Number of needles
NHands NHands
}; };
explicit QwtAnalogClock(QWidget* parent = NULL); explicit QwtAnalogClock( QWidget* parent = NULL );
#if QT_VERSION < 0x040000
explicit QwtAnalogClock(QWidget* parent, const char *name);
#endif
virtual ~QwtAnalogClock(); virtual ~QwtAnalogClock();
virtual void setHand(Hand, QwtDialNeedle *); void setHand( Hand, QwtDialNeedle * );
const QwtDialNeedle *hand(Hand) const;
QwtDialNeedle *hand(Hand);
public slots: const QwtDialNeedle *hand( Hand ) const;
QwtDialNeedle *hand( Hand );
public Q_SLOTS:
void setCurrentTime(); void setCurrentTime();
void setTime(const QTime & = QTime::currentTime()); void setTime( const QTime & );
protected: protected:
virtual QwtText scaleLabel(double) const; virtual void drawNeedle( QPainter *, const QPointF &,
double radius, double direction, QPalette::ColorGroup ) const;
virtual void drawNeedle(QPainter *, const QPoint &,
int radius, double direction, QPalette::ColorGroup) const;
virtual void drawHand(QPainter *, Hand, const QPoint &, virtual void drawHand( QPainter *, Hand, const QPointF &,
int radius, double direction, QPalette::ColorGroup) const; double radius, double direction, QPalette::ColorGroup ) const;
private: private:
virtual void setNeedle(QwtDialNeedle *); // use setHand instead
void initClock(); void setNeedle( QwtDialNeedle * );
QwtDialNeedle *d_hand[NHands]; QwtDialNeedle *d_hand[NHands];
}; };
......
This diff is collapsed.
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#ifndef QWT_ARROW_BUTTON_H #ifndef QWT_ARROW_BUTTON_H
#define QWT_ARROW_BUTTON_H #define QWT_ARROW_BUTTON_H
#include <qpushbutton.h>
#include "qwt_global.h" #include "qwt_global.h"
#include <qpushbutton.h>
/*! /*!
\brief Arrow Button \brief Arrow Button
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
class QWT_EXPORT QwtArrowButton : public QPushButton class QWT_EXPORT QwtArrowButton : public QPushButton
{ {
public: public:
explicit QwtArrowButton (int num, Qt::ArrowType, QWidget *parent = NULL); explicit QwtArrowButton ( int num, Qt::ArrowType, QWidget *parent = NULL );
virtual ~QwtArrowButton(); virtual ~QwtArrowButton();
Qt::ArrowType arrowType() const; Qt::ArrowType arrowType() const;
...@@ -33,18 +33,16 @@ public: ...@@ -33,18 +33,16 @@ public:
virtual QSize minimumSizeHint() const; virtual QSize minimumSizeHint() const;
protected: protected:
#if QT_VERSION >= 0x040000 virtual void paintEvent( QPaintEvent *event );
virtual void paintEvent(QPaintEvent *event);
#endif
virtual void drawButtonLabel(QPainter *p); virtual void drawButtonLabel( QPainter *p );
virtual void drawArrow(QPainter *, virtual void drawArrow( QPainter *,
const QRect &, Qt::ArrowType) const; const QRect &, Qt::ArrowType ) const;
virtual QRect labelRect() const; virtual QRect labelRect() const;
virtual QSize arrowSize(Qt::ArrowType, virtual QSize arrowSize( Qt::ArrowType,
const QSize &boundingSize) const; const QSize &boundingSize ) const;
virtual void keyPressEvent(QKeyEvent *); virtual void keyPressEvent( QKeyEvent * );
private: private:
class PrivateData; class PrivateData;
......
This diff is collapsed.
...@@ -11,27 +11,30 @@ ...@@ -11,27 +11,30 @@
#define QWT_CLIPPER_H #define QWT_CLIPPER_H
#include "qwt_global.h" #include "qwt_global.h"
#include "qwt_array.h" #include "qwt_interval.h"
#include "qwt_polygon.h" #include <qpolygon.h>
#include "qwt_double_rect.h" #include <qvector.h>
#include "qwt_double_interval.h"
class QRect; class QRect;
class QRectF;
/*! /*!
\brief Some clipping algos \brief Some clipping algorithms
*/ */
class QWT_EXPORT QwtClipper class QWT_EXPORT QwtClipper
{ {
public: public:
static QwtPolygon clipPolygon(const QRect &, const QwtPolygon &); static QPolygon clipPolygon( const QRect &,
static QwtPolygonF clipPolygonF(const QwtDoubleRect &, const QwtPolygonF &); const QPolygon &, bool closePolygon = false );
static QPolygon clipPolygon( const QRectF &,
const QPolygon &, bool closePolygon = false );
#if QT_VERSION >= 0x040000 static QPolygonF clipPolygonF( const QRectF &,
static QwtArray<QwtDoubleInterval> clipCircle( const QPolygonF &, bool closePolygon = false );
const QwtDoubleRect &, const QwtDoublePoint &, double radius);
#endif static QVector<QwtInterval> clipCircle(
const QRectF &, const QPointF &, double radius );
}; };
#endif #endif
This diff is collapsed.
...@@ -10,21 +10,10 @@ ...@@ -10,21 +10,10 @@
#ifndef QWT_COLOR_MAP_H #ifndef QWT_COLOR_MAP_H
#define QWT_COLOR_MAP_H #define QWT_COLOR_MAP_H
#include <qglobal.h> #include "qwt_global.h"
#include "qwt_interval.h"
#include <qcolor.h> #include <qcolor.h>
#if QT_VERSION < 0x040000
#include <qvaluevector.h>
#else
#include <qvector.h> #include <qvector.h>
#endif
#include "qwt_array.h"
#include "qwt_double_interval.h"
#if defined(QWT_TEMPLATEDLL)
// MOC_SKIP_BEGIN
template class QWT_EXPORT QwtArray<double>;
// MOC_SKIP_END
#endif
/*! /*!
\brief QwtColorMap is used to map values into colors. \brief QwtColorMap is used to map values into colors.
...@@ -45,67 +34,60 @@ class QWT_EXPORT QwtColorMap ...@@ -45,67 +34,60 @@ class QWT_EXPORT QwtColorMap
{ {
public: public:
/*! /*!
- RGB\n Format for color mapping
The map is intended to map into QRgb values.
- Indexed\n
The map is intended to map into 8 bit values, that
are indices into the color table.
\sa rgb(), colorIndex(), colorTable() \sa rgb(), colorIndex(), colorTable()
*/ */
enum Format { enum Format
{
//! The map is intended to map into RGB values.
RGB, RGB,
/*!
The map is intended to map into 8 bit values, that
are indices into the color table.
*/
Indexed Indexed
}; };
QwtColorMap(Format = QwtColorMap::RGB ); QwtColorMap( Format = QwtColorMap::RGB );
virtual ~QwtColorMap(); virtual ~QwtColorMap();
inline Format format() const; Format format() const;
//! Clone the color map
virtual QwtColorMap *copy() const = 0;
/*! /*!
Map a value of a given interval into a rgb value. Map a value of a given interval into a RGB value.
\param interval Range for the values \param interval Range for the values
\param value Value \param value Value
\return rgb value, corresponding to value \return RGB value, corresponding to value
*/ */
virtual QRgb rgb( virtual QRgb rgb( const QwtInterval &interval,
const QwtDoubleInterval &interval, double value) const = 0; double value ) const = 0;
/*! /*!
Map a value of a given interval into a color index Map a value of a given interval into a color index
\param interval Range for the values \param interval Range for the values
\param value Value \param value Value
\return color index, corresponding to value \return color index, corresponding to value
*/ */
virtual unsigned char colorIndex( virtual unsigned char colorIndex(
const QwtDoubleInterval &interval, double value) const = 0; const QwtInterval &interval, double value ) const = 0;
QColor color(const QwtDoubleInterval &, double value) const; QColor color( const QwtInterval &, double value ) const;
#if QT_VERSION < 0x040000 virtual QVector<QRgb> colorTable( const QwtInterval & ) const;
virtual QValueVector<QRgb> colorTable(const QwtDoubleInterval &) const;
#else
virtual QVector<QRgb> colorTable(const QwtDoubleInterval &) const;
#endif
private: private:
Format d_format; Format d_format;
}; };
/*! /*!
\brief QwtLinearColorMap builds a color map from color stops. \brief QwtLinearColorMap builds a color map from color stops.
A color stop is a color at a specific position. The valid 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 range for the positions is [0.0, 1.0]. When mapping a value
into a color it is translated into this interval. If into a color it is translated into this interval according to mode().
mode() == FixedColors the color is calculated from the next lower
color stop. If mode() == ScaledColors the color is calculated
by interpolating the colors of the adjacent stops.
*/ */
class QWT_EXPORT QwtLinearColorMap: public QwtColorMap class QWT_EXPORT QwtLinearColorMap: public QwtColorMap
{ {
...@@ -114,67 +96,66 @@ public: ...@@ -114,67 +96,66 @@ public:
Mode of color map Mode of color map
\sa setMode(), mode() \sa setMode(), mode()
*/ */
enum Mode { enum Mode
{
//! Return the color from the next lower color stop
FixedColors, FixedColors,
//! Interpolating the colors of the adjacent stops.
ScaledColors ScaledColors
}; };
QwtLinearColorMap(QwtColorMap::Format = QwtColorMap::RGB); QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
QwtLinearColorMap( const QColor &from, const QColor &to, QwtLinearColorMap( const QColor &from, const QColor &to,
QwtColorMap::Format = QwtColorMap::RGB); QwtColorMap::Format = QwtColorMap::RGB );
QwtLinearColorMap(const QwtLinearColorMap &);
virtual ~QwtLinearColorMap(); virtual ~QwtLinearColorMap();
QwtLinearColorMap &operator=(const QwtLinearColorMap &); void setMode( Mode );
virtual QwtColorMap *copy() const;
void setMode(Mode);
Mode mode() const; Mode mode() const;
void setColorInterval(const QColor &color1, const QColor &color2); void setColorInterval( const QColor &color1, const QColor &color2 );
void addColorStop(double value, const QColor&); void addColorStop( double value, const QColor& );
QwtArray<double> colorStops() const; QVector<double> colorStops() const;
QColor color1() const; QColor color1() const;
QColor color2() const; QColor color2() const;
virtual QRgb rgb(const QwtDoubleInterval &, double value) const; virtual QRgb rgb( const QwtInterval &, double value ) const;
virtual unsigned char colorIndex( virtual unsigned char colorIndex(
const QwtDoubleInterval &, double value) const; const QwtInterval &, double value ) const;
class ColorStops; class ColorStops;
private: private:
// Disabled copy constructor and operator=
QwtLinearColorMap( const QwtLinearColorMap & );
QwtLinearColorMap &operator=( const QwtLinearColorMap & );
class PrivateData; class PrivateData;
PrivateData *d_data; PrivateData *d_data;
}; };
/*! /*!
\brief QwtAlphaColorMap variies the alpha value of a color \brief QwtAlphaColorMap varies the alpha value of a color
*/ */
class QWT_EXPORT QwtAlphaColorMap: public QwtColorMap class QWT_EXPORT QwtAlphaColorMap: public QwtColorMap
{ {
public: public:
QwtAlphaColorMap(const QColor & = QColor(Qt::gray)); QwtAlphaColorMap( const QColor & = QColor( Qt::gray ) );
QwtAlphaColorMap(const QwtAlphaColorMap &);
virtual ~QwtAlphaColorMap(); virtual ~QwtAlphaColorMap();
QwtAlphaColorMap &operator=(const QwtAlphaColorMap &); void setColor( const QColor & );
virtual QwtColorMap *copy() const;
void setColor(const QColor &);
QColor color() const; QColor color() const;
virtual QRgb rgb(const QwtDoubleInterval &, double value) const; virtual QRgb rgb( const QwtInterval &, double value ) const;
private: private:
QwtAlphaColorMap( const QwtAlphaColorMap & );
QwtAlphaColorMap &operator=( const QwtAlphaColorMap & );
virtual unsigned char colorIndex( virtual unsigned char colorIndex(
const QwtDoubleInterval &, double value) const; const QwtInterval &, double value ) const;
class PrivateData; class PrivateData;
PrivateData *d_data; PrivateData *d_data;
...@@ -194,13 +175,16 @@ private: ...@@ -194,13 +175,16 @@ private:
color table once and find the color using colorIndex(). color table once and find the color using colorIndex().
*/ */
inline QColor QwtColorMap::color( inline QColor QwtColorMap::color(
const QwtDoubleInterval &interval, double value) const const QwtInterval &interval, double value ) const
{ {
if ( d_format == RGB ) { if ( d_format == RGB )
return QColor( rgb(interval, value) ); {
} else { return QColor( rgb( interval, value ) );
const unsigned int index = colorIndex(interval, value); }
return colorTable(interval)[index]; // slow else
{
const unsigned int index = colorIndex( interval, value );
return colorTable( interval )[index]; // slow
} }
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment