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
Loading...
Searching...
No Matches

base class for drawing a key (or legend) More...

#include <jkqtpkey.h>

Inheritance diagram for JKQTPBaseKey:
[legend]
Collaboration diagram for JKQTPBaseKey:
[legend]

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 JKQTPKeyStylegetCurrentKeyStyle () 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
 
JKQTBasePlottergetParent ()
 parent plotter class
 
const JKQTBasePlottergetParent () 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 &currentSize, 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
 
JKQTMathTextgetParentMathText ()
 retun parents JKQTMathText* object
 
const JKQTMathTextgetParentMathText () const
 retun parents JKQTMathText* object
 
virtual JKQTPKeyStylekeyStyle ()
 provides the keyStyle to use for sizing/drawing this object
 
virtual const JKQTPKeyStylekeyStyle () const
 provides the keyStyle to use for sizing/drawing this object
 
void redrawPlot ()
 signals the parent JKQTBasePlotter to redraw
 

Protected Attributes

JKQTBasePlotterparent
 parent plotter class
 

Private Attributes

JKQTPKeyStyle localKeyStyle
 current style properties for this key/legend
 

Detailed Description

base class for drawing a key (or legend)

The class JKQTPBaseKey implements the basic layouting and drawing of a key/legend.

Key/Legend Styling

With JKQTPKeyStyle you can style the appearance of a key/legend:

In addition it is possible to set:

See also
JKQTPBaseKey, JKQTBasePlotter, JKQTBasePlotterStyle, Styling System
Note
The class JKQTPBaseKey offers setters (slots) and getters for all the properties in the used instance of JKQTPKeyStyle .

Usage

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.

Implementation Details

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:

See also
JKQTPKeyStyle, JKQTPMainKey

Constructor & Destructor Documentation

◆ JKQTPBaseKey()

JKQTPBaseKey::JKQTPBaseKey ( JKQTBasePlotter parent)
explicit

class constructor

◆ ~JKQTPBaseKey()

virtual JKQTPBaseKey::~JKQTPBaseKey ( )
virtual

class destructor

Member Function Documentation

◆ calcLayoutSize()

void JKQTPBaseKey::calcLayoutSize ( JKQTPEnhancedPainter painter,
KeySizeDescription layout 
) const
protected

◆ drawEntrySample()

virtual void JKQTPBaseKey::drawEntrySample ( int  item,
JKQTPEnhancedPainter painter,
const QRectF &  rect 
)
protectedpure virtual

draws the sample for legend entry item into the given rect, using the given painter

Implemented in JKQTPMainKey.

◆ drawKey()

virtual void JKQTPBaseKey::drawKey ( JKQTPEnhancedPainter painter,
const QRectF &  rect,
const KeySizeDescription layout 
)
virtual

draw the key

Parameters
painterthe painter to use for drawing
rectthe 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
layoutoutput of getSize(), possibly modified by modifySize()
Note
It is expected that the owning JKQTBasePlotter first calls getSize() and the determmines a QREct that fits the legend. The latter is the supplied as rect to this function for subsequent drawing. It is also expected that the legends contents does not changed in the meantime!

◆ extendLayoutSize()

virtual QSizeF JKQTPBaseKey::extendLayoutSize ( QSizeF  rawLayoutSize,
JKQTPEnhancedPainter painter,
QPointF *  offset = nullptr 
) const
protectedvirtual

takes the size calculated by KeyLayoutDescription::calcOverallWidth() and KeyLayoutDescription::calcOverallHeight() and extends it with margins, line widths, ... optionally returns the one-sided offset

◆ getBackgroundBrush()

const QBrush & JKQTPBaseKey::getBackgroundBrush ( ) const
inline

color of the key background

◆ getBackgroundColor()

QColor JKQTPBaseKey::getBackgroundColor ( ) const
inline

color of the key background

◆ getColumnSeparation()

double JKQTPBaseKey::getColumnSeparation ( ) const
inline

distance between two columns of key entries [in units of width of 'X' set in fontName, fontSize]

◆ getCurrentKeyStyle()

const JKQTPKeyStyle & JKQTPBaseKey::getCurrentKeyStyle ( ) const

current style properties (JKQTPKeyStyle) for this JKQTPKey

See also
JKQTPKeyStyle

◆ getEntryColor()

virtual QColor JKQTPBaseKey::getEntryColor ( int  item) const
protectedpure virtual

returns the label color of legend entry item 's text part

Implemented in JKQTPMainKey.

◆ getEntryCount()

virtual int JKQTPBaseKey::getEntryCount ( ) const
protectedpure virtual

returns the number of legend entries

Implemented in JKQTPMainKey.

◆ getEntryText()

virtual QString JKQTPBaseKey::getEntryText ( int  item) const
protectedpure virtual

returns the label text (my contain markup for a JKQTMathText) of legend entry item 's text part

Implemented in JKQTPMainKey.

◆ getFontSize()

double JKQTPBaseKey::getFontSize ( ) const
inline

font size for key labels [in points]

◆ getFrameColor()

QColor JKQTPBaseKey::getFrameColor ( ) const
inline

color of the key frame line

◆ getFrameLineStyle()

Qt::PenStyle JKQTPBaseKey::getFrameLineStyle ( ) const
inline

linestyle for the frame

◆ getFrameRounding()

double JKQTPBaseKey::getFrameRounding ( ) const
inline

rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt]

◆ getFrameVisible()

bool JKQTPBaseKey::getFrameVisible ( ) const
inline

indicates whether to plot a frame around the key

◆ getFrameWidth()

double JKQTPBaseKey::getFrameWidth ( ) const
inline

width of the key frame line [pt]

◆ getKeyLayout()

virtual KeyLayoutDescription JKQTPBaseKey::getKeyLayout ( JKQTPEnhancedPainter painter)
protectedvirtual

calculates all layout properties of the key/legend,necessary to size and draw it

This is internally called by getSize() and drawKey().

◆ getLayout()

JKQTPKeyLayout JKQTPBaseKey::getLayout ( ) const
inline

the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for details and examples

◆ getParent() [1/2]

JKQTBasePlotter * JKQTPBaseKey::getParent ( )
inline

parent plotter class

◆ getParent() [2/2]

const JKQTBasePlotter * JKQTPBaseKey::getParent ( ) const
inline

parent plotter class

◆ getParentMathText() [1/2]

JKQTMathText * JKQTPBaseKey::getParentMathText ( )
protected

retun parents JKQTMathText* object

◆ getParentMathText() [2/2]

const JKQTMathText * JKQTPBaseKey::getParentMathText ( ) const
protected

retun parents JKQTMathText* object

◆ getPosition()

JKQTPKeyPosition JKQTPBaseKey::getPosition ( ) const
inline

key position inside or besides the plot area, see JKQTPKeyPositions for details and examples

◆ getSampleLineLength()

double JKQTPBaseKey::getSampleLineLength ( ) const
inline

length of the line samples in the key [in units of width of 'X' set in fontName, fontSize]

◆ getSize()

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.

◆ getTextColor()

QColor JKQTPBaseKey::getTextColor ( ) const
inline

color of the key entries' text

◆ getVisible()

bool JKQTPBaseKey::getVisible ( ) const
inline

indicates whether to plot a key

◆ getXMargin()

double JKQTPBaseKey::getXMargin ( ) const
inline

x-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]

◆ getXOffset()

double JKQTPBaseKey::getXOffset ( ) const
inline

x-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]

◆ getXSeparation()

double JKQTPBaseKey::getXSeparation ( ) const
inline

distance between key line example and key text [in units of width of 'X' set in fontName, fontSize]

◆ getYMargin()

double JKQTPBaseKey::getYMargin ( ) const
inline

y-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]

◆ getYOffset()

double JKQTPBaseKey::getYOffset ( ) const
inline

y-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]

◆ getYSeparation()

double JKQTPBaseKey::getYSeparation ( ) const
inline

distance between two key entries [in units of height of fontName, fontSize]

◆ keyStyle() [1/2]

virtual JKQTPKeyStyle & JKQTPBaseKey::keyStyle ( )
protectedvirtual

provides the keyStyle to use for sizing/drawing this object

Reimplemented in JKQTPMainKey.

◆ keyStyle() [2/2]

virtual const JKQTPKeyStyle & JKQTPBaseKey::keyStyle ( ) const
protectedvirtual

provides the keyStyle to use for sizing/drawing this object

Reimplemented in JKQTPMainKey.

◆ loadSettings()

virtual void JKQTPBaseKey::loadSettings ( const QSettings &  settings,
const QString &  group = QString("plots/key/") 
)
virtual

loads the plot properties from a QSettings object

◆ modifySize()

virtual void JKQTPBaseKey::modifySize ( JKQTPEnhancedPainter painter,
KeySizeDescription currentSize,
QSizeF  preliminaryPlotSize 
)
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.

Note
This function is declared virtual so it can be used as a customization point!

◆ redrawPlot()

void JKQTPBaseKey::redrawPlot ( )
protected

signals the parent JKQTBasePlotter to redraw

◆ saveSettings()

virtual void JKQTPBaseKey::saveSettings ( QSettings &  settings,
const QString &  group = QString("plots/key/") 
) const
virtual

saves the plot properties into a QSettings object.

This method only saves those properties that differ from their default value.

◆ setBackgroundBrush

void JKQTPBaseKey::setBackgroundBrush ( const QBrush &  __value)
inlineslot

color of the key background

◆ setBackgroundColor [1/2]

void JKQTPBaseKey::setBackgroundColor ( QColor  __value)
inlineslot

color of the key background

◆ setBackgroundColor [2/2]

void JKQTPBaseKey::setBackgroundColor ( QColor  __value,
Qt::BrushStyle  __style 
)
inlineslot

color of the key background

◆ setColumnSeparation

void JKQTPBaseKey::setColumnSeparation ( double  __value)
inlineslot

distance between two columns of key entries [in units of width of 'X' set in fontName, fontSize]

◆ setCurrentKeyStyle()

void JKQTPBaseKey::setCurrentKeyStyle ( const JKQTPKeyStyle style)

replace the current style properties for this JKQTPKey

See also
JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), Styling System

◆ setFontSize

void JKQTPBaseKey::setFontSize ( double  __value)
inlineslot

font size for key labels [in points]

◆ setFrameColor

void JKQTPBaseKey::setFrameColor ( QColor  __value)
inlineslot

color of the key frame line

◆ setFrameLineStyle

void JKQTPBaseKey::setFrameLineStyle ( Qt::PenStyle  __value)
inlineslot

linestyle for the frame

◆ setFrameRounding

void JKQTPBaseKey::setFrameRounding ( double  __value)
inlineslot

rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt]

◆ setFrameVisible

void JKQTPBaseKey::setFrameVisible ( bool  __value)
inlineslot

indicates whether to plot a frame around the key

◆ setFrameWidth

void JKQTPBaseKey::setFrameWidth ( double  __value)
inlineslot

width of the key frame line [pt]

◆ setLayout

void JKQTPBaseKey::setLayout ( JKQTPKeyLayout  __value)
inlineslot

the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for details and examples

◆ setParent()

virtual void JKQTPBaseKey::setParent ( JKQTBasePlotter parent)
virtual

◆ setPosition

void JKQTPBaseKey::setPosition ( JKQTPKeyPosition  __value)
inlineslot

key position inside or besides the plot area, see JKQTPKeyPositions for details and examples

◆ setSampleLineLength

void JKQTPBaseKey::setSampleLineLength ( double  __value)
inlineslot

length of the line samples in the key [in units of width of 'X' set in fontName, fontSize]

◆ setTextColor

void JKQTPBaseKey::setTextColor ( QColor  __value)
inlineslot

color of the key entries' text

◆ setVisible

void JKQTPBaseKey::setVisible ( bool  __value)
inlineslot

indicates whether to plot a key

◆ setXMargin

void JKQTPBaseKey::setXMargin ( double  __value)
inlineslot

x-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]

◆ setXOffset

void JKQTPBaseKey::setXOffset ( double  __value)
inlineslot

x-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]

◆ setXSeparation

void JKQTPBaseKey::setXSeparation ( double  __value)
inlineslot

distance between key line example and key text [in units of width of 'X' set in fontName, fontSize]

◆ setYMargin

void JKQTPBaseKey::setYMargin ( double  __value)
inlineslot

y-distance between key frame and key content [in units of width of 'X' set in fontName, fontSize]

◆ setYOffset

void JKQTPBaseKey::setYOffset ( double  __value)
inlineslot

y-offset of the key from the border of the plot [in units of width of 'X' set in fontName, fontSize]

◆ setYSeparation

void JKQTPBaseKey::setYSeparation ( double  __value)
inlineslot

distance between two key entries [in units of height of fontName, fontSize]

Member Data Documentation

◆ localKeyStyle

JKQTPKeyStyle JKQTPBaseKey::localKeyStyle
private

current style properties for this key/legend

See also
JKQTPKeyStyle

◆ parent

JKQTBasePlotter* JKQTPBaseKey::parent
protected

parent plotter class


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