29#include "jkqtplotter/jkqtplotter_imexport.h"
30#include "jkqtplotter/jkqtpkeystyle.h"
95 virtual void loadSettings(
const QSettings &settings,
const QString& group=QString(
"plots/key/"));
101 virtual void saveSettings(QSettings& settings,
const QString& group=QString(
"plots/key/"))
const;
107 KeyItemData(
int _id=-1,
const QString& _text=
"",
const QSizeF _size=QSizeF());
140 std::unique_ptr<KeyLayoutDescription>
d;
195 inline bool getVisible()
const {
return keyStyle().visible; }
197 inline double getXMargin()
const {
return keyStyle().xMargin; }
199 inline double getYMargin()
const {
return keyStyle().yMargin; }
201 inline double getXOffset()
const {
return keyStyle().xOffset; }
203 inline double getYOffset()
const {
return keyStyle().yOffset; }
234 inline void setVisible(
bool __value) { keyStyle().visible = __value; redrawPlot(); }
236 inline void setFrameVisible(
bool __value) { keyStyle().frameVisible = __value; redrawPlot(); }
238 inline void setFrameWidth(
double __value) { keyStyle().frameWidth = __value; redrawPlot(); }
240 inline void setFrameRounding(
double __value) { keyStyle().frameRounding = __value; redrawPlot(); }
242 inline void setFontSize(
double __value) { keyStyle().fontSize = __value; redrawPlot(); }
246 inline void setXMargin(
double __value) { keyStyle().xMargin = __value; redrawPlot(); }
248 inline void setYMargin(
double __value) { keyStyle().yMargin = __value; redrawPlot(); }
250 inline void setXOffset(
double __value) { keyStyle().xOffset = __value; redrawPlot(); }
252 inline void setYOffset(
double __value) { keyStyle().yOffset = __value; redrawPlot(); }
254 inline void setXSeparation(
double __value) { keyStyle().xSeparation = __value; redrawPlot(); }
256 inline void setYSeparation(
double __value) { keyStyle().ySeparation = __value; redrawPlot(); }
264 inline void setFrameColor(QColor __value) { keyStyle().frameColor = __value; redrawPlot(); }
266 inline void setFrameLineStyle(Qt::PenStyle __value) { keyStyle().frameLineStyle = __value; redrawPlot(); }
268 inline void setTextColor(QColor __value) { keyStyle().textColor = __value; redrawPlot(); }
270 inline void setBackgroundColor(QColor __value) { keyStyle().backgroundBrush = __value; redrawPlot(); }
272 inline void setBackgroundColor(QColor __value, Qt::BrushStyle __style) { keyStyle().backgroundBrush = QBrush(__value, __style); redrawPlot(); }
274 inline void setBackgroundBrush(
const QBrush& __value) { keyStyle().backgroundBrush = __value; redrawPlot(); }
304 double calcOverallWidth(
double sampleLineLength,
double xSeparation,
double columnSeparation)
const;
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
base class for drawing a key (or legend)
Definition jkqtpkey.h:83
const JKQTPKeyStyle & getCurrentKeyStyle() const
current style properties (JKQTPKeyStyle) for this JKQTPKey
const JKQTBasePlotter * getParent() const
parent plotter class
Definition jkqtpkey.h:176
bool getVisible() const
indicates whether to plot a key
Definition jkqtpkey.h:195
void setPosition(JKQTPKeyPosition __value)
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples
Definition jkqtpkey.h:260
virtual QSizeF extendLayoutSize(QSizeF rawLayoutSize, JKQTPEnhancedPainter &painter, QPointF *offset=nullptr) const
takes the size calculated by KeyLayoutDescription::calcOverallWidth() and KeyLayoutDescription::calcO...
virtual void loadSettings(const QSettings &settings, const QString &group=QString("plots/key/"))
loads the plot properties from a QSettings object
virtual void saveSettings(QSettings &settings, const QString &group=QString("plots/key/")) const
saves the plot properties into a QSettings object.
void setXSeparation(double __value)
distance between key line example and key text [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:254
void redrawPlot()
signals the parent JKQTBasePlotter to redraw
void setYOffset(double __value)
y-offset of the key from the border of the plot [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:252
void setSampleLineLength(double __value)
length of the line samples in the key [in units of width of 'X' set in fontName, fontSize]
Definition jkqtpkey.h:244
Qt::PenStyle getFrameLineStyle() const
linestyle for the frame
Definition jkqtpkey.h:217
void setFrameWidth(double __value)
width of the key frame line [pt]
Definition jkqtpkey.h:238
double getXOffset() const
x-offset of the key from the border of the plot [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:201
void setColumnSeparation(double __value)
distance between two columns of key entries [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:258
void setFrameColor(QColor __value)
color of the key frame line
Definition jkqtpkey.h:264
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 void drawKey(JKQTPEnhancedPainter &painter, const QRectF &rect, const KeySizeDescription &layout)
draw the key
double getFrameWidth() const
width of the key frame line [pt]
Definition jkqtpkey.h:225
virtual ~JKQTPBaseKey()
class destructor
KeySizeDescription getSize(JKQTPEnhancedPainter &painter)
calculates the size required for the key
QColor getTextColor() const
color of the key entries' text
Definition jkqtpkey.h:219
const QBrush & getBackgroundBrush() const
color of the key background
Definition jkqtpkey.h:223
virtual QString getEntryText(int item) const =0
returns the label text (my contain markup for a JKQTMathText) of legend entry item 's text part
bool getFrameVisible() const
indicates whether to plot a frame around the key
Definition jkqtpkey.h:193
virtual int getEntryCount() const =0
returns the number of legend entries
double getXMargin() const
x-distance between key frame and key content [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:197
virtual JKQTPKeyStyle & keyStyle()
provides the keyStyle to use for sizing/drawing this object
QColor getBackgroundColor() const
color of the key background
Definition jkqtpkey.h:221
JKQTPKeyPosition getPosition() const
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples
Definition jkqtpkey.h:211
double getColumnSeparation() const
distance between two columns of key entries [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:209
void setXMargin(double __value)
x-distance between key frame and key content [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:246
double getXSeparation() const
distance between key line example and key text [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:205
void setYSeparation(double __value)
distance between two key entries [in units of height of fontName, fontSize]
Definition jkqtpkey.h:256
const JKQTMathText * getParentMathText() const
retun parents JKQTMathText* object
QColor getFrameColor() const
color of the key frame line
Definition jkqtpkey.h:215
virtual const JKQTPKeyStyle & keyStyle() const
provides the keyStyle to use for sizing/drawing this object
void setFrameRounding(double __value)
rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt]
Definition jkqtpkey.h:240
void setFrameLineStyle(Qt::PenStyle __value)
linestyle for the frame
Definition jkqtpkey.h:266
double getSampleLineLength() const
length of the line samples in the key [in units of width of 'X' set in fontName, fontSize]
Definition jkqtpkey.h:231
JKQTMathText * getParentMathText()
retun parents JKQTMathText* object
double getYMargin() const
y-distance between key frame and key content [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:199
virtual void modifySize(JKQTPEnhancedPainter &painter, KeySizeDescription ¤tSize, QSizeF preliminaryPlotSize)
econd stage of size calculation
JKQTPKeyLayout getLayout() const
the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for...
Definition jkqtpkey.h:213
JKQTBasePlotter * parent
parent plotter class
Definition jkqtpkey.h:344
void setFontSize(double __value)
font size for key labels [in points]
Definition jkqtpkey.h:242
double getFontSize() const
font size for key labels [in points]
Definition jkqtpkey.h:227
void setLayout(JKQTPKeyLayout __value)
the key layout, i.e. how the entries are distributed over the available space, see JKQTPKeyLayout for...
Definition jkqtpkey.h:262
void setBackgroundBrush(const QBrush &__value)
color of the key background
Definition jkqtpkey.h:274
void setBackgroundColor(QColor __value, Qt::BrushStyle __style)
color of the key background
Definition jkqtpkey.h:272
JKQTPBaseKey(JKQTBasePlotter *parent)
class constructor
void setXOffset(double __value)
x-offset of the key from the border of the plot [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:250
void setTextColor(QColor __value)
color of the key entries' text
Definition jkqtpkey.h:268
void setBackgroundColor(QColor __value)
color of the key background
Definition jkqtpkey.h:270
void setCurrentKeyStyle(const JKQTPKeyStyle &style)
replace the current style properties for this JKQTPKey
virtual void setParent(JKQTBasePlotter *parent)
void setFrameVisible(bool __value)
indicates whether to plot a frame around the key
Definition jkqtpkey.h:236
JKQTPKeyStyle localKeyStyle
current style properties for this key/legend
Definition jkqtpkey.h:350
void calcLayoutSize(JKQTPEnhancedPainter &painter, KeySizeDescription &layout) const
fill KeySizeDescription::requiredSize
double getYSeparation() const
distance between two key entries [in units of height of fontName, fontSize]
Definition jkqtpkey.h:207
void setVisible(bool __value)
indicates whether to plot a key
Definition jkqtpkey.h:234
virtual KeyLayoutDescription getKeyLayout(JKQTPEnhancedPainter &painter)
calculates all layout properties of the key/legend,necessary to size and draw it
JKQTBasePlotter * getParent()
parent plotter class
Definition jkqtpkey.h:178
virtual QColor getEntryColor(int item) const =0
returns the label color of legend entry item 's text part
double getYOffset() const
y-offset of the key from the border of the plot [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:203
void setYMargin(double __value)
y-distance between key frame and key content [in units of width of 'X' set in fontName,...
Definition jkqtpkey.h:248
double getFrameRounding() const
rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt]
Definition jkqtpkey.h:229
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of ...
Definition jkqtpkeystyle.h:49
concrete class for drawing the main plot key (or legend). This class reads the key entries from the g...
Definition jkqtpkey.h:362
QList< const JKQTPPlotElement * > getPlotElements() const
returns all graph classes from parent JKQTBasePlotter for the key
virtual void drawEntrySample(int item, JKQTPEnhancedPainter &painter, const QRectF &rect) override
draws the sample for legend entry item into the given rect, using the given painter
virtual QColor getEntryColor(int item) const override
returns the label color of legend entry item 's text part
JKQTPMainKey(JKQTBasePlotter *parent)
class constructor
JKQTPPlotElement * getPlotElement(int item)
returns the graph class from parent JKQTBasePlotter for the given item in the key
virtual int getEntryCount() const override
returns the number of legend entries
virtual QString getEntryText(int item) const override
returns the label text (my contain markup for a JKQTMathText) of legend entry item 's text part
virtual ~JKQTPMainKey()
class destructor
virtual JKQTPKeyStyle & keyStyle() override
provides the keyStyle to use for sizing/drawing this object
virtual const JKQTPKeyStyle & keyStyle() const override
provides the keyStyle to use for sizing/drawing this object (extracted from the parent JKQTBasePlotte...
const JKQTPPlotElement * getPlotElement(int item) const
returns the graph class from parent JKQTBasePlotter for the given item in the key
this virtual base class of every element, which is part of a JKQTPlotter plot and may appear in its k...
Definition jkqtpgraphsbase.h:62
JKQTPKeyLayout
layout of the key
Definition jkqtptools.h:632
QFlags< JKQTPKeyPositions > JKQTPKeyPosition
position of the key
Definition jkqtptools.h:607
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89
describes one column of items in the key
Definition jkqtpkey.h:287
double calcMaxLabelWidth() const
calculates the max. text width of the column in pixels
KeyColumnDescription(const KeyItemData &item1)
QList< KeyItemData > rows
list of all items in this row of key items
Definition jkqtpkey.h:291
double calcColumnWidth(double sampleLineLength, double xSeparation) const
calculates the width of the column in pixels
describes a single key entry
Definition jkqtpkey.h:106
int id
id of the item, used to call drawEntrySample() etc.
Definition jkqtpkey.h:109
QSizeF size
size of text in pixels
Definition jkqtpkey.h:113
QString text
text/label text/markup in the enry
Definition jkqtpkey.h:111
KeyItemData(int _id=-1, const QString &_text="", const QSizeF _size=QSizeF())
struct, describing basic layout and size properties of a key/legend, mostly used as return value of g...
Definition jkqtpkey.h:300
void redistributeOverColumns(int cols, bool colMajor=true)
takes all elements in columns and redistributes them over the given number of columns,...
double calcOverallWidth(double sampleLineLength, double xSeparation, double columnSeparation) const
calculates the width over all columns
void redistributeOverRows(int rows, bool rowMajor=true)
takes all elements in columns and redistributes them over the given number of rows,...
int calcRowCount() const
calculates the number of rows
QList< KeyColumnDescription > columns
list of all columns with items in the key
Definition jkqtpkey.h:302
double calcRowHeight(int i, double sampleHeight) const
calculate the hieght of the i -th column
void redistributeIntoOneColumn()
put all items into one column
double calcOverallHeight(double ySeparation, double sampleHeight) const
calculates the width over all columns
int countItems() const
calculate the number of items
struct, describing basic layout and size properties of a key/legend, mostly used as return value of g...
Definition jkqtpkey.h:119
KeyLocation keyLocation
where the size requiredSize has to be resevred for the key
Definition jkqtpkey.h:137
KeySizeDescription(QSize _requiredSize=QSize(), KeyLocation _keyLocation=keyInside)
std::unique_ptr< KeyLayoutDescription > d
private data
Definition jkqtpkey.h:140
KeySizeDescription(const KeySizeDescription &other)
QSizeF requiredSize
required spacefor the key/legend [pixels]
Definition jkqtpkey.h:135
KeyLocation
type describing the position of the key
Definition jkqtpkey.h:122
@ keyOutsideRight
on the right of the plot
Definition jkqtpkey.h:125
@ keyOutsideLeft
on the left of the plot
Definition jkqtpkey.h:124
@ keyOutsideTop
above the plot
Definition jkqtpkey.h:126
@ keyInside
somewhere inside the plot
Definition jkqtpkey.h:123
KeySizeDescription & operator=(const KeySizeDescription &other)