Version: 6.3.1
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

QtxColorScale Class Reference

Color Scale widget.

#include <QtxColorScale.h>

Inheritance diagram for QtxColorScale:
Inheritance graph

Public Types

enum  Mode { Auto, User }
 

Color scale color/label mode.

More...
enum  Position { None, Left, Right, Center }
 

Color scale title, label position.

More...
enum  DumpMode { NoDump, TitleDump, ScaleDump, FullDump }
 

Dump mode.

More...
enum  Flags {
  AtBorder = 0x001, Reverse = 0x002, Integer = 0x004, WrapTitle = 0x008,
  PreciseFormat = 0x010, Transparent = 0x020
}
 

Color scale flags (bitwise).

More...

Public Member Functions

 QtxColorScale (QWidget *=0, Qt::WindowFlags=0)
 Constructor.
 QtxColorScale (const int, QWidget *=0, Qt::WindowFlags=0)
 Constructor.
virtual ~QtxColorScale ()
 Destructor.
double minimum () const
 Get color scale minimum value.
double maximum () const
 Get color scale maximum value.
void range (double &, double &) const
 Get color scale range.
int dumpMode () const
 Get Color scale dump mode.
int labelMode () const
 Get label mode.
int colorMode () const
 Get color mode.
int intervalsNumber () const
 Get number of color scale intervals.
QString title () const
 Get color scale title.
QString format () const
 Get current format of the number presentation.
QString label (const int) const
 Get user label for the specified color scale interval.
QColor color (const int) const
 Get user color for the specified color scale interval.
void labels (QStringList &) const
 Get user labels for all color scale intervals.
void colors (QList< QColor > &) const
 Get user colors for all color scale intervals.
int labelPosition () const
 Get label position.
int titlePosition () const
 Get title position.
void setMinimum (const double)
 Set color scale minimum value.
void setMaximum (const double)
 Set color scale maximum value.
void setRange (const double, const double)
 Set color scale range.
void setDumpMode (const int)
 Set color scale dump mode.
void setColorMode (const int)
 Set color scale color mode.
void setLabelMode (const int)
 Set color scale label mode.
void setIntervalsNumber (const int)
 Set number of color scale intervals.
void setTitle (const QString &)
 Set color scale title.
void setFormat (const QString &)
 Set current format of the number presentation.
void setLabel (const QString &, const int=-1)
 Set user label for the specified color scale interval.
void setColor (const QColor &, const int=-1)
 Set user color for the specified color scale interval.
void setLabels (const QStringList &)
 Set user labels for all color scale intervals.
void setColors (const QList< QColor > &)
 Set user colors for all color scale intervals.
void setLabelPosition (const int)
 Set label position.
void setTitlePosition (const int)
 Set title position.
void setFlags (const int)
 Set color scale flags.
bool testFlags (const int) const
 Test color scale flags.
void clearFlags (const int)
 Clear (reset) color scale flags.
QPixmap dump () const
 Dump color scale into pixmap with current size.
QPixmap dump (const int=-1, const int=-1) const
 Dump color scale into pixmap with the specified size.
QPixmap dump (const QColor &, const int=-1, const int=-1) const
 Dump color scale into pixmap with the specified size and background color.
virtual QSize minimumSizeHint () const
 Get widget's minumum size hint.
virtual QSize sizeHint () const
 Get widget's default size hint.
virtual void show ()
 Show color scale (reimplemented from QFrame).
virtual void hide ()
 Hide color scale (reimplemented from QFrame).

Protected Member Functions

virtual void paintEvent (QPaintEvent *)
 Paint widget.
virtual void drawContents (QPainter *)
 Draw color scale (reimplemented from QFrame).

Private Member Functions

void updateScale ()
 Update color scale.
QString getFormat () const
 Generate number presentation format.
QString getLabel (const int) const
 Get color scale label text corresponding to the specified interval.
QColor getColor (const int) const
 Get color scale color corresponding to the specified interval.
double getNumber (const int) const
 Get color scale value corresponding to the specified interval.
QTextDocument * textDocument (const int) const
 Get text document (rich text) for the color scale title representation.
void drawScale (QPainter *, const bool, const int, const int, const int, const int, const bool, const bool, const bool) const
 Draw color scale contents.
void drawScale (QPainter *, const QColor &, const bool, const int, const int, const int, const int, const bool, const bool, const bool) const
 Draw color scale contents.
QSize calculateSize (const bool, const int, const bool, const bool, const bool) const
 Calculate color scale size.

Private Attributes

double myMin
 lower limit
double myMax
 upper limit
QString myTitle
 title
QString myFormat
 number presentation format
QString myPrecise
 double values precision format
int myInterval
 number of color scale intervals
int myDumpMode
 dump mode (QtxColorScale.DumpMode)
int myColorMode
 color mode (QtxColorScale.Mode)
int myLabelMode
 label mode (QtxColorScale.Mode)
QList< QColor > myColors
 list of colors
QList< QString > myLabels
 list of labels
int myFlags
 color scale flags (QtxColorScale.Flags)
int myLabelPos
 label position (QtxColorScale.Position)
int myTitlePos
 title position (QtxColorScale.Position)

Member Enumeration Documentation

Enumerator:
Auto 

auto

User 

user defined

Enumerator:
None 

do not draw

Left 

draw at the left

Right 

draw at the right

Center 

draw at the center

Enumerator:
NoDump 

do not dump

TitleDump 

dump title

ScaleDump 

dump scale

FullDump 

dump all

Enumerator:
AtBorder 

diplay values at colors boundaries

Reverse 

display color scale in reverse order

Integer 

round numbers to integer values

WrapTitle 

wrap title to several lines

PreciseFormat 

autodetect decimal point precision for color scale values

Transparent 

transparent background (not implemented yet!)


Constructor & Destructor Documentation

QtxColorScale::QtxColorScale ( QWidget parent = 0,
Qt::WindowFlags  f = 0 
)
Parameters:
parentparent widget
fwidget flags
QtxColorScale::QtxColorScale ( const int  num,
QWidget parent = 0,
Qt::WindowFlags  f = 0 
)
Parameters:
numnumber of color scale intervals
parentparent widget
fwidget flags
QtxColorScale::~QtxColorScale ( ) [virtual]

Does nothing for the moment.


Member Function Documentation

double QtxColorScale::minimum ( ) const
Returns:
lower limit of the color scale

References myMin.

double QtxColorScale::maximum ( ) const
Returns:
upper limit of the color scale

References myMax.

void QtxColorScale::range ( double &  min,
double &  max 
) const
Parameters:
minreturning lower limit of the color scale
maxreturning upper limit of the color scale

References myMax, and myMin.

int QtxColorScale::dumpMode ( ) const
Returns:
current dump mode (QtxColorScale.DumpMode)

References myDumpMode.

int QtxColorScale::labelMode ( ) const
Returns:
current label mode (QtxColorScale.Mode)

References myLabelMode.

int QtxColorScale::colorMode ( ) const
Returns:
current color mode (QtxColorScale.Mode)

References myColorMode.

int QtxColorScale::intervalsNumber ( ) const
Returns:
number of intervals

References myInterval.

QString QtxColorScale::title ( ) const
Returns:
current title

References myTitle.

QString QtxColorScale::format ( ) const

This format is used to output values in the color scale labels in "Auto" label mode. The format uses sprintf specification.

Returns:
current format

References myFormat.

QString QtxColorScale::label ( const int  idx) const
Parameters:
idxinterval index
Returns:
user label for specified interval

References myLabels.

QColor QtxColorScale::color ( const int  idx) const
Parameters:
idxinterval index
Returns:
user color for specified interval

References myColors.

void QtxColorScale::labels ( QStringList &  list) const
Parameters:
listreturning labels list

References myLabels.

void QtxColorScale::colors ( QList< QColor > &  list) const
Parameters:
listreturning colors list

References myColors.

int QtxColorScale::labelPosition ( ) const
Returns:
label position (QtxColorScale.Position)

References myLabelPos.

int QtxColorScale::titlePosition ( ) const
Returns:
title position (QtxColorScale.Position)

References myTitlePos.

void QtxColorScale::setMinimum ( const double  val)
Parameters:
vallower limit of the color scale

References maximum(), and setRange().

void QtxColorScale::setMaximum ( const double  val)
Parameters:
valupper limit of the color scale

References minimum(), and setRange().

void QtxColorScale::setRange ( const double  min,
const double  max 
)
Parameters:
minlower limit of the color scale
maxupper limit of the color scale

References Auto, colorMode(), labelMode(), myMax, myMin, myPrecise, and updateScale().

void QtxColorScale::setDumpMode ( const int  mode)
Parameters:
modenew dump mode (QtxColorScale.DumpMode)

References myDumpMode.

void QtxColorScale::setColorMode ( const int  mode)
Parameters:
modenew color mode (QtxColorScale.Mode)

References myColorMode, and updateScale().

void QtxColorScale::setLabelMode ( const int  mode)
Parameters:
modenew label mode (QtxColorScale.Mode)

References myLabelMode, and updateScale().

void QtxColorScale::setIntervalsNumber ( const int  num)
Parameters:
numnumber of intervals

References myInterval, myPrecise, and updateScale().

void QtxColorScale::setTitle ( const QString &  str)
Parameters:
strnew title

References myTitle, and updateScale().

void QtxColorScale::setFormat ( const QString &  format)
See also:
format()
Parameters:
formatnew number presentation format

References Auto, colorMode(), format(), myFormat, myPrecise, and updateScale().

void QtxColorScale::setLabel ( const QString &  txt,
const int  idx = -1 
)

If number of interval is negative then user label will be added as new to the end of list.

Parameters:
txtuser label
idxinterval index

References myLabels, and updateScale().

void QtxColorScale::setColor ( const QColor &  clr,
const int  idx = -1 
)

If number of interval is negative then user color will be added as new to the end of list.

Parameters:
clruser color
idxinterval index

References myColors, and updateScale().

void QtxColorScale::setLabels ( const QStringList &  list)
Parameters:
listnew labels list

References myLabels, and updateScale().

void QtxColorScale::setColors ( const QList< QColor > &  list)
Parameters:
listnew colors list

References myColors, and updateScale().

void QtxColorScale::setLabelPosition ( const int  pos)
Parameters:
posnew label position (QtxColorScale.Position)

References Center, myLabelPos, None, and updateScale().

void QtxColorScale::setTitlePosition ( const int  pos)
Parameters:
posnew title position (QtxColorScale.Position)

References Center, myTitlePos, None, and updateScale().

void QtxColorScale::setFlags ( const int  flags)
Parameters:
flagsnew flags

References myFlags, and updateScale().

bool QtxColorScale::testFlags ( const int  flags) const
Returns:
true if specified flags are set

References myFlags.

void QtxColorScale::clearFlags ( const int  flags)
Parameters:
flagscolor scale flags to be cleared

References myFlags, and updateScale().

QPixmap QtxColorScale::dump ( ) const
QPixmap QtxColorScale::dump ( const int  w = -1,
const int  h = -1 
) const
Parameters:
wpixmap width
hpixmap height
Returns:
generated pixmap

References color(), and dump().

QPixmap QtxColorScale::dump ( const QColor &  bg,
const int  w = -1,
const int  h = -1 
) const
Parameters:
bgpixmap background color
wpixmap width
hpixmap height
Returns:
generated pixmap

References calculateSize(), drawScale(), dumpMode(), FullDump, label(), labelPosition(), myDumpMode, myFlags, NoDump, None, ScaleDump, title(), TitleDump, titlePosition(), and WrapTitle.

QSize QtxColorScale::minimumSizeHint ( ) const [virtual]
Returns:
minimum size hint

References calculateSize(), labelPosition(), myFlags, None, and titlePosition().

QSize QtxColorScale::sizeHint ( ) const [virtual]
Returns:
size hint

References calculateSize(), labelPosition(), myFlags, None, and titlePosition().

void QtxColorScale::show ( ) [virtual]
void QtxColorScale::hide ( ) [virtual]
void QtxColorScale::paintEvent ( QPaintEvent *  e) [protected, virtual]
Parameters:
epaint event

References drawContents().

void QtxColorScale::drawContents ( QPainter *  p) [protected, virtual]
Parameters:
ppainter

References drawScale(), labelPosition(), None, and titlePosition().

void QtxColorScale::updateScale ( ) [private]
QString QtxColorScale::getFormat ( ) const [private]
Returns:
format for number labels

References format(), getNumber(), Integer, intervalsNumber(), myPrecise, PreciseFormat, and testFlags().

QString QtxColorScale::getLabel ( const int  idx) const [private]
Parameters:
idxinterval index
Returns:
color scale label text

References getFormat(), getNumber(), Integer, label(), labelMode(), testFlags(), and User.

QColor QtxColorScale::getColor ( const int  idx) const [private]
Parameters:
idxinterval index
Returns:
color scale color

References color(), colorMode(), intervalsNumber(), Qtx.scaleColor(), and User.

double QtxColorScale::getNumber ( const int  idx) const [private]
Parameters:
idxinterval index
Returns:
color scale value

References intervalsNumber(), maximum(), and minimum().

QTextDocument * QtxColorScale::textDocument ( const int  ) const [private]

If title is not defined (empty string) then null pointer is returned. The calling function is responsible for the returning object deleting.

Parameters:
flagscolor scale flags (not used)
Returns:
text document or 0 if title is not set

References Center, Left, None, Right, title(), and titlePosition().

void QtxColorScale::drawScale ( QPainter *  p,
const bool  transp,
const int  X,
const int  Y,
const int  W,
const int  H,
const bool  drawTitle,
const bool  drawLabel,
const bool  drawColors 
) const [private]
Parameters:
ppainter
transpif true color scale is drawn on transparent background
Xcolor scale x coordinate
Ycolor scale y coordinate
Wcolor scale width
Hcolor scale height
drawTitleif true, draw title
drawLabelif true, draw labels
drawColorsif true, draw colors

References color().

void QtxColorScale::drawScale ( QPainter *  p,
const QColor &  bg,
const bool  transp,
const int  X,
const int  Y,
const int  W,
const int  H,
const bool  drawTitle,
const bool  drawLabel,
const bool  drawColors 
) const [private]
Parameters:
ppainter
bgbackground color
transpif true color scale is drawn on transparent background
Xcolor scale x coordinate
Ycolor scale y coordinate
Wcolor scale width
Hcolor scale height
drawTitleif true, draw title
drawLabelif true, draw labels
drawColorsif true, draw colors

References AtBorder, Center, colors(), getColor(), getLabel(), intervalsNumber(), labelPosition(), labels(), Left, myFlags, Reverse, Right, testFlags(), textDocument(), and title().

QSize QtxColorScale::calculateSize ( const bool  min,
const int  flags,
const bool  title,
const bool  labels,
const bool  colors 
) const [private]
Parameters:
minif true, color scale size is calculated to be as smallest as possible
flagscolor scale flags
titlecolor scale title
labelsif true take into account labels
colorsif true take into account colors
Returns:
color scale size

References AtBorder, getLabel(), intervalsNumber(), myFormat, myTitle, and textDocument().


Field Documentation

double QtxColorScale.myMin [private]
double QtxColorScale.myMax [private]
QString QtxColorScale.myTitle [private]
QString QtxColorScale.myFormat [private]
QString QtxColorScale.myPrecise [private]
int QtxColorScale.myInterval [private]
int QtxColorScale.myDumpMode [private]
QList<QColor> QtxColorScale.myColors [private]
QList<QString> QtxColorScale.myLabels [private]
int QtxColorScale.myFlags [private]
int QtxColorScale.myLabelPos [private]
int QtxColorScale.myTitlePos [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS