Color Scale widget.
#include <QtxColorScale.h>
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... | |
enum QtxColorScale::Flags |
enum QtxColorScale::Mode |
QtxColorScale::QtxColorScale | ( | QWidget * | parent = 0 , |
Qt::WindowFlags | f = 0 |
||
) |
parent | parent widget |
f | widget flags |
num | number of color scale intervals |
parent | parent widget |
f | widget flags |
|
virtual |
Does nothing for the moment.
|
private |
min | if true , color scale size is calculated to be as smallest as possible |
flags | color scale flags |
title | color scale title |
labels | if true take into account labels |
colors | if true take into account colors |
References AtBorder, getLabel(), intervalsNumber(), myFormat, myTitle, and textDocument().
void QtxColorScale::clearFlags | ( | const int | flags | ) |
flags | color scale flags to be cleared |
References myFlags, and updateScale().
QColor QtxColorScale::color | ( | const int | idx | ) | const |
int QtxColorScale::colorMode | ( | ) | const |
References myColorMode.
void QtxColorScale::colors | ( | QList< QColor > & | list | ) | const |
list | returning colors list |
References myColors.
|
protectedvirtual |
p | painter |
References drawScale(), labelPosition(), None, and titlePosition().
|
private |
p | painter |
transp | if true color scale is drawn on transparent background |
X | color scale x coordinate |
Y | color scale y coordinate |
W | color scale width |
H | color scale height |
drawTitle | if true , draw title |
drawLabel | if true , draw labels |
drawColors | if true , draw colors |
References color().
|
private |
p | painter |
bg | background color |
transp | if true color scale is drawn on transparent background |
X | color scale x coordinate |
Y | color scale y coordinate |
W | color scale width |
H | color scale height |
drawTitle | if true , draw title |
drawLabel | if true , draw labels |
drawColors | if true , draw colors |
References AtBorder, Center, colors(), getColor(), getLabel(), intervalsNumber(), labelPosition(), labels(), Left, myFlags, Reverse, Right, testFlags(), textDocument(), and title().
QPixmap QtxColorScale::dump | ( | ) | const |
References drawScale(), dumpMode(), FullDump, label(), labelPosition(), myDumpMode, NoDump, None, ScaleDump, title(), TitleDump, and titlePosition().
bg | pixmap background color |
w | pixmap width |
h | pixmap height |
References calculateSize(), drawScale(), dumpMode(), FullDump, label(), labelPosition(), myDumpMode, myFlags, NoDump, None, ScaleDump, title(), TitleDump, titlePosition(), and WrapTitle.
int QtxColorScale::dumpMode | ( | ) | const |
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.
References myFormat.
|
private |
idx | interval index |
References color(), colorMode(), intervalsNumber(), Qtx::scaleColor(), and User.
|
private |
References format(), getNumber(), Integer, intervalsNumber(), myPrecise, PreciseFormat, and testFlags().
|
private |
idx | interval index |
References getFormat(), getNumber(), Integer, label(), labelMode(), testFlags(), and User.
|
private |
idx | interval index |
References intervalsNumber(), maximum(), and minimum().
|
virtual |
int QtxColorScale::intervalsNumber | ( | ) | const |
References myInterval.
QString QtxColorScale::label | ( | const int | idx | ) | const |
int QtxColorScale::labelMode | ( | ) | const |
References myLabelMode.
int QtxColorScale::labelPosition | ( | ) | const |
References myLabelPos.
void QtxColorScale::labels | ( | QStringList & | list | ) | const |
list | returning labels list |
References myLabels.
double QtxColorScale::maximum | ( | ) | const |
References myMax.
double QtxColorScale::minimum | ( | ) | const |
References myMin.
|
virtual |
References calculateSize(), labelPosition(), myFlags, None, and titlePosition().
|
protectedvirtual |
e | paint event |
References drawContents().
void QtxColorScale::range | ( | double & | min, |
double & | max | ||
) | const |
If number of interval is negative then user color will be added as new to the end of list.
clr | user color |
idx | interval index |
References myColors, and updateScale().
void QtxColorScale::setColorMode | ( | const int | mode | ) |
mode | new color mode (QtxColorScale::Mode) |
References myColorMode, and updateScale().
list | new colors list |
References myColors, and updateScale().
void QtxColorScale::setDumpMode | ( | const int | mode | ) |
mode | new dump mode (QtxColorScale::DumpMode) |
References myDumpMode.
void QtxColorScale::setFlags | ( | const int | flags | ) |
flags | new flags |
References myFlags, and updateScale().
void QtxColorScale::setFormat | ( | const QString & | format | ) |
format | new number presentation format |
References Auto, colorMode(), format(), myFormat, myPrecise, and updateScale().
void QtxColorScale::setIntervalsNumber | ( | const int | num | ) |
num | number of intervals |
References myInterval, myPrecise, and updateScale().
If number of interval is negative then user label will be added as new to the end of list.
txt | user label |
idx | interval index |
References myLabels, and updateScale().
void QtxColorScale::setLabelMode | ( | const int | mode | ) |
mode | new label mode (QtxColorScale::Mode) |
References myLabelMode, and updateScale().
void QtxColorScale::setLabelPosition | ( | const int | pos | ) |
pos | new label position (QtxColorScale::Position) |
References Center, myLabelPos, None, and updateScale().
void QtxColorScale::setLabels | ( | const QStringList & | list | ) |
list | new labels list |
References myLabels, and updateScale().
void QtxColorScale::setMaximum | ( | const double | val | ) |
val | upper limit of the color scale |
References minimum(), and setRange().
void QtxColorScale::setMinimum | ( | const double | val | ) |
val | lower limit of the color scale |
References maximum(), and setRange().
min | lower limit of the color scale |
max | upper limit of the color scale |
References Auto, colorMode(), labelMode(), myMax, myMin, myPrecise, and updateScale().
void QtxColorScale::setTitle | ( | const QString & | str | ) |
str | new title |
References myTitle, and updateScale().
void QtxColorScale::setTitlePosition | ( | const int | pos | ) |
pos | new title position (QtxColorScale::Position) |
References Center, myTitlePos, None, and updateScale().
|
virtual |
|
virtual |
References calculateSize(), labelPosition(), myFlags, None, and titlePosition().
bool QtxColorScale::testFlags | ( | const int | flags | ) | const |
true
if specified flags are set References myFlags.
|
private |
If title is not defined (empty string) then null pointer is returned. The calling function is responsible for the returning object deleting.
flags | color scale flags (not used) |
References Center, doc, Left, None, Right, title(), and titlePosition().
QString QtxColorScale::title | ( | ) | const |
References myTitle.
int QtxColorScale::titlePosition | ( | ) | const |
References myTitlePos.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |