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
jkqtpgeolines.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 jkqtpgeolines_H_INCLUDED
21#define jkqtpgeolines_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/** \brief This JKQTPGeometricPlotElement is used to draw a line, optionally line-end decorations (aka arrows) are pssible, but switched off by default.
36 * \ingroup jkqtplotter_geoplots
37 *
38 * \image html JKQTPGeoLine_HeadTail.png
39 *
40 *
41 * \image html plot_geoline.png
42 *
43 * \note This class support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
44 * and non-linear axes are chosen, the line is drawn as a curves, instead of straight
45 * a straight line. In the mode
46 * JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement the line is drawn as a straight line.
47 *
48 * You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
49 * \code
50 * line->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
51 * line->setTailDecoratorStyle(JKQTPCircleDecorator);
52 * \endcode
53 *
54 * This results in arrows drawn at the start (aka x1/y1, =tail) and end (aka x2/y2, =head) of the line.
55 *
56 *
57 * \note The convenience class JKQTPGeoArrow activates line-end decorations (aka arows) by default and allows to select them in the constructor.
58 *
59 * \see JKQTPGeoArrow, \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
60 *
61 */
63 Q_OBJECT
64 public:
65 /** \brief class constructor
66 *
67 * \param parent the parent plotter object
68 * \param x1 x-coordinate of first point of line
69 * \param y1 y-coordinate of first point of line
70 * \param x2 x-coordinate of second point of line
71 * \param y2 y-coordinate of second point of line
72 *
73 */
74 JKQTPGeoLine(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2);
75 /** \brief class constructor
76 *
77 * \param parent the parent plotter object
78 * \param x1 x-coordinate of first point of line
79 * \param y1 y-coordinate of first point of line
80 * \param x2 x-coordinate of second point of line
81 * \param y2 y-coordinate of second point of line
82 */
83 JKQTPGeoLine(JKQTPlotter* parent, double x1, double y1, double x2, double y2);
84
85
86
87
88 /** \brief class constructor
89 *
90 * \param parent the parent plotter object
91 * \param p1 first point of line (tail)
92 * \param p2 second point of line (head)
93 *
94 */
95 JKQTPGeoLine(JKQTBasePlotter* parent, const QPointF& p1, const QPointF& p2);
96 /** \brief class constructor
97 *
98 * \param parent the parent plotter object
99 * \param p1 first point of line (tail)
100 * \param p2 second point of line (head)
101 */
102 JKQTPGeoLine(JKQTPlotter* parent, const QPointF& p1, const QPointF& p2);
103
104
105
106
107 /** \brief class constructor
108 *
109 * \param parent the parent plotter object
110 * \param line the line
111 *
112 */
113 JKQTPGeoLine(JKQTBasePlotter* parent, const QLineF& line);
114 /** \brief class constructor
115 *
116 * \param parent the parent plotter object
117 * \param line the line
118 */
119 JKQTPGeoLine(JKQTPlotter* parent, const QLineF& line);
120
121
122
123 /** \copydoc JKQTPPlotElement::getXMinMax() */
124 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
125 /** \copydoc JKQTPPlotElement::getYMinMax() */
126 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
127
128 /** \brief plots the graph to the plotter object specified as parent
129 *
130 * \note This function support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
131 * and non-linear axes are chosen, the line will possibly be represented as a curve,
132 * instead of a straight line.
133 */
134 virtual void draw(JKQTPEnhancedPainter& painter) override;
135
136 /** \copydoc x1 */
137 void setX1(double __value);
138 /** \copydoc x1 */
139 double getX1() const;
140 /** \copydoc y1 */
141 void setY1(double __value);
142 /** \copydoc y1 */
143 double getY1() const;
144 /** \copydoc x2 */
145 void setX2(double __value);
146 /** \copydoc x2 */
147 double getX2() const;
148 /** \copydoc y2 */
149 void setY2(double __value);
150 /** \copydoc y2 */
151 double getY2() const;
152
153 /** \brief return line-start/tail (x1,y1) as QPointF */
154 QPointF getP1() const;
155 /** \brief set line-start/tail (x1,y1) as QPointF */
156 void setP1(const QPointF& p);
157 /** \brief return line-end/head (x2,y2) as QPointF */
158 QPointF getP2() const;
159 /** \brief set line-end/head (x2,y2) as QPointF */
160 void setP2(const QPointF& p);
161 /** \brief return the line as a QLineF object */
162 QLineF getLine() const;
163 /** \brief define the line as a QLineF object */
164 void setLine(const QLineF& line);
165 protected:
166 /** \brief x-coordinate of first point of line */
167 double x1;
168 /** \brief y-coordinate of first point of line */
169 double y1;
170 /** \brief x-coordinate of second point of line */
171 double x2;
172 /** \brief y-coordinate of second point of line */
173 double y2;
174
175};
176
177
178/** \brief This convenience specialisation of JKQTPGeoLine is used to draw a line with decorations (e.g. arrows)
179 * \ingroup jkqtplotter_geoplots
180 *
181 * This class does not add any functionality on top of JKQTPGeoLine, just activates line-end markers by default!
182 *
183 * \image html JKQTPGeoLine_HeadTail.png
184 *
185 * \image html plot_geoarrows.png
186 *
187 * \see JKQTPLineDecoratorStyle, JKQTPGeoLine, \ref JKQTPlotterGeometricArrows and \ref JKQTPlotterGeometricGraphs
188 *
189 */
191 Q_OBJECT
192public:
193 /** \brief class constructor
194 *
195 * \param parent the parent plotter object
196 * \param x1 x-coordinate of first point of line
197 * \param y1 y-coordinate of first point of line
198 * \param x2 x-coordinate of second point of line
199 * \param y2 y-coordinate of second point of line
200 * \param headStyle decorator/arrow style of the head
201 * \param tailStyle decorator/arrow style of the tail
202 */
203 JKQTPGeoArrow(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator);
204 /** \brief class constructor
205 *
206 * \param parent the parent plotter object
207 * \param x1 x-coordinate of first point of line
208 * \param y1 y-coordinate of first point of line
209 * \param x2 x-coordinate of second point of line
210 * \param y2 y-coordinate of second point of line
211 * \param headStyle decorator/arrow style of the head
212 * \param tailStyle decorator/arrow style of the tail
213 */
214 JKQTPGeoArrow(JKQTPlotter* parent, double x1, double y1, double x2, double y2, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator);
215 /** \brief class constructor
216 *
217 * \param parent the parent plotter object
218 * \param p1 first point of line (tail)
219 * \param p2 second point of line (head)
220 * \param headStyle decorator/arrow style of the head
221 * \param tailStyle decorator/arrow style of the tail
222 */
224 /** \brief class constructor
225 *
226 * \param parent the parent plotter object
227 * \param p1 first point of line (tail)
228 * \param p2 second point of line (head)
229 * \param headStyle decorator/arrow style of the head
230 * \param tailStyle decorator/arrow style of the tail
231 */
233
234
235
236
237 /** \brief class constructor
238 *
239 * \param parent the parent plotter object
240 * \param line the line
241 * \param headStyle decorator/arrow style of the head
242 * \param tailStyle decorator/arrow style of the tail
243 *
244 */
246 /** \brief class constructor
247 *
248 * \param parent the parent plotter object
249 * \param line the line
250 * \param headStyle decorator/arrow style of the head
251 * \param tailStyle decorator/arrow style of the tail
252 */
254};
255
256
257
258
259
260/** \brief This JKQTPGeometricPlotElement is used to draw an infinite line
261 * \ingroup jkqtplotter_geoplots
262 *
263 * an infinite line has a starting point and then goes on in a given direction
264 * until the end of the plotting range.
265 *
266 * \image html plot_geoinfiniteline.png
267 *
268 *
269 * \note This class support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
270 * and non-linear axes are chosen, the line is drawn as a curves, instead of straight
271 * a straight line. In the mode
272 * JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement the line is drawn as a straight line.
273 *
274 * You can add a decorator to the head of the line (i.e. the given start point (x,y) ) iff this line is one-sided, i.e. two_sided \c ==false .
275 *
276 * \see \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
277 *
278 */
280 Q_OBJECT
281 public:
282 /** \brief class constructor
283 *
284 * \param parent the parent plotter object
285 * \param x x-coordinate of start point of line
286 * \param y y-coordinate of start point of line
287 * \param dx x-direction of the line
288 * \param dy y-direction of the line
289 */
290 JKQTPGeoInfiniteLine(JKQTBasePlotter* parent, double x, double y, double dx, double dy);
291 /** \brief class constructor
292 *
293 * \param parent the parent plotter object
294 * \param x x-coordinate of start point of line
295 * \param y y-coordinate of start point of line
296 * \param dx x-direction of the line
297 * \param dy y-direction of the line
298 */
299 JKQTPGeoInfiniteLine(JKQTPlotter* parent, double x, double y, double dx, double dy);
300
301
302 /** \copydoc JKQTPPlotElement::getXMinMax() */
303 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
304 /** \copydoc JKQTPPlotElement::getYMinMax() */
305 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
306
307 /** \brief plots the graph to the plotter object specified as parent
308 *
309 * \note This function support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
310 * and non-linear axes are chosen, the line will possibly be represented as a curve,
311 * instead of a straight line.
312 */
313 virtual void draw(JKQTPEnhancedPainter& painter) override;
314
315 /** \copydoc x */
316 void setX(double __value);
317 /** \copydoc x */
318 double getX() const;
319 /** \copydoc y */
320 void setY(double __value);
321 /** \copydoc y */
322 double getY() const;
323 /** \copydoc dx */
324 void setDx(double __value);
325 /** \copydoc dx */
326 double getDx() const;
327 /** \copydoc dy */
328 void setDy(double __value);
329 /** \copydoc dy */
330 double getDy() const;
331 /** \copydoc two_sided */
332 void setTwoSided(bool __value);
333 /** \copydoc two_sided */
334 bool getTwoSided() const;
335 /** \brief return point (x,y) on the line as QPointF */
336 QPointF getP() const;
337 /** \brief set point (x,y) on the line as QPointF */
338 void setP(const QPointF& p);
339 protected:
340 /** \brief x-coordinate of a point on the line */
341 double x;
342 /** \brief y-coordinate of a point on the line */
343 double y;
344 /** \brief x-component of the slope of the line */
345 double dx;
346 /** \brief y-component of the slope of the line */
347 double dy;
348 /** \brief indicates whether the line ends at the given point \f$ (x,y) \f$ (false, default),
349 * or is infinite in both directions (true) */
351};
352
353
354/** \brief This JKQTPGeometricPlotElement is used to draw a poly line
355 * \ingroup jkqtplotter_geoplots
356 *
357 * \image html plot_geolines.png
358 *
359 * \note This class support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
360 * and non-linear axes are chosen, the points of the poly-line will be possibly
361 * connected by curves, instead of straight lines. In the mode
362 * JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement the points are connected by straight
363 * lines, independent of the linearity or non-linearity of the coordinate axes.
364 *
365 * You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
366 * \code
367 * polyLine->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
368 * polyLine->setTailDecoratorStyle(JKQTPCircleDecorator);
369 * \endcode
370 *
371 * This results in arrows drawn at the start (=tail) and end (=head) of the poly-line:
372 *
373 * \image html geo_arrow_polylines.png
374 *
375 * \see \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
376 *
377 */
379 Q_OBJECT
380 public:
381 /** \brief class constructor
382 *
383 * \param parent the parent plotter object
384 * \param points points on the polygon
385 */
386 JKQTPGeoPolyLines(JKQTBasePlotter* parent, const QVector<QPointF>& points);
387 /** \brief class constructor
388 *
389 * \param parent the parent plotter object
390 * \param points points on the polygon
391 */
392 JKQTPGeoPolyLines(JKQTPlotter* parent, const QVector<QPointF>& points);
393 /** \brief class constructor
394 *
395 * \param parent the parent plotter object
396 */
398 /** \brief class constructor
399 *
400 * \param parent the parent plotter object
401 */
403
404
405 /** \copydoc JKQTPPlotElement::getXMinMax() */
406 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
407 /** \copydoc JKQTPPlotElement::getYMinMax() */
408 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
409
410 /** \brief plots the graph to the plotter object specified as parent
411 *
412 * \note This function support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
413 * and non-linear axes are chosen, the points of the poly-line will be possibly
414 * connected by curves, instead of straight lines. In the mode
415 * JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement the points are connected by straight
416 * lines, independent of the linearity or non-linearity of the coordinate axes.
417 */
418 virtual void draw(JKQTPEnhancedPainter& painter) override;
419
420 /** \copydoc points */
421 void setPoints(const QVector<QPointF> & __value);
422 /** \copydoc points */
423 QVector<QPointF> getPoints() const;
424
425 /** \brief append a point to the polygon \see points */
426 void appendPoint(const QPointF& p);
427
428 /** \brief append a point to the polygon \see points */
429 void appendPoint(const double x, const double y);
430
431 /** \brief returns the number of points \see points */
432 int getPointCount() const;
433 /** \brief returns the i-th of point \see points */
434 const QPointF& getPoint(int i) const;
435 /** \brief returns the i-th of point \see points */
436 QPointF& getPoint(int i);
437 /** \brief overwrites the i-th point \see points */
438 void setPoint(int i, const QPointF& point);
439 /** \brief deletes the i-the point \see points */
440 void removePoint(int i);
441 /** \brief returns an iterator to the first point \see points */
442 QVector<QPointF>::iterator pointsBegin();
443 /** \brief returns an iterator after the last point \see points */
444 QVector<QPointF>::iterator pointsEnd();
445 /** \brief returns a constant iterator to the first point \see points */
446 QVector<QPointF>::const_iterator pointsCBegin() const;
447 /** \brief returns a constant iterator after the last point \see points */
448 QVector<QPointF>::const_iterator pointsCEnd() const;
449 protected:
450 /** \brief list with all points on the poly-line */
451 QVector<QPointF> points;
452};
453
454
455
456/** \brief This JKQTPGeometricPlotElement is used to draw a bezier curve
457 * \ingroup jkqtplotter_geoplots
458 *
459 * \image html JKQTPGeoBezierCurveGraphic.png "drawn with JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement"
460 *
461 * \see \ref JKQTPlotterGeometricBezier, JKQTPGeoBaseDecoratedLine
462 *
463 * \section JKQTPGeoBezierCurveDrawMode DrawMode for JKQTPGeoBezierCurve
464 * This class support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve , which will only have a significant effect with logarithmic axes.
465 * THe image above is the default JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement on a linear axis.
466 *
467 * On logarithmic axes (x&y) the two modes draw very different shapes:
468 *
469 * \image html JKQTPGeoBezierCurveLogMath.png "drawn with JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve"
470 * \image html JKQTPGeoBezierCurveLogGraphic.png "drawn with JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement"
471 *
472 * For DrawAsGraphicElement only the control points are converted to screen-coordinates, but drawing takes place in the (linear) screen-system.
473 * For DrawAsMathematicalCurve drawing is done in the log-coordinate system.
474 *
475 * \section JKQTPGeoBezierCurveDecorators Line-End Decorators for JKQTPGeoBezierCurve
476 *
477 * You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
478 * \code
479 * bezier->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
480 * bezier->setTailDecoratorStyle(JKQTPCircleDecorator);
481 * \endcode
482 *
483 * \see \ref JKQTPlotterGeometricBezier
484 *
485 */
487 Q_OBJECT
488public:
489 /** \brief class constructor with start, end and one control point (i.e. a quadratic bezier curve)
490 *
491 * \param parent the parent plotter object
492 * \param start start point
493 * \param control1 control-point in between start and end
494 * \param end end point
495 */
496 JKQTPGeoBezierCurve(JKQTBasePlotter* parent, const QPointF& start, const QPointF& control1, const QPointF& end);
497 /** \brief class constructor with start, end and one control point (i.e. a quadratic bezier curve)
498 *
499 * \param parent the parent plotter object
500 * \param start start point
501 * \param control1 control-point in between start and end
502 * \param end end point
503 */
504 JKQTPGeoBezierCurve(JKQTPlotter* parent, const QPointF& start, const QPointF& control1, const QPointF& end);
505 /** \brief class constructor with start, end and two control points (i.e. a cubic bezier curve)
506 *
507 * \param parent the parent plotter object
508 * \param start start point
509 * \param control1 1st control-point in between start and end
510 * \param control2 2nd control-point in between start and end
511 * \param end end point
512 */
513 JKQTPGeoBezierCurve(JKQTBasePlotter* parent, const QPointF& start, const QPointF& control1, const QPointF& control2, const QPointF& end);
514 /** \brief class constructor with start, end and two control points (i.e. a cubic bezier curve)
515 *
516 * \param parent the parent plotter object
517 * \param start start point
518 * \param control1 1st control-point in between start and end
519 * \param control2 2nd control-point in between start and end
520 * \param end end point
521 */
522 JKQTPGeoBezierCurve(JKQTPlotter* parent, const QPointF& start, const QPointF& control1, const QPointF& control2, const QPointF& end);
523 /** \brief class constructor
524 *
525 * \param parent the parent plotter object
526 */
528 /** \brief class constructor
529 *
530 * \param parent the parent plotter object
531 */
533
534
535
536 /** \copydoc JKQTPPlotElement::getXMinMax() */
537 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
538 /** \copydoc JKQTPPlotElement::getYMinMax() */
539 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
540
541 /** \brief plots the graph to the plotter object specified as parent
542 *
543 * \note This function support JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve. If set,
544 * and non-linear axes are chosen, the points of the poly-line will be possibly
545 * connected by curves, instead of straight lines. In the mode
546 * JKQTPGeometricPlotElement::DrawMode::DrawAsGraphicElement the points are connected by straight
547 * lines, independent of the linearity or non-linearity of the coordinate axes.
548 */
549 virtual void draw(JKQTPEnhancedPainter& painter) override;
550
551 /** \copydoc points */
552 void setPoints(const QVector<QPointF> & __value);
553 /** \copydoc points */
554 QVector<QPointF> getPoints() const;
555
556 /** \brief get the start point of the curve */
557 QPointF getStart()const;
558 /** \brief get the end point of the curve */
559 QPointF getEnd()const;
560 /** \brief get the control point 1 of the curve */
561 QPointF getControl1()const;
562 /** \brief get the control point 2 of the curve */
563 QPointF getControl2()const;
564 /** \brief set a linear bezier curve (2 control points) */
565 void setLine(const QPointF& start, const QPointF& end);
566 /** \brief set a quadratic bezier curve (3 control points) */
567 void setQuad(const QPointF& start, const QPointF& control1, const QPointF& end);
568 /** \brief set a cubic bezier curve (4 control points) */
569 void setCubic(const QPointF& start, const QPointF& control1, const QPointF& control2, const QPointF& end);
570 /** \brief set a cubic bezier curve (5 control points) */
571 void setQuartic(const QPointF& start, const QPointF& control1, const QPointF& control2, const QPointF& control3, const QPointF& end);
572 /** \brief get the degree of the curve (number of points -1) */
573 int getDegree() const;
574 /** \brief get the number of control points (including start and end) */
576
577protected:
578 /** \brief list with all control points of the bezier curve
579 *
580 * \note This class supports at most 4 points are alllowed
581 */
582 QVector<QPointF> points;
583};
584
585
586/** \brief This JKQTPGeometricPlotElement is used to draw an arc
587 * \ingroup jkqtplotter_geoplots
588 *
589 *
590 * A pie on linear and log-log axes (start angle: 10deg and end-angle 110deg):
591 *
592 * \image html plot_geopie.png
593 *
594 * \note This class support the JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve only.
595 * This means that arcs are always treated as mathematical curves, as no meaningful
596 * parametrization for arcs on non-linear axes could be found!
597 *
598 * \see \ref JKQTPlotterGeometricGraphs, JKQTPGeoChord, JKQTPGeoPie, JKQTPGeoEllipse
599 */
601 Q_OBJECT
602 public:
603 /** \brief class constructor
604
605 * \param parent the parent plotter object
606 * \param x x-coordinate of center of ellipse
607 * \param y y-coordinate of center of ellipse
608 * \param width width of ellipse (2 * half axis)
609 * \param height of ellipse (2 * half axis)
610 * \param angleStart if we only draw an arc, this is the starting angle in degrees
611 * \param angleStop if we only draw an arc, this is the ending angle in degrees
612
613 */
614 JKQTPGeoArc(JKQTBasePlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop);
615 /** \brief class constructor
616
617 * \param parent the parent plotter object
618 * \param x x-coordinate of center of ellipse
619 * \param y y-coordinate of center of ellipse
620 * \param width width of ellipse (2 * half axis)
621 * \param height of ellipse (2 * half axis)
622 * \param angleStart if we only draw an arc, this is the starting angle in degrees
623 * \param angleStop if we only draw an arc, this is the ending angle in degrees
624
625 */
626 JKQTPGeoArc(JKQTPlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop);
627
628 /** \copydoc JKQTPPlotElement::getXMinMax() */
629 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
630 /** \copydoc JKQTPPlotElement::getYMinMax() */
631 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
632
633
634 /** \brief plots the graph to the plotter object specified as parent
635 *
636 * \note This function support the JKQTPGeometricPlotElement::DrawMode::DrawAsMathematicalCurve only.
637 * This means that arcs are always treated as mathematical curves, as no meaningful
638 * parametrization for arcs on non-linear axes could be found!
639 */
640 virtual void draw(JKQTPEnhancedPainter& painter) override;
641
642
643 /** \copydoc angleStart */
644 void setAngleStart(double __value);
645 /** \copydoc angleStart */
646 double getAngleStart() const;
647 /** \copydoc angleStop */
648 void setAngleStop(double __value);
649 /** \copydoc angleStop */
650 double getAngleStop() const;
651 /** \copydoc x */
652 void setX(double __value);
653 /** \copydoc x */
654 double getX() const;
655 /** \copydoc y */
656 void setY(double __value);
657 /** \copydoc y */
658 double getY() const;
659 /** \brief returns the center point of the arc */
660 QPointF getCenter() const;
661 /** \brief sets the center point of the arc */
662 void setCenter(const QPointF& center);
663 /** \copydoc width */
664 void setWidth(double __value);
665 /** \copydoc width */
666 double getWidth() const;
667 /** \copydoc height */
668 void setHeight(double __value);
669 /** \copydoc height */
670 double getHeight() const;
671 /** \brief returns the size (width and height) of the arc */
672 QSizeF getSize() const;
673 /** \brief sets the size (width and height) of the arc */
674 void setSize(const QSizeF& size);
675 /** \copydoc angle */
676 void setAngle(double __value);
677 /** \copydoc angle */
678 double getAngle() const;
679 protected:
680 /** \brief x-coordinate of a center of the rectangle */
681 double x;
682 /** \brief y-coordinate of a center of the rectangle */
683 double y;
684 /** \brief width of a center of the rectangle */
685 double width;
686 /** \brief height of a center of the rectangle */
687 double height;
688 /** \brief rotation angle of rectangle [degrees] around (x,y) */
689 double angle;
690 /** \brief if we only draw an arc, this is the starting angle in degrees */
692 /** \brief if we only draw an arc, this is the ending angle in degrees */
693 double angleStop;
694
695
696 /** \brief closing mode for arcs: secand or pie */
697 /** \brief returns the transformation matrix used for this rectangle */
698 QTransform getTransform();
699 /** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */
700 QPolygonF getPolygon();
701
702};
703
704
705
706
707#endif // jkqtpgeolines_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 JKQTPGeometricPlotElement is used to draw an arc.
Definition jkqtpgeolines.h:600
double height
height of a center of the rectangle
Definition jkqtpgeolines.h:687
QPolygonF getPolygon()
returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate ...
JKQTPGeoArc(JKQTPlotter *parent, double x, double y, double width, double height, double angleStart, double angleStop)
class constructor
double angle
rotation angle of rectangle [degrees] around (x,y)
Definition jkqtpgeolines.h:689
JKQTPGeoArc(JKQTBasePlotter *parent, double x, double y, double width, double height, double angleStart, double angleStop)
class constructor
void setWidth(double __value)
width of a center of the rectangle
double getWidth() const
width of a center of the rectangle
void setSize(const QSizeF &size)
sets the size (width and height) of the arc
QSizeF getSize() const
returns the size (width and height) of the arc
double getAngleStop() const
if we only draw an arc, this is the ending angle in degrees
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
void setX(double __value)
x-coordinate of a center of the rectangle
double x
x-coordinate of a center of the rectangle
Definition jkqtpgeolines.h:681
double width
width of a center of the rectangle
Definition jkqtpgeolines.h:685
double angleStop
if we only draw an arc, this is the ending angle in degrees
Definition jkqtpgeolines.h:693
void setAngle(double __value)
rotation angle of rectangle [degrees] around (x,y)
double getX() const
x-coordinate of a center of the rectangle
QPointF getCenter() const
returns the center point of the arc
void setAngleStart(double __value)
if we only draw an arc, this is the starting angle in degrees
double y
y-coordinate of a center of the rectangle
Definition jkqtpgeolines.h:683
double angleStart
if we only draw an arc, this is the starting angle in degrees
Definition jkqtpgeolines.h:691
void setAngleStop(double __value)
if we only draw an arc, this is the ending angle in degrees
double getY() const
y-coordinate of a center of the rectangle
QTransform getTransform()
closing mode for arcs: secand or pie
double getAngle() const
rotation angle of rectangle [degrees] around (x,y)
double getHeight() const
height of a center of the rectangle
double getAngleStart() const
if we only draw an arc, this is the starting angle in degrees
void setY(double __value)
y-coordinate of a center of the rectangle
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
void setCenter(const QPointF &center)
sets the center point of the arc
void setHeight(double __value)
height of a center of the rectangle
This convenience specialisation of JKQTPGeoLine is used to draw a line with decorations (e....
Definition jkqtpgeolines.h:190
JKQTPGeoArrow(JKQTPlotter *parent, double x1, double y1, double x2, double y2, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator)
class constructor
JKQTPGeoArrow(JKQTBasePlotter *parent, double x1, double y1, double x2, double y2, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator)
class constructor
JKQTPGeoArrow(JKQTPlotter *parent, const QPointF &p1, const QPointF &p2, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator)
class constructor
JKQTPGeoArrow(JKQTBasePlotter *parent, const QPointF &p1, const QPointF &p2, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator)
class constructor
JKQTPGeoArrow(JKQTBasePlotter *parent, const QLineF &line, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator)
class constructor
JKQTPGeoArrow(JKQTPlotter *parent, const QLineF &line, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator)
class constructor
This JKQTPGeometricPlotElement is used as base class for geometric drawing elements that consist of l...
Definition jkqtpgeobase.h:81
This JKQTPGeometricPlotElement is used as base class for geometric drawing elements that consist of l...
Definition jkqtpgeobase.h:130
This JKQTPGeometricPlotElement is used as base class for geometric drawing elements that only consist...
Definition jkqtpgeobase.h:39
This JKQTPGeometricPlotElement is used to draw a bezier curve.
Definition jkqtpgeolines.h:486
QPointF getStart() const
get the start point of the curve
QVector< QPointF > getPoints() const
list with all control points of the bezier curve
void setQuad(const QPointF &start, const QPointF &control1, const QPointF &end)
set a quadratic bezier curve (3 control points)
QVector< QPointF > points
list with all control points of the bezier curve
Definition jkqtpgeolines.h:582
JKQTPGeoBezierCurve(JKQTBasePlotter *parent, const QPointF &start, const QPointF &control1, const QPointF &end)
class constructor with start, end and one control point (i.e. a quadratic bezier curve)
void setPoints(const QVector< QPointF > &__value)
list with all control points of the bezier curve
QPointF getControl1() const
get the control point 1 of the curve
void setCubic(const QPointF &start, const QPointF &control1, const QPointF &control2, const QPointF &end)
set a cubic bezier curve (4 control points)
JKQTPGeoBezierCurve(JKQTPlotter *parent)
class constructor
JKQTPGeoBezierCurve(JKQTBasePlotter *parent)
class constructor
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
QPointF getEnd() const
get the end point of the curve
JKQTPGeoBezierCurve(JKQTBasePlotter *parent, const QPointF &start, const QPointF &control1, const QPointF &control2, const QPointF &end)
class constructor with start, end and two control points (i.e. a cubic bezier curve)
JKQTPGeoBezierCurve(JKQTPlotter *parent, const QPointF &start, const QPointF &control1, const QPointF &end)
class constructor with start, end and one control point (i.e. a quadratic bezier curve)
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
JKQTPGeoBezierCurve(JKQTPlotter *parent, const QPointF &start, const QPointF &control1, const QPointF &control2, const QPointF &end)
class constructor with start, end and two control points (i.e. a cubic bezier curve)
QPointF getControl2() const
get the control point 2 of the curve
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
void setQuartic(const QPointF &start, const QPointF &control1, const QPointF &control2, const QPointF &control3, const QPointF &end)
set a cubic bezier curve (5 control points)
int getDegree() const
get the degree of the curve (number of points -1)
void setLine(const QPointF &start, const QPointF &end)
set a linear bezier curve (2 control points)
int getNumberOfCOntrolPoints() const
get the number of control points (including start and end)
This JKQTPGeometricPlotElement is used to draw an infinite line.
Definition jkqtpgeolines.h:279
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
double getX() const
x-coordinate of a point on the line
void setDx(double __value)
x-component of the slope of the line
double getDy() const
y-component of the slope of the line
JKQTPGeoInfiniteLine(JKQTPlotter *parent, double x, double y, double dx, double dy)
class constructor
void setDy(double __value)
y-component of the slope of the line
void setTwoSided(bool __value)
indicates whether the line ends at the given point (false, default), or is infinite in both directio...
double y
y-coordinate of a point on the line
Definition jkqtpgeolines.h:343
double dy
y-component of the slope of the line
Definition jkqtpgeolines.h:347
bool two_sided
indicates whether the line ends at the given point (false, default), or is infinite in both directio...
Definition jkqtpgeolines.h:350
void setP(const QPointF &p)
set point (x,y) on the line as QPointF
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
QPointF getP() const
return point (x,y) on the line as QPointF
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
void setY(double __value)
y-coordinate of a point on the line
bool getTwoSided() const
indicates whether the line ends at the given point (false, default), or is infinite in both directio...
double dx
x-component of the slope of the line
Definition jkqtpgeolines.h:345
JKQTPGeoInfiniteLine(JKQTBasePlotter *parent, double x, double y, double dx, double dy)
class constructor
double getY() const
y-coordinate of a point on the line
double getDx() const
x-component of the slope of the line
double x
x-coordinate of a point on the line
Definition jkqtpgeolines.h:341
void setX(double __value)
x-coordinate of a point on the line
This JKQTPGeometricPlotElement is used to draw a line, optionally line-end decorations (aka arrows) a...
Definition jkqtpgeolines.h:62
QLineF getLine() const
return the line as a QLineF object
double y1
y-coordinate of first point of line
Definition jkqtpgeolines.h:169
double getX2() const
x-coordinate of second point of line
void setX1(double __value)
x-coordinate of first point of line
JKQTPGeoLine(JKQTPlotter *parent, const QLineF &line)
class constructor
double x2
x-coordinate of second point of line
Definition jkqtpgeolines.h:171
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
JKQTPGeoLine(JKQTBasePlotter *parent, const QPointF &p1, const QPointF &p2)
class constructor
double y2
y-coordinate of second point of line
Definition jkqtpgeolines.h:173
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
JKQTPGeoLine(JKQTPlotter *parent, double x1, double y1, double x2, double y2)
class constructor
void setY1(double __value)
y-coordinate of first point of line
double getY1() const
y-coordinate of first point of line
QPointF getP2() const
return line-end/head (x2,y2) as QPointF
void setLine(const QLineF &line)
define the line as a QLineF object
double getX1() const
x-coordinate of first point of line
void setY2(double __value)
y-coordinate of second point of line
JKQTPGeoLine(JKQTPlotter *parent, const QPointF &p1, const QPointF &p2)
class constructor
void setX2(double __value)
x-coordinate of second point of line
QPointF getP1() const
return line-start/tail (x1,y1) as QPointF
JKQTPGeoLine(JKQTBasePlotter *parent, const QLineF &line)
class constructor
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
double x1
x-coordinate of first point of line
Definition jkqtpgeolines.h:167
JKQTPGeoLine(JKQTBasePlotter *parent, double x1, double y1, double x2, double y2)
class constructor
void setP1(const QPointF &p)
set line-start/tail (x1,y1) as QPointF
void setP2(const QPointF &p)
set line-end/head (x2,y2) as QPointF
double getY2() const
y-coordinate of second point of line
This JKQTPGeometricPlotElement is used to draw a poly line.
Definition jkqtpgeolines.h:378
JKQTPGeoPolyLines(JKQTPlotter *parent, const QVector< QPointF > &points)
class constructor
void removePoint(int i)
deletes the i-the point
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
const QPointF & getPoint(int i) const
returns the i-th of point
QVector< QPointF >::iterator pointsBegin()
returns an iterator to the first point
QVector< QPointF >::iterator pointsEnd()
returns an iterator after the last point
QPointF & getPoint(int i)
returns the i-th of point
JKQTPGeoPolyLines(JKQTBasePlotter *parent, const QVector< QPointF > &points)
class constructor
QVector< QPointF >::const_iterator pointsCEnd() const
returns a constant iterator after the last point
void appendPoint(const QPointF &p)
append a point to the polygon
void appendPoint(const double x, const double y)
append a point to the polygon
JKQTPGeoPolyLines(JKQTPlotter *parent)
class constructor
void setPoints(const QVector< QPointF > &__value)
list with all points on the poly-line
QVector< QPointF >::const_iterator pointsCBegin() const
returns a constant iterator to the first point
QVector< QPointF > points
list with all points on the poly-line
Definition jkqtpgeolines.h:451
QVector< QPointF > getPoints() const
list with all points on the poly-line
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
void setPoint(int i, const QPointF &point)
overwrites the i-th point
int getPointCount() const
returns the number of points
JKQTPGeoPolyLines(JKQTBasePlotter *parent)
class constructor
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
JKQTPLineDecoratorStyle
symbols that can be used to plot a datapoint for a graph
Definition jkqtpdrawingtools.h:365
@ JKQTPNoDecorator
no decorator, i.e. a simple line-end
Definition jkqtpdrawingtools.h:366
@ JKQTPDefaultLineDecorator
a default symbol used for plotting
Definition jkqtpdrawingtools.h:394