[89] | 1 | #ifndef __LABELPIXMAP_H__
|
---|
| 2 | #define __LABELPIXMAP_H__
|
---|
| 3 |
|
---|
| 4 | #include <qpixmap.h>
|
---|
| 5 | #include <qimage.h>
|
---|
| 6 | #include <qfont.h>
|
---|
| 7 | #include <qpainter.h>
|
---|
| 8 | #include <qfontmetrics.h>
|
---|
| 9 |
|
---|
| 10 | #include "qwt3d_drawable.h"
|
---|
| 11 |
|
---|
| 12 | namespace Qwt3D
|
---|
| 13 | {
|
---|
| 14 |
|
---|
| 15 | //! A Qt string or an output device dependent string
|
---|
| 16 | class QWT3D_EXPORT Label : public Drawable
|
---|
| 17 | {
|
---|
| 18 |
|
---|
| 19 | public:
|
---|
| 20 |
|
---|
| 21 | Label();
|
---|
| 22 | //! Construct label and initialize with font
|
---|
| 23 | Label(const QString & family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
---|
| 24 |
|
---|
| 25 | //! Sets the labels font
|
---|
| 26 | void setFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
---|
| 27 |
|
---|
| 28 | void adjust(int gap); //!< Fine tunes label;
|
---|
| 29 | double gap() const {return gap_;} //!< Returns the gap caused by adjust();
|
---|
| 30 | void setPosition(Qwt3D::Triple pos, ANCHOR a = BottomLeft); //!< Sets the labels position
|
---|
| 31 | void setRelPosition(Tuple rpos, ANCHOR a); //!< Sets the labels position relative to screen
|
---|
| 32 | Qwt3D::Triple first() const { return beg_;} //!< Receives bottom left label position
|
---|
| 33 | Qwt3D::Triple second() const { return end_;} //!< Receives top right label position
|
---|
| 34 | ANCHOR anchor() const { return anchor_; } //!< Defines an anchor point for the labels surrounding rectangle
|
---|
| 35 | virtual void setColor(double r, double g, double b, double a = 1);
|
---|
| 36 | virtual void setColor(Qwt3D::RGBA rgba);
|
---|
| 37 |
|
---|
| 38 | /*!
|
---|
| 39 | \brief Sets the labels string
|
---|
| 40 | For unicode labeling (<tt> QChar(0x3c0) </tt> etc.) please look at <a href="http://www.unicode.org/charts/">www.unicode.org</a>.
|
---|
| 41 | */
|
---|
| 42 | void setString(QString const& s);
|
---|
| 43 | void draw(); //!< Actual drawing
|
---|
| 44 |
|
---|
| 45 | /**
|
---|
| 46 | \brief Decides about use of PDF standard fonts for PDF output
|
---|
| 47 | If true, Label can use one of the PDF standard fonts (unprecise positioning for now),
|
---|
| 48 | otherwise it dumps pixmaps in the PDF stream (poor quality)
|
---|
| 49 | */
|
---|
| 50 | static void useDeviceFonts(bool val);
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | private:
|
---|
| 54 |
|
---|
| 55 | Qwt3D::Triple beg_, end_, pos_;
|
---|
| 56 | QPixmap pm_;
|
---|
| 57 | QImage buf_, tex_;
|
---|
| 58 | QFont font_;
|
---|
| 59 | QString text_;
|
---|
| 60 |
|
---|
| 61 | ANCHOR anchor_;
|
---|
| 62 |
|
---|
| 63 | void init();
|
---|
| 64 | void init(const QString & family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
---|
| 65 | void update(); //!< Enforces an update of the internal pixmap
|
---|
| 66 | void convert2screen();
|
---|
| 67 | double width() const;
|
---|
| 68 | double height() const;
|
---|
| 69 |
|
---|
| 70 | int gap_;
|
---|
| 71 |
|
---|
| 72 | bool flagforupdate_;
|
---|
| 73 |
|
---|
| 74 | static bool devicefonts_;
|
---|
| 75 |
|
---|
| 76 | };
|
---|
| 77 |
|
---|
| 78 | } // ns
|
---|
| 79 |
|
---|
| 80 | #endif
|
---|