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
jkqtpgeoannotations.h
1/*
2 Copyright (c) 2008-2024 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#ifndef jkqtpgeoannotations_H_INCLUDED
21#define jkqtpgeoannotations_H_INCLUDED
22
23
24#include <QString>
25#include <QPainter>
26#include <QPair>
27#include "jkqtplotter/graphs/jkqtpgeobase.h"
28#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
29#include "jkqtplotter/jkqtptools.h"
30#include "jkqtplotter/jkqtplotter_imexport.h"
31#include "jkqtmathtext/jkqtmathtext.h"
32
33
34
35
36/*! \brief This virtual JKQTPPlotAnnotationElement descendent may be used to display a single symbol (marker).
37 \ingroup jkqtplotter_annotations
38
39 \see \ref JKQTPlotterGeometricGraphs
40
41 */
43 Q_OBJECT
44 public:
45 /*! \brief class contructor
46
47 \param parent parent plotter widget
48 \param x x-coordinate of symbol center
49 \param y y-coordinate of symbol center
50 \param symbol symbol type
51 \param symbolSize size of the symbol in pt
52 */
53 JKQTPGeoSymbol(JKQTBasePlotter* parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize);
54 /*! \brief class contructor
55
56 \param parent parent plotter widget
57 \param x x-coordinate of symbol center
58 \param y y-coordinate of symbol center
59 \param symbol symbol type
60 \param symbolSize size of the symbol in pt
61 */
62 JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize);
63 /*! \brief class contructor
64
65 \param parent parent plotter widget
66 \param x x-coordinate of symbol center
67 \param y y-coordinate of symbol center
68 \param symbol symbol type
69 \param symbolSize size of the symbol in pt
70 \param color color of drawing
71 \param fillColor fill color of the symbol (if filled)
72 */
73 JKQTPGeoSymbol(JKQTBasePlotter* parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor);
74 /*! \brief class contructor
75
76 \param parent parent plotter widget
77 \param x x-coordinate of symbol center
78 \param y y-coordinate of symbol center
79 \param symbol symbol type
80 \param symbolSize size of the symbol in pt
81 \param color color of drawing
82 \param fillColor fill color of the symbol (if filled)
83 */
84 JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor);
85
86 /*! \brief class contructor
87
88 \param parent parent plotter widget
89 \param x x-coordinate of symbol center
90 \param y y-coordinate of symbol center
91 \param symbol symbol type
92 \param symbolSize size of the symbol in pt
93 \param color color of drawing
94 */
95 JKQTPGeoSymbol(JKQTBasePlotter* parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color);
96 /*! \brief class contructor
97
98 \param parent parent plotter widget
99 \param x x-coordinate of symbol center
100 \param y y-coordinate of symbol center
101 \param symbol symbol type
102 \param symbolSize size of the symbol in pt
103 \param color color of drawing
104 */
105 JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color);
106
107
108 /*! \brief class contructor
109
110 \param parent parent plotter widget
111 \param x x-coordinate of symbol center
112 \param y y-coordinate of symbol center
113 \param symbol symbol type
114 */
115 JKQTPGeoSymbol(JKQTBasePlotter* parent, double x, double y, JKQTPGraphSymbols symbol);
116
117 /*! \brief class contructor
118
119 \param parent parent plotter widget
120 \param x x-coordinate of symbol center
121 \param y y-coordinate of symbol center
122 \param symbol symbol type
123 */
124 JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y, JKQTPGraphSymbols symbol);
125 /*! \brief class contructor
126
127 \param parent parent plotter widget
128 \param x x-coordinate of symbol center
129 \param y y-coordinate of symbol center
130 */
131 JKQTPGeoSymbol(JKQTBasePlotter* parent, double x, double y);
132
133 /*! \brief class contructor
134
135 \param parent parent plotter widget
136 \param x x-coordinate of symbol center
137 \param y y-coordinate of symbol center
138 */
139 JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y);
140 /** \copydoc x */
141 double getX() const;
142 /** \copydoc y */
143 double getY() const;
144 /** \brief returns x and y at the same time \see x, y */
145 QPointF getP() const;
146
147 /** \copydoc JKQTPPlotElement::getXMinMax() */
148 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
149 /** \copydoc JKQTPPlotElement::getYMinMax() */
150 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
151
152 /** \brief plots the graph to the plotter object specified as parent */
153 virtual void draw(JKQTPEnhancedPainter& painter) override;
154
155 /** \brief plots a key marker inside the specified rectangle \a rect */
156 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
157 /** \brief returns the color to be used for the key label */
158 virtual QColor getKeyLabelColor() const override;
159 public Q_SLOTS:
160 /** set the symbol color and symbol fill color */
161 virtual void setColor(QColor c);
162
163 /** \copydoc x */
164 void setX(double __value);
165 /** \copydoc y */
166 void setY(double __value);
167 /** \brief set x and y at the same time \see x, y */
168 void setP(const QPointF& p);
169
170 protected:
171 /** \brief x-position (in plot coordinates) of the symbol (symbol center) */
172 double x;
173 /** \brief y-position (in plot coordinates) of the symbol (symbol center) */
174 double y;
175
176};
177
178
179/*! \brief This JKQTPPlotAnnotationElement is used to display text. It uses the JKQTMathText
180 class in order to display LaTeX formulas.
181 \ingroup jkqtplotter_annotations
182
183 \see \ref JKQTPlotterGeometricGraphs
184 */
186 Q_OBJECT
187 public:
188 /*! \brief class contructor
189
190 \param parent parent plotter widget
191 \param x x-coordinate of text
192 \param y y-coordinate of text
193 \param text the text to display
194 \param color color of drawing
195 \param fontSize base font size of text
196 */
197 JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize, QColor color);
198 /*! \brief class contructor
199
200 \param parent parent plotter widget
201 \param x x-coordinate of text
202 \param y y-coordinate of text
203 \param text the text to display
204 \param color color of drawing
205 \param fontSize base font size of text
206 */
207 JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize, QColor color);
208
209 /*! \brief class contructor
210
211 \param parent parent plotter widget
212 \param x x-coordinate of text
213 \param y y-coordinate of text
214 \param text the text to display
215 \param fontSize base font size of text
216 */
217 JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize);
218 /*! \brief class contructor
219
220 \param parent parent plotter widget
221 \param x x-coordinate of text
222 \param y y-coordinate of text
223 \param text the text to display
224 \param fontSize base font size of text
225 */
226 JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize);
227
228
229 /*! \brief class contructor
230
231 \param parent parent plotter widget
232 \param x x-coordinate of text
233 \param y y-coordinate of text
234 \param text the text to display
235 */
236 JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text);
237 /*! \brief class contructor
238
239 \param parent parent plotter widget
240 \param x x-coordinate of text
241 \param y y-coordinate of text
242 \param text the text to display
243 */
244 JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text);
245
246 /** \copydoc text */
247 QString getText() const;
248 /** \copydoc x */
249 double getX() const;
250 /** \copydoc y */
251 double getY() const;
252 /** \brief returns x and y at the same time \see x, y */
253 QPointF getP() const;
254
255
256 /** \copydoc JKQTPPlotAnnotationElement::getXMinMax() */
257 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
258 /** \copydoc JKQTPPlotAnnotationElement::getYMinMax() */
259 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
260
261 /** \brief plots the graph to the plotter object specified as parent */
262 virtual void draw(JKQTPEnhancedPainter& painter) override;
263
264 /** \brief plots a key marker inside the specified rectangle \a rect */
265 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
266 /** \brief returns the color to be used for the key label */
267 virtual QColor getKeyLabelColor() const override;
268 public Q_SLOTS:
269 /** \brief set line and fill color */
270 virtual void setColor(QColor c) ;
271
272 /** \copydoc text */
273 void setText(const QString & __value);
274 /** \copydoc x */
275 void setX(double __value);
276 /** \copydoc y */
277 void setY(double __value);
278 /** \brief set x and y at the same time \see x, y */
279 void setP(const QPointF& p);
280
281 protected:
282 /** \brief x-position (in plot coordinates) of the text (left/baseline) */
283 double x;
284 /** \brief y-position (in plot coordinates) of the text (left/baseline) */
285 double y;
286
287 /** \brief the text to display */
288 QString text;
289 /** \brief return a pen, that may be used for drawing */
291};
292
293
294
295#endif // jkqtpgeoannotations_H_INCLUDED
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
This virtual JKQTPPlotAnnotationElement descendent may be used to display a single symbol (marker).
Definition jkqtpgeoannotations.h:42
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
void setP(const QPointF &p)
set x and y at the same time
JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor)
class contructor
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
void setX(double __value)
x-position (in plot coordinates) of the symbol (symbol center)
JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor)
class contructor
JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color)
class contructor
double y
y-position (in plot coordinates) of the symbol (symbol center)
Definition jkqtpgeoannotations.h:174
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
double getY() const
y-position (in plot coordinates) of the symbol (symbol center)
JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y)
class contructor
JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol)
class contructor
JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize)
class contructor
void setY(double __value)
y-position (in plot coordinates) of the symbol (symbol center)
JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize)
class contructor
virtual void setColor(QColor c)
JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color)
class contructor
JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol)
class contructor
JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y)
class contructor
double getX() const
x-position (in plot coordinates) of the symbol (symbol center)
double x
x-position (in plot coordinates) of the symbol (symbol center)
Definition jkqtpgeoannotations.h:172
QPointF getP() const
returns x and y at the same time
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
This JKQTPPlotAnnotationElement is used to display text. It uses the JKQTMathText class in order to d...
Definition jkqtpgeoannotations.h:185
JKQTPGeoText(JKQTPlotter *parent, double x, double y, const QString &text, double fontSize)
class contructor
void setY(double __value)
y-position (in plot coordinates) of the text (left/baseline)
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
JKQTPGeoText(JKQTPlotter *parent, double x, double y, const QString &text)
class contructor
double getX() const
x-position (in plot coordinates) of the text (left/baseline)
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
JKQTPGeoText(JKQTPlotter *parent, double x, double y, const QString &text, double fontSize, QColor color)
class contructor
QPointF getP() const
returns x and y at the same time
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
double x
x-position (in plot coordinates) of the text (left/baseline)
Definition jkqtpgeoannotations.h:283
JKQTPGeoText(JKQTBasePlotter *parent, double x, double y, const QString &text, double fontSize, QColor color)
class contructor
QString getText() const
the text to display
QPen getPen(JKQTPEnhancedPainter &painter)
return a pen, that may be used for drawing
void setX(double __value)
x-position (in plot coordinates) of the text (left/baseline)
QString text
the text to display
Definition jkqtpgeoannotations.h:288
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
double y
y-position (in plot coordinates) of the text (left/baseline)
Definition jkqtpgeoannotations.h:285
double getY() const
y-position (in plot coordinates) of the text (left/baseline)
JKQTPGeoText(JKQTBasePlotter *parent, double x, double y, const QString &text, double fontSize)
class contructor
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
void setP(const QPointF &p)
set x and y at the same time
void setText(const QString &__value)
the text to display
JKQTPGeoText(JKQTBasePlotter *parent, double x, double y, const QString &text)
class contructor
virtual void setColor(QColor c)
set line and fill color
This Mix-In class provides setter/getter methods, storage and other facilities for the graph symbols ...
Definition jkqtpgraphsbasestylingmixins.h:379
This Mix-In class provides setter/getter methods, storage and other facilities for text in graphs.
Definition jkqtpgraphsbasestylingmixins.h:640
this is the virtual base class of all JKQTPPlotElement's in a JKQTPlotter plot that represent annotat...
Definition jkqtpgraphsbase.h:550
plotter widget for scientific plots (uses JKQTBasePlotter to do the actual drawing)
Definition jkqtplotter.h:364
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89
JKQTPGraphSymbols
symbols that can be used to plot a datapoint for a graph
Definition jkqtpdrawingtools.h:143