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

Protected Member Functions

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

Private Member Functions

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

Private Attributes

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

Member Enumeration Documentation

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!)

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

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

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().

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

References myFlags, and updateScale().

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

References myColors.

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

References myColorMode.

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

References myColors.

void QtxColorScale::drawContents ( QPainter *  p)
protectedvirtual
Parameters
ppainter

References drawScale(), labelPosition(), None, 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().

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.

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

References myDumpMode.

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.

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

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

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.

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

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

void QtxColorScale::hide ( )
virtual
int QtxColorScale::intervalsNumber ( ) const
Returns
number of intervals

References myInterval.

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

References myLabels.

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

References myLabelMode.

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

References myLabelPos.

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

References myLabels.

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

References myMax.

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

References myMin.

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

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

void QtxColorScale::paintEvent ( QPaintEvent *  e)
protectedvirtual
Parameters
epaint event

References drawContents().

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.

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::setColorMode ( const int  mode)
Parameters
modenew color mode (QtxColorScale::Mode)

References myColorMode, and updateScale().

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

References myColors, and updateScale().

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

References myDumpMode.

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

References myFlags, 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::setIntervalsNumber ( const int  num)
Parameters
numnumber of intervals

References myInterval, 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::setLabelMode ( const int  mode)
Parameters
modenew label mode (QtxColorScale::Mode)

References myLabelMode, and updateScale().

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

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

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

References myLabels, and updateScale().

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

References minimum(), and setRange().

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

References maximum(), 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::setTitle ( const QString &  str)
Parameters
strnew title

References myTitle, and updateScale().

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

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

void QtxColorScale::show ( )
virtual
QSize QtxColorScale::sizeHint ( ) const
virtual
Returns
size hint

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

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

References myFlags.

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, doc, Left, None, Right, title(), and titlePosition().

QString QtxColorScale::title ( ) const
Returns
current title

References myTitle.

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

References myTitlePos.

void QtxColorScale::updateScale ( )
private

Member Data Documentation

int QtxColorScale::myColorMode
private
QList<QColor> QtxColorScale::myColors
private
int QtxColorScale::myDumpMode
private
int QtxColorScale::myFlags
private
QString QtxColorScale::myFormat
private
int QtxColorScale::myInterval
private
int QtxColorScale::myLabelMode
private
int QtxColorScale::myLabelPos
private
QList<QString> QtxColorScale::myLabels
private
double QtxColorScale::myMax
private
double QtxColorScale::myMin
private
QString QtxColorScale::myPrecise
private
QString QtxColorScale::myTitle
private
int QtxColorScale::myTitlePos
private

The documentation for this class was generated from the following files: