[89] | 1 | #ifndef __COLORGENERATOR_H__
|
---|
| 2 | #define __COLORGENERATOR_H__
|
---|
| 3 |
|
---|
| 4 | #include <qstring.h>
|
---|
| 5 | #include "qwt3d_global.h"
|
---|
| 6 | #include "qwt3d_types.h"
|
---|
| 7 |
|
---|
| 8 | namespace Qwt3D
|
---|
| 9 | {
|
---|
| 10 |
|
---|
| 11 | //! Abstract base class for color functors
|
---|
| 12 | /*!
|
---|
| 13 | Use your own color model by providing an implementation of operator()(double x, double y, double z).
|
---|
| 14 | Colors destructor has been declared \c protected, in order to use only heap based objects. Plot3D
|
---|
| 15 | will handle the objects destruction.
|
---|
| 16 | See StandardColor for an example
|
---|
| 17 | */
|
---|
| 18 | class QWT3D_EXPORT Color
|
---|
| 19 | {
|
---|
| 20 | public:
|
---|
| 21 | virtual Qwt3D::RGBA operator()(double x, double y, double z) const = 0; //!< Implement your color model here
|
---|
| 22 | virtual Qwt3D::RGBA operator()(Qwt3D::Triple const& t) const {return this->operator()(t.x,t.y,t.z);}
|
---|
| 23 | //! Should create a color vector usable by ColorLegend. The default implementation returns his argument
|
---|
| 24 | virtual Qwt3D::ColorVector& createVector(Qwt3D::ColorVector& vec) { return vec; }
|
---|
| 25 |
|
---|
| 26 | void destroy() const { delete this;}
|
---|
| 27 |
|
---|
| 28 | protected:
|
---|
| 29 | virtual ~Color(){} //!< Allow heap based objects only
|
---|
| 30 | };
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | class Plot3D;
|
---|
| 35 | //! Standard color model for Plot3D - implements the data driven operator()(double x, double y, double z)
|
---|
| 36 | /*!
|
---|
| 37 | The class has a ColorVector representing z values, which will be used by operator()(double x, double y, double z)
|
---|
| 38 | */
|
---|
| 39 | class QWT3D_EXPORT StandardColor : public Color
|
---|
| 40 | {
|
---|
| 41 | public:
|
---|
| 42 | //! Initializes with data and set up a ColorVector with a size of 100 z values (default);
|
---|
| 43 | explicit StandardColor(Qwt3D::Plot3D* data, unsigned size = 100);
|
---|
| 44 | Qwt3D::RGBA operator()(double x, double y, double z) const; //!< Receives z-dependend color from ColorVector
|
---|
| 45 | void setColorVector(Qwt3D::ColorVector const& cv);
|
---|
| 46 | void reset(unsigned size=100); //!< Resets the standard colors;
|
---|
| 47 | void setAlpha(double a); //!< Sets unitary alpha value for all colors
|
---|
| 48 | /**
|
---|
| 49 | \brief Creates color vector
|
---|
| 50 |
|
---|
| 51 | Creates a color vector used by ColorLegend. This is essentially a copy from the internal used vector.
|
---|
| 52 | \return The vector created
|
---|
| 53 | */
|
---|
| 54 | Qwt3D::ColorVector& createVector(Qwt3D::ColorVector& vec) {vec = colors_; return vec;}
|
---|
| 55 |
|
---|
| 56 | protected:
|
---|
| 57 | Qwt3D::ColorVector colors_;
|
---|
| 58 | Qwt3D::Plot3D* data_;
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | } // ns
|
---|
| 62 |
|
---|
| 63 | #endif
|
---|