1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
23 // File: QtxColorScale.h
24 // Author: Sergey TELKOV
26 #ifndef QTXCOLORSCALE_H
27 #define QTXCOLORSCALE_H
37 #pragma warning( disable:4251 )
40 class QTX_EXPORT QtxColorScale : public QFrame
45 //! Color scale color/label mode.
48 User //!< user defined
50 //! Color scale title, label position.
52 None, //!< do not draw
53 Left, //!< draw at the left
54 Right, //!< draw at the right
55 Center //!< draw at the center
59 NoDump, //!< do not dump
60 TitleDump, //!< dump title
61 ScaleDump, //!< dump scale
62 FullDump //!< dump all
64 //! Color scale flags (bitwise).
66 AtBorder = 0x001, //!< diplay values at colors boundaries
67 Reverse = 0x002, //!< display color scale in reverse order
68 Integer = 0x004, //!< round numbers to integer values
69 WrapTitle = 0x008, //!< wrap title to several lines
70 PreciseFormat = 0x010, //!< autodetect decimal point precision for color scale values
71 Transparent = 0x020 //!< transparent background (not implemented yet!)
75 QtxColorScale( QWidget* = 0, Qt::WindowFlags = 0 );
76 QtxColorScale( const int, QWidget* = 0, Qt::WindowFlags = 0 );
77 virtual ~QtxColorScale();
79 double minimum() const;
80 double maximum() const;
81 void range( double&, double& ) const;
83 int labelMode() const;
84 int colorMode() const;
85 int intervalsNumber() const;
87 QString title() const;
88 QString format() const;
89 QString label( const int ) const;
90 QColor color( const int ) const;
91 void labels( QStringList& ) const;
92 void colors( QList<QColor>& ) const;
94 int labelPosition() const;
95 int titlePosition() const;
97 void setMinimum( const double );
98 void setMaximum( const double );
99 void setRange( const double, const double );
100 void setDumpMode( const int );
101 void setColorMode( const int );
102 void setLabelMode( const int );
103 void setIntervalsNumber( const int );
105 void setTitle( const QString& );
106 void setFormat( const QString& );
107 void setLabel( const QString&, const int = -1 );
108 void setColor( const QColor&, const int = -1 );
109 void setLabels( const QStringList& );
110 void setColors( const QList<QColor>& );
112 void setLabelPosition( const int );
113 void setTitlePosition( const int );
115 void setFlags( const int );
116 bool testFlags( const int ) const;
117 void clearFlags( const int );
119 QPixmap dump() const;
120 QPixmap dump( const int = -1, const int = -1 ) const;
121 QPixmap dump( const QColor&, const int = -1, const int = -1 ) const;
123 virtual QSize minimumSizeHint() const;
124 virtual QSize sizeHint() const;
130 virtual void paintEvent( QPaintEvent* );
131 virtual void drawContents( QPainter* );
135 QString getFormat() const;
136 QString getLabel( const int ) const;
137 QColor getColor( const int ) const;
138 double getNumber( const int ) const;
139 QTextDocument* textDocument( const int ) const;
140 void drawScale( QPainter*, const bool, const int, const int,
141 const int, const int, const bool, const bool, const bool ) const;
142 void drawScale( QPainter*, const QColor&, const bool,
143 const int, const int, const int, const int,
144 const bool, const bool, const bool ) const;
145 QSize calculateSize( const bool, const int,
146 const bool, const bool, const bool ) const;
149 double myMin; //!< lower limit
150 double myMax; //!< upper limit
151 QString myTitle; //!< title
152 QString myFormat; //!< number presentation format
153 QString myPrecise; //!< double values precision format
154 int myInterval; //!< number of color scale intervals
155 int myDumpMode; //!< dump mode (QtxColorScale::DumpMode)
156 int myColorMode; //!< color mode (QtxColorScale::Mode)
157 int myLabelMode; //!< label mode (QtxColorScale::Mode)
159 QList<QColor> myColors; //!< list of colors
160 QList<QString> myLabels; //!< list of labels
162 int myFlags; //!< color scale flags (QtxColorScale::Flags)
163 int myLabelPos; //!< label position (QtxColorScale::Position)
164 int myTitlePos; //!< title position (QtxColorScale::Position)
168 #pragma warning( default:4251 )
171 #endif // QTXCOLORSCALE_H