| 1 | /******************************************************************************
|
|---|
| 2 | * Qwt Widget Library
|
|---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
|---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
|---|
| 5 | *
|
|---|
| 6 | * This library is free software; you can redistribute it and/or
|
|---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
|---|
| 8 | *****************************************************************************/
|
|---|
| 9 |
|
|---|
| 10 | #ifndef QWT_PLOT_VECTOR_FIELD_H
|
|---|
| 11 | #define QWT_PLOT_VECTOR_FIELD_H
|
|---|
| 12 |
|
|---|
| 13 | #include "qwt_global.h"
|
|---|
| 14 | #include "qwt_plot_seriesitem.h"
|
|---|
| 15 |
|
|---|
| 16 | class QwtVectorFieldSymbol;
|
|---|
| 17 | class QwtColorMap;
|
|---|
| 18 | class QPen;
|
|---|
| 19 | class QBrush;
|
|---|
| 20 |
|
|---|
| 21 | /*!
|
|---|
| 22 | \brief A plot item, that represents a vector field
|
|---|
| 23 |
|
|---|
| 24 | A vector field is a representation of a points with a given magnitude and direction
|
|---|
| 25 | as arrows. While the direction affects the direction of the arrow, the magnitude
|
|---|
| 26 | might be represented as a color or by the length of the arrow.
|
|---|
| 27 |
|
|---|
| 28 | \sa QwtVectorFieldSymbol, QwtVectorFieldSample
|
|---|
| 29 | */
|
|---|
| 30 | class QWT_EXPORT QwtPlotVectorField
|
|---|
| 31 | : public QwtPlotSeriesItem
|
|---|
| 32 | , public QwtSeriesStore< QwtVectorFieldSample >
|
|---|
| 33 | {
|
|---|
| 34 | public:
|
|---|
| 35 | /*!
|
|---|
| 36 | Depending on the origin the indicator symbol ( usually an arrow )
|
|---|
| 37 | will be to the position of the corresponding sample.
|
|---|
| 38 | */
|
|---|
| 39 | enum IndicatorOrigin
|
|---|
| 40 | {
|
|---|
| 41 | //! symbol points to the sample position
|
|---|
| 42 | OriginHead,
|
|---|
| 43 |
|
|---|
| 44 | //! The arrow starts at the sample position
|
|---|
| 45 | OriginTail,
|
|---|
| 46 |
|
|---|
| 47 | //! The arrow is centered at the sample position
|
|---|
| 48 | OriginCenter
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | /*!
|
|---|
| 52 | Attributes to modify the rendering
|
|---|
| 53 | \sa setPaintAttribute(), testPaintAttribute()
|
|---|
| 54 | */
|
|---|
| 55 | enum PaintAttribute
|
|---|
| 56 | {
|
|---|
| 57 | /*
|
|---|
| 58 | FilterVectors calculates an average sample from all samples
|
|---|
| 59 | that lie in the same cell of a grid that is determined by
|
|---|
| 60 | setting the rasterSize().
|
|---|
| 61 |
|
|---|
| 62 | \sa setRasterSize()
|
|---|
| 63 | */
|
|---|
| 64 | FilterVectors = 0x01
|
|---|
| 65 | };
|
|---|
| 66 |
|
|---|
| 67 | Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
|
|---|
| 68 |
|
|---|
| 69 | /*!
|
|---|
| 70 | Depending on the MagnitudeMode the magnitude component will have
|
|---|
| 71 | an impact on the attributes of the symbol/arrow.
|
|---|
| 72 |
|
|---|
| 73 | \sa setMagnitudeMode()
|
|---|
| 74 | */
|
|---|
| 75 | enum MagnitudeMode
|
|---|
| 76 | {
|
|---|
| 77 | /*!
|
|---|
| 78 | The magnitude will be mapped to a color using a color map
|
|---|
| 79 | \sa magnitudeRange(), colorMap()
|
|---|
| 80 | */
|
|---|
| 81 | MagnitudeAsColor = 0x01,
|
|---|
| 82 |
|
|---|
| 83 | /*!
|
|---|
| 84 | The magnitude will have an impact on the length of the arrow/symbol
|
|---|
| 85 | \sa arrowLength(), magnitudeScaleFactor()
|
|---|
| 86 | */
|
|---|
| 87 | MagnitudeAsLength = 0x02
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | Q_DECLARE_FLAGS( MagnitudeModes, MagnitudeMode )
|
|---|
| 91 |
|
|---|
| 92 | explicit QwtPlotVectorField( const QString& title = QString() );
|
|---|
| 93 | explicit QwtPlotVectorField( const QwtText& title );
|
|---|
| 94 |
|
|---|
| 95 | virtual ~QwtPlotVectorField();
|
|---|
| 96 |
|
|---|
| 97 | void setPaintAttribute( PaintAttribute, bool on = true );
|
|---|
| 98 | bool testPaintAttribute( PaintAttribute ) const;
|
|---|
| 99 |
|
|---|
| 100 | void setMagnitudeMode( MagnitudeMode, bool on = true );
|
|---|
| 101 | bool testMagnitudeMode( MagnitudeMode ) const;
|
|---|
| 102 |
|
|---|
| 103 | void setSymbol( QwtVectorFieldSymbol* );
|
|---|
| 104 | const QwtVectorFieldSymbol* symbol() const;
|
|---|
| 105 |
|
|---|
| 106 | void setPen( const QPen& );
|
|---|
| 107 | QPen pen() const;
|
|---|
| 108 |
|
|---|
| 109 | void setBrush( const QBrush& );
|
|---|
| 110 | QBrush brush() const;
|
|---|
| 111 |
|
|---|
| 112 | void setRasterSize( const QSizeF& );
|
|---|
| 113 | QSizeF rasterSize() const;
|
|---|
| 114 |
|
|---|
| 115 | void setIndicatorOrigin( IndicatorOrigin );
|
|---|
| 116 | IndicatorOrigin indicatorOrigin() const;
|
|---|
| 117 |
|
|---|
| 118 | void setSamples( const QVector< QwtVectorFieldSample >& );
|
|---|
| 119 | void setSamples( QwtVectorFieldData* );
|
|---|
| 120 |
|
|---|
| 121 | void setColorMap( QwtColorMap* );
|
|---|
| 122 | const QwtColorMap* colorMap() const;
|
|---|
| 123 |
|
|---|
| 124 | void setMagnitudeRange( const QwtInterval& );
|
|---|
| 125 | QwtInterval magnitudeRange() const;
|
|---|
| 126 |
|
|---|
| 127 | void setMinArrowLength( double );
|
|---|
| 128 | double minArrowLength() const;
|
|---|
| 129 |
|
|---|
| 130 | void setMaxArrowLength( double );
|
|---|
| 131 | double maxArrowLength() const;
|
|---|
| 132 |
|
|---|
| 133 | virtual double arrowLength( double magnitude ) const;
|
|---|
| 134 |
|
|---|
| 135 | virtual QRectF boundingRect() const QWT_OVERRIDE;
|
|---|
| 136 |
|
|---|
| 137 | virtual void drawSeries( QPainter*,
|
|---|
| 138 | const QwtScaleMap& xMap, const QwtScaleMap& yMap,
|
|---|
| 139 | const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
|
|---|
| 140 |
|
|---|
| 141 | virtual int rtti() const QWT_OVERRIDE;
|
|---|
| 142 |
|
|---|
| 143 | virtual QwtGraphic legendIcon(
|
|---|
| 144 | int index, const QSizeF& ) const QWT_OVERRIDE;
|
|---|
| 145 |
|
|---|
| 146 | void setMagnitudeScaleFactor( double factor );
|
|---|
| 147 | double magnitudeScaleFactor() const;
|
|---|
| 148 |
|
|---|
| 149 | protected:
|
|---|
| 150 | virtual void drawSymbols( QPainter*,
|
|---|
| 151 | const QwtScaleMap& xMap, const QwtScaleMap& yMap,
|
|---|
| 152 | const QRectF& canvasRect, int from, int to ) const;
|
|---|
| 153 |
|
|---|
| 154 | virtual void drawSymbol( QPainter*,
|
|---|
| 155 | double x, double y, double vx, double vy ) const;
|
|---|
| 156 |
|
|---|
| 157 | virtual void dataChanged() QWT_OVERRIDE;
|
|---|
| 158 |
|
|---|
| 159 | private:
|
|---|
| 160 | void init();
|
|---|
| 161 |
|
|---|
| 162 | class PrivateData;
|
|---|
| 163 | PrivateData* m_data;
|
|---|
| 164 | };
|
|---|
| 165 |
|
|---|
| 166 | Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotVectorField::PaintAttributes )
|
|---|
| 167 | Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotVectorField::MagnitudeModes )
|
|---|
| 168 |
|
|---|
| 169 | #endif
|
|---|