JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
|
base class for drawing a key (or legend) More...
#include <jkqtpkey.h>
Classes | |
struct | KeyColumnDescription |
describes one column of items in the key More... | |
struct | KeyItemData |
describes a single key entry More... | |
struct | KeyLayoutDescription |
struct, describing basic layout and size properties of a key/legend, mostly used as return value of getSize(). More... | |
struct | KeySizeDescription |
struct, describing basic layout and size properties of a key/legend, mostly used as return value of getSize(). More... | |
Public Slots | |
void | setBackgroundBrush (const QBrush &__value) |
color of the key background | |
void | setBackgroundColor (QColor __value) |
color of the key background | |
void | setBackgroundColor (QColor __value, Qt::BrushStyle __style) |
color of the key background | |
void | setColumnSeparation (double __value) |
distance between two columns of key entries [in units of width of 'X' set in fontName, fontSize] | |
void | setFontSize (double __value) |
font size for key labels [in points] | |
void | setFrameColor (QColor __value) |
color of the key frame line | |
void | setFrameLineStyle (Qt::PenStyle __value) |
linestyle for the frame | |
void | setFrameRounding (double __value) |
rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt] | |
void | setFrameVisible (bool __value) |
indicates whether to plot a frame around the key | |
void | setFrameWidth (double __value) |
width of the key frame line [pt] | |
void | setLayout (JKQTPKeyLayout __value) |
the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for details and examples | |
void | setPosition (JKQTPKeyPosition __value) |
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples | |
void | setSampleLineLength (double __value) |
length of the line samples in the key [in units of width of 'X' set in fontName, fontSize] | |
void | setTextColor (QColor __value) |
color of the key entries' text | |
void | setVisible (bool __value) |
indicates whether to plot a key | |
void | setXMargin (double __value) |
x-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize] | |
void | setXOffset (double __value) |
x-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize] | |
void | setXSeparation (double __value) |
distance between key line example and key text [in units of width of 'X' set in fontName, fontSize] | |
void | setYMargin (double __value) |
y-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize] | |
void | setYOffset (double __value) |
y-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize] | |
void | setYSeparation (double __value) |
distance between two key entries [in units of height of fontName, fontSize] | |
Public Member Functions | |
JKQTPBaseKey (JKQTBasePlotter *parent) | |
class constructor | |
virtual | ~JKQTPBaseKey () |
class destructor | |
virtual void | drawKey (JKQTPEnhancedPainter &painter, const QRectF &rect, const KeySizeDescription &layout) |
draw the key | |
const QBrush & | getBackgroundBrush () const |
color of the key background | |
QColor | getBackgroundColor () const |
color of the key background | |
double | getColumnSeparation () const |
distance between two columns of key entries [in units of width of 'X' set in fontName, fontSize] | |
const JKQTPKeyStyle & | getCurrentKeyStyle () const |
current style properties (JKQTPKeyStyle) for this JKQTPKey | |
double | getFontSize () const |
font size for key labels [in points] | |
QColor | getFrameColor () const |
color of the key frame line | |
Qt::PenStyle | getFrameLineStyle () const |
linestyle for the frame | |
double | getFrameRounding () const |
rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt] | |
bool | getFrameVisible () const |
indicates whether to plot a frame around the key | |
double | getFrameWidth () const |
width of the key frame line [pt] | |
JKQTPKeyLayout | getLayout () const |
the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for details and examples | |
JKQTBasePlotter * | getParent () |
parent plotter class | |
const JKQTBasePlotter * | getParent () const |
parent plotter class | |
JKQTPKeyPosition | getPosition () const |
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples | |
double | getSampleLineLength () const |
length of the line samples in the key [in units of width of 'X' set in fontName, fontSize] | |
KeySizeDescription | getSize (JKQTPEnhancedPainter &painter) |
calculates the size required for the key | |
QColor | getTextColor () const |
color of the key entries' text | |
bool | getVisible () const |
indicates whether to plot a key | |
double | getXMargin () const |
x-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize] | |
double | getXOffset () const |
x-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize] | |
double | getXSeparation () const |
distance between key line example and key text [in units of width of 'X' set in fontName, fontSize] | |
double | getYMargin () const |
y-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize] | |
double | getYOffset () const |
y-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize] | |
double | getYSeparation () const |
distance between two key entries [in units of height of fontName, fontSize] | |
virtual void | loadSettings (const QSettings &settings, const QString &group=QString("plots/key/")) |
loads the plot properties from a QSettings object | |
virtual void | modifySize (JKQTPEnhancedPainter &painter, KeySizeDescription ¤tSize, QSizeF preliminaryPlotSize) |
econd stage of size calculation | |
virtual void | saveSettings (QSettings &settings, const QString &group=QString("plots/key/")) const |
saves the plot properties into a QSettings object. | |
void | setCurrentKeyStyle (const JKQTPKeyStyle &style) |
replace the current style properties for this JKQTPKey | |
virtual void | setParent (JKQTBasePlotter *parent) |
Protected Member Functions | |
void | calcLayoutSize (JKQTPEnhancedPainter &painter, KeySizeDescription &layout) const |
fill KeySizeDescription::requiredSize | |
virtual void | drawEntrySample (int item, JKQTPEnhancedPainter &painter, const QRectF &rect)=0 |
draws the sample for legend entry item into the given rect, using the given painter | |
virtual QSizeF | extendLayoutSize (QSizeF rawLayoutSize, JKQTPEnhancedPainter &painter, QPointF *offset=nullptr) const |
takes the size calculated by KeyLayoutDescription::calcOverallWidth() and KeyLayoutDescription::calcOverallHeight() and extends it with margins, line widths, ... optionally returns the one-sided offset | |
virtual QColor | getEntryColor (int item) const =0 |
returns the label color of legend entry item 's text part | |
virtual int | getEntryCount () const =0 |
returns the number of legend entries | |
virtual QString | getEntryText (int item) const =0 |
returns the label text (my contain markup for a JKQTMathText) of legend entry item 's text part | |
virtual KeyLayoutDescription | getKeyLayout (JKQTPEnhancedPainter &painter) |
calculates all layout properties of the key/legend,necessary to size and draw it | |
JKQTMathText * | getParentMathText () |
retun parents JKQTMathText* object | |
const JKQTMathText * | getParentMathText () const |
retun parents JKQTMathText* object | |
virtual JKQTPKeyStyle & | keyStyle () |
provides the keyStyle to use for sizing/drawing this object | |
virtual const JKQTPKeyStyle & | keyStyle () const |
provides the keyStyle to use for sizing/drawing this object | |
void | redrawPlot () |
signals the parent JKQTBasePlotter to redraw | |
Protected Attributes | |
JKQTBasePlotter * | parent |
parent plotter class | |
Private Attributes | |
JKQTPKeyStyle | localKeyStyle |
current style properties for this key/legend | |
base class for drawing a key (or legend)
The class JKQTPBaseKey implements the basic layouting and drawing of a key/legend.
With JKQTPKeyStyle you can style the appearance of a key/legend:
In addition it is possible to set:
The functions in JKQTPBaseKey are mainly used for drawing the main key in a JKQTBasePlotter. The instance representing that main key is accessible via JKQTPBaseKey::getMainKey(). It is not a direct instance of JKQTPBaseKey, which is impossible, as it is pure virtual, but an instance of JKQTPMainKey, which extends JKQTPBaseKey with access to the titles assigned to each JKQTPPlotElement (see JKQTPPlotElement::getTitle(), JKQTPPlotElement::setTitle()) and its key-marker (JKQTPPlotElement::drawKeyMarker()).
Note however that it is also possible to draw additional keys into the graph (e.g. to show the size/color classes in a parametrized scatter graph), if the corresponding JKQTPPlotElement implements this.
It relies on these protected virtual functions to determine the contents of the legend items:
So you can derive from JKQTPBaseKey and implement these to provide a new source of data.
There are additional customization points in this class. You can also override the default implementations of these functions to change the way keys/legends are drawn:
|
explicit |
class constructor
|
virtual |
class destructor
|
protected |
|
protectedpure virtual |
draws the sample for legend entry item into the given rect, using the given painter
Implemented in JKQTPMainKey.
|
virtual |
draw the key
painter | the painter to use for drawing |
rect | the rectangle to plot the key into, depending on JKQTPKeyStyle::position this is either the plot rectangle itself, or a rectangle outside the plot that fits the key |
layout | output of getSize(), possibly modified by modifySize() |
|
protectedvirtual |
takes the size calculated by KeyLayoutDescription::calcOverallWidth() and KeyLayoutDescription::calcOverallHeight() and extends it with margins, line widths, ... optionally returns the one-sided offset
|
inline |
color of the key background
|
inline |
color of the key background
|
inline |
distance between two columns of key entries [in units of width of 'X' set in fontName, fontSize]
const JKQTPKeyStyle & JKQTPBaseKey::getCurrentKeyStyle | ( | ) | const |
current style properties (JKQTPKeyStyle) for this JKQTPKey
|
protectedpure virtual |
returns the label color of legend entry item 's text part
Implemented in JKQTPMainKey.
|
protectedpure virtual |
returns the number of legend entries
Implemented in JKQTPMainKey.
|
protectedpure virtual |
returns the label text (my contain markup for a JKQTMathText) of legend entry item 's text part
Implemented in JKQTPMainKey.
|
inline |
font size for key labels [in points]
|
inline |
color of the key frame line
|
inline |
linestyle for the frame
|
inline |
rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt]
|
inline |
indicates whether to plot a frame around the key
|
inline |
width of the key frame line [pt]
|
protectedvirtual |
|
inline |
the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for details and examples
|
inline |
parent plotter class
|
inline |
parent plotter class
|
protected |
retun parents JKQTMathText* object
|
protected |
retun parents JKQTMathText* object
|
inline |
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples
|
inline |
length of the line samples in the key [in units of width of 'X' set in fontName, fontSize]
KeySizeDescription JKQTPBaseKey::getSize | ( | JKQTPEnhancedPainter & | painter | ) |
calculates the size required for the key
This function internally calls getLayout(), which is (together with drawKey() ) a customization point for key layout.
|
inline |
color of the key entries' text
|
inline |
indicates whether to plot a key
|
inline |
x-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]
|
inline |
x-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]
|
inline |
distance between key line example and key text [in units of width of 'X' set in fontName, fontSize]
|
inline |
y-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]
|
inline |
y-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]
|
inline |
distance between two key entries [in units of height of fontName, fontSize]
|
protectedvirtual |
provides the keyStyle to use for sizing/drawing this object
Reimplemented in JKQTPMainKey.
|
protectedvirtual |
provides the keyStyle to use for sizing/drawing this object
Reimplemented in JKQTPMainKey.
|
virtual |
loads the plot properties from a QSettings object
|
virtual |
econd stage of size calculation
This functions allows to again modify the KeySizeDescription currentSize in a second step, when the preliminary size of the plot is known (given as preliminaryPlotSize ).
This is used to implement the JKQTPKeyLayout::JKQTPKeyLayoutMultiColumn and JKQTPKeyLayout::JKQTPKeyLayoutMultiRow, where the distribution of entries over rows/columns is calculated here.
|
protected |
signals the parent JKQTBasePlotter to redraw
|
virtual |
saves the plot properties into a QSettings object.
This method only saves those properties that differ from their default value.
|
inlineslot |
color of the key background
|
inlineslot |
color of the key background
|
inlineslot |
color of the key background
|
inlineslot |
distance between two columns of key entries [in units of width of 'X' set in fontName, fontSize]
void JKQTPBaseKey::setCurrentKeyStyle | ( | const JKQTPKeyStyle & | style | ) |
replace the current style properties for this JKQTPKey
|
inlineslot |
font size for key labels [in points]
|
inlineslot |
color of the key frame line
|
inlineslot |
linestyle for the frame
|
inlineslot |
rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt]
|
inlineslot |
indicates whether to plot a frame around the key
|
inlineslot |
width of the key frame line [pt]
|
inlineslot |
the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for details and examples
|
virtual |
|
inlineslot |
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples
|
inlineslot |
length of the line samples in the key [in units of width of 'X' set in fontName, fontSize]
|
inlineslot |
color of the key entries' text
|
inlineslot |
indicates whether to plot a key
|
inlineslot |
x-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]
|
inlineslot |
x-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]
|
inlineslot |
distance between key line example and key text [in units of width of 'X' set in fontName, fontSize]
|
inlineslot |
y-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]
|
inlineslot |
y-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]
|
inlineslot |
distance between two key entries [in units of height of fontName, fontSize]
|
private |
current style properties for this key/legend
|
protected |
parent plotter class