Commit 1c4fdc2e authored by Gus Grubba's avatar Gus Grubba

First shot at it

parent 2f5324fd
......@@ -99,15 +99,6 @@ SOURCES += \
libs/shapelib/shpopen.c \
libs/shapelib/safileio.c
#
# [REQUIRED] QWT plotting library dependency. Provides plotting capabilities.
#
!MobileBuild {
include(libs/qwt.pri)
DEPENDPATH += libs/qwt
INCLUDEPATH += libs/qwt
}
#
# [REQUIRED] SDL dependency. Provides joystick/gamepad support.
# The SDL is packaged with QGC for the Mac and Windows. Linux support requires installing the SDL
......
######################################################################
# 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
add_library(qwt
qwt_abstract_legend.cpp
qwt_abstract_scale.cpp
qwt_abstract_scale_draw.cpp
qwt_abstract_slider.cpp
qwt_analog_clock.cpp
qwt_arrow_button.cpp
qwt_clipper.cpp
qwt_color_map.cpp
qwt_compass.cpp
qwt_compass_rose.cpp
qwt_counter.cpp
qwt_curve_fitter.cpp
qwt_dial.cpp
qwt_dial_needle.cpp
qwt_dyngrid_layout.cpp
qwt_event_pattern.cpp
qwt_graphic.cpp
qwt_interval.cpp
qwt_knob.cpp
qwt_legend.cpp
qwt_legend_data.cpp
qwt_legend_label.cpp
qwt_magnifier.cpp
qwt_math.cpp
qwt_null_paintdevice.cpp
qwt_painter.cpp
qwt_painter_command.cpp
qwt_panner.cpp
qwt_picker.cpp
qwt_picker_machine.cpp
qwt_pixel_matrix.cpp
qwt_plot.cpp
qwt_plot_axis.cpp
qwt_plot_canvas.cpp
qwt_plot_curve.cpp
qwt_plot_dict.cpp
qwt_plot_grid.cpp
qwt_plot_item.cpp
qwt_plot_layout.cpp
qwt_plot_magnifier.cpp
qwt_plot_marker.cpp
qwt_plot_panner.cpp
qwt_plot_picker.cpp
qwt_plot_rasteritem.cpp
qwt_plot_scaleitem.cpp
qwt_plot_seriesitem.cpp
qwt_plot_spectrogram.cpp
qwt_plot_svgitem.cpp
qwt_plot_xml.cpp
qwt_plot_zoomer.cpp
qwt_point_data.cpp
qwt_point_mapper.cpp
qwt_raster_data.cpp
qwt_round_scale_draw.cpp
qwt_scale_div.cpp
qwt_scale_draw.cpp
qwt_scale_engine.cpp
qwt_scale_map.cpp
qwt_scale_widget.cpp
qwt_series_data.cpp
qwt_slider.cpp
qwt_spline.cpp
qwt_symbol.cpp
qwt_text.cpp
qwt_text_engine.cpp
qwt_text_label.cpp
qwt_thermo.cpp
qwt_transform.cpp
qwt_wheel.cpp
qwt_widget_overlay.cpp
)
target_link_libraries(qwt
Qt5::Concurrent
Qt5::Core
Qt5::Svg
Qt5::Widgets
)
target_include_directories(qwt INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
/* -*- 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_H
#define QWT_H
#include "qwt_global.h"
/*!
Some constants for use within Qwt.
*/
namespace Qwt
{
};
#endif
######################################################################
# 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_scale.h \
$$QWTSRCDIR/qwt_abstract_scale_draw.h \
$$QWTSRCDIR/qwt_abstract_slider.h \
$$QWTSRCDIR/qwt_analog_clock.h \
$$QWTSRCDIR/qwt_array.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_data.h \
$$QWTSRCDIR/qwt_dial.h \
$$QWTSRCDIR/qwt_dial_needle.h \
$$QWTSRCDIR/qwt_double_interval.h \
$$QWTSRCDIR/qwt_double_range.h \
$$QWTSRCDIR/qwt_double_rect.h \
$$QWTSRCDIR/qwt_dyngrid_layout.h \
$$QWTSRCDIR/qwt_event_pattern.h \
$$QWTSRCDIR/qwt_global.h \
$$QWTSRCDIR/qwt_interval_data.h \
$$QWTSRCDIR/qwt_knob.h \
$$QWTSRCDIR/qwt_layout_metrics.h \
$$QWTSRCDIR/qwt_legend.h \
$$QWTSRCDIR/qwt_legend_item.h \
$$QWTSRCDIR/qwt_legend_itemmanager.h \
$$QWTSRCDIR/qwt_magnifier.h \
$$QWTSRCDIR/qwt_math.h \
$$QWTSRCDIR/qwt_paint_buffer.h \
$$QWTSRCDIR/qwt_painter.h \
$$QWTSRCDIR/qwt_panner.h \
$$QWTSRCDIR/qwt_picker.h \
$$QWTSRCDIR/qwt_picker_machine.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_printfilter.h \
$$QWTSRCDIR/qwt_plot_rasteritem.h \
$$QWTSRCDIR/qwt_plot_scaleitem.h \
$$QWTSRCDIR/qwt_plot_spectrogram.h \
$$QWTSRCDIR/qwt_plot_svgitem.h \
$$QWTSRCDIR/qwt_plot_zoomer.h \
$$QWTSRCDIR/qwt_polygon.h \
$$QWTSRCDIR/qwt_raster_data.h \
$$QWTSRCDIR/qwt_rect.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_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_valuelist.h \
$$QWTSRCDIR/qwt_wheel.h
SOURCES += $$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_data.cpp \
$$QWTSRCDIR/qwt_dial.cpp \
$$QWTSRCDIR/qwt_dial_needle.cpp \
$$QWTSRCDIR/qwt_double_interval.cpp \
$$QWTSRCDIR/qwt_double_range.cpp \
$$QWTSRCDIR/qwt_double_rect.cpp \
$$QWTSRCDIR/qwt_dyngrid_layout.cpp \
$$QWTSRCDIR/qwt_event_pattern.cpp \
$$QWTSRCDIR/qwt_interval_data.cpp \
$$QWTSRCDIR/qwt_knob.cpp \
$$QWTSRCDIR/qwt_layout_metrics.cpp \
$$QWTSRCDIR/qwt_legend.cpp \
$$QWTSRCDIR/qwt_legend_item.cpp \
$$QWTSRCDIR/qwt_magnifier.cpp \
$$QWTSRCDIR/qwt_math.cpp \
$$QWTSRCDIR/qwt_paint_buffer.cpp \
$$QWTSRCDIR/qwt_painter.cpp \
$$QWTSRCDIR/qwt_panner.cpp \
$$QWTSRCDIR/qwt_picker.cpp \
$$QWTSRCDIR/qwt_picker_machine.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_print.cpp \
$$QWTSRCDIR/qwt_plot_printfilter.cpp \
$$QWTSRCDIR/qwt_plot_rasteritem.cpp \
$$QWTSRCDIR/qwt_plot_scaleitem.cpp \
$$QWTSRCDIR/qwt_plot_spectrogram.cpp \
$$QWTSRCDIR/qwt_plot_svgitem.cpp \
$$QWTSRCDIR/qwt_plot_xml.cpp \
$$QWTSRCDIR/qwt_plot_zoomer.cpp \
$$QWTSRCDIR/qwt_raster_data.cpp \
$$QWTSRCDIR/qwt_rect.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_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_wheel.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.
/* -*- 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
/* -*- 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_scale_draw.h"
#include "qwt_math.h"
#include "qwt_text.h"
#include "qwt_painter.h"
#include "qwt_scale_map.h"
#include <qpainter.h>
#include <qpalette.h>
#include <qmap.h>
#include <qlocale.h>
class QwtAbstractScaleDraw::PrivateData
{
public:
PrivateData():
spacing( 4.0 ),
penWidth( 0 ),
minExtent( 0.0 )
{
components = QwtAbstractScaleDraw::Backbone
| QwtAbstractScaleDraw::Ticks
| QwtAbstractScaleDraw::Labels;
tickLength[QwtScaleDiv::MinorTick] = 4.0;
tickLength[QwtScaleDiv::MediumTick] = 6.0;
tickLength[QwtScaleDiv::MajorTick] = 8.0;
}
ScaleComponents components;
QwtScaleMap map;
QwtScaleDiv scaleDiv;
double spacing;
double tickLength[QwtScaleDiv::NTickTypes];
int penWidth;
double minExtent;
QMap<double, QwtText> labelCache;
};
/*!
\brief Constructor
The range of the scale is initialized to [0, 100],
The spacing (distance between ticks and labels) is
set to 4, the tick lengths are set to 4,6 and 8 pixels
*/
QwtAbstractScaleDraw::QwtAbstractScaleDraw()
{
d_data = new QwtAbstractScaleDraw::PrivateData;
}
//! Destructor
QwtAbstractScaleDraw::~QwtAbstractScaleDraw()
{
delete d_data;
}
/*!
En/Disable a component of the scale
\param component Scale component
\param enable On/Off
\sa hasComponent()
*/
void QwtAbstractScaleDraw::enableComponent(
ScaleComponent component, bool enable )
{
if ( enable )
d_data->components |= component;
else
d_data->components &= ~component;
}
/*!
Check if a component is enabled
\param component Component type
\return true, when component is enabled
\sa enableComponent()
*/
bool QwtAbstractScaleDraw::hasComponent( ScaleComponent component ) const
{
return ( d_data->components & component );
}
/*!
Change the scale division
\param scaleDiv New scale division
*/
void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv &scaleDiv )
{
d_data->scaleDiv = scaleDiv;
d_data->map.setScaleInterval( scaleDiv.lowerBound(), scaleDiv.upperBound() );
d_data->labelCache.clear();
}
/*!
Change the transformation of the scale
\param transformation New scale transformation
*/
void QwtAbstractScaleDraw::setTransformation(
QwtTransform *transformation )
{
d_data->map.setTransformation( transformation );
}
//! \return Map how to translate between scale and pixel values
const QwtScaleMap &QwtAbstractScaleDraw::scaleMap() const
{
return d_data->map;
}
//! \return Map how to translate between scale and pixel values
QwtScaleMap &QwtAbstractScaleDraw::scaleMap()
{
return d_data->map;
}
//! \return scale division
const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const
{
return d_data->scaleDiv;
}
/*!
\brief Specify the width of the scale pen
\param width Pen width
\sa penWidth()
*/
void QwtAbstractScaleDraw::setPenWidth( int width )
{
if ( width < 0 )
width = 0;
if ( width != d_data->penWidth )
d_data->penWidth = width;
}
/*!
\return Scale pen width
\sa setPenWidth()
*/
int QwtAbstractScaleDraw::penWidth() const
{
return d_data->penWidth;
}
/*!
\brief Draw the scale
\param painter The painter
\param palette Palette, text color is used for the labels,
foreground color for ticks and backbone
*/
void QwtAbstractScaleDraw::draw( QPainter *painter,
const QPalette& palette ) const
{
painter->save();
QPen pen = painter->pen();
pen.setWidth( d_data->penWidth );
pen.setCosmetic( false );
painter->setPen( pen );
if ( hasComponent( QwtAbstractScaleDraw::Labels ) )
{
painter->save();
painter->setPen( palette.color( QPalette::Text ) ); // ignore pen style
const QList<double> &majorTicks =
d_data->scaleDiv.ticks( QwtScaleDiv::MajorTick );
for ( int i = 0; i < majorTicks.count(); i++ )
{
const double v = majorTicks[i];
if ( d_data->scaleDiv.contains( v ) )
drawLabel( painter, v );
}
painter->restore();
}
if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
{
painter->save();
QPen pen = painter->pen();
pen.setColor( palette.color( QPalette::WindowText ) );
pen.setCapStyle( Qt::FlatCap );
painter->setPen( pen );
for ( int tickType = QwtScaleDiv::MinorTick;
tickType < QwtScaleDiv::NTickTypes; tickType++ )
{
const QList<double> &ticks = d_data->scaleDiv.ticks( tickType );
for ( int i = 0; i < ticks.count(); i++ )
{
const double v = ticks[i];
if ( d_data->scaleDiv.contains( v ) )
drawTick( painter, v, d_data->tickLength[tickType] );
}
}
painter->restore();
}
if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
{
painter->save();
QPen pen = painter->pen();
pen.setColor( palette.color( QPalette::WindowText ) );
pen.setCapStyle( Qt::FlatCap );
painter->setPen( pen );
drawBackbone( painter );
painter->restore();
}
painter->restore();
}
/*!
\brief Set the spacing between tick and labels
The spacing is the distance between ticks and labels.
The default spacing is 4 pixels.
\param spacing Spacing
\sa spacing()
*/
void QwtAbstractScaleDraw::setSpacing( double spacing )
{
if ( spacing < 0 )
spacing = 0;
d_data->spacing = spacing;
}
/*!
\brief Get the spacing
The spacing is the distance between ticks and labels.
The default spacing is 4 pixels.
\return Spacing
\sa setSpacing()
*/
double QwtAbstractScaleDraw::spacing() const
{
return d_data->spacing;
}
/*!
\brief Set a minimum for the extent
The extent is calculated from the components of the
scale draw. In situations, where the labels are
changing and the layout depends on the extent (f.e scrolling
a scale), setting an upper limit as minimum extent will
avoid jumps of the layout.
\param minExtent Minimum extent
\sa extent(), minimumExtent()
*/
void QwtAbstractScaleDraw::setMinimumExtent( double minExtent )
{
if ( minExtent < 0.0 )
minExtent = 0.0;
d_data->minExtent = minExtent;
}
/*!
Get the minimum extent
\return Minimum extent
\sa extent(), setMinimumExtent()
*/
double QwtAbstractScaleDraw::minimumExtent() const
{
return d_data->minExtent;
}
/*!
Set the length of the ticks
\param tickType Tick type
\param length New length
\warning the length is limited to [0..1000]
*/
void QwtAbstractScaleDraw::setTickLength(
QwtScaleDiv::TickType tickType, double length )
{
if ( tickType < QwtScaleDiv::MinorTick ||
tickType > QwtScaleDiv::MajorTick )
{
return;
}
if ( length < 0.0 )
length = 0.0;
const double maxTickLen = 1000.0;
if ( length > maxTickLen )
length = maxTickLen;
d_data->tickLength[tickType] = length;
}
/*!
\return Length of the ticks
\sa setTickLength(), maxTickLength()
*/
double QwtAbstractScaleDraw::tickLength( QwtScaleDiv::TickType tickType ) const
{
if ( tickType < QwtScaleDiv::MinorTick ||
tickType > QwtScaleDiv::MajorTick )
{
return 0;
}
return d_data->tickLength[tickType];
}
/*!
\return Length of the longest tick
Useful for layout calculations
\sa tickLength(), setTickLength()
*/
double QwtAbstractScaleDraw::maxTickLength() const
{
double length = 0.0;
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
length = qMax( length, d_data->tickLength[i] );
return length;
}
/*!
\brief Convert a value into its representing label
The value is converted to a plain text using
QLocale().toString(value).
This method is often overloaded by applications to have individual
labels.
\param value Value
\return Label string.
*/
QwtText QwtAbstractScaleDraw::label( double value ) const
{
return QLocale().toString( value );
}
/*!
\brief Convert a value into its representing label and cache it.
The conversion between value and label is called very often
in the layout and painting code. Unfortunately the
calculation of the label sizes might be slow (really slow
for rich text in Qt4), so it's necessary to cache the labels.
\param font Font
\param value Value
\return Tick label
*/
const QwtText &QwtAbstractScaleDraw::tickLabel(
const QFont &font, double value ) const
{
QMap<double, QwtText>::const_iterator it = d_data->labelCache.find( value );
if ( it == d_data->labelCache.end() )
{
QwtText lbl = label( value );
lbl.setRenderFlags( 0 );
lbl.setLayoutAttribute( QwtText::MinimumLayout );
( void )lbl.textSize( font ); // initialize the internal cache
it = d_data->labelCache.insert( value, lbl );
}
return ( *it );
}
/*!
Invalidate the cache used by tickLabel()
The cache is invalidated, when a new QwtScaleDiv is set. If
the labels need to be changed. while the same QwtScaleDiv is set,
invalidateCache() needs to be called manually.
*/
void QwtAbstractScaleDraw::invalidateCache()
{
d_data->labelCache.clear();
}
/* -*- 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
This diff is collapsed.
/* -*- 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
/* -*- 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_analog_clock.h"
#include "qwt_round_scale_draw.h"
#include <qmath.h>
#include <qlocale.h>
class QwtAnalogClockScaleDraw: public QwtRoundScaleDraw
{
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 ) ) );
}
};
/*!
Constructor
\param parent Parent widget
*/
QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
QwtDial( parent )
{
setWrapping( true );
setReadOnly( true );
setOrigin( 270.0 );
setScaleDraw( new QwtAnalogClockScaleDraw() );
setTotalSteps( 60 );
const int secondsPerHour = 60.0 * 60.0;
QList<double> majorTicks;
QList<double> minorTicks;
for ( int i = 0; i < 12; i++ )
{
majorTicks += i * secondsPerHour;
for ( int j = 1; j < 5; j++ )
minorTicks += i * secondsPerHour + j * secondsPerHour / 5.0;
}
QwtScaleDiv scaleDiv;
scaleDiv.setInterval( 0.0, 12.0 * secondsPerHour );
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;
int width;
for ( int i = 0; i < NHands; i++ )
{
if ( i == SecondHand )
{
width = 2;
handColor = knobColor.dark( 120 );
}
else
{
width = 8;
handColor = knobColor;
}
QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
hand->setWidth( width );
d_hand[i] = NULL;
setHand( static_cast<Hand>( i ), hand );
}
}
//! Destructor
QwtAnalogClock::~QwtAnalogClock()
{
for ( int i = 0; i < NHands; i++ )
delete d_hand[i];
}
/*!
Nop method, use setHand() instead
\sa setHand()
*/
void QwtAnalogClock::setNeedle( QwtDialNeedle * )
{
// no op
return;
}
/*!
Set a clock hand
\param hand Specifies the type of hand
\param needle Hand
\sa hand()
*/
void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle *needle )
{
if ( hand >= 0 && hand < NHands )
{
delete d_hand[hand];
d_hand[hand] = needle;
}
}
/*!
\return Clock hand
\param hd Specifies the type of hand
\sa setHand()
*/
QwtDialNeedle *QwtAnalogClock::hand( Hand hd )
{
if ( hd < 0 || hd >= NHands )
return NULL;
return d_hand[hd];
}
/*!
\return Clock hand
\param hd Specifies the type of hand
\sa setHand()
*/
const QwtDialNeedle *QwtAnalogClock::hand( Hand hd ) const
{
return const_cast<QwtAnalogClock *>( this )->hand( hd );
}
/*!
\brief Set the current time
*/
void QwtAnalogClock::setCurrentTime()
{
setTime( QTime::currentTime() );
}
/*!
Set a time
\param time Time to display
*/
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 );
}
/*!
\brief Draw the needle
A clock has no single needle but three hands instead. drawNeedle()
translates value() into directions for the hands and calls
drawHand().
\param painter Painter
\param center Center of the clock
\param radius Maximum length for the hands
\param dir Dummy, not used.
\param colorGroup ColorGroup
\sa drawHand()
*/
void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF &center,
double radius, double dir, QPalette::ColorGroup colorGroup ) const
{
Q_UNUSED( dir );
if ( isValid() )
{
const double hours = value() / ( 60.0 * 60.0 );
const double minutes =
( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0;
const double seconds = value() - qFloor(hours) * 60.0 * 60.0
- qFloor(minutes) * 60.0;
double angle[NHands];
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 );
}
}
}
/*!
Draw a clock hand
\param painter Painter
\param hd Specify the type of hand
\param center Center of the clock
\param radius Maximum length for the hands
\param direction Direction of the hand in degrees, counter clockwise
\param cg ColorGroup
*/
void QwtAnalogClock::drawHand( QPainter *painter, Hand hd,
const QPointF &center, double radius, double direction,
QPalette::ColorGroup cg ) const
{
const QwtDialNeedle *needle = hand( hd );
if ( needle )
{
if ( hd == HourHand )
radius = qRound( 0.8 * radius );
needle->draw( painter, center, radius, direction, cg );
}
}
/* -*- 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
/* -*- 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
*****************************************************************************/
// vim: expandtab
#ifndef QWT_ARRAY_H
#define QWT_ARRAY_H
#include "qwt_global.h"
/*!
\def QwtArray
*/
#if QT_VERSION < 0x040000
#include <qmemarray.h>
#define QwtArray QMemArray
#else
#include <qvector.h>
#define QwtArray QVector
#endif
#endif
/* -*- 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_arrow_button.h"
#include "qwt_math.h"
#include <qpainter.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qevent.h>
#include <qapplication.h>
static const int MaxNum = 3;
static const int Margin = 2;
static const int Spacing = 1;
class QwtArrowButton::PrivateData
{
public:
int num;
Qt::ArrowType arrowType;
};
static QStyleOptionButton styleOpt( const QwtArrowButton* btn )
{
QStyleOptionButton option;
option.init( btn );
option.features = QStyleOptionButton::None;
if ( btn->isFlat() )
option.features |= QStyleOptionButton::Flat;
if ( btn->menu() )
option.features |= QStyleOptionButton::HasMenu;
if ( btn->autoDefault() || btn->isDefault() )
option.features |= QStyleOptionButton::AutoDefaultButton;
if ( btn->isDefault() )
option.features |= QStyleOptionButton::DefaultButton;
if ( btn->isDown() )
option.state |= QStyle::State_Sunken;
if ( !btn->isFlat() && !btn->isDown() )
option.state |= QStyle::State_Raised;
return option;
}
/*!
\param num Number of arrows
\param arrowType see Qt::ArrowType in the Qt docs.
\param parent Parent widget
*/
QwtArrowButton::QwtArrowButton( int num,
Qt::ArrowType arrowType, QWidget *parent ):
QPushButton( parent )
{
d_data = new PrivateData;
d_data->num = qBound( 1, num, MaxNum );
d_data->arrowType = arrowType;
setAutoRepeat( true );
setAutoDefault( false );
switch ( d_data->arrowType )
{
case Qt::LeftArrow:
case Qt::RightArrow:
setSizePolicy( QSizePolicy::Expanding,
QSizePolicy::Fixed );
break;
default:
setSizePolicy( QSizePolicy::Fixed,
QSizePolicy::Expanding );
}
}
//! Destructor
QwtArrowButton::~QwtArrowButton()
{
delete d_data;
d_data = NULL;
}
/*!
\brief The direction of the arrows
*/
Qt::ArrowType QwtArrowButton::arrowType() const
{
return d_data->arrowType;
}
/*!
\brief The number of arrows
*/
int QwtArrowButton::num() const
{
return d_data->num;
}
/*!
\return the bounding rectangle for the label
*/
QRect QwtArrowButton::labelRect() const
{
const int m = Margin;
QRect r = rect();
r.setRect( r.x() + m, r.y() + m,
r.width() - 2 * m, r.height() - 2 * m );
if ( isDown() )
{
QStyleOptionButton option = styleOpt( this );
const int ph = style()->pixelMetric(
QStyle::PM_ButtonShiftHorizontal, &option, this );
const int pv = style()->pixelMetric(
QStyle::PM_ButtonShiftVertical, &option, this );
r.translate( ph, pv );
}
return r;
}
/*!
Paint event handler
\param event Paint event
*/
void QwtArrowButton::paintEvent( QPaintEvent *event )
{
QPushButton::paintEvent( event );
QPainter painter( this );
drawButtonLabel( &painter );
}
/*!
\brief Draw the button label
\param painter Painter
\sa The Qt Manual for QPushButton
*/
void QwtArrowButton::drawButtonLabel( QPainter *painter )
{
const bool isVertical = d_data->arrowType == Qt::UpArrow ||
d_data->arrowType == Qt::DownArrow;
const QRect r = labelRect();
QSize boundingSize = labelRect().size();
if ( isVertical )
boundingSize.transpose();
const int w =
( boundingSize.width() - ( MaxNum - 1 ) * Spacing ) / MaxNum;
QSize arrow = arrowSize( Qt::RightArrow,
QSize( w, boundingSize.height() ) );
if ( isVertical )
arrow.transpose();
QRect contentsSize; // aligned rect where to paint all arrows
if ( d_data->arrowType == Qt::LeftArrow || d_data->arrowType == Qt::RightArrow )
{
contentsSize.setWidth( d_data->num * arrow.width()
+ ( d_data->num - 1 ) * Spacing );
contentsSize.setHeight( arrow.height() );
}
else
{
contentsSize.setWidth( arrow.width() );
contentsSize.setHeight( d_data->num * arrow.height()
+ ( d_data->num - 1 ) * Spacing );
}
QRect arrowRect( contentsSize );
arrowRect.moveCenter( r.center() );
arrowRect.setSize( arrow );
painter->save();
for ( int i = 0; i < d_data->num; i++ )
{
drawArrow( painter, arrowRect, d_data->arrowType );
int dx = 0;
int dy = 0;
if ( isVertical )
dy = arrow.height() + Spacing;
else
dx = arrow.width() + Spacing;
arrowRect.translate( dx, dy );
}
painter->restore();
if ( hasFocus() )
{
QStyleOptionFocusRect option;
option.init( this );
option.backgroundColor = palette().color( QPalette::Window );
style()->drawPrimitive( QStyle::PE_FrameFocusRect,
&option, painter, this );
}
}
/*!
Draw an arrow int a bounding rectangle
\param painter Painter
\param r Rectangle where to paint the arrow
\param arrowType Arrow type
*/
void QwtArrowButton::drawArrow( QPainter *painter,
const QRect &r, Qt::ArrowType arrowType ) const
{
QPolygon pa( 3 );
switch ( arrowType )
{
case Qt::UpArrow:
pa.setPoint( 0, r.bottomLeft() );
pa.setPoint( 1, r.bottomRight() );
pa.setPoint( 2, r.center().x(), r.top() );
break;
case Qt::DownArrow:
pa.setPoint( 0, r.topLeft() );
pa.setPoint( 1, r.topRight() );
pa.setPoint( 2, r.center().x(), r.bottom() );
break;
case Qt::RightArrow:
pa.setPoint( 0, r.topLeft() );
pa.setPoint( 1, r.bottomLeft() );
pa.setPoint( 2, r.right(), r.center().y() );
break;
case Qt::LeftArrow:
pa.setPoint( 0, r.topRight() );
pa.setPoint( 1, r.bottomRight() );
pa.setPoint( 2, r.left(), r.center().y() );
break;
default:
break;
}
painter->save();
painter->setRenderHint( QPainter::Antialiasing, true );
painter->setPen( Qt::NoPen );
painter->setBrush( palette().brush( QPalette::ButtonText ) );
painter->drawPolygon( pa );
painter->restore();
}
/*!
\return a size hint
*/
QSize QwtArrowButton::sizeHint() const
{
const QSize hint = minimumSizeHint();
return hint.expandedTo( QApplication::globalStrut() );
}
/*!
\brief Return a minimum size hint
*/
QSize QwtArrowButton::minimumSizeHint() const
{
const QSize asz = arrowSize( Qt::RightArrow, QSize() );
QSize sz(
2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(),
2 * Margin + asz.height()
);
if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow )
sz.transpose();
QStyleOption styleOption;
styleOption.init( this );
sz = style()->sizeFromContents( QStyle::CT_PushButton,
&styleOption, sz, this );
return sz;
}
/*!
Calculate the size for a arrow that fits into a rectangle of a given size
\param arrowType Arrow type
\param boundingSize Bounding size
\return Size of the arrow
*/
QSize QwtArrowButton::arrowSize( Qt::ArrowType arrowType,
const QSize &boundingSize ) const
{
QSize bs = boundingSize;
if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
bs.transpose();
const int MinLen = 2;
const QSize sz = bs.expandedTo(
QSize( MinLen, 2 * MinLen - 1 ) ); // minimum
int w = sz.width();
int h = 2 * w - 1;
if ( h > sz.height() )
{
h = sz.height();
w = ( h + 1 ) / 2;
}
QSize arrSize( w, h );
if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
arrSize.transpose();
return arrSize;
}
/*!
\brief autoRepeat for the space keys
*/
void QwtArrowButton::keyPressEvent( QKeyEvent *event )
{
if ( event->isAutoRepeat() && event->key() == Qt::Key_Space )
Q_EMIT clicked();
QPushButton::keyPressEvent( event );
}
/* -*- 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
This diff is collapsed.
/* -*- 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
This diff is collapsed.
/* -*- 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( 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
/* -*- 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_column_symbol.h"
#include "qwt_math.h"
#include "qwt_painter.h"
#include <qpainter.h>
#include <qpalette.h>
static void qwtDrawBox( QPainter *p, const QRectF &rect,
const QPalette &pal, double lw )
{
if ( lw > 0.0 )
{
if ( rect.width() == 0.0 )
{
p->setPen( pal.dark().color() );
p->drawLine( rect.topLeft(), rect.bottomLeft() );
return;
}
if ( rect.height() == 0.0 )
{
p->setPen( pal.dark().color() );
p->drawLine( rect.topLeft(), rect.topRight() );
return;
}
lw = qMin( lw, rect.height() / 2.0 - 1.0 );
lw = qMin( lw, rect.width() / 2.0 - 1.0 );
const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 );
QPolygonF polygon( outerRect );
if ( outerRect.width() > 2 * lw &&
outerRect.height() > 2 * lw )
{
const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw );
polygon = polygon.subtracted( innerRect );
}
p->setPen( Qt::NoPen );
p->setBrush( pal.dark() );
p->drawPolygon( polygon );
}
const QRectF windowRect = rect.adjusted( lw, lw, -lw + 1, -lw + 1 );
if ( windowRect.isValid() )
p->fillRect( windowRect, pal.window() );
}
static void qwtDrawPanel( QPainter *painter, const QRectF &rect,
const QPalette &pal, double lw )
{
if ( lw > 0.0 )
{
if ( rect.width() == 0.0 )
{
painter->setPen( pal.window().color() );
painter->drawLine( rect.topLeft(), rect.bottomLeft() );
return;
}
if ( rect.height() == 0.0 )
{
painter->setPen( pal.window().color() );
painter->drawLine( rect.topLeft(), rect.topRight() );
return;
}
lw = qMin( lw, rect.height() / 2.0 - 1.0 );
lw = qMin( lw, rect.width() / 2.0 - 1.0 );
const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 );
const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw );
QPolygonF lines[2];
lines[0] += outerRect.bottomLeft();
lines[0] += outerRect.topLeft();
lines[0] += outerRect.topRight();
lines[0] += innerRect.topRight();
lines[0] += innerRect.topLeft();
lines[0] += innerRect.bottomLeft();
lines[1] += outerRect.topRight();
lines[1] += outerRect.bottomRight();
lines[1] += outerRect.bottomLeft();
lines[1] += innerRect.bottomLeft();
lines[1] += innerRect.bottomRight();
lines[1] += innerRect.topRight();
painter->setPen( Qt::NoPen );
painter->setBrush( pal.light() );
painter->drawPolygon( lines[0] );
painter->setBrush( pal.dark() );
painter->drawPolygon( lines[1] );
}
painter->fillRect( rect.adjusted( lw, lw, -lw + 1, -lw + 1 ), pal.window() );
}
class QwtColumnSymbol::PrivateData
{
public:
PrivateData():
style( QwtColumnSymbol::Box ),
frameStyle( QwtColumnSymbol::Raised ),
lineWidth( 2 )
{
palette = QPalette( Qt::gray );
}
QwtColumnSymbol::Style style;
QwtColumnSymbol::FrameStyle frameStyle;
QPalette palette;
int lineWidth;
};
/*!
Constructor
\param style Style of the symbol
\sa setStyle(), style(), Style
*/
QwtColumnSymbol::QwtColumnSymbol( Style style )
{
d_data = new PrivateData();
d_data->style = style;
}
//! Destructor
QwtColumnSymbol::~QwtColumnSymbol()
{
delete d_data;
}
/*!
Specify the symbol style
\param style Style
\sa style(), setPalette()
*/
void QwtColumnSymbol::setStyle( Style style )
{
d_data->style = style;
}
/*!
\return Current symbol style
\sa setStyle()
*/
QwtColumnSymbol::Style QwtColumnSymbol::style() const
{
return d_data->style;
}
/*!
Assign a palette for the symbol
\param palette Palette
\sa palette(), setStyle()
*/
void QwtColumnSymbol::setPalette( const QPalette &palette )
{
d_data->palette = palette;
}
/*!
\return Current palette
\sa setPalette()
*/
const QPalette& QwtColumnSymbol::palette() const
{
return d_data->palette;
}
/*!
Set the frame, that is used for the Box style.
\param frameStyle Frame style
\sa frameStyle(), setLineWidth(), setStyle()
*/
void QwtColumnSymbol::setFrameStyle( FrameStyle frameStyle )
{
d_data->frameStyle = frameStyle;
}
/*!
\return Current frame style, that is used for the Box style.
\sa setFrameStyle(), lineWidth(), setStyle()
*/
QwtColumnSymbol::FrameStyle QwtColumnSymbol::frameStyle() const
{
return d_data->frameStyle;
}
/*!
Set the line width of the frame, that is used for the Box style.
\param width Width
\sa lineWidth(), setFrameStyle()
*/
void QwtColumnSymbol::setLineWidth( int width )
{
if ( width < 0 )
width = 0;
d_data->lineWidth = width;
}
/*!
\return Line width of the frame, that is used for the Box style.
\sa setLineWidth(), frameStyle(), setStyle()
*/
int QwtColumnSymbol::lineWidth() const
{
return d_data->lineWidth;
}
/*!
Draw the symbol depending on its style.
\param painter Painter
\param rect Directed rectangle
\sa drawBox()
*/
void QwtColumnSymbol::draw( QPainter *painter,
const QwtColumnRect &rect ) const
{
painter->save();
switch ( d_data->style )
{
case QwtColumnSymbol::Box:
{
drawBox( painter, rect );
break;
}
default:;
}
painter->restore();
}
/*!
Draw the symbol when it is in Box style.
\param painter Painter
\param rect Directed rectangle
\sa draw()
*/
void QwtColumnSymbol::drawBox( QPainter *painter,
const QwtColumnRect &rect ) const
{
QRectF r = rect.toRect();
if ( QwtPainter::roundingAlignment( painter ) )
{
r.setLeft( qRound( r.left() ) );
r.setRight( qRound( r.right() ) );
r.setTop( qRound( r.top() ) );
r.setBottom( qRound( r.bottom() ) );
}
switch ( d_data->frameStyle )
{
case QwtColumnSymbol::Raised:
{
qwtDrawPanel( painter, r, d_data->palette, d_data->lineWidth );
break;
}
case QwtColumnSymbol::Plain:
{
qwtDrawBox( painter, r, d_data->palette, d_data->lineWidth );
break;
}
default:
{
painter->fillRect( r, d_data->palette.window() );
}
}
}
This diff is collapsed.
This diff is collapsed.
/* -*- 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 &center,
double radius, double north, QPalette::ColorGroup ) const;
virtual void drawScaleContents( QPainter *,
const QPointF &center, double radius ) const;
virtual void keyPressEvent( QKeyEvent * );
private:
class PrivateData;
PrivateData *d_data;
};
#endif
This diff is collapsed.
This diff is collapsed.
/* -*- 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_COMPAT_H_
#define _QWT_COMPAT_H_
#include "qwt_global.h"
#include "qwt_interval.h"
#include "qwt_point_3d.h"
#include <qlist.h>
#include <qvector.h>
#include <qpoint.h>
#include <qsize.h>
#include <qrect.h>
#include <qpolygon.h>
// A couple of definition for Qwt5 compatibility
#define qwtMax qMax
#define qwtMin qMin
#define qwtAbs qAbs
#define qwtRound qRound
#define QwtArray QVector
typedef QList<double> QwtValueList;
typedef QPointF QwtDoublePoint;
typedef QSizeF QwtDoubleSize;
typedef QRectF QwtDoubleRect;
typedef QPolygon QwtPolygon;
typedef QPolygonF QwtPolygonF;
typedef QwtInterval QwtDoubleInterval;
typedef QwtPoint3D QwtDoublePoint3D;
#endif
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.
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