Version: 9.15.0
QtxColorScale Class Reference

Color Scale widget. More...

#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...
 

Detailed Description

Color Scale widget.

Member Enumeration Documentation

◆ DumpMode

Dump mode.

Enumerator
NoDump 

do not dump

TitleDump 

dump title

ScaleDump 

dump scale

FullDump 

dump all

◆ Flags

Color scale flags (bitwise).

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

◆ Mode

Color scale color/label mode.

Enumerator
Auto 

auto

User 

user defined

◆ Position

Color scale title, label position.

Enumerator
None 

do not draw

Left 

draw at the left

Right 

draw at the right

Center 

draw at the center

Constructor & Destructor Documentation

◆ QtxColorScale() [1/2]

QtxColorScale::QtxColorScale ( QWidget parent = 0,
Qt::WindowFlags  f = 0 
)

Constructor.

Parameters
parentparent widget
fwidget flags

◆ QtxColorScale() [2/2]

QtxColorScale::QtxColorScale ( const int  num,
QWidget parent = 0,
Qt::WindowFlags  f = 0 
)

Constructor.

Parameters
numnumber of color scale intervals
parentparent widget
fwidget flags

◆ ~QtxColorScale()

QtxColorScale::~QtxColorScale ( )
virtual

Destructor.

Does nothing for the moment.

Member Function Documentation

◆ calculateSize()

QSize QtxColorScale::calculateSize ( const bool  min,
const int  flags,
const bool  title,
const bool  labels,
const bool  colors 
) const
private

Calculate color scale size.

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, colors(), getLabel(), intervalsNumber(), labels(), myFormat, myTitle, textDocument(), and title().

◆ clearFlags()

void QtxColorScale::clearFlags ( const int  flags)

Clear (reset) color scale flags.

Parameters
flagscolor scale flags to be cleared

References myFlags, and updateScale().

◆ color()

QColor QtxColorScale::color ( const int  idx) const

Get user color for the specified color scale interval.

Parameters
idxinterval index
Returns
user color for specified interval

References myColors.

◆ colorMode()

int QtxColorScale::colorMode ( ) const

Get color mode.

Returns
current color mode (QtxColorScale::Mode)

References myColorMode.

◆ colors()

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

Get user colors for all color scale intervals.

Parameters
listreturning colors list

References myColors.

◆ drawContents()

void QtxColorScale::drawContents ( QPainter *  p)
protectedvirtual

Draw color scale (reimplemented from QFrame).

Parameters
ppainter

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

◆ drawScale() [1/2]

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

Draw color scale contents.

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

◆ drawScale() [2/2]

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

Draw color scale contents.

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

◆ dump() [1/3]

QPixmap QtxColorScale::dump ( ) const

Dump color scale into pixmap with current size.

Returns
generated pixmap

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

◆ dump() [2/3]

QPixmap QtxColorScale::dump ( const int  w = -1,
const int  h = -1 
) const

Dump color scale into pixmap with the specified size.

Parameters
wpixmap width
hpixmap height
Returns
generated pixmap

References color(), and dump().

◆ dump() [3/3]

QPixmap QtxColorScale::dump ( const QColor &  bg,
const int  w = -1,
const int  h = -1 
) const

Dump color scale into pixmap with the specified size and background color.

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.

◆ dumpMode()

int QtxColorScale::dumpMode ( ) const

Get Color scale dump mode.

Returns
current dump mode (QtxColorScale::DumpMode)

References myDumpMode.

◆ format()

QString QtxColorScale::format ( ) const

Get current format of the number presentation.

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.

◆ getColor()

QColor QtxColorScale::getColor ( const int  idx) const
private

Get color scale color corresponding to the specified interval.

Parameters
idxinterval index
Returns
color scale color

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

◆ getFormat()

QString QtxColorScale::getFormat ( ) const
private

Generate number presentation format.

Returns
format for number labels

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

◆ getLabel()

QString QtxColorScale::getLabel ( const int  idx) const
private

Get color scale label text corresponding to the specified interval.

Parameters
idxinterval index
Returns
color scale label text

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

◆ getNumber()

double QtxColorScale::getNumber ( const int  idx) const
private

Get color scale value corresponding to the specified interval.

Parameters
idxinterval index
Returns
color scale value

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

◆ hide()

void QtxColorScale::hide ( )
virtual

Hide color scale (reimplemented from QFrame).

◆ intervalsNumber()

int QtxColorScale::intervalsNumber ( ) const

Get number of color scale intervals.

Returns
number of intervals

References myInterval.

◆ label()

QString QtxColorScale::label ( const int  idx) const

Get user label for the specified color scale interval.

Parameters
idxinterval index
Returns
user label for specified interval

References myLabels.

◆ labelMode()

int QtxColorScale::labelMode ( ) const

Get label mode.

Returns
current label mode (QtxColorScale::Mode)

References myLabelMode.

◆ labelPosition()

int QtxColorScale::labelPosition ( ) const

Get label position.

Returns
label position (QtxColorScale::Position)

References myLabelPos.

◆ labels()

void QtxColorScale::labels ( QStringList &  list) const

Get user labels for all color scale intervals.

Parameters
listreturning labels list

References myLabels.

◆ maximum()

double QtxColorScale::maximum ( ) const

Get color scale maximum value.

Returns
upper limit of the color scale

References myMax.

◆ minimum()

double QtxColorScale::minimum ( ) const

Get color scale minimum value.

Returns
lower limit of the color scale

References myMin.

◆ minimumSizeHint()

QSize QtxColorScale::minimumSizeHint ( ) const
virtual

Get widget's minumum size hint.

Returns
minimum size hint

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

◆ paintEvent()

void QtxColorScale::paintEvent ( QPaintEvent *  )
protectedvirtual

Paint widget.

Parameters
epaint event

References drawContents().

◆ range()

void QtxColorScale::range ( double &  min,
double &  max 
) const

Get color scale range.

Parameters
minreturning lower limit of the color scale
maxreturning upper limit of the color scale

References myMax, and myMin.

◆ setColor()

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

Set user color for the specified color scale interval.

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

◆ setColorMode()

void QtxColorScale::setColorMode ( const int  mode)

Set color scale color mode.

Parameters
modenew color mode (QtxColorScale::Mode)

References myColorMode, and updateScale().

◆ setColors()

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

Set user colors for all color scale intervals.

Parameters
listnew colors list

References myColors, and updateScale().

◆ setDumpMode()

void QtxColorScale::setDumpMode ( const int  mode)

Set color scale dump mode.

Parameters
modenew dump mode (QtxColorScale::DumpMode)

References myDumpMode.

◆ setFlags()

void QtxColorScale::setFlags ( const int  flags)

Set color scale flags.

Parameters
flagsnew flags

References myFlags, and updateScale().

◆ setFormat()

void QtxColorScale::setFormat ( const QString &  format)

Set current format of the number presentation.

See also
format()
Parameters
formatnew number presentation format

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

◆ setIntervalsNumber()

void QtxColorScale::setIntervalsNumber ( const int  num)

Set number of color scale intervals.

Parameters
numnumber of intervals

References myInterval, myPrecise, and updateScale().

◆ setLabel()

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

Set user label for the specified color scale interval.

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

◆ setLabelMode()

void QtxColorScale::setLabelMode ( const int  mode)

Set color scale label mode.

Parameters
modenew label mode (QtxColorScale::Mode)

References myLabelMode, and updateScale().

◆ setLabelPosition()

void QtxColorScale::setLabelPosition ( const int  pos)

Set label position.

Parameters
posnew label position (QtxColorScale::Position)

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

◆ setLabels()

void QtxColorScale::setLabels ( const QStringList &  list)

Set user labels for all color scale intervals.

Parameters
listnew labels list

References myLabels, and updateScale().

◆ setMaximum()

void QtxColorScale::setMaximum ( const double  val)

Set color scale maximum value.

Parameters
valupper limit of the color scale

References minimum(), and setRange().

◆ setMinimum()

void QtxColorScale::setMinimum ( const double  val)

Set color scale minimum value.

Parameters
vallower limit of the color scale

References maximum(), and setRange().

◆ setRange()

void QtxColorScale::setRange ( const double  min,
const double  max 
)

Set color scale range.

Parameters
minlower limit of the color scale
maxupper limit of the color scale

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

◆ setTitle()

void QtxColorScale::setTitle ( const QString &  str)

Set color scale title.

Parameters
strnew title

References myTitle, and updateScale().

◆ setTitlePosition()

void QtxColorScale::setTitlePosition ( const int  pos)

Set title position.

Parameters
posnew title position (QtxColorScale::Position)

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

◆ show()

void QtxColorScale::show ( )
virtual

Show color scale (reimplemented from QFrame).

◆ sizeHint()

QSize QtxColorScale::sizeHint ( ) const
virtual

Get widget's default size hint.

Returns
size hint

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

◆ testFlags()

bool QtxColorScale::testFlags ( const int  flags) const

Test color scale flags.

Returns
true if specified flags are set

References myFlags.

◆ textDocument()

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

Get text document (rich text) for the color scale title representation.

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

◆ title()

QString QtxColorScale::title ( ) const

Get color scale title.

Returns
current title

References myTitle.

◆ titlePosition()

int QtxColorScale::titlePosition ( ) const

Get title position.

Returns
title position (QtxColorScale::Position)

References myTitlePos.

◆ updateScale()

void QtxColorScale::updateScale ( )
private

Update color scale.

Member Data Documentation

◆ myColorMode

int QtxColorScale::myColorMode
private

color mode (QtxColorScale::Mode)

◆ myColors

QList<QColor> QtxColorScale::myColors
private

list of colors

◆ myDumpMode

int QtxColorScale::myDumpMode
private

◆ myFlags

int QtxColorScale::myFlags
private

color scale flags (QtxColorScale::Flags)

◆ myFormat

QString QtxColorScale::myFormat
private

number presentation format

◆ myInterval

int QtxColorScale::myInterval
private

number of color scale intervals

◆ myLabelMode

int QtxColorScale::myLabelMode
private

label mode (QtxColorScale::Mode)

◆ myLabelPos

int QtxColorScale::myLabelPos
private

label position (QtxColorScale::Position)

◆ myLabels

QList<QString> QtxColorScale::myLabels
private

list of labels

◆ myMax

double QtxColorScale::myMax
private

upper limit

◆ myMin

double QtxColorScale::myMin
private

lower limit

◆ myPrecise

QString QtxColorScale::myPrecise
private

double values precision format

◆ myTitle

QString QtxColorScale::myTitle
private

title

◆ myTitlePos

int QtxColorScale::myTitlePos
private

title position (QtxColorScale::Position)


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