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
Drawing & Graphics Tools
Collaboration diagram for Drawing & Graphics Tools:

Classes

class  JKQTPEnhancedPainter
 this class extends the QPainter More...
 
struct  JKQTPlotterDrawingTools
 tool class with static values used by JKQTPlotter/JKQTBasePlotter More...
 
struct  JKQTPSymbolPathsInternnal
 internal datastructure used in JKQTPPlotSymbol() to precalculate certain data only once per runtime More...
 

Typedefs

typedef std::function< void(QPainter &p)> JKQTPCustomGraphSymbolFunctor
 functor used to draw a custom JKQTPGraphSymbols
 

Enumerations

enum  JKQTPGraphSymbols : uint64_t {
  JKQTPNoSymbol =0 ,
  JKQTPDot ,
  JKQTPCross ,
  JKQTPPlus ,
  JKQTPCircle ,
  JKQTPFilledCircle ,
  JKQTPRect ,
  JKQTPFilledRect ,
  JKQTPTriangle ,
  JKQTPFilledTriangle ,
  JKQTPDiamond ,
  JKQTPFilledDiamond ,
  JKQTPstar ,
  JKQTPFilledStar ,
  JKQTPPentagon ,
  JKQTPFilledPentagon ,
  JKQTPAsterisc ,
  JKQTPHourglass ,
  JKQTPFilledHourglass ,
  JKQTPCurvedTriangle ,
  JKQTPFilledCurvedTriangle ,
  JKQTPHexagon ,
  JKQTPFilledHexagon ,
  JKQTPRectCross ,
  JKQTPRectPlus ,
  JKQTPRectTriangle ,
  JKQTPRectDownTriangle ,
  JKQTPRectLeftTriangle ,
  JKQTPRectRightTriangle ,
  JKQTPCircleCross ,
  JKQTPCirclePlus ,
  JKQTPCirclePeace ,
  JKQTPDiamondPlus ,
  JKQTPDiamondCross ,
  JKQTPTripod ,
  JKQTPDownTripod ,
  JKQTPLeftTripod ,
  JKQTPRightTripod ,
  JKQTPAsterisc6 ,
  JKQTPAsterisc8 ,
  JKQTPPeace ,
  JKQTPTarget ,
  JKQTPDownTriangle ,
  JKQTPFilledDownTriangle ,
  JKQTPLeftTriangle ,
  JKQTPFilledLeftTriangle ,
  JKQTPRightTriangle ,
  JKQTPFilledRightTriangle ,
  JKQTPDownCurvedTriangle ,
  JKQTPFilledDownCurvedTriangle ,
  JKQTPLeftCurvedTriangle ,
  JKQTPFilledLeftCurvedTriangle ,
  JKQTPRightCurvedTriangle ,
  JKQTPFilledRightCurvedTriangle ,
  JKQTPOctagon ,
  JKQTPFilledOctagon ,
  JKQTPUpDownTriangle ,
  JKQTPFilledUpDownTriangle ,
  JKQTPHorizontalHourglass ,
  JKQTPFilledHorizontalHourglass ,
  JKQTPSantaClauseHouse ,
  JKQTPFilledSantaClauseHouse ,
  JKQTPMale ,
  JKQTPFemale ,
  JKQTPSymbolCount ,
  JKQTPMaxSymbolID =JKQTPSymbolCount-1 ,
  JKQTPDefaultSymbol =JKQTPCross ,
  JKQTPCharacterSymbol =0x100 ,
  JKQTPFilledCharacterSymbol =JKQTPCharacterSymbol+0xFFFF+0xF ,
  JKQTPFirstCustomSymbol =JKQTPFilledCharacterSymbol+0xFFFF+0xF
}
 symbols that can be used to plot a datapoint for a graph More...
 
enum  JKQTPLineDecoratorStyle {
  JKQTPNoDecorator =0 ,
  JKQTPArrow ,
  JKQTPFilledArrow ,
  JKQTPTriangleDecorator ,
  JKQTPFilledTriangleDecorator ,
  JKQTPTriangleDecoratorAndBar ,
  JKQTPFilledTriangleDecoratorAndBar ,
  JKQTPDoubleArrow ,
  JKQTPFilledDoubleArrow ,
  JKQTPCircleDecorator ,
  JKQTPFilledCircleDecorator ,
  JKQTPRectangleDecorator ,
  JKQTPFilledRectangleDecorator ,
  JKQTPArrowAndBar ,
  JKQTPDoubleArrowAndBar ,
  JKQTPBarDecorator ,
  JKQTPBracketDecorator ,
  JKQTPDiamondDecorator ,
  JKQTPDiamondDecoratorAndBar ,
  JKQTPFilledDiamondDecorator ,
  JKQTPFilledDiamondDecoratorAndBar ,
  JKQTPHalfBarDecorator ,
  JKQTPHarpoonDecorator ,
  JKQTPHarpoonDecoratorAndBar ,
  JKQTPSkewedBarDecorator ,
  JKQTPLineDecoratorCount ,
  JKQTPMaxLineDecoratorID =JKQTPLineDecoratorCount-1 ,
  JKQTPDefaultLineDecorator =JKQTPFilledArrow
}
 symbols that can be used to plot a datapoint for a graph More...
 

Functions

JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPCleanPolygon (const QPolygonF &poly, double distanceThreshold=0.3)
 cleans a polygon by uniting all consecutive points that were closer than distanceThreshold are united
 
QLineF JKQTPClipLine (const QLineF &line, const QRectF &clipRect)
 clips the given line line to the given rectangle clipRect
 
QLineF JKQTPClipLine (const QLineF &line, double xmin, double xmax, double ymin, double ymax)
 clips the given line line to the given rectangle rectangle xmin .. xmax and ymin ... ymax
 
bool JKQTPClipLine (double &x1, double &y1, double &x2, double &y2, double xmin, double xmax, double ymin, double ymax)
 clips the given line (x1 , y1 ) – (x2 , y2 ) to the given rectangle xmin .. xmax and ymin ... ymax
 
JKQTCOMMON_LIB_EXPORT bool JKQTPClipLine (QLineF &line, const QRectF &clippingRect)
 clip a QLineF line to the rectangle defines by clippingRect
 
JKQTCOMMON_LIB_EXPORT QList< QPolygonF > JKQTPClipPolyLine (const QPolygonF &polyline_in, const QRectF &clipRect)
 clips the given poly-line polyline_in to the given rectangle clipRect
 
JKQTCOMMON_LIB_EXPORT QList< QPolygonF > JKQTPClipPolyLines (const QList< QPolygonF > &polylines_in, const QRectF &clipRect)
 clips the given list of poly-lines polylines_in to the given rectangle clipRect
 
template<class TPainter >
void JKQTPDrawTooltip (TPainter &painter, double x, double y, const QRectF &rect)
 draw a tooltip, using the current brush and pen of the provided painter
 
template<int N>
std::array< QPointF, N *2 > JKQTPGetStarCoordinates (double inner_radius=0.5)
 return the consecutive ccordinates of the tips of a N-tipped star on a circle of radius 1. Inner tips are on a irle of radius inner_radius.
 
JKQTCOMMON_LIB_EXPORT QString JKQTPGraphSymbols2NameString (JKQTPGraphSymbols pos)
 converts a JKQTPGraphSymbols variable into a human-readable string
 
JKQTCOMMON_LIB_EXPORT QString JKQTPGraphSymbols2String (JKQTPGraphSymbols pos)
 converts a JKQTPGraphSymbols variable into a identifier string
 
JKQTCOMMON_LIB_EXPORT QString JKQTPLineDecoratorStyle2NameString (JKQTPLineDecoratorStyle pos)
 converts a JKQTPLineDecoratorStyle variable into a human-readable string
 
JKQTCOMMON_LIB_EXPORT QString JKQTPLineDecoratorStyle2String (JKQTPLineDecoratorStyle pos)
 converts a JKQTPLineDecoratorStyle variable into a identifier string
 
JKQTCOMMON_LIB_EXPORT double JKQTPLineDecoratorStyleCalcDecoratorSize (double line_width, double decoratorSizeFactor)
 calculates the tail decorator size from the line width line_width, using decoratorSizeFactor and a non-linear scaling function that levels off towards small line_width and increases sub-linearly for large ones, so the arrow heads to not grow too much
 
template<class TPainter >
void JKQTPPlotDecoratedLine (TPainter &painter, const QLineF &l, JKQTPLineDecoratorStyle style1, double size1, JKQTPLineDecoratorStyle style2, double size2)
 plot a line with the given decorators style1 and a style2 at the start- and end-point repsectively, using the painter's current pen
 
template<class TPainter >
void JKQTPPlotLineDecorator (TPainter &painter, double x, double y, double angle_rad, JKQTPLineDecoratorStyle style, double size, QPointF *line_start=nullptr)
 plot the specified symbol at pixel position x,y. Note that this function only draws the decorator, NOT the line pointing to it!
 
JKQTCOMMON_LIB_EXPORT void JKQTPPlotSymbol (QPaintDevice &paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor, const QFont &symbolFont)
 plot the specified symbol at pixel position x,y, thread-safe
 
template<class TPainter >
void JKQTPPlotSymbol (TPainter &painter, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor, QFont symbolFont)
 plot the specified symbol at pixel position x,y, thread-safe
 
JKQTCOMMON_LIB_EXPORT JKQTPGraphSymbols JKQTPRegisterCustomGraphSymbol (const JKQTPCustomGraphSymbolFunctor &)
 register a JKQTPCustomGraphSymbolFunctor that draws a custom symbol.Returns an ID that allows to access the symbol!, thread-safe
 
JKQTCOMMON_LIB_EXPORT JKQTPGraphSymbols JKQTPRegisterCustomGraphSymbol (JKQTPCustomGraphSymbolFunctor &&)
 register a JKQTPCustomGraphSymbolFunctor that draws a custom symbol.Returns an ID that allows to access the symbol!, thread-safe
 
JKQTCOMMON_LIB_EXPORT void JKQTPReplaceCurrentColor (QColor &col, const QColor &currentColor)
 check whether col equals JKQTPlotterDrawingTools::CurrentColorPlaceholder (or one of its variants) and then replace it by currentColor
 
JKQTCOMMON_LIB_EXPORT void JKQTPReplaceCurrentColor (QGradient &grad, const QColor &currentColor)
 check whether any color in grad equals JKQTPlotterDrawingTools::CurrentColorPlaceholder (or one of its variants) and then replace it by currentColor
 
JKQTCOMMON_LIB_EXPORT QPolygonF jkqtpRotateRect (QRectF r, double angle)
 rotate a rectangle by given angle (rotates all points around the center of the rectangle and returns it as a QPolygonF)
 
JKQTCOMMON_LIB_EXPORT QList< QPolygonF > JKQTPSimplifyPolyLines (const QList< QPolygonF > &lines_in, double maxDeltaXY=1.0)
 tries to reduce the complexity of the given list of poly-lines lines_in, but keeping the appearance as if all lines were drawn
 
JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPSimplifyPolyLines (const QPolygonF &lines_in, double maxDeltaXY=1.0)
 tries to reduce the complexity of the given poly-line lines_in, but keeping the appearance as if all lines were drawn
 
JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSimplyfyLineSegemnts (const QVector< QPointF > &points, double maxConsecutiveAngleDegree=0.2)
 takes a list of points and tries to reduce them. Three points are merged to two, if they form a straight line
 
JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitEllipseIntoPoints (double x, double y, double a, double b, double angle_start=0, double angle_end=360, double alpha=0, int controlPoints=180, QPointF *x_start=nullptr, QPointF *x_end=nullptr)
 represent an ellipse as a series of points on the ellipse
 
JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitEllipseIntoPoints (std::function< QPointF(QPointF)> fTransform, double x, double y, double a, double b, double angle_start=0, double angle_end=360, double alpha=0, QPointF *x_start=nullptr, QPointF *x_end=nullptr, QPointF *x_start_notrafo=nullptr, QPointF *x_end_notrafo=nullptr)
 represent an ellipse as a series of points on the ellipse
 
JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitLineIntoPoints (const QLineF &line, int controlPoints=180)
 represent a line as a series of points on the ellipse
 
JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitLineIntoPoints (const QLineF &line, std::function< QPointF(QPointF)> fTransform)
 represent a line as a series of points on the ellipse
 
JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitPolylineIntoPoints (const QVector< QPointF > &line, std::function< QPointF(QPointF)> fTransform)
 represent a poly-line as a series of points on the ellipse
 
JKQTCOMMON_LIB_EXPORT QVector< QPolygonF > JKQTPUnifyLinesToPolygons (const QVector< QLineF > &lines, double distanceThreshold=0.3, int searchMaxSurroundingElements=10)
 takes a list of QLineF objesct lines and tries to combine as many of them as possible to QPolygonF objects. Note: This method implements an incomplete algorithm with searchMaxSurroundingElements>0, as solving the complete problem is very time-consuming (cubic runtime)
 
JKQTCOMMON_LIB_EXPORT JKQTPGraphSymbols String2JKQTPGraphSymbols (const QString &pos)
 converts a String into a JKQTPGraphSymbols
 
JKQTCOMMON_LIB_EXPORT JKQTPLineDecoratorStyle String2JKQTPLineDecoratorStyle (const QString &pos)
 converts a String into a JKQTPLineDecoratorStyle
 

Variables

static JKQTCOMMON_LIB_EXPORT JKQTPSynchronized< QVector< JKQTPCustomGraphSymbolFunctor > > JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore
 stores all custom JKQTPGraphSymbols registered using JKQTPRegisterCustomGraphSymbol
 

Detailed Description

Specialized drawing functions used by the plotters and LaTeX renderers.

Typedef Documentation

◆ JKQTPCustomGraphSymbolFunctor

typedef std::function<void(QPainter& p)> JKQTPCustomGraphSymbolFunctor

functor used to draw a custom JKQTPGraphSymbols

Draw the symbol with these properties:

  • center at (0,0)
  • width 1, i.e. x=-0.5...0.5
  • height 1, i.e. y=-0.5...0.5
  • you can assume that a proper pen and brush is set with the correct properties
  • scaling to the final size is donw by JKQTPPlotSymbol()
  • drawing is protected by surronding p.save(); and p.restore(); in JKQTPPlotSymbol()

As an example, the following code-snippet:

[](QPainter& p) {
p.drawEllipse(QPointF(-0.2, -0.2), 0.3, 0.3);
p.setBrush(Qt::NoBrush);
p.drawEllipse(QPointF(0.2, -0.2), 0.3, 0.3);
p.drawEllipse(QPointF(0, 0.2), 0.3, 0.3);
};

generates this symbol:

Enumeration Type Documentation

◆ JKQTPGraphSymbols

enum JKQTPGraphSymbols : uint64_t

symbols that can be used to plot a datapoint for a graph

Enumerator
JKQTPNoSymbol 

plots no symbol at all (usefull together with error bars)

JKQTPDot 

a small dot

JKQTPCross 

a X cross

JKQTPPlus 

a + cross

JKQTPCircle 

an unfilled circle

JKQTPFilledCircle 

a filled circle

JKQTPRect 

an unfilled rectangle

JKQTPFilledRect 

a filled rectangle

JKQTPTriangle 

an unfilled triangle (tip at top)

JKQTPFilledTriangle 

a filled triangle (tip at top)

JKQTPDiamond 

an unfilled diamond

JKQTPFilledDiamond 

a filled diamond

JKQTPstar 

an unfilled diamond

JKQTPFilledStar 

a filled diamond

JKQTPPentagon 

an unfilled pentagon

JKQTPFilledPentagon 

a filled pentagon

JKQTPAsterisc 

an asterisc star with 5 arms

JKQTPHourglass 

an hour glass symbol

JKQTPFilledHourglass 

a filled hour glass symbol

JKQTPCurvedTriangle 

a curved triangle

JKQTPFilledCurvedTriangle 

a filled curved triangle

JKQTPHexagon 

an unfilled hexagon

JKQTPFilledHexagon 

a filled hexagon

JKQTPRectCross 

a square symbol with a cross inside

JKQTPRectPlus 

a square symbol with a plus inside

JKQTPRectTriangle 

a square symbol with a triangle inside

JKQTPRectDownTriangle 

a square symbol with a triangle (tip to the bottom) inside

JKQTPRectLeftTriangle 

a square symbol with a triangle (tip to the left) inside

JKQTPRectRightTriangle 

a square symbol with a triangle (tip to the right) inside

JKQTPCircleCross 

a circle symbol with a cross inside

JKQTPCirclePlus 

a circle symbol with a plus inside

JKQTPCirclePeace 

a circled peace symbol

JKQTPDiamondPlus 

a diamond symbol with a plus inside

JKQTPDiamondCross 

a diamond symbol with a cross inside

JKQTPTripod 

a tripod symbol

JKQTPDownTripod 

a tripod symbol, pointing down

JKQTPLeftTripod 

a tripod symbol, pointing to the left

JKQTPRightTripod 

a tripod symbol, pointing to the right

JKQTPAsterisc6 

an asterisc star with 6 arms

JKQTPAsterisc8 

an asterisc star with 8 arms

JKQTPPeace 

a peace symbol

JKQTPTarget 

a target symbol (circle with cross)

JKQTPDownTriangle 

an unfilled triangle (tip at bottom)

JKQTPFilledDownTriangle 

a filled triangle (tip at bottom)

JKQTPLeftTriangle 

an unfilled triangle (tip to the left)

JKQTPFilledLeftTriangle 

a filled triangle (tip to the left)

JKQTPRightTriangle 

an unfilled triangle (tip to the right)

JKQTPFilledRightTriangle 

a filled triangle (tip to the right)

JKQTPDownCurvedTriangle 

a curved triangle, pointing down

JKQTPFilledDownCurvedTriangle 

a filled curved triangle, pointing down

JKQTPLeftCurvedTriangle 

a curved triangle, pointing to the left

JKQTPFilledLeftCurvedTriangle 

a filled curved triangle, pointing to the left

JKQTPRightCurvedTriangle 

a curved triangle, pointing to the right

JKQTPFilledRightCurvedTriangle 

a filled curved triangle, pointing to the right

JKQTPOctagon 

an unfilled octagon

JKQTPFilledOctagon 

a filled octagon

JKQTPUpDownTriangle 

a overlay of an up and a down triangle symbol

JKQTPFilledUpDownTriangle 

a filled version of the overlay of an up and a down triangle

JKQTPHorizontalHourglass 

a horizontal hour glass symbol

JKQTPFilledHorizontalHourglass 

a filled horizontal hour glass symbol

JKQTPSantaClauseHouse 

a small house symbol ("Das is das haus vom Nicolaus")

JKQTPFilledSantaClauseHouse 

a filled small house symbol ("Das is das haus vom Nicolaus")

JKQTPMale 

a male symbol

JKQTPFemale 

a female symbol

JKQTPSymbolCount 

can be used to iterate over all symbols using: for (int i=0; i<static_cast<int>(JKQTPSymbolCount); i++) { JKQTPGraphSymbols s=static_cast<JKQTPGraphSymbols>(i); ... }

JKQTPMaxSymbolID 

points to the last available symbol, can be used to iterate over all symbols: for (int i=0; i<=static_cast<int>(JKQTPMaxSymbolID); i++) { JKQTPGraphSymbols s=static_cast<JKQTPGraphSymbols>(i); ... }

JKQTPDefaultSymbol 

a default symbol used for plotting

JKQTPCharacterSymbol 

draw a font-character as symbol with defined fill-brush (taken from symbol-color), you can use any character from a QFont by supplying JKQTPCharacterSymbol+QChar('').unicode() as JKQTPGraphSymbols

generated by JKQTPCharacterSymbol+QChar('@').unicode()
generated by JKQTPCharacterSymbol+QChar(0x2663).unicode()
JKQTPFilledCharacterSymbol 

draw a font-character as symbol with defined outline-pen and fill-brush, you can use any character from a QFont by supplying JKQTPFilledCharacterSymbol+QChar('').unicode() as JKQTPGraphSymbols

generated by JKQTPFilledCharacterSymbol+QChar('@').unicode()
generated by JKQTPFilledCharacterSymbol+QChar(0x2663).unicode()
JKQTPFirstCustomSymbol 

draw a completely custom symbol, defined by supplying a functor to JKQTPRegisterCustomGraphSymbol()

generated by <code>[](QPainter& p) { p.drawEllipse(QPointF(-0.2, -0.2), 0.3, 0.3); p.setBrush(Qt::NoBrush); p.drawEllipse(QPointF(0.2, -0.2), 0.3, 0.3); p.drawEllipse(QPointF(0, 0.2), 0.3, 0.3); };</code>


◆ JKQTPLineDecoratorStyle

symbols that can be used to plot a datapoint for a graph

Note that all arrows end at the designated line-end (here indicated by dashed grey lines), even circles and rectangle:

See also
JKQTPPlotLineDecorator(), JKQTPPlotDecoratedLine(), JKQTPLineDecoratorStyle, JKQTPLineDecoratorStyleCalcDecoratorSize()
Example (JKQTPlotter): Plotting Arrows and Example (JKQTPlotter): Plotting Geometric Objects for usage examples.
Enumerator
JKQTPNoDecorator 

no decorator, i.e. a simple line-end

JKQTPArrow 

a simple arrow tip, unfilled

JKQTPFilledArrow 

a nice filled arrow tip

JKQTPTriangleDecorator 

a triangular arrow tip

JKQTPFilledTriangleDecorator 

a triangular filled arrow tip

JKQTPTriangleDecoratorAndBar 

a triangular arrow tip, with vertical bar

JKQTPFilledTriangleDecoratorAndBar 

a triangular filled arrow tip, with vertical bar

JKQTPDoubleArrow 

a nice double-arrow tip

JKQTPFilledDoubleArrow 

a nice filled double-arrow tip

JKQTPCircleDecorator 

an open circle tip

JKQTPFilledCircleDecorator 

a filled circle tip

JKQTPRectangleDecorator 

an open rectangle tip

JKQTPFilledRectangleDecorator 

a filled rectangle tip

JKQTPArrowAndBar 

a simple arrow tip, unfilled, with vertical bar

JKQTPDoubleArrowAndBar 

a simple double-arrow tip, unfilled, with vertical bar

JKQTPBarDecorator 

a full vertical bar

JKQTPBracketDecorator 

a vertical bracket decorator

JKQTPDiamondDecorator 

an open diamond tip

JKQTPDiamondDecoratorAndBar 

an open diamond tip

JKQTPFilledDiamondDecorator 

a filled diamond tip

JKQTPFilledDiamondDecoratorAndBar 

a filled diamond tip

JKQTPHalfBarDecorator 

a half vertical bar

JKQTPHarpoonDecorator 

an harpoon arrow

JKQTPHarpoonDecoratorAndBar 

an harpoon arrow, with vertical bar

JKQTPSkewedBarDecorator 

a skewed vertical bar

JKQTPLineDecoratorCount 

can be used to iterate over all symbols using: for (int i=0; i<static_cast<int>(JKQTPLineDecoratorCount); i++) { JKQTPLineDecoratorStyle s=static_cast<JKQTPLineDecoratorStyle>(i); ... }

JKQTPMaxLineDecoratorID 

points to the last available symbol, can be used to iterate over all symbols: for (int i=0; i<=static_cast<int>(JKQTPMaxLineDecoratorID); i++) { JKQTPLineDecoratorStyle s=static_cast<JKQTPLineDecoratorStyle>(i); ... }

JKQTPDefaultLineDecorator 

a default symbol used for plotting

Function Documentation

◆ JKQTPCleanPolygon()

JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPCleanPolygon ( const QPolygonF &  poly,
double  distanceThreshold = 0.3 
)

cleans a polygon by uniting all consecutive points that were closer than distanceThreshold are united

Parameters
polypolygon to clean
distanceThresholdif two end-points are closer together as this value, they are united to a single point
Returns
a cleaned polygon, where all consecutive points that were closer than distanceThreshold are united

◆ JKQTPClipLine() [1/4]

QLineF JKQTPClipLine ( const QLineF &  line,
const QRectF &  clipRect 
)
inline

clips the given line line to the given rectangle clipRect

Parameters
lineline to be clipped
clipRectrectangle to clip to
Returns
the clipped line or a line with 0-length, i.e. QLineF()

This function implements the algorithm descripbed in https://www.researchgate.net/publication/335018076_Another_Simple_but_Faster_Method_for_2D_Line_Clipping

◆ JKQTPClipLine() [2/4]

QLineF JKQTPClipLine ( const QLineF &  line,
double  xmin,
double  xmax,
double  ymin,
double  ymax 
)
inline

clips the given line line to the given rectangle rectangle xmin .. xmax and ymin ... ymax

Returns
the clipped line or a line with 0-length, i.e. QLineF()

This function implements the algorithm descripbed in https://www.researchgate.net/publication/335018076_Another_Simple_but_Faster_Method_for_2D_Line_Clipping

◆ JKQTPClipLine() [3/4]

bool JKQTPClipLine ( double &  x1,
double &  y1,
double &  x2,
double &  y2,
double  xmin,
double  xmax,
double  ymin,
double  ymax 
)
inline

clips the given line (x1 , y1 ) – (x2 , y2 ) to the given rectangle xmin .. xmax and ymin ... ymax

Returns
the clipped line in x1 , y1 , x2 , y2 and true if the line is still to be drawn or false else

This function implements the algorithm descripbed in https://www.researchgate.net/publication/335018076_Another_Simple_but_Faster_Method_for_2D_Line_Clipping i.e. in Pseudocode

// x1 , y1 , x2 , y2 , xmin , ymax , xmax , ymin //
if not ( x1<xmin and x2<xmin ) and not ( x1>xmax and x2>xmax ) then
    if not ( y1<ymin and y2<ymin ) and not ( y1>ymax and y2>ymax ) then
        x[1]= x1
        y[1]= y1
        x[2]= x2
        y[2]= y2
        i =1
        repeat
            if x[i] < xmin then
                x[i] = xmin
                y[i] = ( ( y2-y1 ) / ( x2-x1 ) ) * ( xmin-x1)+y1
            elseif x[i] > xmax then
                x[i] = xmax
                y[i] = ( ( y2-y1 ) / ( x2-x1 ) ) * ( xmax-x1)+y1
            endif
            if y[i] < ymin then
                y[i] = ymin
                x[i] = ( ( x2-x1 ) / ( y2-y1 ) ) * ( ymin-y1)+x1
            elseif y[i] > ymax then
                y[i] = ymax
                x[i] = ( ( x2-x1 ) / ( y2-y1 ) ) * ( ymax-y1)+x1
            endif
            i = i + 1
        until i >2
        if not ( x [1 ] < xmin and x [2 ] < xmin ) and not ( x [1 ] >xmax and x [2 ] >xmax ) then
            drawLine ( x[1] , y[1] , x[2] , y[2] )
        endif
    endif
endif

◆ JKQTPClipLine() [4/4]

JKQTCOMMON_LIB_EXPORT bool JKQTPClipLine ( QLineF &  line,
const QRectF &  clippingRect 
)

clip a QLineF line to the rectangle defines by clippingRect

Parameters
[in,out]lineThe line to clip, if clipping is possible this is modified to the clipped line. If the line is outside clippingRect this is modified to line=QLineF() i.e. a null-line!
clippingRectthe rectangle to clip to
Returns
true, if the line had at least some points within clippingRect, false otherwise. The clipped line (or a null-line) is returned in the by-refrence parameter line
See also
This function uses the Linag-Barsky-Algorithm: https://en.wikipedia.org/wiki/Liang%E2%80%93Barsky_algorithm https://www.skytopia.com/project/articles/compsci/clipping.html

◆ JKQTPClipPolyLine()

JKQTCOMMON_LIB_EXPORT QList< QPolygonF > JKQTPClipPolyLine ( const QPolygonF &  polyline_in,
const QRectF &  clipRect 
)

clips the given poly-line polyline_in to the given rectangle clipRect

Parameters
polyline_inpoly-line to be clipped
clipRectrectangle to clip to
Returns
a list of poly-lines representing the clipped line.

◆ JKQTPClipPolyLines()

JKQTCOMMON_LIB_EXPORT QList< QPolygonF > JKQTPClipPolyLines ( const QList< QPolygonF > &  polylines_in,
const QRectF &  clipRect 
)

clips the given list of poly-lines polylines_in to the given rectangle clipRect

Parameters
polylines_inlist of poly-lines to be clipped
clipRectrectangle to clip to
Returns
a list of poly-lines representing the clipped lines. Note that some lines may be split further so the number of poly-lines in the output may actually be larger than the number of polylines in the input!

◆ JKQTPDrawTooltip()

template<class TPainter >
void JKQTPDrawTooltip ( TPainter &  painter,
double  x,
double  y,
const QRectF &  rect 
)
inline

draw a tooltip, using the current brush and pen of the provided painter

Template Parameters
TPainterType of painter: A class like JKQTPEnhancedPainter or QPainter
Parameters
painterQPainter-like object to use for painting
xx-coordinate of position the tooltip points to
yy-coordinate of position the tooltip points to
rectrectangle of the main tooltip area

◆ JKQTPGetStarCoordinates()

template<int N>
std::array< QPointF, N *2 > JKQTPGetStarCoordinates ( double  inner_radius = 0.5)
inline

return the consecutive ccordinates of the tips of a N-tipped star on a circle of radius 1. Inner tips are on a irle of radius inner_radius.

◆ JKQTPGraphSymbols2NameString()

JKQTCOMMON_LIB_EXPORT QString JKQTPGraphSymbols2NameString ( JKQTPGraphSymbols  pos)

converts a JKQTPGraphSymbols variable into a human-readable string

◆ JKQTPGraphSymbols2String()

JKQTCOMMON_LIB_EXPORT QString JKQTPGraphSymbols2String ( JKQTPGraphSymbols  pos)

converts a JKQTPGraphSymbols variable into a identifier string

◆ JKQTPLineDecoratorStyle2NameString()

JKQTCOMMON_LIB_EXPORT QString JKQTPLineDecoratorStyle2NameString ( JKQTPLineDecoratorStyle  pos)

converts a JKQTPLineDecoratorStyle variable into a human-readable string

◆ JKQTPLineDecoratorStyle2String()

JKQTCOMMON_LIB_EXPORT QString JKQTPLineDecoratorStyle2String ( JKQTPLineDecoratorStyle  pos)

converts a JKQTPLineDecoratorStyle variable into a identifier string

◆ JKQTPLineDecoratorStyleCalcDecoratorSize()

JKQTCOMMON_LIB_EXPORT double JKQTPLineDecoratorStyleCalcDecoratorSize ( double  line_width,
double  decoratorSizeFactor 
)

calculates the tail decorator size from the line width line_width, using decoratorSizeFactor and a non-linear scaling function that levels off towards small line_width and increases sub-linearly for large ones, so the arrow heads to not grow too much

See also
JKQTPPlotLineDecorator(), JKQTPPlotDecoratedLine(), JKQTPLineDecoratorStyle, JKQTPLineDecoratorStyleCalcDecoratorSize()

◆ JKQTPPlotDecoratedLine()

template<class TPainter >
void JKQTPPlotDecoratedLine ( TPainter &  painter,
const QLineF &  l,
JKQTPLineDecoratorStyle  style1,
double  size1,
JKQTPLineDecoratorStyle  style2,
double  size2 
)
inline

plot a line with the given decorators style1 and a style2 at the start- and end-point repsectively, using the painter's current pen

Template Parameters
TPainterType of painter: A class like JKQTPEnhancedPainter or QPainter
Parameters
painterthe QPainter to draw to
lline to draw
style1type of the first decorator to plot, see JKQTPLineDecoratorStyle
size1size of the first decorator
style2type of the second decorator to plot, see JKQTPLineDecoratorStyle
size2size of the second decorator
Note
a decorator fills at most the space x...x+size and y-size/2...y-size/2 (where size is size1 or size2), but may be smaller (e.g. arrows are typically less high than the full size pixels ).
See also
JKQTPPlotLineDecorator(), JKQTPPlotDecoratedLine(), JKQTPLineDecoratorStyle, JKQTPLineDecoratorStyleCalcDecoratorSize()

◆ JKQTPPlotLineDecorator()

template<class TPainter >
void JKQTPPlotLineDecorator ( TPainter &  painter,
double  x,
double  y,
double  angle_rad,
JKQTPLineDecoratorStyle  style,
double  size,
QPointF *  line_start = nullptr 
)
inline

plot the specified symbol at pixel position x,y. Note that this function only draws the decorator, NOT the line pointing to it!

Template Parameters
TPainterType of painter: A class like JKQTPEnhancedPainter or QPainter
Parameters
painterthe QPainter to draw to
xx-coordinate of the decorator tip
yy-coordinate of the decorator tip
angle_radangle of the line pointing to (x,y), given in radians, 0rad points to the right, >0rad is a counter-clockwise rotation, as calculated by atan2() from dx, dy of a line!
styletype of the decorator to plot, see JKQTPLineDecoratorStyle
sizesize of the decorator in pixels, the decorator fills at most the space x...x+size and y-size/2...y-size/2, but may be smaller (e.g. arrows are typically less high than the full size pixels ).
[out]line_startoptional output parameter: when drawing the line let it end here, not necessarily at (x,y)
See also
JKQTPPlotLineDecorator(), JKQTPPlotDecoratedLine(), JKQTPLineDecoratorStyle, JKQTPLineDecoratorStyleCalcDecoratorSize()

◆ JKQTPPlotSymbol() [1/2]

JKQTCOMMON_LIB_EXPORT void JKQTPPlotSymbol ( QPaintDevice &  paintDevice,
double  x,
double  y,
JKQTPGraphSymbols  symbol,
double  size,
double  symbolLineWidth,
QColor  color,
QColor  fillColor,
const QFont &  symbolFont 
)

plot the specified symbol at pixel position x,y, thread-safe

Parameters
paintDevicethe paint device to draw on
xx-coordinate of the symbol center
yy-coordinate of the symbol center
symboltype of the symbol to plot, see JKQTPGraphSymbols
sizesize (width/height) of the symbol around (x , y)
symbolLineWidthwidth of the lines used to draw the symbol
colorcolor of the symbol lines
fillColorcolor of the symbol filling
symbolFontfont used to draw symbols like JKQTPCharacterSymbol+QChar('@').unicode()

◆ JKQTPPlotSymbol() [2/2]

template<class TPainter >
void JKQTPPlotSymbol ( TPainter &  painter,
double  x,
double  y,
JKQTPGraphSymbols  symbol,
double  size,
double  symbolLineWidth,
QColor  color,
QColor  fillColor,
QFont  symbolFont 
)
inline

plot the specified symbol at pixel position x,y, thread-safe

Template Parameters
TPainterType of painter: A class like JKQTPEnhancedPainter or QPainter
Parameters
painterthe QPainter to draw to
xx-coordinate of the symbol center
yy-coordinate of the symbol center
symboltype of the symbol to plot, see JKQTPGraphSymbols
sizesize (width/height) of the symbol around (x , y)
symbolLineWidthwidth of the lines used to draw the symbol
colorcolor of the symbol lines
fillColorcolor of the symbol filling
symbolFontfont used to draw symbols like JKQTPCharacterSymbol+QChar('@').unicode()

◆ JKQTPRegisterCustomGraphSymbol() [1/2]

JKQTCOMMON_LIB_EXPORT JKQTPGraphSymbols JKQTPRegisterCustomGraphSymbol ( const JKQTPCustomGraphSymbolFunctor )

register a JKQTPCustomGraphSymbolFunctor that draws a custom symbol.Returns an ID that allows to access the symbol!, thread-safe

The functor is stored in the global/static store JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore, i.e. these are available throughout the runtime of the program

See also
JKQTPCustomGraphSymbolFunctor for an example

◆ JKQTPRegisterCustomGraphSymbol() [2/2]

register a JKQTPCustomGraphSymbolFunctor that draws a custom symbol.Returns an ID that allows to access the symbol!, thread-safe

The functor is stored in the global/static store JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore, i.e. these are available throughout the runtime of the program

See also
JKQTPCustomGraphSymbolFunctor for an example

◆ JKQTPReplaceCurrentColor() [1/2]

JKQTCOMMON_LIB_EXPORT void JKQTPReplaceCurrentColor ( QColor &  col,
const QColor &  currentColor 
)

◆ JKQTPReplaceCurrentColor() [2/2]

JKQTCOMMON_LIB_EXPORT void JKQTPReplaceCurrentColor ( QGradient &  grad,
const QColor &  currentColor 
)

check whether any color in grad equals JKQTPlotterDrawingTools::CurrentColorPlaceholder (or one of its variants) and then replace it by currentColor

See also
JKQTPlotterDrawingTools::CurrentColorPlaceholder, JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ... , JKQTFillStyleSummmary

◆ jkqtpRotateRect()

JKQTCOMMON_LIB_EXPORT QPolygonF jkqtpRotateRect ( QRectF  r,
double  angle 
)

rotate a rectangle by given angle (rotates all points around the center of the rectangle and returns it as a QPolygonF)

◆ JKQTPSimplifyPolyLines() [1/2]

JKQTCOMMON_LIB_EXPORT QList< QPolygonF > JKQTPSimplifyPolyLines ( const QList< QPolygonF > &  lines_in,
double  maxDeltaXY = 1.0 
)

tries to reduce the complexity of the given list of poly-lines lines_in, but keeping the appearance as if all lines were drawn

Parameters
lines_inlist of poly-lines to be simplified
maxDeltaXYa group has to be either less wide or less high than this, typically equals the linewidth of the poly-line
Returns
a simplified version of lines_in

◆ JKQTPSimplifyPolyLines() [2/2]

JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPSimplifyPolyLines ( const QPolygonF &  lines_in,
double  maxDeltaXY = 1.0 
)

tries to reduce the complexity of the given poly-line lines_in, but keeping the appearance as if all lines were drawn

Parameters
lines_inpoly-line to be simplified
maxDeltaXYa group has to be either less wide or less high than this, typically equals the linewidth of the poly-line
Returns
a simplified version of lines_in

◆ JKQTPSimplyfyLineSegemnts()

JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSimplyfyLineSegemnts ( const QVector< QPointF > &  points,
double  maxConsecutiveAngleDegree = 0.2 
)

takes a list of points and tries to reduce them. Three points are merged to two, if they form a straight line

Returns
a cleaned QVector<QPointF>
Parameters
pointsinput poly-line
maxConsecutiveAngleDegreeis two consecutive line-segments differ by an angle smaller than this, they can be merged
Note
this implements an incomplete algorithm

◆ JKQTPSplitEllipseIntoPoints() [1/2]

JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitEllipseIntoPoints ( double  x,
double  y,
double  a,
double  b,
double  angle_start = 0,
double  angle_end = 360,
double  alpha = 0,
int  controlPoints = 180,
QPointF *  x_start = nullptr,
QPointF *  x_end = nullptr 
)

represent an ellipse as a series of points on the ellipse

Returns
a QVector<QPointF> with points that may be used for drawing
Parameters
xcenter of ellipse (x-coordinate)
ycenter of ellipse (y-coordinate)
ahalf axis in x-direction
bhalf axis in y-direction
angle_startstarting angle of ellipse section
angle_endending angle of ellipse section
alpharotation angle of ellipse
controlPointsthe number of points to use for drawing
[out]x_startfirst point of ellipse
[out]x_endlast point of ellipse
Note
all angles are given in degrees [0..360]

◆ JKQTPSplitEllipseIntoPoints() [2/2]

JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitEllipseIntoPoints ( std::function< QPointF(QPointF)>  fTransform,
double  x,
double  y,
double  a,
double  b,
double  angle_start = 0,
double  angle_end = 360,
double  alpha = 0,
QPointF *  x_start = nullptr,
QPointF *  x_end = nullptr,
QPointF *  x_start_notrafo = nullptr,
QPointF *  x_end_notrafo = nullptr 
)

represent an ellipse as a series of points on the ellipse

Returns
a QVector<QPointF> with points that may be used for drawing
Parameters
fTransforma function that transforms a point in graph coordinate space into pixel coordinate space
xcenter of ellipse (x-coordinate)
ycenter of ellipse (y-coordinate)
ahalf axis in x-direction
bhalf axis in y-direction
angle_startstarting angle of ellipse section
angle_endending angle of ellipse section
alpharotation angle of ellipse
[out]x_startfirst point of ellipse, with fTransform applied
[out]x_endlast point of ellipse, with fTransform applied
[out]x_start_notrafofirst point of ellipse, without fTransform applied
[out]x_end_notrafolast point of ellipse, without fTransform applied
Note
all angles are given in degrees [0..360]

◆ JKQTPSplitLineIntoPoints() [1/2]

JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitLineIntoPoints ( const QLineF &  line,
int  controlPoints = 180 
)

represent a line as a series of points on the ellipse

Returns
a QVector<QPointF> with points that may be used for drawing
Parameters
linethe line to draw
controlPointsthe number of points to use for drawing

◆ JKQTPSplitLineIntoPoints() [2/2]

JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitLineIntoPoints ( const QLineF &  line,
std::function< QPointF(QPointF)>  fTransform 
)

represent a line as a series of points on the ellipse

Returns
a QVector<QPointF> with points that may be used for drawing
Parameters
linethe line to draw in graph coordinate space
fTransforma function that transforms a point in graph coordinate space into pixel coordinate space

◆ JKQTPSplitPolylineIntoPoints()

JKQTCOMMON_LIB_EXPORT QVector< QPointF > JKQTPSplitPolylineIntoPoints ( const QVector< QPointF > &  line,
std::function< QPointF(QPointF)>  fTransform 
)

represent a poly-line as a series of points on the ellipse

Returns
a QVector<QPointF> with points that may be used for drawing
Parameters
linethe poly-line to draw in graph coordinate space
fTransforma function that transforms a point in graph coordinate space into pixel coordinate space

◆ JKQTPUnifyLinesToPolygons()

JKQTCOMMON_LIB_EXPORT QVector< QPolygonF > JKQTPUnifyLinesToPolygons ( const QVector< QLineF > &  lines,
double  distanceThreshold = 0.3,
int  searchMaxSurroundingElements = 10 
)

takes a list of QLineF objesct lines and tries to combine as many of them as possible to QPolygonF objects. Note: This method implements an incomplete algorithm with searchMaxSurroundingElements>0, as solving the complete problem is very time-consuming (cubic runtime)

Parameters
linesline segments to unify
distanceThresholdif two end-points are closer together as this value, they are united to a single point
searchMaxSurroundingElementslimits the search for a connected polygon to at most this number of neighbors
Returns
a vector of QPolygonF objects, which contain longer line-segments formed from lines

◆ String2JKQTPGraphSymbols()

JKQTCOMMON_LIB_EXPORT JKQTPGraphSymbols String2JKQTPGraphSymbols ( const QString &  pos)

converts a String into a JKQTPGraphSymbols

◆ String2JKQTPLineDecoratorStyle()

JKQTCOMMON_LIB_EXPORT JKQTPLineDecoratorStyle String2JKQTPLineDecoratorStyle ( const QString &  pos)

converts a String into a JKQTPLineDecoratorStyle

Variable Documentation

◆ JKQTPCustomGraphSymbolStore

JKQTCOMMON_LIB_EXPORT JKQTPSynchronized<QVector<JKQTPCustomGraphSymbolFunctor> > JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore
static

stores all custom JKQTPGraphSymbols registered using JKQTPRegisterCustomGraphSymbol