JKQtPlotter/lib/jkqtplotter/jkqtpgraphsgeometric.h
jkriege2 69ad2a0182 - added styling system for JKQTPlotter (+example app)
- improved documentation
- changed: using static const variables instead of \c #define for fixed default values (e.g. JKQTPImageTools::LUTSIZE, JKQTPImageTools::PALETTE_ICON_WIDTH, JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, JKQTMathText::ABS_MIN_LINEWIDTH ...)
- new: added debugging option, which surrounds different regions with visible rectangles (JKQTBasePlotter::enableDebugShowRegionBoxes() )
- fixed: colorbars at top were positioned over the plot label
- new: frames (plot viewport, key/legend ...) may be rounded off at the corners
- new: diverse new styling options (default font name/size ...)
- speed improvements to JKQTMathText::useSTIX()
2019-02-09 12:43:12 +01:00

1451 lines
57 KiB
C++

/*
Copyright (c) 2008-2019 Jan W. Krieger (<jan@jkrieger.de>)
This software is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License (LGPL) as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License (LGPL) for more details.
You should have received a copy of the GNU Lesser General Public License (LGPL)
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QString>
#include <QPainter>
#include <QPair>
#include "jkqtplotter/jkqtpgraphs.h"
#include "jkqtplottertools/jkqtptools.h"
#include "jkqtplottertools/jkqtp_imexport.h"
#include "jkqtmathtext/jkqtmathtext.h"
#ifndef jkqtpgraphsgeometric_H_INCLUDED
#define jkqtpgraphsgeometric_H_INCLUDED
/*! \brief This JKQTPPlotObject is used as base class for geometric drawing
elements that only consist of lines (i.e. no filling of any kind is done)
\ingroup jkqtplotter_geoplots
*/
class JKQTP_LIB_EXPORT JKQTPGeoBaseLine: public JKQTPPlotObject {
Q_OBJECT
public:
/*! \brief class contructor
\param color color of drawing
\param style line style of drawing
\param lineWidth lineWidth of drawing
*/
explicit JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr);
/*! \brief class contructor
\param color color of drawing
\param style line style of drawing
\param lineWidth lineWidth of drawing
*/
explicit JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent);
/*! \copydoc color
\see see color for details */
inline virtual void setColor(const QColor & __value)
{
this->color = __value;
}
/*! \copydoc color
\see see color for details */
inline virtual QColor getColor() const
{
return this->color;
}
/*! \copydoc style
\see see style for details */
inline virtual void setStyle(const Qt::PenStyle & __value)
{
this->style = __value;
}
/*! \copydoc style
\see see style for details */
inline virtual Qt::PenStyle getStyle() const
{
return this->style;
}
/*! \copydoc lineWidth
\see see lineWidth for details */
inline virtual void setLineWidth(double __value)
{
this->lineWidth = __value;
}
/*! \copydoc lineWidth
\see see lineWidth for details */
inline virtual double getLineWidth() const
{
return this->lineWidth;
}
/** \brief sets the alpha-channel of the \a color (i.e. its transparency) */
virtual void setAlpha(float alpha);
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() override;
protected:
/** \brief color of the graph */
QColor color;
/** \brief linestyle of the graph lines */
Qt::PenStyle style;
/** \brief width (pixels) of the graph */
double lineWidth;
/** \brief return a pen, that may be used for drawing */
QPen getPen(JKQTPEnhancedPainter &painter);
};
/*! \brief This JKQTPPlotObject is used as base class for geometric drawing
elements that only consist of lines (i.e. no filling of any kind is done)
\ingroup jkqtplotter_geoplots
*/
class JKQTP_LIB_EXPORT JKQTPGeoBaseFilled: public JKQTPGeoBaseLine {
Q_OBJECT
public:
/*! \brief class contructor
\param color color of drawing
\param fillColor color of the filling in the drawing
\param style line style of drawing
\param fillStyle filling style of the graph
\param lineWidth lineWidth of drawing
*/
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style=Qt::SolidLine, Qt::BrushStyle fillStyle=Qt::SolidPattern, JKQTBasePlotter* parent=nullptr);
/*! \brief class contructor
\param color color of drawing
\param fillColor color of the filling in the drawing
\param style line style of drawing
\param fillStyle filling style of the graph
\param lineWidth lineWidth of drawing
*/
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTPlotter* parent);
/*! \brief class contructor
\param color color of drawing
\param fillColor color of the filling in the drawing
\param style line style of drawing
\param lineWidth lineWidth of drawing
*/
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent);
/*! \brief class contructor
\param color color of drawing
\param fillColor color of the filling in the drawing
\param lineWidth lineWidth of drawing
*/
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, JKQTPlotter* parent);
/*! \brief class contructor
\param color color of drawing
\param fillColor color of the filling in the drawing
*/
JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTPlotter* parent);
/*! \copydoc fillColor
\see see fillColor for details */
inline virtual void setFillColor(const QColor & __value)
{
this->fillColor = __value;
}
/*! \copydoc fillColor
\see see fillColor for details */
inline virtual QColor getFillColor() const
{
return this->fillColor;
}
/*! \copydoc fillStyle
\see see fillStyle for details */
inline virtual void setFillStyle(const Qt::BrushStyle & __value)
{
this->fillStyle = __value;
}
/*! \copydoc fillStyle
\see see fillStyle for details */
inline virtual Qt::BrushStyle getFillStyle() const
{
return this->fillStyle;
}
/** \brief sets the alpha-channel of the \a color and \a fillColor (i.e. its transparency) to the same value */
virtual void setAlpha(float alpha) override;
/** \brief sets the alpha-channel of the \a color and \a fillColor (i.e. its transparency) */
virtual void setAlpha(float alphaLine, float alphaFill);
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
protected:
/** \brief filling color of the graph */
QColor fillColor;
/** \brief fill style for the curve */
Qt::BrushStyle fillStyle;
/** \brief return a brush that may be used for drawing */
QBrush getBrush(JKQTPEnhancedPainter& painter);
};
/*! \brief This virtual JKQTPGraph descendent may be used to display a single symbol (marker).
\ingroup jkqtplotter_geoplots
*/
class JKQTP_LIB_EXPORT JKQTPGeoSymbol: public JKQTPPlotObject {
Q_OBJECT
public:
/*! \brief class contructor
\param parent parent plotter widget
\param x x-coordinate of symbol center
\param y y-coordinate of symbol center
\param symbol symbol type
\param symbolSize size of the symbol in pt
\param color color of drawing
\param fillColor fill color of the symbol (if filled)
*/
JKQTPGeoSymbol(JKQTBasePlotter* parent, double x, double y, JKQTPGraphSymbols symbol=JKQTPCross, double symbolSize=10, QColor color=QColor("black"), QColor fillColor=QColor("grey"));
/*! \brief class contructor
\param parent parent plotter widget
\param x x-coordinate of symbol center
\param y y-coordinate of symbol center
\param symbol symbol type
\param symbolSize size of the symbol in pt
\param color color of drawing
\param fillColor fill color of the symbol (if filled)
*/
JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y, JKQTPGraphSymbols symbol=JKQTPCross, double symbolSize=10, QColor color=QColor("black"), QColor fillColor=QColor("grey"));
/*! \copydoc color
\see see color for details */
inline virtual void setColor(const QColor & __value)
{
this->color = __value;
}
/*! \copydoc color
\see see color for details */
inline virtual QColor getColor() const
{
return this->color;
}
/*! \copydoc fillColor
\see see fillColor for details */
inline virtual void setFillColor(const QColor & __value)
{
this->fillColor = __value;
}
/*! \copydoc fillColor
\see see fillColor for details */
inline virtual QColor getFillColor() const
{
return this->fillColor;
}
/*! \copydoc symbol
\see see symbol for details */
inline virtual void setSymbol(const JKQTPGraphSymbols & __value)
{
this->symbol = __value;
}
/*! \copydoc symbol
\see see symbol for details */
inline virtual JKQTPGraphSymbols getSymbol() const
{
return this->symbol;
}
/*! \copydoc symbolSize
\see see symbolSize for details */
inline virtual void setSymbolSize(double __value)
{
this->symbolSize = __value;
}
/*! \copydoc symbolSize
\see see symbolSize for details */
inline virtual double getSymbolSize() const
{
return this->symbolSize;
}
/*! \copydoc symbolWidth
\see see symbolWidth for details */
inline virtual void setSymbolWidth(double __value)
{
this->symbolWidth = __value;
}
/*! \copydoc symbolWidth
\see see symbolWidth for details */
inline virtual double getSymbolWidth() const
{
return this->symbolWidth;
}
/*! \copydoc x
\see see x for details */
inline virtual void setX(double __value)
{
this->x = __value;
}
/*! \copydoc x
\see see x for details */
inline virtual double getX() const
{
return this->x;
}
/*! \copydoc y
\see see y for details */
inline virtual void setY(double __value)
{
this->y = __value;
}
/*! \copydoc y
\see see y for details */
inline virtual double getY() const
{
return this->y;
}
/** \copydoc JKQTPGraph::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero);
/** \copydoc JKQTPGraph::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero);
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter);
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect);
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() override;
protected:
double x,y;
/** \brief color of the graph */
QColor color;
/** \brief fill-color of the graph */
QColor fillColor;
/** \brief size of the symbol in pt */
double symbolSize;
/** \brief width of the symbol lines in pt */
double symbolWidth;
/** \brief type of the symbol */
JKQTPGraphSymbols symbol;
};
/*! \brief This JKQTPPlotObject is used to display text. It uses the JKQTMathText
class in order to display LaTeX formulas.
\ingroup jkqtplotter_geoplots
*/
class JKQTP_LIB_EXPORT JKQTPGeoText: public JKQTPPlotObject {
Q_OBJECT
public:
/*! \brief class contructor
\param parent parent plotter widget
\param x x-coordinate of text
\param y y-coordinate of text
\param text the text to display
\param color color of drawing
\param fontSize base font size of text
*/
JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize=10, QColor color=QColor("black"));
/*! \brief class contructor
\param parent parent plotter widget
\param x x-coordinate of text
\param y y-coordinate of text
\param text the text to display
\param color color of drawing
\param fontSize base font size of text
*/
JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize=10, QColor color=QColor("black"));
/*! \copydoc color
\see see color for details */
inline virtual void setColor(const QColor & __value)
{
this->color = __value;
}
/*! \copydoc color
\see see color for details */
inline virtual QColor getColor() const
{
return this->color;
}
/*! \copydoc text
\see see text for details */
inline virtual void setText(const QString & __value)
{
this->text = __value;
}
/*! \copydoc fontName
\see see fontName for details */
inline virtual void setFontName(const QString & __value)
{
this->fontName = __value;
}
/*! \copydoc text
\see see text for details */
inline virtual QString getText() const
{
return this->text;
}
/*! \copydoc fontName
\see see fontName for details */
inline virtual QString getFontName() const
{
return this->fontName;
}
/*! \copydoc fontSize
\see see fontSize for details */
inline virtual void setFontSize(double __value)
{
this->fontSize = __value;
}
/*! \copydoc fontSize
\see see fontSize for details */
inline virtual double getFontSize() const
{
return this->fontSize;
}
/*! \copydoc x
\see see x for details */
inline virtual void setX(double __value)
{
this->x = __value;
}
/*! \copydoc x
\see see x for details */
inline virtual double getX() const
{
return this->x;
}
/*! \copydoc y
\see see y for details */
inline virtual void setY(double __value)
{
this->y = __value;
}
/*! \copydoc y
\see see y for details */
inline virtual double getY() const
{
return this->y;
}
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() override;
protected:
double x,y;
/** \brief color of the graph */
QColor color;
/** \brief base font size of text */
double fontSize;
/** \brief the text to display */
QString fontName;
/** \brief the text to display */
QString text;
/** \brief return a pen, that may be used for drawing */
QPen getPen(JKQTPEnhancedPainter& painter);
};
/*! \brief This JKQTPPlotObject is used to draw a line
\ingroup jkqtplotter_geoplots
\image html plot_geoline.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoLine: public JKQTPGeoBaseLine {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x1 x-coordinate of first point of line
\param y1 y-coordinate of first point of line
\param x2 x-coordinate of second point of line
\param y2 y-coordinate of second point of line
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoLine(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/*! \brief class constructor
\param parent the parent plotter class
\param x1 x-coordinate of first point of line
\param y1 y-coordinate of first point of line
\param x2 x-coordinate of second point of line
\param y2 y-coordinate of second point of line
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoLine(JKQTPlotter* parent, double x1, double y1, double x2, double y2, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc x1
\see see x1 for details */
inline virtual void setX1(double __value)
{
this->x1 = __value;
}
/*! \copydoc x1
\see see x1 for details */
inline virtual double getX1() const
{
return this->x1;
}
/*! \copydoc y1
\see see y1 for details */
inline virtual void setY1(double __value)
{
this->y1 = __value;
}
/*! \copydoc y1
\see see y1 for details */
inline virtual double getY1() const
{
return this->y1;
}
/*! \copydoc x2
\see see x2 for details */
inline virtual void setX2(double __value)
{
this->x2 = __value;
}
/*! \copydoc x2
\see see x2 for details */
inline virtual double getX2() const
{
return this->x2;
}
/*! \copydoc y2
\see see y2 for details */
inline virtual void setY2(double __value)
{
this->y2 = __value;
}
/*! \copydoc y2
\see see y2 for details */
inline virtual double getY2() const
{
return this->y2;
}
protected:
double x1, y1, x2, y2;
};
/*! \brief This JKQTPPlotObject is used to draw an infinite line
\ingroup jkqtplotter_geoplots
an infinite line has a starting point and then goes on in a given direction
until the end of the plotting range.
\image html plot_geoinfiniteline.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoInfiniteLine: public JKQTPGeoBaseLine {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of start point of line
\param y y-coordinate of start point of line
\param dx x-direction of the line
\param dy y-direction of the line
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoInfiniteLine(JKQTBasePlotter* parent, double x, double y, double dx, double dy, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of start point of line
\param y y-coordinate of start point of line
\param dx x-direction of the line
\param dy y-direction of the line
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoInfiniteLine(JKQTPlotter* parent, double x, double y, double dx, double dy, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc x
\see see x for details */
inline virtual void setX(double __value)
{
this->x = __value;
}
/*! \copydoc x
\see see x for details */
inline virtual double getX() const
{
return this->x;
}
/*! \copydoc y
\see see y for details */
inline virtual void setY(double __value)
{
this->y = __value;
}
/*! \copydoc y
\see see y for details */
inline virtual double getY() const
{
return this->y;
}
/*! \copydoc dx
\see see dx for details */
inline virtual void setDx(double __value)
{
this->dx = __value;
}
/*! \copydoc dx
\see see dx for details */
inline virtual double getDx() const
{
return this->dx;
}
/*! \copydoc dy
\see see dy for details */
inline virtual void setDy(double __value)
{
this->dy = __value;
}
/*! \copydoc dy
\see see dy for details */
inline virtual double getDy() const
{
return this->dy;
}
/*! \copydoc two_sided
\see see two_sided for details */
inline virtual void setTwoSided(bool __value)
{
this->two_sided = __value;
}
/*! \copydoc two_sided
\see see two_sided for details */
inline virtual bool getTwoSided() const
{
return this->two_sided;
}
protected:
double x, y, dx, dy;
/** \brief indicates whether the line ends at the given point \f$ (x,y) \f$ (false, default),
* or is infinite in both directions (true) */
bool two_sided;
};
/*! \brief This JKQTPPlotObject is used to draw a poly line
\ingroup jkqtplotter_geoplots
\image html plot_geolines.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoPolyLines: public JKQTPGeoBaseLine {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param points points on the polygon
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoPolyLines(JKQTBasePlotter* parent, const QVector<QPointF>& points, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/*! \brief class constructor
\param parent the parent plotter class
\param points points on the polygon
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoPolyLines(JKQTPlotter* parent, const QVector<QPointF>& points, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/*! \brief class constructor
\param parent the parent plotter class
\param points points on the polygon
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoPolyLines(JKQTBasePlotter* parent, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/*! \brief class constructor
\param parent the parent plotter class
\param points points on the polygon
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoPolyLines(JKQTPlotter* parent, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc points
\see see points for details */
inline virtual void setPoints(const QVector<QPointF> & __value)
{
this->points = __value;
}
/*! \copydoc points
\see see points for details */
inline virtual QVector<QPointF> getPoints() const
{
return this->points;
}
/** \brief append a point to the polygon */
inline void appendPoint(const QPointF& p) {
points.append(p);
}
/** \brief append a point to the polygon */
inline void appendPoint(const double x, const double y) {
points.append(QPointF(x, y));
}
protected:
QVector<QPointF> points;
};
/*! \brief This JKQTPPlotObject is used to draw a rectangle
\ingroup jkqtplotter_geoplots
\image html plot_georectangle.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoRectangle: public JKQTPGeoBaseFilled {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of rectangle
\param y y-coordinate of center of rectangle
\param width width of rectangle
\param height of rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoRectangle(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of rectangle
\param y y-coordinate of center of rectangle
\param width width of rectangle
\param height of rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoRectangle(JKQTPlotter* parent, double x, double y, double width, double height, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of rectangle
\param y y-coordinate of center of rectangle
\param width width of rectangle
\param height of rectangle
\param angle rotation angle of the rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoRectangle(JKQTBasePlotter* parent, double x, double y, double width, double height, double angle, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of rectangle
\param y y-coordinate of center of rectangle
\param width width of rectangle
\param height of rectangle
\param angle rotation angle of the rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoRectangle(JKQTPlotter* parent, double x, double y, double width, double height, double angle, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param bottomleft bottom left corner of rectangle
\param topright top right corner of rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoRectangle(JKQTBasePlotter* parent, QPointF bottomleft, QPointF topright, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param bottomleft bottom left corner of rectangle
\param topright top right corner of rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoRectangle(JKQTPlotter* parent, QPointF bottomleft, QPointF topright, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc x
\see see x for details */
inline virtual void setX(double __value)
{
this->x = __value;
}
/*! \copydoc x
\see see x for details */
inline virtual double getX() const
{
return this->x;
}
/*! \copydoc y
\see see y for details */
inline virtual void setY(double __value)
{
this->y = __value;
}
/*! \copydoc y
\see see y for details */
inline virtual double getY() const
{
return this->y;
}
/*! \copydoc width
\see see width for details */
inline virtual void setWidth(double __value)
{
this->width = __value;
}
/*! \copydoc width
\see see width for details */
inline virtual double getWidth() const
{
return this->width;
}
/*! \copydoc height
\see see height for details */
inline virtual void setHeight(double __value)
{
this->height = __value;
}
/*! \copydoc height
\see see height for details */
inline virtual double getHeight() const
{
return this->height;
}
/*! \copydoc angle
\see see angle for details */
inline virtual void setAngle(double __value)
{
this->angle = __value;
}
/*! \copydoc angle
\see see angle for details */
inline virtual double getAngle() const
{
return this->angle;
}
void setBottomleftrectangle(double x, double y, double width, double height);
protected:
double x,y,width,height;
/** \brief rotation angle of rectangle */
double angle;
/** \brief returns the transformation matrix used for this rectangle */
QMatrix getMatrix();
/** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */
QPolygonF getPolygon();
};
/*! \brief This JKQTPPlotObject is used to draw a polygon
\ingroup jkqtplotter_geoplots
\image html plot_geopolygon.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param points points on the polygon
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor color of the filling
\param fillStyle style of the filling
*/
JKQTPGeoPolygon(JKQTBasePlotter* parent, const QVector<QPointF>& points, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param points points on the polygon
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor color of the filling
\param fillStyle style of the filling
*/
JKQTPGeoPolygon(JKQTPlotter* parent, const QVector<QPointF>& points, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor color of the filling
\param fillStyle style of the filling
*/
JKQTPGeoPolygon(JKQTBasePlotter* parent, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor color of the filling
\param fillStyle style of the filling
*/
JKQTPGeoPolygon(JKQTPlotter* parent, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc points
\see see points for details */
inline virtual void setPoints(const QVector<QPointF> & __value)
{
this->points = __value;
}
/*! \copydoc points
\see see points for details */
inline virtual QVector<QPointF> getPoints() const
{
return this->points;
}
/** \brief append a point to the polygon */
inline void appendPoint(const QPointF& p) {
points.append(p);
}
/** \brief append a point to the polygon */
inline void appendPoint(const double x, const double y) {
points.append(QPointF(x, y));
}
protected:
QVector<QPointF> points;
};
/*! \brief This JKQTPPlotObject is used to draw an ellipse
\ingroup jkqtplotter_geoplots
\image html plot_geoellipse.png
\see <a href="http://www.codeguru.com/cpp/g-m/gdi/article.php/c131">http://www.codeguru.com/cpp/g-m/gdi/article.php/c131</a> and
<a href="http://en.wikipedia.org/wiki/Ellipse#General_parametric_form">http://en.wikipedia.org/wiki/Ellipse#General_parametric_form</a>
*/
class JKQTP_LIB_EXPORT JKQTPGeoEllipse: public JKQTPGeoRectangle {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of ellipse
\param fillStyle filling style of ellipse
*/
JKQTPGeoEllipse(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of ellipse
\param fillStyle filling style of ellipse
*/
JKQTPGeoEllipse(JKQTPlotter* parent, double x, double y, double width, double height, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of rectangle
\param y y-coordinate of center of rectangle
\param width width of rectangle
\param height of rectangle
\param angle rotation angle of the rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoEllipse(JKQTBasePlotter* parent, double x, double y, double width, double height, double angle, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of rectangle
\param y y-coordinate of center of rectangle
\param width width of rectangle
\param height of rectangle
\param angle rotation angle of the rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoEllipse(JKQTPlotter* parent, double x, double y, double width, double height, double angle, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param bottomleft bottom left corner of rectangle
\param topright top right corner of rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoEllipse(JKQTBasePlotter* parent, QPointF bottomleft, QPointF topright, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param bottomleft bottom left corner of rectangle
\param topright top right corner of rectangle
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of rectangle
\param fillStyle filling style of rectangle
*/
JKQTPGeoEllipse(JKQTPlotter* parent, QPointF bottomleft, QPointF topright, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc controlPoints
\see see controlPoints for details */
inline virtual void setControlPoints(const unsigned int & __value)
{
this->controlPoints = __value;
}
/*! \copydoc controlPoints
\see see controlPoints for details */
inline virtual unsigned int getControlPoints() const
{
return this->controlPoints;
}
protected:
/** \brief number of steps/control points to draw the ellipse */
unsigned int controlPoints;
};
/*! \brief This JKQTPPlotObject is used to draw an arc
\ingroup jkqtplotter_geoplots
\image html plot_geoarc.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoArc: public JKQTPGeoBaseLine {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoArc(JKQTBasePlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
*/
JKQTPGeoArc(JKQTPlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc controlPoints
\see see controlPoints for details */
inline virtual void setControlPoints(const unsigned int & __value)
{
this->controlPoints = __value;
}
/*! \copydoc controlPoints
\see see controlPoints for details */
inline virtual unsigned int getControlPoints() const
{
return this->controlPoints;
}
/*! \copydoc angleStart
\see see angleStart for details */
inline virtual void setAngleStart(double __value)
{
this->angleStart = __value;
}
/*! \copydoc angleStart
\see see angleStart for details */
inline virtual double getAngleStart() const
{
return this->angleStart;
}
/*! \copydoc angleStop
\see see angleStop for details */
inline virtual void setAngleStop(double __value)
{
this->angleStop = __value;
}
/*! \copydoc angleStop
\see see angleStop for details */
inline virtual double getAngleStop() const
{
return this->angleStop;
}
/*! \copydoc x
\see see x for details */
inline virtual void setX(double __value)
{
this->x = __value;
}
/*! \copydoc x
\see see x for details */
inline virtual double getX() const
{
return this->x;
}
/*! \copydoc y
\see see y for details */
inline virtual void setY(double __value)
{
this->y = __value;
}
/*! \copydoc y
\see see y for details */
inline virtual double getY() const
{
return this->y;
}
/*! \copydoc width
\see see width for details */
inline virtual void setWidth(double __value)
{
this->width = __value;
}
/*! \copydoc width
\see see width for details */
inline virtual double getWidth() const
{
return this->width;
}
/*! \copydoc height
\see see height for details */
inline virtual void setHeight(double __value)
{
this->height = __value;
}
/*! \copydoc height
\see see height for details */
inline virtual double getHeight() const
{
return this->height;
}
/*! \copydoc angle
\see see angle for details */
inline virtual void setAngle(double __value)
{
this->angle = __value;
}
/*! \copydoc angle
\see see angle for details */
inline virtual double getAngle() const
{
return this->angle;
}
protected:
double x,y,width,height;
/** \brief rotation angle of rectangle */
double angle;
/** \brief if we only draw an arc, this is the starting angle in degrees */
double angleStart;
/** \brief if we only draw an arc, this is the ending angle in degrees */
double angleStop;
/** \brief closing mode for arcs: secand or pie */
double angle_start;
/** \brief if we only draw an arc, this is the ending angle */
double angle_end;
/** \brief closing mode for arcs: secand or pie */
/** \brief returns the transformation matrix used for this rectangle */
QMatrix getMatrix();
/** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */
QPolygonF getPolygon();
/** \brief number of steps/control points to draw the ellipse */
unsigned int controlPoints;
};
/*! \brief This JKQTPPlotObject is used to draw a pie
\ingroup jkqtplotter_geoplots
\image html plot_geopie.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoPie: public JKQTPGeoEllipse {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of ellipse
\param fillStyle filling style of ellipse
*/
JKQTPGeoPie(JKQTBasePlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of ellipse
\param fillStyle filling style of ellipse
*/
JKQTPGeoPie(JKQTPlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
/*! \copydoc angleStart
\see see angleStart for details */
inline virtual void setAngleStart(double __value)
{
this->angleStart = __value;
}
/*! \copydoc angleStart
\see see angleStart for details */
inline virtual double getAngleStart() const
{
return this->angleStart;
}
/*! \copydoc angleStop
\see see angleStop for details */
inline virtual void setAngleStop(double __value)
{
this->angleStop = __value;
}
/*! \copydoc angleStop
\see see angleStop for details */
inline virtual double getAngleStop() const
{
return this->angleStop;
}
protected:
/** \brief if we only draw an arc, this is the starting angle */
double angleStart;
/** \brief if we only draw an arc, this is the ending angle */
double angleStop;
};
/*! \brief This JKQTPPlotObject is used to draw a chord
\ingroup jkqtplotter_geoplots
\image html plot_geochord.png
*/
class JKQTP_LIB_EXPORT JKQTPGeoChord: public JKQTPGeoPie {
Q_OBJECT
public:
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of ellipse
\param fillStyle filling style of ellipse
*/
JKQTPGeoChord(JKQTBasePlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/*! \brief class constructor
\param parent the parent plotter class
\param x x-coordinate of center of ellipse
\param y y-coordinate of center of ellipse
\param width width of ellipse (2 * half axis)
\param height of ellipse (2 * half axis)
\param color color of line
\param lineWidth width of line
\param style line style
\param fillColor filling color of ellipse
\param fillStyle filling style of ellipse
*/
JKQTPGeoChord(JKQTPlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern);
/** \copydoc JKQTPPlotObject::getXMinMax() */
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
/** \copydoc JKQTPPlotObject::getYMinMax() */
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override;
};
#endif // jkqtpgraphsgeometric_H_INCLUDED