Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxColorScale.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: QtxColorScale.h
24 // Author: Sergey TELKOV
25 //
26 #ifndef QTXCOLORSCALE_H
27 #define QTXCOLORSCALE_H
28 
29 #include "Qtx.h"
30 
31 #include <QFrame>
32 #include <QList>
33 
34 class QTextDocument;
35 
36 #ifdef WIN32
37 #pragma warning( disable:4251 )
38 #endif
39 
41 {
42  Q_OBJECT
43 
44 public:
46  typedef enum {
47  Auto,
48  User
49  } Mode;
51  typedef enum {
52  None,
53  Left,
55  Center
56  } Position;
58  typedef enum {
62  FullDump
63  } DumpMode;
65  typedef enum {
66  AtBorder = 0x001,
67  Reverse = 0x002,
68  Integer = 0x004,
69  WrapTitle = 0x008,
70  PreciseFormat = 0x010,
71  Transparent = 0x020
72  } Flags;
73 
74 public:
75  QtxColorScale( QWidget* = 0, Qt::WindowFlags = 0 );
76  QtxColorScale( const int, QWidget* = 0, Qt::WindowFlags = 0 );
77  virtual ~QtxColorScale();
78 
79  double minimum() const;
80  double maximum() const;
81  void range( double&, double& ) const;
82  int dumpMode() const;
83  int labelMode() const;
84  int colorMode() const;
85  int intervalsNumber() const;
86 
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;
93 
94  int labelPosition() const;
95  int titlePosition() const;
96 
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 );
104 
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>& );
111 
112  void setLabelPosition( const int );
113  void setTitlePosition( const int );
114 
115  void setFlags( const int );
116  bool testFlags( const int ) const;
117  void clearFlags( const int );
118 
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;
122 
123  virtual QSize minimumSizeHint() const;
124  virtual QSize sizeHint() const;
125 
126  virtual void show();
127  virtual void hide();
128 
129 protected:
130  virtual void paintEvent( QPaintEvent* );
131  virtual void drawContents( QPainter* );
132 
133 private:
134  void updateScale();
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;
147 
148 private:
149  double myMin;
150  double myMax;
151  QString myTitle;
152  QString myFormat;
153  QString myPrecise;
158 
161 
162  int myFlags;
165 };
166 
167 #ifdef WIN32
168 #pragma warning( default:4251 )
169 #endif
170 
171 #endif // QTXCOLORSCALE_H