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
jkqtpkey.h
1/*
2 Copyright (c) 2023-2023 Jan W. Krieger (<jan@jkrieger.de>)
3
4
5
6 This software is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License (LGPL) as published by
8 the Free Software Foundation, either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License (LGPL) for more details.
15
16 You should have received a copy of the GNU Lesser General Public License (LGPL)
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20
21
22
23#ifndef JKQTPKEY_H
24#define JKQTPKEY_H
25
26
27#include <QString>
28#include <QPainter>
29#include "jkqtplotter/jkqtplotter_imexport.h"
30#include "jkqtplotter/jkqtpkeystyle.h"
31
32// forward declarations
33class JKQTBasePlotter;
35class JKQTMathText;
36
37
38
39/*! \brief base class for drawing a key (or legend)
40 \ingroup jkqtpbaseplotter_elements
41
42 The class JKQTPBaseKey implements the basic layouting and drawing of a key/legend.
43
44 \section JKQTPBaseKey_Styling Key/Legend Styling
45
46 \copydetails JKQTPKeyStyle
47
48 \note The class JKQTPBaseKey offers setters (slots) and getters for all the properties in the used instance of JKQTPKeyStyle .
49
50 \section JKQTPBaseKey_Usage Usage
51
52 The functions in JKQTPBaseKey are mainly used for drawing the main key in a JKQTBasePlotter.
53 The instance representing that main key is accessible via JKQTPBaseKey::getMainKey().
54 It is not a direct instance of JKQTPBaseKey, which is impossible, as it is pure virtual,
55 but an instance of JKQTPMainKey, which extends JKQTPBaseKey with access to the titles assigned to
56 each JKQTPPlotElement (see JKQTPPlotElement::getTitle(), JKQTPPlotElement::setTitle()) and its key-marker (JKQTPPlotElement::drawKeyMarker()).
57
58 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),
59 if the corresponding JKQTPPlotElement implements this.
60
61
62
63 \section JKQTPBaseKey_ImplementationDetails Implementation Details
64
65 It relies on these protected virtual functions to determine the contents of the legend items:
66 - JKQTPBaseKey::getEntryCount()
67 - JKQTPBaseKey::getEntryTextExtent()
68 - JKQTPBaseKey::getEntryText()
69 - JKQTPBaseKey::drawEntrySample()
70 .
71 So you can derive from JKQTPBaseKey and implement these to provide a new source of data.
72
73 There are additional customization points in this class. You can also override the
74 default implementations of these functions to change the way keys/legends are drawn:
75 - JKQTPBaseKey::drawKey()
76 - JKQTPBaseKey::getLayout()
77 - JKQTPBaseKey::modifySize()
78 .
79
80 \see JKQTPKeyStyle, JKQTPMainKey
81
82 */
83class JKQTPLOTTER_LIB_EXPORT JKQTPBaseKey: public QObject {
84 Q_OBJECT
85 protected:
86 struct KeyLayoutDescription; // forward
87 public:
88
89 /** \brief class constructor */
90 explicit JKQTPBaseKey(JKQTBasePlotter* parent);
91 /** \brief class destructor */
92 virtual ~JKQTPBaseKey();
93 virtual void setParent(JKQTBasePlotter* parent);
94 /** \brief loads the plot properties from a QSettings object */
95 virtual void loadSettings(const QSettings &settings, const QString& group=QString("plots/key/"));
96
97 /** \brief saves the plot properties into a QSettings object.
98 *
99 * This method only saves those properties that differ from their default value.
100 */
101 virtual void saveSettings(QSettings& settings, const QString& group=QString("plots/key/")) const;
102
103
104
105 /** \brief describes a single key entry */
107 KeyItemData(int _id=-1, const QString& _text="", const QSizeF _size=QSizeF());
108 /** \brief id of the item, used to call drawEntrySample() etc. */
109 int id;
110 /** \brief text/label text/markup in the enry */
111 QString text;
112 /** \brief size of \a text in pixels */
113 QSizeF size;
114
115 };
116
117
118 /** \brief struct, describing basic layout and size properties of a key/legend, mostly used as return value of getSize(). */
120
121 /** \brief type describing the position of the key */
123 keyInside, /*!< \brief somewhere inside the plot */
124 keyOutsideLeft, /*!< \brief on the left of the plot */
125 keyOutsideRight, /*!< \brief on the right of the plot */
126 keyOutsideTop, /*!< \brief above the plot */
127 keyOutsideBottom /*!< \brief below the plot */
128 };
129
130 KeySizeDescription(QSize _requiredSize=QSize(), KeyLocation _keyLocation=keyInside);
133
134 /** \brief required spacefor the key/legend [pixels] */
136 /** \brief where the size requiredSize has to be resevred for the key */
138
139 /** \brief private data \internal */
140 std::unique_ptr<KeyLayoutDescription> d;
141
142 };
143
144 /** \brief calculates the size required for the key
145 *
146 * This function internally calls getLayout(), which is (together with drawKey() )
147 * a customization point for key layout.
148 */
150 /** \brief econd stage of size calculation
151 *
152 * This functions allows to again modify the KeySizeDescription \a currentSize in a second step,
153 * when the preliminary size of the plot is known (given as \a preliminaryPlotSize ).
154 *
155 * This is used to implement the JKQTPKeyLayout::JKQTPKeyLayoutMultiColumn and JKQTPKeyLayout::JKQTPKeyLayoutMultiRow,
156 * where the distribution of entries over rows/columns is calculated here.
157 *
158 * \note This function is declared virtual so it can be used as a customization point!
159 */
160 virtual void modifySize(JKQTPEnhancedPainter& painter, KeySizeDescription& currentSize, QSizeF preliminaryPlotSize) ;
161
162 /** \brief draw the key
163 *
164 * \param painter the painter to use for drawing
165 * \param rect the rectangle to plot the key into, depending on JKQTPKeyStyle::position this is either the plot rectangle itself, or
166 * a rectangle outside the plot that fits the key
167 * \param layout output of getSize(), possibly modified by modifySize()
168 *
169 * \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 \a rect to this function for subsequent drawing.
170 * It is also expected that the legends contents does not changed in the meantime!
171 */
172 virtual void drawKey(JKQTPEnhancedPainter& painter, const QRectF &rect, const KeySizeDescription &layout);
173
174
175 /** \copydoc parent */
176 inline const JKQTBasePlotter* getParent() const { return parent; }
177 /** \copydoc parent */
178 inline JKQTBasePlotter* getParent() { return parent; }
179
180 /** \brief current style properties (JKQTPKeyStyle) for this JKQTPKey
181 *
182 * \see JKQTPKeyStyle
183 */
185
186 /** \brief replace the current style properties for this JKQTPKey
187 *
188 * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), \ref jkqtpplotter_styling
189 */
191
192 /** \copydoc JKQTPKeyStyle::frameVisible */
193 inline bool getFrameVisible() const { return keyStyle().frameVisible; }
194 /** \copydoc JKQTPKeyStyle::visible */
195 inline bool getVisible() const { return keyStyle().visible; }
196 /** \copydoc JKQTPKeyStyle::xMargin */
197 inline double getXMargin() const { return keyStyle().xMargin; }
198 /** \copydoc JKQTPKeyStyle::yMargin */
199 inline double getYMargin() const { return keyStyle().yMargin; }
200 /** \copydoc JKQTPKeyStyle::xOffset */
201 inline double getXOffset() const { return keyStyle().xOffset; }
202 /** \copydoc JKQTPKeyStyle::yOffset */
203 inline double getYOffset() const { return keyStyle().yOffset; }
204 /** \copydoc JKQTPKeyStyle::xSeparation */
205 inline double getXSeparation() const { return keyStyle().xSeparation; }
206 /** \copydoc JKQTPKeyStyle::ySeparation */
207 inline double getYSeparation() const { return keyStyle().ySeparation; }
208 /** \copydoc JKQTPKeyStyle::columnSeparation */
209 inline double getColumnSeparation() const { return keyStyle().columnSeparation; }
210 /** \copydoc JKQTPKeyStyle::position */
211 inline JKQTPKeyPosition getPosition() const { return keyStyle().position; }
212 /** \copydoc JKQTPKeyStyle::layout */
213 inline JKQTPKeyLayout getLayout() const { return keyStyle().layout; }
214 /** \copydoc JKQTPKeyStyle::frameColor */
215 inline QColor getFrameColor() const { return keyStyle().frameColor; }
216 /** \copydoc JKQTPKeyStyle::frameLineStyle */
217 inline Qt::PenStyle getFrameLineStyle() const { return keyStyle().frameLineStyle; }
218 /** \copydoc JKQTPKeyStyle::textColor */
219 inline QColor getTextColor() const { return keyStyle().textColor; }
220 /** \copydoc JKQTPKeyStyle::backgroundBrush */
221 inline QColor getBackgroundColor() const { return keyStyle().backgroundBrush.color(); }
222 /** \copydoc JKQTPKeyStyle::backgroundBrush */
223 inline const QBrush& getBackgroundBrush() const { return keyStyle().backgroundBrush; }
224 /** \copydoc JKQTPKeyStyle::frameWidth */
225 inline double getFrameWidth() const { return keyStyle().frameWidth; }
226 /** \copydoc JKQTPKeyStyle::fontSize */
227 inline double getFontSize() const { return keyStyle().fontSize; }
228 /** \copydoc JKQTPKeyStyle::frameRounding */
229 inline double getFrameRounding() const { return keyStyle().frameRounding; }
230 /** \copydoc JKQTPKeyStyle::sampleLineLength */
231 inline double getSampleLineLength() const { return keyStyle().sampleLineLength; }
232 public Q_SLOTS:
233 /** \copydoc JKQTPKeyStyle::visible */
234 inline void setVisible(bool __value) { keyStyle().visible = __value; redrawPlot(); }
235 /** \copydoc JKQTPKeyStyle::frameVisible */
236 inline void setFrameVisible(bool __value) { keyStyle().frameVisible = __value; redrawPlot(); }
237 /** \copydoc JKQTPKeyStyle::frameWidth */
238 inline void setFrameWidth(double __value) { keyStyle().frameWidth = __value; redrawPlot(); }
239 /** \copydoc JKQTPKeyStyle::frameRounding */
240 inline void setFrameRounding(double __value) { keyStyle().frameRounding = __value; redrawPlot(); }
241 /** \copydoc JKQTPKeyStyle::fontSize */
242 inline void setFontSize(double __value) { keyStyle().fontSize = __value; redrawPlot(); }
243 /** \copydoc JKQTPKeyStyle::sampleLineLength */
244 inline void setSampleLineLength(double __value) { keyStyle().sampleLineLength = __value; redrawPlot(); }
245 /** \copydoc JKQTPKeyStyle::xMargin */
246 inline void setXMargin(double __value) { keyStyle().xMargin = __value; redrawPlot(); }
247 /** \copydoc JKQTPKeyStyle::yMargin */
248 inline void setYMargin(double __value) { keyStyle().yMargin = __value; redrawPlot(); }
249 /** \copydoc JKQTPKeyStyle::xOffset */
250 inline void setXOffset(double __value) { keyStyle().xOffset = __value; redrawPlot(); }
251 /** \copydoc JKQTPKeyStyle::yOffset */
252 inline void setYOffset(double __value) { keyStyle().yOffset = __value; redrawPlot(); }
253 /** \copydoc JKQTPKeyStyle::xSeparation */
254 inline void setXSeparation(double __value) { keyStyle().xSeparation = __value; redrawPlot(); }
255 /** \copydoc JKQTPKeyStyle::ySeparation */
256 inline void setYSeparation(double __value) { keyStyle().ySeparation = __value; redrawPlot(); }
257 /** \copydoc JKQTPKeyStyle::columnSeparation */
258 inline void setColumnSeparation(double __value) { keyStyle().columnSeparation = __value; redrawPlot(); }
259 /** \copydoc JKQTPKeyStyle::position */
260 inline void setPosition(JKQTPKeyPosition __value) { keyStyle().position = __value; redrawPlot(); }
261 /** \copydoc JKQTPKeyStyle::layout */
262 inline void setLayout(JKQTPKeyLayout __value) { keyStyle().layout = __value; redrawPlot(); }
263 /** \copydoc JKQTPKeyStyle::frameColor */
264 inline void setFrameColor(QColor __value) { keyStyle().frameColor = __value; redrawPlot(); }
265 /** \copydoc JKQTPKeyStyle::frameLineStyle */
266 inline void setFrameLineStyle(Qt::PenStyle __value) { keyStyle().frameLineStyle = __value; redrawPlot(); }
267 /** \copydoc JKQTPKeyStyle::textColor */
268 inline void setTextColor(QColor __value) { keyStyle().textColor = __value; redrawPlot(); }
269 /** \copydoc JKQTPKeyStyle::backgroundBrush */
270 inline void setBackgroundColor(QColor __value) { keyStyle().backgroundBrush = __value; redrawPlot(); }
271 /** \copydoc JKQTPKeyStyle::backgroundBrush */
272 inline void setBackgroundColor(QColor __value, Qt::BrushStyle __style) { keyStyle().backgroundBrush = QBrush(__value, __style); redrawPlot(); }
273 /** \copydoc JKQTPKeyStyle::backgroundBrush */
274 inline void setBackgroundBrush(const QBrush& __value) { keyStyle().backgroundBrush = __value; redrawPlot(); }
275
276 protected:
277 /** \brief returns the number of legend entries */
278 virtual int getEntryCount() const =0;
279 /** \brief returns the label text (my contain markup for a JKQTMathText) of legend entry \a item 's text part */
280 virtual QString getEntryText(int item) const =0;
281 /** \brief returns the label color of legend entry \a item 's text part */
282 virtual QColor getEntryColor(int item) const =0;
283 /** \brief draws the sample for legend entry \a item into the given \a rect, using the given \a painter */
284 virtual void drawEntrySample(int item, JKQTPEnhancedPainter& painter, const QRectF& rect) =0;
285
286 /** \brief describes one column of items in the key */
290 /** \brief list of all items in this row of key items */
291 QList<KeyItemData> rows;
292
293 /** \brief calculates the max. text width of the column in pixels */
294 double calcMaxLabelWidth() const;
295 /** \brief calculates the width of the column in pixels */
296 double calcColumnWidth(double sampleLineLength, double xSeparation) const;
297 };
298
299 /** \brief struct, describing basic layout and size properties of a key/legend, mostly used as return value of getSize(). */
301 /** \brief list of all columns with items in the key */
302 QList<KeyColumnDescription> columns;
303 /** \brief calculates the width over all columns */
304 double calcOverallWidth(double sampleLineLength, double xSeparation, double columnSeparation) const;
305 /** \brief calculates the width over all columns */
306 double calcOverallHeight(double ySeparation, double sampleHeight) const;
307 /** \brief calculate the hieght of the \a i -th column */
308 double calcRowHeight(int i, double sampleHeight) const;
309 /** \brief calculates the number of rows */
310 int calcRowCount() const;
311 /** \brief calculate the number of items */
312 int countItems() const;
313 /** \brief put all items into one column */
315 /** \brief takes all elements in columns and redistributes them over the given number of rows, items are distributed as equally as possible (last row may have fewer items) */
316 void redistributeOverRows(int rows, bool rowMajor=true);
317 /** \brief takes all elements in columns and redistributes them over the given number of columns, items are distributed as equally as possible (last column may have fewer items) */
318 void redistributeOverColumns(int cols, bool colMajor=true);
319 };
320
321 /** \brief calculates all layout properties of the key/legend,necessary to size and draw it
322 *
323 * This is internally called by getSize() and drawKey().
324 */
326 /** \brief fill KeySizeDescription::requiredSize */
328 /** \brief takes the size calculated by KeyLayoutDescription::calcOverallWidth() and KeyLayoutDescription::calcOverallHeight() and extends it with margins, line widths, ... optionally returns the one-sided offset*/
329 virtual QSizeF extendLayoutSize(QSizeF rawLayoutSize, JKQTPEnhancedPainter &painter, QPointF* offset=nullptr) const;
330 /** \brief provides the keyStyle to use for sizing/drawing this object */
331 virtual const JKQTPKeyStyle& keyStyle() const;
332 /** \brief provides the keyStyle to use for sizing/drawing this object */
334
335 /** \brief signals the parent JKQTBasePlotter to redraw */
337 /** \brief retun parents JKQTMathText* object */
339 /** \brief retun parents JKQTMathText* object */
341
342
343 /** \brief parent plotter class */
345 private:
346 /** \brief current style properties for this key/legend
347 *
348 * \see JKQTPKeyStyle
349 */
351};
352
353
354/*! \brief concrete class for drawing the main plot key (or legend).
355 * This class reads the key entries from the graphs list of its parent JKQTBasePlotter und references the JKQTPKeyStyle object from JKQTBasePlotterStyle::keyStyle in the parent JKQTBasePlotter.
356 \ingroup jkqtpbaseplotter_elements
357
358
359 \see JKQTPKeyStyle
360
361 */
363 Q_OBJECT
364 protected:
365 public:
366
367 /** \brief class constructor */
368 explicit JKQTPMainKey(JKQTBasePlotter* parent);
369 /** \brief class destructor */
370 virtual ~JKQTPMainKey();
371 protected:
372 /** \copydoc JKQTPBaseKey::getEntryCount() */
373 virtual int getEntryCount() const override;
374 /** \copydoc JKQTPBaseKey::getEntryText() */
375 virtual QString getEntryText(int item) const override;
376 /** \copydoc JKQTPBaseKey::getEntryColor() */
377 virtual QColor getEntryColor(int item) const override;
378 /** \copydoc JKQTPBaseKey::drawEntrySample() */
379 virtual void drawEntrySample(int item, JKQTPEnhancedPainter& painter, const QRectF& rect) override;
380 /** \brief returns the graph class from parent JKQTBasePlotter for the given \a item in the key */
381 const JKQTPPlotElement* getPlotElement(int item) const;
382 /** \brief returns the graph class from parent JKQTBasePlotter for the given \a item in the key */
384 /** \brief returns all graph classes from parent JKQTBasePlotter for the key */
385 QList<const JKQTPPlotElement*> getPlotElements() const;
386 /** \brief provides the keyStyle to use for sizing/drawing this object (extracted from the parent JKQTBasePlotters's */
387 virtual const JKQTPKeyStyle& keyStyle() const;
388 /** \brief provides the keyStyle to use for sizing/drawing this object */
390};
391#endif // JKQTPKEY_H
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 &currentSize, 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 const JKQTPKeyStyle & keyStyle() const
provides the keyStyle to use for sizing/drawing this object (extracted from the parent JKQTBasePlotte...
virtual JKQTPKeyStyle & keyStyle()
provides the keyStyle to use for sizing/drawing this object
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
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)