1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: QtxColorScale.h
23 // Author: Sergey TELKOV
25 #ifndef QTXCOLORSCALE_H
26 #define QTXCOLORSCALE_H
36 #pragma warning( disable:4251 )
39 class QTX_EXPORT QtxColorScale : public QFrame
44 //! Color scale color/label mode.
47 User //!< user defined
49 //! Color scale title, label position.
51 None, //!< do not draw
52 Left, //!< draw at the left
53 Right, //!< draw at the right
54 Center //!< draw at the center
58 NoDump, //!< do not dump
59 TitleDump, //!< dump title
60 ScaleDump, //!< dump scale
61 FullDump //!< dump all
63 //! Color scale flags (bitwise).
65 AtBorder = 0x001, //!< diplay values at colors boundaries
66 Reverse = 0x002, //!< display color scale in reverse order
67 Integer = 0x004, //!< round numbers to integer values
68 WrapTitle = 0x008, //!< wrap title to several lines
69 PreciseFormat = 0x010, //!< autodetect decimal point precision for color scale values
70 Transparent = 0x020 //!< transparent background (not implemented yet!)
74 QtxColorScale( QWidget* = 0, Qt::WindowFlags = 0 );
75 QtxColorScale( const int, QWidget* = 0, Qt::WindowFlags = 0 );
76 virtual ~QtxColorScale();
78 double minimum() const;
79 double maximum() const;
80 void range( double&, double& ) const;
82 int labelMode() const;
83 int colorMode() const;
84 int intervalsNumber() const;
86 QString title() const;
87 QString format() const;
88 QString label( const int ) const;
89 QColor color( const int ) const;
90 void labels( QStringList& ) const;
91 void colors( QList<QColor>& ) const;
93 int labelPosition() const;
94 int titlePosition() const;
96 void setMinimum( const double );
97 void setMaximum( const double );
98 void setRange( const double, const double );
99 void setDumpMode( const int );
100 void setColorMode( const int );
101 void setLabelMode( const int );
102 void setIntervalsNumber( const int );
104 void setTitle( const QString& );
105 void setFormat( const QString& );
106 void setLabel( const QString&, const int = -1 );
107 void setColor( const QColor&, const int = -1 );
108 void setLabels( const QStringList& );
109 void setColors( const QList<QColor>& );
111 void setLabelPosition( const int );
112 void setTitlePosition( const int );
114 void setFlags( const int );
115 bool testFlags( const int ) const;
116 void clearFlags( const int );
118 QPixmap dump() const;
119 QPixmap dump( const int = -1, const int = -1 ) const;
120 QPixmap dump( const QColor&, const int = -1, const int = -1 ) const;
122 virtual QSize minimumSizeHint() const;
123 virtual QSize sizeHint() const;
129 virtual void paintEvent( QPaintEvent* );
130 virtual void drawContents( QPainter* );
134 QString getFormat() const;
135 QString getLabel( const int ) const;
136 QColor getColor( const int ) const;
137 double getNumber( const int ) const;
138 QTextDocument* textDocument( const int ) const;
139 void drawScale( QPainter*, const bool, const int, const int,
140 const int, const int, const bool, const bool, const bool ) const;
141 void drawScale( QPainter*, const QColor&, const bool,
142 const int, const int, const int, const int,
143 const bool, const bool, const bool ) const;
144 QSize calculateSize( const bool, const int,
145 const bool, const bool, const bool ) const;
148 double myMin; //!< lower limit
149 double myMax; //!< upper limit
150 QString myTitle; //!< title
151 QString myFormat; //!< number presentation format
152 QString myPrecise; //!< double values precision format
153 int myInterval; //!< number of color scale intervals
154 int myDumpMode; //!< dump mode (QtxColorScale::DumpMode)
155 int myColorMode; //!< color mode (QtxColorScale::Mode)
156 int myLabelMode; //!< label mode (QtxColorScale::Mode)
158 QList<QColor> myColors; //!< list of colors
159 QList<QString> myLabels; //!< list of labels
161 int myFlags; //!< color scale flags (QtxColorScale::Flags)
162 int myLabelPos; //!< label position (QtxColorScale::Position)
163 int myTitlePos; //!< title position (QtxColorScale::Position)
167 #pragma warning( default:4251 )
170 #endif // QTXCOLORSCALE_H