- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...) - new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
@ -21,7 +21,10 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
|
||||
<li> fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/37">#37: CMake installs things into $PREFIX/doc/*.txt </a>, thanks to <a href="https://github.com/certik">user:certik</a></li>
|
||||
<li> fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/45">#45: Build error on mac jkqtfastplotter.cpp:342:28: Variable has incomplete type 'QPainterPath'</a>, thanks to <a href="https://github.com/abdedixit">user:abdedixit</a></li>
|
||||
<li>removed the usage of some deprecated functions and objects (e.g. QMatrix)</li>
|
||||
<li> new: added geometric plot objects JKQTPGeoArrow to draw arrows (aka lines with added line-end decorators, also extended JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines to draw line-end decorator (aka arrows)</li>
|
||||
<li>improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)</li>
|
||||
<li>improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)</li>
|
||||
<li>new: added geometric plot objects JKQTPGeoArrow to draw arrows (aka lines with added line-end decorators, also extended JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines to draw line-end decorator (aka arrows)</li>
|
||||
<li>new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves</li>
|
||||
</ul>
|
||||
|
||||
\subsection page_whatsnew_TRUNK_DOWNLOAD trunk: Download
|
||||
|
BIN
doc/images/JKQTPPlotObject_DrawAsGraphicElement.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
doc/images/JKQTPPlotObject_DrawAsMathematicalCurve.png
Normal file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 60 KiB |
BIN
doc/images/plot_geoellipse_rotated.png
Normal file
After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 68 KiB |
@ -29,6 +29,7 @@ add_subdirectory(errorbarstyles)
|
||||
add_subdirectory(filledgraphs)
|
||||
add_subdirectory(functionplot)
|
||||
add_subdirectory(geometric)
|
||||
add_subdirectory(geo_simple)
|
||||
add_subdirectory(imageplot)
|
||||
add_subdirectory(imageplot_userpal)
|
||||
add_subdirectory(imageplot_modifier)
|
||||
|
@ -1,73 +1,73 @@
|
||||
# Example (JKQTPlotter): Plotting Geometric Objects {#JKQTPlotterGeometricGraphs}
|
||||
|
||||
This project shows the capabilities of JKQTPlotter to also draw geometric elements, like circles, ellipses, rectangles etc.
|
||||
This project shows the capabilities of JKQTPlotter `plot` to also draw geometric elements, like circles, ellipses, rectangles etc.
|
||||
|
||||
The source code of the main application can be found in [`geometric.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/geometric/geometric.cpp). First a plot is generated and the axis aspect ratio is set to 1, so an accurate plot is generated. Then several geometric graphs are added to the plot. Here are some examples, you can find more more examples in the source code of the example:
|
||||
The source code of the main application can be found in [`geometric.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/geometric/geometric.cpp). First a plot is generated and the axis aspect ratio is set to 1, so an accurate plot is generated. Then several geometric graphs are added to the plot-> Here are some examples, you can find more more examples in the source code of the example:
|
||||
|
||||
```.cpp
|
||||
// a text element
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,0.6, "$x_{1/2}=\\frac{\\sqrt{b^2-4ac}}{2a}$", 10, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,0.6, "$x_{1/2}=\\frac{\\sqrt{b^2-4ac}}{2a}$", 10, QColor("red")));
|
||||
|
||||
|
||||
// a single symbol
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.1,0.6, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.1,0.6, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// a line
|
||||
plot.addGraph(new JKQTPGeoLine(&plot, 1, 0.05, 1.9, 0.9, QColor("red"), 2));
|
||||
plot->addGraph(new JKQTPGeoLine(plot, 1, 0.05, 1.9, 0.9, QColor("red"), 2));
|
||||
|
||||
// an arrow
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.4, 2.5, 0.4, 2.65, QColor("green"), JKQTPArrowAndStop, JKQTPFilledArrow, 1));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.4, 2.5, 0.4, 2.65, QColor("green"), JKQTPArrowAndStop, JKQTPFilledArrow, 1));
|
||||
|
||||
|
||||
// a one-sided infinite line with slope dy/dx=0.25/0.2
|
||||
JKQTPGeoInfiniteLine* infLine=new JKQTPGeoInfiniteLine(&plot, 1.7, 0.2, 0.2, 0.25, QColor("green"), 1.5, Qt::PenStyle::DashLine);
|
||||
JKQTPGeoInfiniteLine* infLine=new JKQTPGeoInfiniteLine(plot, 1.7, 0.2, 0.2, 0.25, QColor("green"), 1.5, Qt::PenStyle::DashLine);
|
||||
infLine->setTwoSided(false);
|
||||
infLine->setAlpha(0.5);
|
||||
plot.addGraph(infLine);
|
||||
plot->addGraph(infLine);
|
||||
|
||||
|
||||
// a polyline
|
||||
QVector<QPointF> p;
|
||||
p<<QPointF(2.1, 0.0)<<QPointF(2.2, 0.92)<<QPointF(2.6, 0.3)<<QPointF(2.9, 0.9);
|
||||
plot.addGraph(new JKQTPGeoPolyLines(&plot, p, QColor("darkgreen"), 4, Qt::PenStyle::DashDotLine));
|
||||
plot->addGraph(new JKQTPGeoPolyLines(plot, p, QColor("darkgreen"), 4, Qt::PenStyle::DashDotLine));
|
||||
|
||||
|
||||
// rectangle:
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, QPointF(0.4,1.3), QPointF(0.9,1.6), QColor("blue"), 1, Qt::SolidLine, rfill));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, QPointF(0.4,1.3), QPointF(0.9,1.6), QColor("blue"), 1, Qt::SolidLine, rfill));
|
||||
// a rotated rectangle (rotated by 35 degrees):
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 0.5,1.5,0.8,0.5, 35, QColor("darkblue"), 2, Qt::DashLine));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 0.5,1.5,0.8,0.5, 35, QColor("darkblue"), 2, Qt::DashLine));
|
||||
|
||||
|
||||
// ellipse:
|
||||
plot.addGraph(new JKQTPGeoEllipse(&plot, QPointF(0.4,1.3), QPointF(0.9,1.6), QColor("blue"), 1, Qt::SolidLine, rfill));
|
||||
plot->addGraph(new JKQTPGeoEllipse(plot, QPointF(0.4,1.3), QPointF(0.9,1.6), QColor("blue"), 1, Qt::SolidLine, rfill));
|
||||
// a rotated ellipse (rotated by 35 degrees):
|
||||
plot.addGraph(new JKQTPGeoEllipse(&plot, 0.5,1.5,0.8,0.5, 35, QColor("darkblue"), 2, Qt::DashLine));
|
||||
plot->addGraph(new JKQTPGeoEllipse(plot, 0.5,1.5,0.8,0.5, 35, QColor("darkblue"), 2, Qt::DashLine));
|
||||
|
||||
|
||||
|
||||
// a polygon
|
||||
JKQTPGeoPolygon* polygongraph=new JKQTPGeoPolygon(&plot, QColor("red"), 2, Qt::PenStyle::DashLine, QColor("salmon"));
|
||||
JKQTPGeoPolygon* polygongraph=new JKQTPGeoPolygon(plot, QColor("red"), 2, Qt::PenStyle::DashLine, QColor("salmon"));
|
||||
polygongraph->appendPoint(2.1, 0.5);
|
||||
polygongraph->appendPoint(2.9, 0.9);
|
||||
polygongraph->appendPoint(2.2, 0.8);
|
||||
polygongraph->appendPoint(2.8, 0.25);
|
||||
polygongraph->appendPoint(2.6, 0.6);
|
||||
polygongraph->setAlpha(0.75);
|
||||
plot.addGraph(polygongraph);
|
||||
plot->addGraph(polygongraph);
|
||||
|
||||
|
||||
|
||||
// an arc from an ellipse from -10 degrees to 117 degrees, centered at 2.5,1.5 and full axes of 0.5 and 0.5
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.5,0.5, -10, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.5,0.5, -10, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine));
|
||||
|
||||
|
||||
// a pie centered at 2.5,2.5 with ellipse axes 0.9 and 0.9 and from angle 0 degrees to 90 degrees
|
||||
plot.addGraph(new JKQTPGeoPie(&plot,2.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
plot->addGraph(new JKQTPGeoPie(plot,2.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
|
||||
|
||||
// a chord centered at 2.5,2.5 with ellipse axes 0.9 and 0.9 and from angle 0 degrees to 90 degrees
|
||||
plot.addGraph(new JKQTPGeoChord(&plot,2.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
plot->addGraph(new JKQTPGeoChord(plot,2.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
|
||||
```
|
||||
|
||||
@ -76,4 +76,59 @@ The result of the example combines all these elements and looks like this:
|
||||
![geometric](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/geometric.png)
|
||||
|
||||
|
||||
The example also adds some control-widgets that allow to change the properties of the plot, especially whether the aspect ratio is maintained and whether the axes have logarithmic scaling. This is achieved by code like this:
|
||||
```.cpp
|
||||
// 1. create a Widget with a plotter and some control-elements
|
||||
QWidget widMain;
|
||||
QGridLayout* layMain=new QGridLayout;
|
||||
widMain.setLayout(layMain);
|
||||
JKQTPlotter* plot=new JKQTPlotter(&widMain);
|
||||
layMain->addWidget(plot, 1,0,1,5);
|
||||
layMain->setRowStretch(1,1);
|
||||
QCheckBox* chk;
|
||||
|
||||
// when checkbox is toggled: aspect-ration is maintained, or not
|
||||
layMain->addWidget(chk=new QCheckBox(QObject::tr("maintain aspect ratio"), &widMain), 0, 0);
|
||||
chk->setChecked(true);
|
||||
QObject::connect(chk, &QCheckBox::toggled, [plot](bool checked) {
|
||||
plot->getPlotter()->setMaintainAspectRatio(checked);
|
||||
plot->getPlotter()->setMaintainAxisAspectRatio(checked);
|
||||
});
|
||||
|
||||
// toggling the checkbox switches between linear and log x-axis
|
||||
layMain->addWidget(chk=new QCheckBox(QObject::tr("x: log-scale"), &widMain), 0, 1);
|
||||
chk->setChecked(false);
|
||||
QObject::connect(chk, &QCheckBox::toggled, plot->getPlotter()->getXAxis(), &JKQTPHorizontalAxis::setLogAxis);
|
||||
// toggling the checkbox switches between linear and log y-axis
|
||||
layMain->addWidget(chk=new QCheckBox(QObject::tr("y: log-scale"), &widMain), 0, 2);
|
||||
chk->setChecked(false);
|
||||
QObject::connect(chk, &QCheckBox::toggled, plot->getPlotter()->getYAxis(), &JKQTPVerticalAxis::setLogAxis);
|
||||
|
||||
QComboBox* cmb;
|
||||
// a combobox to select the DrawMode of all graph elements
|
||||
layMain->addWidget(new QLabel(QObject::tr("DrawMode: "), &widMain), 0, 3);
|
||||
layMain->addWidget(cmb=new QComboBox(&widMain), 0, 4);
|
||||
cmb->addItem(QObject::tr("DrawAsGraphicElement"));
|
||||
cmb->addItem(QObject::tr("DrawAsMathematicalCurve"));
|
||||
cmb->setCurrentIndex(0);
|
||||
QObject::connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [plot](int index) {
|
||||
for (size_t i=0; i<plot->getPlotter()->getGraphCount(); i++) {
|
||||
JKQTPPlotObject* obj=dynamic_cast<JKQTPPlotObject*>(plot->getPlotter()->getGraph(i));
|
||||
if (obj) {
|
||||
obj->setDrawMode((index==0)?JKQTPPlotObject::DrawAsGraphicElement:JKQTPPlotObject::DrawAsMathematicalCurve);
|
||||
}
|
||||
}
|
||||
plot->redrawPlot();
|
||||
});
|
||||
```
|
||||
|
||||
Now you can play with these controls and see how the different shapes get distorted when these properties change, in dependence of whether the DrawMode is `JKQTPPlotObject::DrawAsMathematicalCurve` or `JKQTPPlotObject::DrawAsGraphicElement`.
|
||||
|
||||
Here is an example on log-log axes and DrawMode = `JKQTPPlotObject::DrawAsGraphicElement`:
|
||||
|
||||
![geometric](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/geometric_loglog_DrawAsGraphicElement.png)
|
||||
|
||||
Here is an example on log-log axes and DrawMode = `JKQTPPlotObject::DrawAsMathematicalCurve`: Observe how straight lines are bent to the appropriate curve!
|
||||
|
||||
![geometric](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/geometric_loglog_DrawAsMathematicalCurve.png)
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
*
|
||||
* \ref JKQTPlotterGeometricGraphs
|
||||
*/
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
@ -13,168 +14,210 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// 1. create a plotter window
|
||||
JKQTPlotter plot;
|
||||
// 1. create a Widget with a plotter and some control-elements
|
||||
QWidget widMain;
|
||||
QGridLayout* layMain=new QGridLayout;
|
||||
widMain.setLayout(layMain);
|
||||
JKQTPlotter* plot=new JKQTPlotter(&widMain);
|
||||
layMain->addWidget(plot, 1,0,1,5);
|
||||
layMain->setRowStretch(1,1);
|
||||
QCheckBox* chk;
|
||||
// when checkbox is toggled: aspect-ration is maintained, or not
|
||||
layMain->addWidget(chk=new QCheckBox(QObject::tr("maintain aspect ratio"), &widMain), 0, 0);
|
||||
chk->setChecked(true);
|
||||
QObject::connect(chk, &QCheckBox::toggled, [plot](bool checked) {
|
||||
plot->getPlotter()->setMaintainAspectRatio(checked);
|
||||
plot->getPlotter()->setMaintainAxisAspectRatio(checked);
|
||||
});
|
||||
// toggling the checkbox switches between linear and log x-axis
|
||||
layMain->addWidget(chk=new QCheckBox(QObject::tr("x: log-scale"), &widMain), 0, 1);
|
||||
chk->setChecked(false);
|
||||
QObject::connect(chk, &QCheckBox::toggled, plot->getPlotter()->getXAxis(), &JKQTPHorizontalAxis::setLogAxis);
|
||||
// toggling the checkbox switches between linear and log y-axis
|
||||
layMain->addWidget(chk=new QCheckBox(QObject::tr("y: log-scale"), &widMain), 0, 2);
|
||||
chk->setChecked(false);
|
||||
QObject::connect(chk, &QCheckBox::toggled, plot->getPlotter()->getYAxis(), &JKQTPVerticalAxis::setLogAxis);
|
||||
QComboBox* cmb;
|
||||
// a combobox to select the DrawMode of all graph elements
|
||||
layMain->addWidget(new QLabel(QObject::tr("DrawMode: "), &widMain), 0, 3);
|
||||
layMain->addWidget(cmb=new QComboBox(&widMain), 0, 4);
|
||||
cmb->addItem(QObject::tr("DrawAsGraphicElement"));
|
||||
cmb->addItem(QObject::tr("DrawAsMathematicalCurve"));
|
||||
cmb->setCurrentIndex(0);
|
||||
QObject::connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [plot](int index) {
|
||||
for (size_t i=0; i<plot->getPlotter()->getGraphCount(); i++) {
|
||||
JKQTPPlotObject* obj=dynamic_cast<JKQTPPlotObject*>(plot->getPlotter()->getGraph(i));
|
||||
if (obj) {
|
||||
obj->setDrawMode((index==0)?JKQTPPlotObject::DrawAsGraphicElement:JKQTPPlotObject::DrawAsMathematicalCurve);
|
||||
}
|
||||
}
|
||||
plot->redrawPlot();
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 2. format graph:
|
||||
// 2.1 set the graph scales manually
|
||||
plot.setXY(0,3.05,0,3.05);
|
||||
plot->setXY(0,3.05,0,3.05);
|
||||
// 2.2 set the asxpect ratio to 1
|
||||
plot.getPlotter()->setMaintainAspectRatio(true);
|
||||
plot.getPlotter()->setAspectRatio(1);
|
||||
plot.getPlotter()->setMaintainAxisAspectRatio(true);
|
||||
plot.getPlotter()->setAxisAspectRatio(1);
|
||||
plot->getPlotter()->setMaintainAspectRatio(true);
|
||||
plot->getPlotter()->setAspectRatio(1);
|
||||
plot->getPlotter()->setMaintainAxisAspectRatio(true);
|
||||
plot->getPlotter()->setAxisAspectRatio(1);
|
||||
// 2.3 set the asxpect ratio to 1
|
||||
plot.getXAxis()->setDrawGrid(false);
|
||||
plot.getYAxis()->setDrawGrid(false);
|
||||
plot->getXAxis()->setDrawGrid(false);
|
||||
plot->getYAxis()->setDrawGrid(false);
|
||||
// 2.4 show 9 minor ticks between two major ticks
|
||||
plot->getXAxis()->setMinorTicks(9);
|
||||
plot->getYAxis()->setMinorTicks(9);
|
||||
|
||||
|
||||
// 3. add some geometric plots
|
||||
// 3.1 some text elements, also with formatting by LaTeX expressions
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,0.95, "\\textbf{Text:}", 14, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,0.1, "A text object in 10pt", 10, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.1,0.1, JKQTPCircle, 5, QColor("grey")));
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,0.3, "A text object in 12pt", 12, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.1,0.3, JKQTPCircle, 5, QColor("grey")));
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,0.6, "$x_{1/2}=\\frac{\\sqrt{b^2-4ac}}{2a}$", 10, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.1,0.6, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,0.95, "\\textbf{Text:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,0.1, "A text object in 10pt", 10, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.1,0.1, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,0.3, "A text object in 12pt", 12, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.1,0.3, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,0.6, "$x_{1/2}=\\frac{\\sqrt{b^2-4ac}}{2a}$", 10, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.1,0.6, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// 3.2 some lines elements (single lines)
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 1.1,0.95, "\\textbf{Lines:}", 14, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoLine(&plot, 1, 0.05, 1.9, 0.9, QColor("red"), 2));
|
||||
plot.addGraph(new JKQTPGeoLine(&plot, 1, 0.1, 1.9, 0.8, QColor("blue"), 1, Qt::PenStyle::DashLine));
|
||||
JKQTPGeoInfiniteLine* infLine=new JKQTPGeoInfiniteLine(&plot, 1.7, 0.2, 0.2, 0.25, QColor("green"), 1.5, Qt::PenStyle::DashLine);
|
||||
plot->addGraph(new JKQTPGeoText(plot, 1.1,0.95, "\\textbf{Lines:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoLine(plot, 1, 0.05, 1.9, 0.9, QColor("red"), 2));
|
||||
plot->addGraph(new JKQTPGeoLine(plot, 1, 0.1, 1.9, 0.8, QColor("blue"), 1, Qt::PenStyle::DashLine));
|
||||
JKQTPGeoInfiniteLine* infLine=new JKQTPGeoInfiniteLine(plot, 1.7, 0.2, 0.2, 0.25, QColor("green"), 1.5, Qt::PenStyle::DashLine);
|
||||
infLine->setTwoSided(false);
|
||||
infLine->setAlpha(0.5);
|
||||
plot.addGraph(infLine);
|
||||
infLine=new JKQTPGeoInfiniteLine(&plot, 1.7, 0.2, 0.2, -0.15, QColor("blue"), 1.5, Qt::PenStyle::SolidLine);
|
||||
plot->addGraph(infLine);
|
||||
infLine=new JKQTPGeoInfiniteLine(plot, 1.7, 0.2, 0.2, -0.15, QColor("blue"), 1.5, Qt::PenStyle::SolidLine);
|
||||
infLine->setTwoSided(true);
|
||||
infLine->setAlpha(0.5);
|
||||
plot.addGraph(infLine);
|
||||
plot->addGraph(infLine);
|
||||
|
||||
// 3.3 some arrows
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,2.95, "\\textbf{Arrows:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,2.95, "\\textbf{Arrows:}", 14, QColor("red")));
|
||||
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.3, 2.1, 0.1, 2.9, QColor("green"), JKQTPTriangleDecoratorAndBar, JKQTPDiamondDecoratorAndBar, 1));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.2, 2.1, 0.2, 2.9, QColor("blue"), JKQTPNoDecorator, JKQTPFilledTriangleDecoratorAndBar, 2));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.1, 2.1, 0.3, 2.9, QColor("orange"), JKQTPDoubleArrowAndBar, JKQTPNoDecorator, 3));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.3, 2.1, 0.1, 2.9, QColor("green"), JKQTPTriangleDecoratorAndBar, JKQTPDiamondDecoratorAndBar, 1));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.2, 2.1, 0.2, 2.9, QColor("blue"), JKQTPNoDecorator, JKQTPFilledTriangleDecoratorAndBar, 2));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.1, 2.1, 0.3, 2.9, QColor("orange"), JKQTPDoubleArrowAndBar, JKQTPNoDecorator, 3));
|
||||
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.6, 2.1, 0.4, 2.9, QColor("green"), JKQTPTriangleDecorator, JKQTPTriangleDecorator, 0.5));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.5, 2.1, 0.5, 2.9, QColor("blue"), JKQTPNoDecorator, JKQTPFilledArrow, 2));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.4, 2.1, 0.6, 2.9, QColor("orange"), JKQTPFilledArrow, JKQTPNoDecorator, 1));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.6, 2.1, 0.4, 2.9, QColor("green"), JKQTPTriangleDecorator, JKQTPTriangleDecorator, 0.5));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.5, 2.1, 0.5, 2.9, QColor("blue"), JKQTPNoDecorator, JKQTPFilledArrow, 2));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.4, 2.1, 0.6, 2.9, QColor("orange"), JKQTPFilledArrow, JKQTPNoDecorator, 1));
|
||||
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.7, 2.1, 0.7, 2.5, QColor("green"), JKQTPArrowAndBar, JKQTPFilledArrow, 0.5));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.8, 2.1, 0.8, 2.5, QColor("orange"), JKQTPArrowAndBar, JKQTPFilledArrow, 1));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.9, 2.1, 0.9, 2.5, QColor("orange"), JKQTPArrowAndBar, JKQTPFilledArrow, 2));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.7, 2.1, 0.7, 2.5, QColor("green"), JKQTPArrowAndBar, JKQTPFilledArrow, 0.5));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.8, 2.1, 0.8, 2.5, QColor("orange"), JKQTPArrowAndBar, JKQTPFilledArrow, 1));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.9, 2.1, 0.9, 2.5, QColor("orange"), JKQTPArrowAndBar, JKQTPFilledArrow, 2));
|
||||
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.7, 2.7, 0.7, 2.9, QColor("green"), JKQTPTriangleDecoratorAndBar, JKQTPFilledCircleDecorator, 0.5));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.8, 2.7, 0.8, 2.9, QColor("orange"), JKQTPTriangleDecoratorAndBar, JKQTPFilledCircleDecorator, 1));
|
||||
plot.addGraph(new JKQTPGeoArrow(&plot, 0.9, 2.7, 0.9, 2.9, QColor("orange"), JKQTPTriangleDecoratorAndBar, JKQTPFilledCircleDecorator, 2));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.7, 2.7, 0.7, 2.9, QColor("green"), JKQTPTriangleDecoratorAndBar, JKQTPFilledCircleDecorator, 0.5));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.8, 2.7, 0.8, 2.9, QColor("orange"), JKQTPTriangleDecoratorAndBar, JKQTPFilledCircleDecorator, 1));
|
||||
plot->addGraph(new JKQTPGeoArrow(plot, 0.9, 2.7, 0.9, 2.9, QColor("orange"), JKQTPTriangleDecoratorAndBar, JKQTPFilledCircleDecorator, 2));
|
||||
|
||||
|
||||
|
||||
// 3.4 some rectangles (you give the center and width/height of the rectangle in the contructor)
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 0.1,1.95, "\\textbf{Rectangles:}", 14, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 0.5,1.5,0.8,0.8, QColor("blue"), 1, Qt::SolidLine, QColor("lightblue")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 0.1,1.95, "\\textbf{Rectangles:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 0.5,1.5,0.8,0.8, QColor("blue"), 1, Qt::SolidLine, QColor("lightblue")));
|
||||
QColor rfill("lightblue"); rfill.setAlphaF(0.5);
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, QPointF(0.4,1.3), QPointF(0.9,1.6), QColor("blue"), 1, Qt::SolidLine, rfill));
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 0.5,1.5,0.8,0.5, 35, QColor("darkblue"), 2, Qt::DashLine));
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 0.5,1.5,0.6,0.6, -7, QColor("orange"), 2, Qt::DotLine, QColor("salmon"), Qt::FDiagPattern));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.5,1.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.4,1.3, JKQTPCircle, 5, QColor("grey")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 0.9,1.6, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, QPointF(0.4,1.3), QPointF(0.9,1.6), QColor("blue"), 1, Qt::SolidLine, rfill));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 0.5,1.5,0.8,0.5, 35, QColor("darkblue"), 2, Qt::DashLine));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 0.5,1.5,0.6,0.6, -7, QColor("orange"), 2, Qt::DotLine, QColor("salmon"), Qt::FDiagPattern));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.5,1.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.4,1.3, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 0.9,1.6, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// 3.5 some circles and elllipses
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 1.1,1.95, "\\textbf{Circles/Ellipses:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 1.1,1.95, "\\textbf{Circles/Ellipses:}", 14, QColor("red")));
|
||||
QColor col=QColor("blue"); col.setAlphaF(0.2);
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 1.5,1.5,0.8,0.8, col, 0.5, Qt::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 1.5,1.5,0.8,0.8, col, 0.5, Qt::SolidLine));
|
||||
col.setAlphaF(1);
|
||||
plot.addGraph(new JKQTPGeoEllipse(&plot, 1.5,1.5,0.8,0.8, col, 1, Qt::SolidLine, QColor("lightblue")));
|
||||
plot->addGraph(new JKQTPGeoEllipse(plot, 1.5,1.5,0.8,0.8, col, 1, Qt::SolidLine, QColor("lightblue")));
|
||||
col=QColor("blue"); col.setAlphaF(0.2);
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, QPointF(1.4,1.3), QPointF(1.9,1.6),col, 0.5, Qt::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, QPointF(1.4,1.3), QPointF(1.9,1.6),col, 0.5, Qt::SolidLine));
|
||||
col.setAlphaF(1);
|
||||
plot.addGraph(new JKQTPGeoEllipse(&plot, QPointF(1.4,1.3), QPointF(1.9,1.6), col, 1, Qt::SolidLine, rfill));
|
||||
plot->addGraph(new JKQTPGeoEllipse(plot, QPointF(1.4,1.3), QPointF(1.9,1.6), col, 1, Qt::SolidLine, rfill));
|
||||
col=QColor("darkblue"); col.setAlphaF(0.2);
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 1.5,1.5,0.8,0.5, 35, col, 0.5, Qt::DashLine));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 1.5,1.5,0.8,0.5, 35, col, 0.5, Qt::DashLine));
|
||||
col.setAlphaF(1);
|
||||
plot.addGraph(new JKQTPGeoEllipse(&plot, 1.5,1.5,0.8,0.5, 35, col, 2, Qt::DashLine));
|
||||
plot->addGraph(new JKQTPGeoEllipse(plot, 1.5,1.5,0.8,0.5, 35, col, 2, Qt::DashLine));
|
||||
col=QColor("orange"); col.setAlphaF(0.2);
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 1.5,1.5,0.6,0.6, -7, col, 0.5, Qt::DotLine));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 1.5,1.5,0.6,0.6, -7, col, 0.5, Qt::DotLine));
|
||||
col.setAlphaF(1);
|
||||
plot.addGraph(new JKQTPGeoEllipse(&plot, 1.5,1.5,0.6,0.6, -7, col, 2, Qt::DotLine, QColor("salmon"), Qt::FDiagPattern));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 1.5,1.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 1.4,1.3, JKQTPCircle, 5, QColor("grey")));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 1.9,1.6, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoEllipse(plot, 1.5,1.5,0.6,0.6, -7, col, 2, Qt::DotLine, QColor("salmon"), Qt::FDiagPattern));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 1.5,1.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 1.4,1.3, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 1.9,1.6, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// 3.6 some polygon elements
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 2.1,0.95, "\\textbf{PolyLines/Polygons:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 2.1,0.95, "\\textbf{PolyLines/Polygons:}", 14, QColor("red")));
|
||||
QVector<QPointF> polygon;
|
||||
polygon<<QPointF(2, 0.1)<<QPointF(2.3, 0.9)<<QPointF(2.6, 0.3)<<QPointF(2, 0.8);
|
||||
JKQTPGeoPolygon* polygraph=new JKQTPGeoPolygon(&plot, polygon, QColor("blue"), 2, Qt::PenStyle::DashLine, QColor("lightblue"));
|
||||
JKQTPGeoPolygon* polygraph=new JKQTPGeoPolygon(plot, polygon, QColor("blue"), 2, Qt::PenStyle::DashLine, QColor("lightblue"));
|
||||
polygraph->setAlpha(0.75);
|
||||
plot.addGraph(polygraph);
|
||||
polygraph=new JKQTPGeoPolygon(&plot, QColor("red"), 2, Qt::PenStyle::DashLine, QColor("salmon"));
|
||||
plot->addGraph(polygraph);
|
||||
polygraph=new JKQTPGeoPolygon(plot, QColor("red"), 2, Qt::PenStyle::DashLine, QColor("salmon"));
|
||||
polygraph->appendPoint(2.1, 0.5);
|
||||
polygraph->appendPoint(2.9, 0.9);
|
||||
polygraph->appendPoint(2.2, 0.8);
|
||||
polygraph->appendPoint(2.8, 0.25);
|
||||
polygraph->appendPoint(2.6, 0.6);
|
||||
polygraph->setAlpha(0.75);
|
||||
plot.addGraph(polygraph);
|
||||
plot->addGraph(polygraph);
|
||||
|
||||
|
||||
// 3.7 a poly-line element
|
||||
QVector<QPointF> p;
|
||||
p<<QPointF(2.1, 0.0)<<QPointF(2.2, 0.92)<<QPointF(2.6, 0.3)<<QPointF(2.9, 0.9);
|
||||
plot.addGraph(new JKQTPGeoPolyLines(&plot, p, QColor("darkgreen"), 4, Qt::PenStyle::DashDotLine));
|
||||
plot->addGraph(new JKQTPGeoPolyLines(plot, p, QColor("darkgreen"), 4, Qt::PenStyle::DashDotLine));
|
||||
|
||||
|
||||
// 3.8 some arcs
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 2.1,1.95, "\\textbf{Arcs:}", 14, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 2.5,1.5,0.9,0.9, QColor("lightgrey"), 0.5, Qt::SolidLine));
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine));
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.8,0.8, 90,180 , QColor("red"), 4, Qt::PenStyle::SolidLine));
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.7,0.7, 180,270 , QColor("darkblue"), 4, Qt::PenStyle::SolidLine));
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.6,0.6, 270,360 , QColor("maroon"), 4, Qt::PenStyle::DashDotLine));
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.5,0.5, -10, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine));
|
||||
plot.addGraph(new JKQTPGeoArc(&plot,2.5,1.5,0.4,0.4, 85, 347 , QColor("darkgreen"), 4, Qt::PenStyle::SolidLine));
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 2.5,1.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 2.1,1.95, "\\textbf{Arcs:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 2.5,1.5,0.9,0.9, QColor("lightgrey"), 0.5, Qt::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.8,0.8, 90,180 , QColor("red"), 4, Qt::PenStyle::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.7,0.7, 180,270 , QColor("darkblue"), 4, Qt::PenStyle::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.6,0.6, 270,360 , QColor("maroon"), 4, Qt::PenStyle::DashDotLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.5,0.5, -10, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine));
|
||||
plot->addGraph(new JKQTPGeoArc(plot,2.5,1.5,0.4,0.4, 85, 347 , QColor("darkgreen"), 4, Qt::PenStyle::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 2.5,1.5, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// 3.9 some pies
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 2.1,2.95, "\\textbf{Pies:}", 14, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 2.5,2.5,0.9,0.9, QColor("lightgrey"), 0.5, Qt::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 2.1,2.95, "\\textbf{Pies:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 2.5,2.5,0.9,0.9, QColor("lightgrey"), 0.5, Qt::SolidLine));
|
||||
JKQTPGeoPie* pie;
|
||||
plot.addGraph(pie=new JKQTPGeoPie(&plot,2.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
plot.addGraph(pie=new JKQTPGeoPie(&plot,2.5,2.5,0.7,0.7, 180,270 , QColor("darkblue"), 4, Qt::PenStyle::SolidLine,QColor("blue")));
|
||||
plot->addGraph(pie=new JKQTPGeoPie(plot,2.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
plot->addGraph(pie=new JKQTPGeoPie(plot,2.5,2.5,0.7,0.7, 180,270 , QColor("darkblue"), 4, Qt::PenStyle::SolidLine,QColor("blue")));
|
||||
pie->setAlpha(0.5);
|
||||
plot.addGraph(pie=new JKQTPGeoPie(&plot,2.5,2.5,0.5,0.3, -25, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine,QColor("red")));
|
||||
plot->addGraph(pie=new JKQTPGeoPie(plot,2.5,2.5,0.5,0.3, -25, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine,QColor("red")));
|
||||
pie->setAlpha(0.5);
|
||||
plot.addGraph(pie=new JKQTPGeoPie(&plot,2.5,2.5,0.25,0.8, 85, 347 , QColor("darkgreen"), 4, Qt::PenStyle::SolidLine,QColor("green")));
|
||||
plot->addGraph(pie=new JKQTPGeoPie(plot,2.5,2.5,0.25,0.8, 85, 347 , QColor("darkgreen"), 4, Qt::PenStyle::SolidLine,QColor("green")));
|
||||
pie->setAlpha(0.5);
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 2.5,2.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 2.5,2.5, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// 3.10 some chords
|
||||
plot.addGraph(new JKQTPGeoText(&plot, 1.1,2.95, "\\textbf{Chords:}", 14, QColor("red")));
|
||||
plot.addGraph(new JKQTPGeoRectangle(&plot, 1.5,2.5,0.9,0.9, QColor("lightgrey"), 0.5, Qt::SolidLine));
|
||||
plot->addGraph(new JKQTPGeoText(plot, 1.1,2.95, "\\textbf{Chords:}", 14, QColor("red")));
|
||||
plot->addGraph(new JKQTPGeoRectangle(plot, 1.5,2.5,0.9,0.9, QColor("lightgrey"), 0.5, Qt::SolidLine));
|
||||
JKQTPGeoChord* chord;
|
||||
plot.addGraph(chord=new JKQTPGeoChord(&plot,1.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
plot.addGraph(chord=new JKQTPGeoChord(&plot,1.5,2.5,0.7,0.7, 180,270 , QColor("darkblue"), 4, Qt::PenStyle::SolidLine,QColor("blue")));
|
||||
plot->addGraph(chord=new JKQTPGeoChord(plot,1.5,2.5,0.9,0.9, 0, 90 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
plot->addGraph(chord=new JKQTPGeoChord(plot,1.5,2.5,0.7,0.7, 180,270 , QColor("darkblue"), 4, Qt::PenStyle::SolidLine,QColor("blue")));
|
||||
chord->setAlpha(0.5);
|
||||
plot.addGraph(chord=new JKQTPGeoChord(&plot,1.5,2.5,0.5,0.3, -25, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine,QColor("red")));
|
||||
plot->addGraph(chord=new JKQTPGeoChord(plot,1.5,2.5,0.5,0.3, -25, 117 , QColor("orange"), 4, Qt::PenStyle::DashLine,QColor("red")));
|
||||
chord->setAlpha(0.5);
|
||||
plot.addGraph(chord=new JKQTPGeoChord(&plot,1.5,2.5,0.25,0.8, 85, 347 , QColor("darkgreen"), 4, Qt::PenStyle::SolidLine,QColor("green")));
|
||||
plot->addGraph(chord=new JKQTPGeoChord(plot,1.5,2.5,0.25,0.8, 85, 347 , QColor("darkgreen"), 4, Qt::PenStyle::SolidLine,QColor("green")));
|
||||
chord->setAlpha(0.5);
|
||||
plot.addGraph(new JKQTPGeoSymbol(&plot, 1.5,2.5, JKQTPCircle, 5, QColor("grey")));
|
||||
plot->addGraph(new JKQTPGeoSymbol(plot, 1.5,2.5, JKQTPCircle, 5, QColor("grey")));
|
||||
|
||||
|
||||
// 4. show plotter and make it a decent size
|
||||
plot.show();
|
||||
plot.resize(800,800);
|
||||
widMain.show();
|
||||
widMain.resize(1100,800);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ set(SOURCES
|
||||
jkqtplinalgtools.cpp
|
||||
jkqtpcodestructuring.cpp
|
||||
jkqtpbasicimagetools.cpp
|
||||
jkqtpgeometrytools.cpp
|
||||
jkqtpdrawingtools.cpp
|
||||
jkqtpenhancedpainter.cpp
|
||||
jkqtphighrestimer.cpp
|
||||
@ -51,6 +52,7 @@ set(HEADERS
|
||||
jkqtplinalgtools.h
|
||||
jkqtpcodestructuring.h
|
||||
jkqtpbasicimagetools.h
|
||||
jkqtpgeometrytools.h
|
||||
jkqtpdrawingtools.h
|
||||
jkqtpenhancedpainter.h
|
||||
jkqtphighrestimer.h
|
||||
|
@ -241,165 +241,6 @@ JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
||||
|
||||
|
||||
|
||||
|
||||
QPolygonF jkqtpRotateRect(QRectF r, double angle) {
|
||||
QPolygonF p;
|
||||
QTransform m;
|
||||
m.rotate(angle);
|
||||
p.append(m.map(r.bottomLeft()));
|
||||
p.append(m.map(r.bottomRight()));
|
||||
p.append(m.map(r.topRight()));
|
||||
p.append(m.map(r.topLeft()));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
QVector<QPointF> JKQTPDrawEllipse(double x, double y, double a, double b, double angle_start, double angle_end, double alpha, int controlPoints, QPointF* x_start, QPointF* x_end) {
|
||||
QVector<QPointF> result;
|
||||
double start=angle_start*JKQTPSTATISTICS_PI/180.0;
|
||||
double stop=angle_end*JKQTPSTATISTICS_PI/180.0;
|
||||
double step=(stop-start)/static_cast<double>(controlPoints);
|
||||
while (fabs(stop-start)/step<10) step=step/2.0;
|
||||
double sina=sin(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
double cosa=cos(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
QPointF xp(x+a*cos(start)*cosa-b*sin(start)*sina, y+a*cos(start)*sina+b*sin(start)*cosa);
|
||||
result.append(xp);
|
||||
if (x_start) *x_start = xp;
|
||||
double t=start+step;
|
||||
for (int i=1; i<controlPoints; i++) {
|
||||
double cost=cos(t);
|
||||
double sint=sin(t);
|
||||
xp=QPointF( x+a*cost*cosa-b*sint*sina, y+a*cost*sina+b*sint*cosa);
|
||||
result.append(xp);
|
||||
//std::cout<<"t="<<t/JKQTPSTATISTICS_PI*180.0<<": sin(al)="<<sina<<" cos(al)="<<cosa<<" sin(t)="<<sint<<" cos(t)="<<cost<<" a="<<a<<" b="<<b<<": ("<<x+a*cost*cosa-b*sint*sina<<", "<<y+a*cost*sina+b*sint*cosa<<") = ("<<xp.x()<<", "<<xp.y()<<") \n";
|
||||
t=t+step;
|
||||
}
|
||||
if (x_end) *x_end=xp;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<QPolygonF> JKQTPUnifyLinesToPolygons(const QVector<QLineF> &lines, double distanceThreshold, int searchMaxSurroundingElements)
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPUnifyLinesToPolygons(%1, %2, %3)").arg(lines.size()).arg(distanceThreshold).arg(searchMaxSurroundingElements));
|
||||
#endif
|
||||
QList<QPolygonF> res;
|
||||
res.reserve(lines.size());
|
||||
|
||||
// first simply convert all lines to polygons
|
||||
for (const QLineF& l: lines) {
|
||||
QPolygonF p;
|
||||
p<<l.p1()<<l.p2();
|
||||
res<<p;
|
||||
}
|
||||
//return res.toVector();
|
||||
// clean the resulting polygon
|
||||
for (QPolygonF& p: res) {
|
||||
p=JKQTPCleanPolygon(p, distanceThreshold);
|
||||
}
|
||||
|
||||
int maxIterations=100;
|
||||
int iter=0;
|
||||
bool found=true;
|
||||
//qDebug()<<" iter "<<-1<<" -> polygons start "<<res.size();
|
||||
while (found && iter<maxIterations) {
|
||||
found=false;
|
||||
int i=0;
|
||||
while (i<res.size()-1) {
|
||||
int j=i+1;
|
||||
while (j<res.size() && j<i+searchMaxSurroundingElements) {
|
||||
if (jkqtp_distance(res[i].first(),res[j].first())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=1; k<res[j].size(); k++) {
|
||||
res[i].prepend(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else if (jkqtp_distance(res[i].first(),res[j].last())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=res[j].size()-2; k>=0; k--) {
|
||||
res[i].prepend(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else if (jkqtp_distance(res[i].last(),res[j].first())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=1; k<res[j].size(); k++) {
|
||||
res[i].append(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else if (jkqtp_distance(res[i].last(),res[j].last())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=res[j].size()-2; k>=0; k--) {
|
||||
res[i].append(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
res[i]=JKQTPCleanPolygon(res[i], distanceThreshold);
|
||||
i++;
|
||||
}
|
||||
//qDebug()<<" iter "<<iter<<" -> polygons left "<<res.size();
|
||||
iter++;
|
||||
}
|
||||
|
||||
return res.toVector();
|
||||
}
|
||||
|
||||
QPolygonF JKQTPCleanPolygon(const QPolygonF &poly, double distanceThreshold)
|
||||
{
|
||||
if (poly.size()<=2) return poly;
|
||||
QPolygonF p;
|
||||
QPointF p0=poly[0];
|
||||
p<<p0;
|
||||
QVector<QPointF> inbetween;
|
||||
int i=1;
|
||||
while (i<poly.size()) {
|
||||
if ((jkqtp_distance(poly[i], p0)<=distanceThreshold)) {
|
||||
inbetween<<poly[i];
|
||||
} else {
|
||||
QPointF pmean(0,0);
|
||||
if (inbetween.size()>0) {
|
||||
for (const QPointF& pi: inbetween) {
|
||||
pmean=QPointF(pmean.x()+pi.x()/static_cast<double>(inbetween.size()), pmean.y()+pi.y()/static_cast<double>(inbetween.size()));
|
||||
}
|
||||
} else {
|
||||
pmean=poly[i];
|
||||
}
|
||||
p<<pmean;
|
||||
p0=pmean;
|
||||
inbetween.clear();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// maybe we have something left to add
|
||||
QPointF pmean(0,0);
|
||||
if (inbetween.size()>0) {
|
||||
for (const QPointF& pi: inbetween) {
|
||||
pmean=QPointF(pmean.x()+pi.x()/static_cast<double>(inbetween.size()), pmean.y()+pi.y()/static_cast<double>(inbetween.size()));
|
||||
}
|
||||
} else {
|
||||
pmean=p0;
|
||||
}
|
||||
|
||||
if (jkqtp_distance(pmean, poly.last())>distanceThreshold) {
|
||||
p<<pmean<<poly.last();
|
||||
} else {
|
||||
if (p.last()!=poly.last()) p<<poly.last();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void JKQTPPlotSymbol(QPaintDevice &paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) {
|
||||
JKQTPEnhancedPainter p(&paintDevice);
|
||||
JKQTPPlotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor);
|
||||
@ -508,3 +349,4 @@ double JKQTPLineDecoratorStyleCalcDecoratorSize(double line_width, double decora
|
||||
if (line_width<=1.0) return decoratorSizeFactor*line_width;
|
||||
return decoratorSizeFactor*pow(line_width, 0.7);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,9 @@
|
||||
#include <QColor>
|
||||
#include <QVector>
|
||||
#include <vector>
|
||||
#include <forward_list>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <QDebug>
|
||||
#include "jkqtcommon/jkqtpmathtools.h"
|
||||
#include "jkqtcommon/jkqtpcodestructuring.h"
|
||||
@ -226,13 +228,7 @@ template <class TPainter>
|
||||
inline void JKQTPPlotLineDecorator(TPainter& painter, double x, double y, double angle_rad, JKQTPLineDecoratorStyle style, double size, QPointF* line_start=nullptr);
|
||||
|
||||
/** \brief calculates the tail decorator size from the line width \a line_width, using decoratorSizeFactor and a non-linear scaling function that levels off towards small \a line_width and increases sub-linearly for large ones, so the arrow heads to not grow too much */
|
||||
JKQTCOMMON_LIB_EXPORT double JKQTPLineDecoratorStyleCalcDecoratorSize(double line_width, double decoratorSizeFactor)
|
||||
;
|
||||
|
||||
/** \brief rotate a rectangle by given angle (rotates all points around the center of the rectangle and returns it as a QPolygonF)
|
||||
* \ingroup jkqtptools_drawing
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QPolygonF jkqtpRotateRect(QRectF r, double angle);
|
||||
JKQTCOMMON_LIB_EXPORT double JKQTPLineDecoratorStyleCalcDecoratorSize(double line_width, double decoratorSizeFactor);
|
||||
|
||||
/*! \brief plot the specified symbol at pixel position x,y
|
||||
\ingroup jkqtptools_drawing
|
||||
@ -265,25 +261,6 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
|
||||
JKQTCOMMON_LIB_EXPORT void JKQTPPlotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
|
||||
/*! \brief draw an ellipse without setting pen or brush, or saving the painter!
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param x center of ellipse (x-coordinate)
|
||||
\param y center of ellipse (y-coordinate)
|
||||
\param a half axis in x-direction
|
||||
\param b half axis in y-direction
|
||||
\param angle_start starting angle of ellipse section
|
||||
\param angle_end ending angle of ellipse section
|
||||
\param alpha rotation angle of ellipse
|
||||
\param controlPoints the number of points to use for drawing
|
||||
\param[out] x_start first point of ellipse
|
||||
\param[out] x_end last point of ellipse
|
||||
|
||||
\note all angles are given in degrees [0..360]
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPointF> JKQTPDrawEllipse(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);
|
||||
|
||||
/*! \brief draw a tooltip, using the current brush and pen of the provided painter
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
@ -299,29 +276,6 @@ template <class TPainter>
|
||||
inline void JKQTPDrawTooltip(TPainter& painter, double x, double y, const QRectF& rect);
|
||||
|
||||
|
||||
/** \brief cleans a polygon by uniting all consecutive points that were closer than distanceThreshold are united
|
||||
* \ingroup jkqtptools_drawing
|
||||
*
|
||||
* \param poly polygon to clean
|
||||
* \param distanceThreshold if two end-points are closer together as this value, they are united to a single point
|
||||
* \return a cleaned polygon, where all consecutive points that were closer than distanceThreshold are united
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPCleanPolygon(const QPolygonF& poly, double distanceThreshold=0.3);
|
||||
|
||||
/** \brief takes a list of QLineF objesct \a lines and tries to combine as many of them as possible to QPolygonF objects.
|
||||
* <b>Note: This method implements an incomplete algorithm with \a searchMaxSurroundingElements>0, as solving
|
||||
* the complete problem is very time-consuming (cubic runtime)</b>
|
||||
* \ingroup jkqtptools_drawing
|
||||
*
|
||||
* \param lines line segments to unify
|
||||
* \param distanceThreshold if two end-points are closer together as this value, they are united to a single point
|
||||
* \param searchMaxSurroundingElements limits the search for a connected polygon to at most this number of neighbors
|
||||
* \return a vector of QPolygonF objects, which contain longer line-segments formed from \a lines
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPolygonF> JKQTPUnifyLinesToPolygons(const QVector<QLineF>& lines, double distanceThreshold=0.3, int searchMaxSurroundingElements=10);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
399
lib/jkqtcommon/jkqtpgeometrytools.cpp
Normal file
@ -0,0 +1,399 @@
|
||||
/*
|
||||
Copyright (c) 2008-2020 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 "jkqtcommon/jkqtpgeometrytools.h"
|
||||
#include <QDebug>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
QPolygonF jkqtpRotateRect(QRectF r, double angle) {
|
||||
QPolygonF p;
|
||||
QTransform m;
|
||||
m.rotate(angle);
|
||||
p.append(m.map(r.bottomLeft()));
|
||||
p.append(m.map(r.bottomRight()));
|
||||
p.append(m.map(r.topRight()));
|
||||
p.append(m.map(r.topLeft()));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVector<QPointF> JKQTPSplitEllipseIntoPoints(double x, double y, double a, double b, double angle_start, double angle_end, double alpha, int controlPoints, QPointF* x_start, QPointF* x_end) {
|
||||
QVector<QPointF> result;
|
||||
const double start=angle_start*JKQTPSTATISTICS_PI/180.0;
|
||||
const double stop=angle_end*JKQTPSTATISTICS_PI/180.0;
|
||||
double step=(stop-start)/static_cast<double>(controlPoints);
|
||||
while (fabs(stop-start)/step<10) step=step/2.0;
|
||||
const double sina=sin(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
const double cosa=cos(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
QPointF xp(x+a*cos(start)*cosa-b*sin(start)*sina, y+a*cos(start)*sina+b*sin(start)*cosa);
|
||||
result.append(xp);
|
||||
if (x_start) *x_start = xp;
|
||||
double t=start+step;
|
||||
for (int i=1; i<controlPoints; i++) {
|
||||
double cost=cos(t);
|
||||
double sint=sin(t);
|
||||
xp=QPointF( x+a*cost*cosa-b*sint*sina, y+a*cost*sina+b*sint*cosa);
|
||||
result.append(xp);
|
||||
//std::cout<<"t="<<t/JKQTPSTATISTICS_PI*180.0<<": sin(al)="<<sina<<" cos(al)="<<cosa<<" sin(t)="<<sint<<" cos(t)="<<cost<<" a="<<a<<" b="<<b<<": ("<<x+a*cost*cosa-b*sint*sina<<", "<<y+a*cost*sina+b*sint*cosa<<") = ("<<xp.x()<<", "<<xp.y()<<") \n";
|
||||
t=t+step;
|
||||
}
|
||||
if (x_end) *x_end=xp;
|
||||
return result;
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPSplitEllipseIntoPoints(std::function<QPointF (QPointF)> fTransform, double x, double y, double a, double b, double angle_start, double angle_end, double alpha, QPointF *x_start, QPointF *x_end)
|
||||
{
|
||||
const double sina=sin(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
const double cosa=cos(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
|
||||
std::function<double(double)> fx = [&](double t) ->double {
|
||||
return fTransform(QPointF(x+a*cos(t)*cosa-b*sin(t)*sina, y+a*cos(t)*sina+b*sin(t)*cosa)).x();
|
||||
};
|
||||
std::function<double(double)> fy = [&](double t) ->double {
|
||||
return fTransform(QPointF(x+a*cos(t)*cosa-b*sin(t)*sina, y+a*cos(t)*sina+b*sin(t)*cosa)).y();
|
||||
};
|
||||
JKQTPAdaptiveFunctionGraphEvaluator eval(fx, fy);
|
||||
|
||||
const QVector<QPointF> points=eval.evaluate(angle_start*JKQTPSTATISTICS_PI/180.0, angle_end*JKQTPSTATISTICS_PI/180.0);
|
||||
if (points.size()>0) {
|
||||
if (x_start) *x_start=points.first();
|
||||
if (x_end) *x_end=points.last();
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<QPolygonF> JKQTPUnifyLinesToPolygons(const QVector<QLineF> &lines, double distanceThreshold, int searchMaxSurroundingElements)
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPUnifyLinesToPolygons(%1, %2, %3)").arg(lines.size()).arg(distanceThreshold).arg(searchMaxSurroundingElements));
|
||||
#endif
|
||||
QList<QPolygonF> res;
|
||||
res.reserve(lines.size());
|
||||
|
||||
// first simply convert all lines to polygons
|
||||
for (const QLineF& l: lines) {
|
||||
QPolygonF p;
|
||||
p<<l.p1()<<l.p2();
|
||||
res<<p;
|
||||
}
|
||||
//return res.toVector();
|
||||
// clean the resulting polygon
|
||||
for (QPolygonF& p: res) {
|
||||
p=JKQTPCleanPolygon(p, distanceThreshold);
|
||||
}
|
||||
|
||||
int maxIterations=100;
|
||||
int iter=0;
|
||||
bool found=true;
|
||||
//qDebug()<<" iter "<<-1<<" -> polygons start "<<res.size();
|
||||
while (found && iter<maxIterations) {
|
||||
found=false;
|
||||
int i=0;
|
||||
while (i<res.size()-1) {
|
||||
int j=i+1;
|
||||
while (j<res.size() && j<i+searchMaxSurroundingElements) {
|
||||
if (jkqtp_distance(res[i].first(),res[j].first())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=1; k<res[j].size(); k++) {
|
||||
res[i].prepend(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else if (jkqtp_distance(res[i].first(),res[j].last())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=res[j].size()-2; k>=0; k--) {
|
||||
res[i].prepend(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else if (jkqtp_distance(res[i].last(),res[j].first())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=1; k<res[j].size(); k++) {
|
||||
res[i].append(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else if (jkqtp_distance(res[i].last(),res[j].last())<=distanceThreshold) {
|
||||
found=true;
|
||||
for (int k=res[j].size()-2; k>=0; k--) {
|
||||
res[i].append(res[j].at(k));
|
||||
}
|
||||
res.removeAt(j);
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
res[i]=JKQTPCleanPolygon(res[i], distanceThreshold);
|
||||
i++;
|
||||
}
|
||||
//qDebug()<<" iter "<<iter<<" -> polygons left "<<res.size();
|
||||
iter++;
|
||||
}
|
||||
|
||||
return res.toVector();
|
||||
}
|
||||
|
||||
QPolygonF JKQTPCleanPolygon(const QPolygonF &poly, double distanceThreshold)
|
||||
{
|
||||
if (poly.size()<=2) return poly;
|
||||
QPolygonF p;
|
||||
QPointF p0=poly[0];
|
||||
p<<p0;
|
||||
QVector<QPointF> inbetween;
|
||||
int i=1;
|
||||
while (i<poly.size()) {
|
||||
if ((jkqtp_distance(poly[i], p0)<=distanceThreshold)) {
|
||||
inbetween<<poly[i];
|
||||
} else {
|
||||
QPointF pmean(0,0);
|
||||
if (inbetween.size()>0) {
|
||||
for (const QPointF& pi: inbetween) {
|
||||
pmean=QPointF(pmean.x()+pi.x()/static_cast<double>(inbetween.size()), pmean.y()+pi.y()/static_cast<double>(inbetween.size()));
|
||||
}
|
||||
} else {
|
||||
pmean=poly[i];
|
||||
}
|
||||
p<<pmean;
|
||||
p0=pmean;
|
||||
inbetween.clear();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// maybe we have something left to add
|
||||
QPointF pmean(0,0);
|
||||
if (inbetween.size()>0) {
|
||||
for (const QPointF& pi: inbetween) {
|
||||
pmean=QPointF(pmean.x()+pi.x()/static_cast<double>(inbetween.size()), pmean.y()+pi.y()/static_cast<double>(inbetween.size()));
|
||||
}
|
||||
} else {
|
||||
pmean=p0;
|
||||
}
|
||||
|
||||
if (jkqtp_distance(pmean, poly.last())>distanceThreshold) {
|
||||
p<<pmean<<poly.last();
|
||||
} else {
|
||||
if (p.last()!=poly.last()) p<<poly.last();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
QVector<QPointF> JKQTPSplitLineIntoPoints(const QLineF &line, int controlPoints)
|
||||
{
|
||||
QVector<QPointF> result;
|
||||
result.reserve(controlPoints);
|
||||
result.push_back(line.p1());
|
||||
for (int i=1; i<controlPoints; i++) {
|
||||
result.push_back(line.p1()+static_cast<double>(i)/static_cast<double>(controlPoints)*(line.p2()-line.p1()));
|
||||
}
|
||||
result.push_back(line.p2());
|
||||
return result;
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPSimplyfyLineSegemnts(const QVector<QPointF> &points, double maxConsecutiveAngleDegree)
|
||||
{
|
||||
QVector<QPointF> result;
|
||||
if (points.size()>2) {
|
||||
result.push_back(points[0]);
|
||||
for (int i=1; i<points.size()-1; i++) {
|
||||
const QLineF l1(result.last(), points[i]);
|
||||
const QLineF l2(points[i], points[i+1]);
|
||||
if (fabs(l1.angle()-l2.angle())>maxConsecutiveAngleDegree && l1.length()>0 ) {
|
||||
result.push_back(points[i]);
|
||||
}
|
||||
}
|
||||
if (result.last()!=points.last()) result.push_back(points.last());
|
||||
return result;
|
||||
} else {
|
||||
return points;
|
||||
}
|
||||
}
|
||||
|
||||
JKQTPAdaptiveFunctionGraphEvaluator::JKQTPAdaptiveFunctionGraphEvaluator(const std::function<double (double)> &fx_, const std::function<double (double)> &fy_, unsigned int minSamples_, unsigned int maxRefinementDegree_, double slopeTolerance_, double minPixelPerSample_):
|
||||
fx(fx_),
|
||||
fy(fy_),
|
||||
minSamples(minSamples_),
|
||||
maxRefinementDegree(maxRefinementDegree_),
|
||||
slopeTolerance(slopeTolerance_),
|
||||
minPixelPerSample(minPixelPerSample_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPAdaptiveFunctionGraphEvaluator::evaluate(double tmin, double tmax) const
|
||||
{
|
||||
InternalList intData;
|
||||
|
||||
double delta_t0=(tmax-tmin)/static_cast<double>(minSamples);
|
||||
|
||||
intData.push_front(std::pair<double, QPointF>(tmin, QPointF(fx(tmin), fy(tmin))));
|
||||
InternalList::iterator a=intData.begin();
|
||||
//qDebug()<<"**************************************************";
|
||||
for (double t=tmin+delta_t0; t<tmax; t=t+delta_t0) {
|
||||
const double treal=t;
|
||||
intData.insert_after(a, std::pair<double, QPointF>(treal, QPointF(fx(treal), fy(treal))));
|
||||
InternalList::iterator b=a; b++;
|
||||
//qDebug()<<"t="<<t<<", dist(a,b)="<<std::distance(a,b);
|
||||
refine(intData, a, b, 0);
|
||||
//qDebug()<<" after refine: dist(a,b)="<<std::distance(a,b);
|
||||
a=b;
|
||||
}
|
||||
intData.insert_after(a, std::pair<double, QPointF>(tmax, QPointF(fx(tmax), fy(tmax))));
|
||||
auto b=a; b++;
|
||||
refine(intData, a, b, 0);
|
||||
// copy data to output data structure
|
||||
QVector<QPointF> result;
|
||||
result.reserve(std::distance(intData.begin(), intData.end()));
|
||||
for (const auto& d: intData) {
|
||||
result.push_back(d.second);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void JKQTPAdaptiveFunctionGraphEvaluator::refine(JKQTPAdaptiveFunctionGraphEvaluator::InternalList &intData, JKQTPAdaptiveFunctionGraphEvaluator::InternalList::iterator a, JKQTPAdaptiveFunctionGraphEvaluator::InternalList::iterator b, unsigned int degree) const
|
||||
{
|
||||
if (degree>=maxRefinementDegree) return;
|
||||
const double ta=a->first;
|
||||
const double tb=b->first;
|
||||
const double tmid=ta+(tb-ta)/2.0;
|
||||
const QPointF pa=a->second;
|
||||
const QPointF pb=b->second;
|
||||
const QPointF pmid(fx(tmid), fy(tmid));
|
||||
const double delta=QLineF(pa, pb).length();
|
||||
|
||||
const double slope_a_mid=(pmid.y()-pa.y())/(pmid.x()-pa.x());
|
||||
const double slope_mid_b=(pb.y()-pmid.y())/(pb.x()-pmid.x());
|
||||
if (fabs(slope_mid_b-slope_a_mid)>slopeTolerance || delta>minPixelPerSample) {
|
||||
intData.insert_after(a, std::pair<double, QPointF>(tmid, pmid));
|
||||
InternalList::iterator abmid=a; abmid++;
|
||||
refine(intData, a, abmid, degree+1);
|
||||
refine(intData, abmid, b, degree+1);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPSplitLineIntoPoints(const QLineF &line, std::function<QPointF (QPointF)> fTransform)
|
||||
{
|
||||
std::function<double(double)> fx = [&line, &fTransform](double t) ->double {
|
||||
return fTransform(line.p1()+t*(line.p2()-line.p1())).x();
|
||||
};
|
||||
std::function<double(double)> fy = [&line, &fTransform](double t) ->double {
|
||||
return fTransform(line.p1()+t*(line.p2()-line.p1())).y();
|
||||
};
|
||||
JKQTPAdaptiveFunctionGraphEvaluator eval(fx, fy);
|
||||
|
||||
return eval.evaluate(0.0,1.0);
|
||||
}
|
||||
|
||||
|
||||
QVector<QPointF> JKQTPSplitPolylineIntoPoints(const QVector<QPointF> &line, std::function<QPointF (QPointF)> fTransform)
|
||||
{
|
||||
QVector<QPointF> result;
|
||||
if (line.size()==2) return JKQTPSplitLineIntoPoints(QLineF(line[0], line[1]), fTransform);
|
||||
if (line.size()>2) {
|
||||
for (int i=1; i<line.size(); i++) {
|
||||
const QVector<QPointF> ps=JKQTPSplitLineIntoPoints(QLineF(line[i-1], line[i]), fTransform);
|
||||
result.reserve(result.size()+ps.size());
|
||||
for (auto& p: ps) {
|
||||
if (result.size()==0 || result.last()!=p) result.push_back(p);
|
||||
}
|
||||
//qDebug()<<"line: "<<QLineF(line[i-1], line[i])<<" --> ps.size()="<<ps.size()<<", result.size()="<<result.size();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool JKQTPClipLine(QLineF &line, const QRectF &clippingRect)
|
||||
{
|
||||
//qDebug()<<"line="<<line<<", clippingRect="<<clippingRect;
|
||||
const qreal p1 = -(line.x2() - line.x1());
|
||||
const qreal p2 = -p1;
|
||||
const qreal p3 = -(line.y2() - line.y1());
|
||||
const qreal p4 = -p3;
|
||||
|
||||
const qreal q1 = line.x1() - std::min(clippingRect.left(),clippingRect.right());
|
||||
const qreal q2 = std::max(clippingRect.left(),clippingRect.right()) - line.x1();
|
||||
const qreal q3 = line.y1() - std::min(clippingRect.bottom(),clippingRect.top());
|
||||
const qreal q4 = std::max(clippingRect.bottom(),clippingRect.top()) - line.y1();
|
||||
|
||||
//qDebug()<<" p1="<<p1<<", p2="<<p2<<", p3="<<p3<<", p4="<<p4;
|
||||
//qDebug()<<" q1="<<q1<<", q2="<<q2<<", q3="<<p3<<", q4="<<p4;
|
||||
|
||||
std::vector<qreal> posarr, negarr;
|
||||
posarr.reserve(5); negarr.reserve(5);
|
||||
posarr.push_back(1);
|
||||
negarr.push_back(0);
|
||||
|
||||
|
||||
if ((p1 == 0 && q1 < 0) || (p2 == 0 && q2 < 0) || (p3 == 0 && q3 < 0) || (p4 == 0 && q4 < 0)) {
|
||||
//qDebug()<<" --> parallel line";
|
||||
line=QLineF();
|
||||
return false;
|
||||
}
|
||||
if (p1 != 0) {
|
||||
const qreal r1 = q1 / p1;
|
||||
const qreal r2 = q2 / p2;
|
||||
if (p1 < 0) {
|
||||
negarr.push_back(r1); // for negative p1, add it to negative array
|
||||
posarr.push_back(r2); // and add p2 to positive array
|
||||
} else {
|
||||
negarr.push_back(r2);
|
||||
posarr.push_back(r1);
|
||||
}
|
||||
}
|
||||
if (p3 != 0) {
|
||||
const qreal r3 = q3 / p3;
|
||||
const qreal r4 = q4 / p4;
|
||||
if (p3 < 0) {
|
||||
negarr.push_back(r3);
|
||||
posarr.push_back(r4);
|
||||
} else {
|
||||
negarr.push_back(r4);
|
||||
posarr.push_back(r3);
|
||||
}
|
||||
}
|
||||
|
||||
const qreal rn1 = *std::max_element(negarr.begin(), negarr.end()); // maximum of negative array
|
||||
const qreal rn2 = *std::min_element(posarr.begin(), posarr.end()); // minimum of positive array
|
||||
|
||||
//qDebug()<<" rn1="<<rn1<<", rn2="<<rn2<<" negarr="<<negarr<<", posarr="<<posarr;
|
||||
|
||||
if (rn1 > rn2) { // reject
|
||||
//qDebug()<<" --> rejected line";
|
||||
line=QLineF();
|
||||
return false;
|
||||
}
|
||||
|
||||
const qreal xn1 = line.x1() + p2 * rn1;
|
||||
const qreal yn1 = line.y1() + p4 * rn1; // computing new points
|
||||
|
||||
const qreal xn2 = line.x1() + p2 * rn2;
|
||||
const qreal yn2 = line.y1() + p4 * rn2;
|
||||
|
||||
line=QLineF(xn1, yn1, xn2, yn2); // the drawing the new line
|
||||
//qDebug()<<" --> clipped line: "<<line;
|
||||
return true;
|
||||
}
|
||||
|
220
lib/jkqtcommon/jkqtpgeometrytools.h
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
Copyright (c) 2020-2020 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 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JKQTPGEOMETRYTOOLS_H_INCLUDED
|
||||
#define JKQTPGEOMETRYTOOLS_H_INCLUDED
|
||||
#include "jkqtcommon/jkqtcommon_imexport.h"
|
||||
#include <QPolygonF>
|
||||
#include <QPolygon>
|
||||
#include <QRectF>
|
||||
#include <QRect>
|
||||
#include <QLineF>
|
||||
#include <QLine>
|
||||
#include <QPainterPath>
|
||||
#include <QVector>
|
||||
#include <vector>
|
||||
#include <forward_list>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <QDebug>
|
||||
#include "jkqtcommon/jkqtpmathtools.h"
|
||||
#include "jkqtcommon/jkqtpcodestructuring.h"
|
||||
|
||||
|
||||
/** \brief rotate a rectangle by given angle (rotates all points around the center of the rectangle and returns it as a QPolygonF)
|
||||
* \ingroup jkqtptools_drawing
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QPolygonF jkqtpRotateRect(QRectF r, double angle);
|
||||
|
||||
|
||||
/** \brief adaptive drawing of a function graph, specified by two function \f$ f_x(t) \f$ and \f$ f_y(t) \f$ evaluated over a parameter range \f$ t\in\left[t_\text{min}..t_\text{max}\tight] \f$ */
|
||||
class JKQTCOMMON_LIB_EXPORT JKQTPAdaptiveFunctionGraphEvaluator {
|
||||
public:
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param fx function \f$ f_x(t) \f$
|
||||
* \param fy function \f$ f_y(t) \f$
|
||||
* \param minSamples the minimum number of points to evaluate the function at
|
||||
* \param maxRefinementDegree the maximum number of recursive refinement steps
|
||||
* each step bisects the interval \f$ [a, b] \f$ into two halfes. So the maximum number
|
||||
* of points plotted at all are thus:
|
||||
* \f[ \mbox{minSamples} \cdot 2^{\mbox{maxRefinementDegree}} \f]
|
||||
* \param slopeTolerance the tolerance for the difference of two subsequent slopes
|
||||
* \param minPixelPerSample create one sample at least every \a minPixelPerSample pixels
|
||||
*/
|
||||
JKQTPAdaptiveFunctionGraphEvaluator(const std::function<double(double)>& fx_, const std::function<double(double)>& fy_, unsigned int minSamples_=10, unsigned int maxRefinementDegree_=5, double slopeTolerance_=0.005, double minPixelPerSample_=32);
|
||||
|
||||
/** \brief evaluate the function specified in the constructor over the given parameter range \a tmin ... \a tmax
|
||||
*
|
||||
* \param tmin lower parameter range limit \f$ t_\text{min} \f$
|
||||
* \param tmax upper parameter range limit \f$ t_\text{max} \f$
|
||||
*/
|
||||
QVector<QPointF> evaluate(double tmin=0.0, double tmax=1.0) const;
|
||||
protected:
|
||||
typedef std::forward_list<std::pair<double, QPointF>> InternalList;
|
||||
/** \brief refine (if necessary) the function graph between the two points \a a and \a b, working on the given list of data \a data */
|
||||
void refine(InternalList& data, InternalList::iterator a, InternalList::iterator b, unsigned int degree) const;
|
||||
|
||||
/** \brief function \f$ f_x(t) \f$ */
|
||||
std::function<double(double)> fx;
|
||||
/** \brief function \f$ f_y(t) \f$ */
|
||||
std::function<double(double)> fy;
|
||||
/** \brief the minimum number of points to evaluate the function at */
|
||||
unsigned int minSamples;
|
||||
/** \brief the maximum number of recursive refinement steps
|
||||
*
|
||||
* each step bisects the interval \f$ [a, b] \f$ into two halfes. So the maximum number
|
||||
* of points plotted at all are thus:
|
||||
* \f[ \mbox{minSamples} \cdot 2^{\mbox{maxRefinementDegree}} \f]
|
||||
*/
|
||||
unsigned int maxRefinementDegree;
|
||||
/** \brief the tolerance for the difference of two subsequent slopes */
|
||||
double slopeTolerance;
|
||||
/** \brief create one sample at least every \a minPixelPerSample pixels */
|
||||
double minPixelPerSample;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief represent an ellipse as a series of points on the ellipse
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param x center of ellipse (x-coordinate)
|
||||
\param y center of ellipse (y-coordinate)
|
||||
\param a half axis in x-direction
|
||||
\param b half axis in y-direction
|
||||
\param angle_start starting angle of ellipse section
|
||||
\param angle_end ending angle of ellipse section
|
||||
\param alpha rotation angle of ellipse
|
||||
\param controlPoints the number of points to use for drawing
|
||||
\param[out] x_start first point of ellipse
|
||||
\param[out] x_end last point of ellipse
|
||||
|
||||
\note all angles are given in degrees [0..360]
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/*! \brief represent an ellipse as a series of points on the ellipse
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param fTransform a function that transforms a point in graph coordinate space into pixel coordinate space
|
||||
\param x center of ellipse (x-coordinate)
|
||||
\param y center of ellipse (y-coordinate)
|
||||
\param a half axis in x-direction
|
||||
\param b half axis in y-direction
|
||||
\param angle_start starting angle of ellipse section
|
||||
\param angle_end ending angle of ellipse section
|
||||
\param alpha rotation angle of ellipse
|
||||
\param[out] x_start first point of ellipse
|
||||
\param[out] x_end last point of ellipse
|
||||
|
||||
\note all angles are given in degrees [0..360]
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
|
||||
/*! \brief represent a line as a series of points on the ellipse
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param line the line to draw
|
||||
\param controlPoints the number of points to use for drawing
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPointF> JKQTPSplitLineIntoPoints(const QLineF& line, int controlPoints=180);
|
||||
|
||||
/*! \brief represent a line as a series of points on the ellipse
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param line the line to draw in graph coordinate space
|
||||
\param fTransform a function that transforms a point in graph coordinate space into pixel coordinate space
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPointF> JKQTPSplitLineIntoPoints(const QLineF& line, std::function<QPointF(QPointF)> fTransform);
|
||||
|
||||
|
||||
/*! \brief represent a poly-line as a series of points on the ellipse
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param line the poly-line to draw in graph coordinate space
|
||||
\param fTransform a function that transforms a point in graph coordinate space into pixel coordinate space
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPointF> JKQTPSplitPolylineIntoPoints(const QVector<QPointF>& line, std::function<QPointF(QPointF)> fTransform);
|
||||
|
||||
|
||||
/*! \brief takes a list of points and tries to reduce them. Three points are merged to two, if they form a straight line
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
\return a cleaned QVector<QPointF>
|
||||
\param points input poly-line
|
||||
\param maxConsecutiveAngleDegree is two consecutive line-segments differ by an angle smaller than this, they can be merged
|
||||
|
||||
\note this implements an incomplete algorithm
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPointF> JKQTPSimplyfyLineSegemnts(const QVector<QPointF>& points, double maxConsecutiveAngleDegree=1.0);
|
||||
|
||||
|
||||
/** \brief cleans a polygon by uniting all consecutive points that were closer than distanceThreshold are united
|
||||
* \ingroup jkqtptools_drawing
|
||||
*
|
||||
* \param poly polygon to clean
|
||||
* \param distanceThreshold if two end-points are closer together as this value, they are united to a single point
|
||||
* \return a cleaned polygon, where all consecutive points that were closer than distanceThreshold are united
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPCleanPolygon(const QPolygonF& poly, double distanceThreshold=0.3);
|
||||
|
||||
/** \brief takes a list of QLineF objesct \a lines and tries to combine as many of them as possible to QPolygonF objects.
|
||||
* <b>Note: This method implements an incomplete algorithm with \a searchMaxSurroundingElements>0, as solving
|
||||
* the complete problem is very time-consuming (cubic runtime)</b>
|
||||
* \ingroup jkqtptools_drawing
|
||||
*
|
||||
* \param lines line segments to unify
|
||||
* \param distanceThreshold if two end-points are closer together as this value, they are united to a single point
|
||||
* \param searchMaxSurroundingElements limits the search for a connected polygon to at most this number of neighbors
|
||||
* \return a vector of QPolygonF objects, which contain longer line-segments formed from \a lines
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QVector<QPolygonF> JKQTPUnifyLinesToPolygons(const QVector<QLineF>& lines, double distanceThreshold=0.3, int searchMaxSurroundingElements=10);
|
||||
|
||||
/** \brief clip a QLineF \a line to the rectangle defines by \a clippingRect
|
||||
* \ingroup jkqtptools_drawing
|
||||
*
|
||||
* \param[in,out] line The line to clip, if clipping is possible this is modified to the clipped line.
|
||||
* If the line is outside \a clippingRect this is modified to \c line=QLineF() i.e. a null-line!
|
||||
* \param clippingRect the rectangle to clip to
|
||||
* \return \c true, if the line had at least some points within \a clippingRect, \c false otherwise.
|
||||
* The clipped line (or a null-line) is returned in the by-refrence parameter \a line
|
||||
*
|
||||
* \see 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
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT bool JKQTPClipLine(QLineF& line, const QRectF& clippingRect);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPGEOMETRYTOOLS_H_INCLUDED
|
@ -24,6 +24,7 @@ isEmpty(JKQTP_COMMON_PRI_INCLUDED) {
|
||||
$$PWD/jkqtcommon/jkqtplinalgtools.h \
|
||||
$$PWD/jkqtcommon/jkqtpcodestructuring.h \
|
||||
$$PWD/jkqtcommon/jkqtpbasicimagetools.h \
|
||||
$$PWD/jkqtcommon/jkqtpgeometrytools.h \
|
||||
$$PWD/jkqtcommon/jkqtpdrawingtools.h \
|
||||
$$PWD/jkqtcommon/jkqtpenhancedpainter.h \
|
||||
$$PWD/jkqtcommon/jkqtphighrestimer.h \
|
||||
@ -47,6 +48,7 @@ isEmpty(JKQTP_COMMON_PRI_INCLUDED) {
|
||||
$$PWD/jkqtcommon/jkqtplinalgtools.cpp \
|
||||
$$PWD/jkqtcommon/jkqtpcodestructuring.cpp \
|
||||
$$PWD/jkqtcommon/jkqtpbasicimagetools.cpp \
|
||||
$$PWD/jkqtcommon/jkqtpgeometrytools.cpp \
|
||||
$$PWD/jkqtcommon/jkqtpdrawingtools.cpp \
|
||||
$$PWD/jkqtcommon/jkqtpenhancedpainter.cpp \
|
||||
$$PWD/jkqtcommon/jkqtphighrestimer.cpp \
|
||||
|
@ -730,7 +730,7 @@ void JKQTPBoxplotHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
|
||||
JKQTPBoxplotVerticalElement::JKQTPBoxplotVerticalElement(JKQTBasePlotter* parent):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPPlotObject(DrawAsGraphicElement, parent)
|
||||
{
|
||||
pos=JKQTP_NAN;
|
||||
median=JKQTP_NAN;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
#include "jkqtcommon/jkqtpenhancedpainter.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtcommon/jkqtpgeometrytools.h"
|
||||
#include <QDebug>
|
||||
#include <QImageWriter>
|
||||
#include <QFileDialog>
|
||||
|
@ -358,13 +358,13 @@ void JKQTPXFunctionLineGraph::refine(doublePair* a, doublePair* b, unsigned int
|
||||
} else {*/
|
||||
xmid=xmid+(static_cast<double>(rand())/static_cast<double>(RAND_MAX)-0.5)*delta/5.0; // shake by 10%
|
||||
//}
|
||||
double realxmid=parent->p2x(xmid);
|
||||
const double realxmid=parent->p2x(xmid);
|
||||
double realfmid = 0.0;
|
||||
if (plotFunction) realfmid=plotFunction(realxmid, params);
|
||||
else if (simplePlotFunction) realfmid=simplePlotFunction(realxmid);
|
||||
double fmid=transformY(realfmid);
|
||||
double a1=(fmid - af)/(xmid - ax);
|
||||
double a2=(bf - fmid)/(bx - xmid);
|
||||
const double fmid=transformY(realfmid);
|
||||
const double a1=(fmid - af)/(xmid - ax);
|
||||
const double a2=(bf - fmid)/(bx - xmid);
|
||||
//std::cout<<std::string(degree*2, ' ')<<"refine( ["<<a->x<<", "<<a->f<<"], ["<<xmid<<", "<<fmid<<"], ["<<b->x<<", "<<b->f<<"] ): a1="<<a1<<", a2="<<a2<<" acrit="<<abs(a2/a1)-1.0<<"\n";
|
||||
//std::cout<<std::string(degree*2, ' ')<<"refine(): a1="<<a1<<", a2="<<a2<<" acrit="<<fabs(a2-a1)<<"\n";
|
||||
if (fabs(a2-a1)>slopeTolerance || delta>minPixelPerSample) {
|
||||
@ -864,7 +864,9 @@ int JKQTPXFunctionLineGraph::getParameterColumn() const
|
||||
return this->parameterColumn;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setParameterColumn(size_t __value) { this->parameterColumn = static_cast<int>(__value); }
|
||||
void JKQTPXFunctionLineGraph::setParameterColumn(size_t __value) {
|
||||
this->parameterColumn = static_cast<int>(__value);
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorParameterColumn(int __value)
|
||||
{
|
||||
@ -876,7 +878,59 @@ int JKQTPXFunctionLineGraph::getErrorParameterColumn() const
|
||||
return this->errorParameterColumn;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorParameterColumn(size_t __value) { this->errorParameterColumn = static_cast<int>(__value); }
|
||||
void JKQTPXFunctionLineGraph::setErrorParameterColumn(size_t __value) {
|
||||
this->errorParameterColumn = static_cast<int>(__value);
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorLineColor(const QColor &__value)
|
||||
{
|
||||
this->errorColor = __value;
|
||||
}
|
||||
|
||||
QColor JKQTPXFunctionLineGraph::getErrorLineColor() const
|
||||
{
|
||||
return this->errorColor;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorFillColor(const QColor &__value)
|
||||
{
|
||||
this->errorFillColor = __value;
|
||||
}
|
||||
|
||||
QColor JKQTPXFunctionLineGraph::getErrorFillColor() const
|
||||
{
|
||||
return this->errorFillColor;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorFillStyle(Qt::BrushStyle __value)
|
||||
{
|
||||
this->errorFillStyle = __value;
|
||||
}
|
||||
|
||||
Qt::BrushStyle JKQTPXFunctionLineGraph::getErrorFillStyle() const
|
||||
{
|
||||
return this->errorFillStyle;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorLineStyle(Qt::PenStyle __value)
|
||||
{
|
||||
this->errorStyle = __value;
|
||||
}
|
||||
|
||||
Qt::PenStyle JKQTPXFunctionLineGraph::getErrorLineStyle() const
|
||||
{
|
||||
return this->errorStyle;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setErrorLineWidth(double __value)
|
||||
{
|
||||
this->errorLineWidth = __value;
|
||||
}
|
||||
|
||||
double JKQTPXFunctionLineGraph::getErrorLineWidth() const
|
||||
{
|
||||
return this->errorLineWidth;
|
||||
}
|
||||
|
||||
void JKQTPXFunctionLineGraph::setSpecialFunction(JKQTPXFunctionLineGraph::SpecialFunction function)
|
||||
{
|
||||
@ -897,32 +951,32 @@ void JKQTPXFunctionLineGraph::setSpecialFunction(JKQTPXFunctionLineGraph::Specia
|
||||
});
|
||||
}
|
||||
else if (function==JKQTPXFunctionLineGraph::Exponential) setPlotFunctionFunctor([](double x, void* param) {
|
||||
double res=0;
|
||||
QVector<double>* d=static_cast<QVector<double>*>(param);
|
||||
if (d) {
|
||||
if (d->size()>=3) {
|
||||
res=d->value(0,0)+d->value(1,0)*exp(x/d->value(2,0));
|
||||
} else if (d->size()>=2) {
|
||||
res=d->value(0,0)*exp(x/d->value(1,0));
|
||||
double res=0;
|
||||
QVector<double>* d=static_cast<QVector<double>*>(param);
|
||||
if (d) {
|
||||
if (d->size()>=3) {
|
||||
res=d->value(0,0)+d->value(1,0)*exp(x/d->value(2,0));
|
||||
} else if (d->size()>=2) {
|
||||
res=d->value(0,0)*exp(x/d->value(1,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
});
|
||||
return res;
|
||||
});
|
||||
else if (function==JKQTPXFunctionLineGraph::PowerLaw) setPlotFunctionFunctor([](double x, void* param) {
|
||||
double res=0;
|
||||
QVector<double>* d=static_cast<QVector<double>*>(param);
|
||||
if (d) {
|
||||
if (d->size()>=3) {
|
||||
res=d->value(0,0)+d->value(1,0)*pow(x, d->value(2,1));
|
||||
} else if (d->size()>=2) {
|
||||
res=d->value(0,0)*pow(x, d->value(1,1));
|
||||
} else if (d->size()>=1) {
|
||||
res=pow(x, d->value(0,1));
|
||||
}
|
||||
double res=0;
|
||||
QVector<double>* d=static_cast<QVector<double>*>(param);
|
||||
if (d) {
|
||||
if (d->size()>=3) {
|
||||
res=d->value(0,0)+d->value(1,0)*pow(x, d->value(2,1));
|
||||
} else if (d->size()>=2) {
|
||||
res=d->value(0,0)*pow(x, d->value(1,1));
|
||||
} else if (d->size()>=1) {
|
||||
res=pow(x, d->value(0,1));
|
||||
}
|
||||
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
return res;
|
||||
});
|
||||
else throw std::runtime_error("unknown special function type");
|
||||
}
|
||||
|
||||
|
@ -250,56 +250,26 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph, public
|
||||
/*! \copydoc errorParameterColumn */
|
||||
void setErrorParameterColumn (size_t __value);
|
||||
|
||||
/*! \copydoc errorColor */
|
||||
virtual void setErrorLineColor(const QColor & __value);
|
||||
/*! \copydoc errorColor */
|
||||
inline virtual void setErrorLineColor(const QColor & __value)
|
||||
{
|
||||
this->errorColor = __value;
|
||||
}
|
||||
/*! \copydoc errorColor */
|
||||
inline virtual QColor getErrorLineColor() const
|
||||
{
|
||||
return this->errorColor;
|
||||
}
|
||||
virtual QColor getErrorLineColor() const;
|
||||
/*! \copydoc errorFillColor */
|
||||
inline virtual void setErrorFillColor(const QColor & __value)
|
||||
{
|
||||
this->errorFillColor = __value;
|
||||
}
|
||||
virtual void setErrorFillColor(const QColor & __value);
|
||||
/*! \copydoc errorFillColor */
|
||||
inline virtual QColor getErrorFillColor() const
|
||||
{
|
||||
return this->errorFillColor;
|
||||
}
|
||||
virtual QColor getErrorFillColor() const;
|
||||
/*! \copydoc errorFillStyle */
|
||||
inline virtual void setErrorFillStyle(Qt::BrushStyle __value)
|
||||
{
|
||||
this->errorFillStyle = __value;
|
||||
}
|
||||
virtual void setErrorFillStyle(Qt::BrushStyle __value);
|
||||
/*! \copydoc errorFillStyle */
|
||||
inline virtual Qt::BrushStyle getErrorFillStyle() const
|
||||
{
|
||||
return this->errorFillStyle;
|
||||
}
|
||||
virtual Qt::BrushStyle getErrorFillStyle() const;
|
||||
/*! \copydoc errorStyle */
|
||||
inline virtual void setErrorLineStyle(Qt::PenStyle __value)
|
||||
{
|
||||
this->errorStyle = __value;
|
||||
}
|
||||
virtual void setErrorLineStyle(Qt::PenStyle __value);
|
||||
/*! \copydoc errorStyle */
|
||||
inline virtual Qt::PenStyle getErrorLineStyle() const
|
||||
{
|
||||
return this->errorStyle;
|
||||
}
|
||||
virtual Qt::PenStyle getErrorLineStyle() const;
|
||||
/*! \copydoc errorLineWidth */
|
||||
inline virtual void setErrorLineWidth(double __value)
|
||||
{
|
||||
this->errorLineWidth = __value;
|
||||
}
|
||||
virtual void setErrorLineWidth(double __value);
|
||||
/*! \copydoc errorLineWidth */
|
||||
inline virtual double getErrorLineWidth() const
|
||||
{
|
||||
return this->errorLineWidth;
|
||||
}
|
||||
virtual double getErrorLineWidth() const;
|
||||
|
||||
/** \copydoc JKQTPGraph::usesColumn() */
|
||||
virtual bool usesColumn(int c) const override;
|
||||
|
@ -30,12 +30,9 @@
|
||||
|
||||
|
||||
|
||||
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize, QColor color):
|
||||
JKQTPPlotObject(parent), JKQTPGraphTextStyleMixin(parent)
|
||||
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x_, double y_, const QString& text_, double fontSize, QColor color):
|
||||
JKQTPGeoText(parent, x_, y_, text_)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
this->text=text;
|
||||
setTextFontSize(fontSize);
|
||||
setTextColor(color);
|
||||
}
|
||||
@ -45,12 +42,10 @@ JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QStrin
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter *parent, double x, double y, const QString &text):
|
||||
JKQTPPlotObject(parent), JKQTPGraphTextStyleMixin(parent)
|
||||
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter *parent, double x_, double y_, const QString& text_):
|
||||
JKQTPPlotObject(DrawAsGraphicElement, parent), JKQTPGraphTextStyleMixin(parent), x(x_),y(y_),text(text_)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
this->text=text;
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoText::JKQTPGeoText(JKQTPlotter *parent, double x, double y, const QString &text):
|
||||
@ -136,7 +131,7 @@ QColor JKQTPGeoText::getKeyLabelColor() const {
|
||||
|
||||
|
||||
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPPlotObject(DrawAsGraphicElement, parent)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
@ -148,15 +143,9 @@ JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQT
|
||||
}
|
||||
|
||||
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPGeoSymbol(parent->getPlotter(), x, y, symbol, symbolSize, color, fillColor)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
setSymbolType(symbol);
|
||||
setSymbolSize(symbolSize);
|
||||
setSymbolColor(color);
|
||||
setSymbolFillColor(fillColor);
|
||||
setSymbolLineWidth(1);
|
||||
|
||||
}
|
||||
|
||||
void JKQTPGeoSymbol::setColor(QColor c)
|
||||
|
@ -27,27 +27,16 @@
|
||||
#include <QApplication>
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
||||
|
||||
JKQTPGeoBaseLine::JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTBasePlotter* parent):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPGeoBaseLine::JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTBasePlotter* parent, DrawMode drawMode):
|
||||
JKQTPPlotObject(drawMode, parent)
|
||||
{
|
||||
setLineColor(color);
|
||||
setLineWidth(lineWidth);
|
||||
setLineStyle(style);
|
||||
}
|
||||
|
||||
JKQTPGeoBaseLine::JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent):
|
||||
JKQTPGeoBaseLine(color, lineWidth, style, parent->getPlotter())
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPGeoBaseLine::JKQTPGeoBaseLine(JKQTBasePlotter *parent):
|
||||
JKQTPPlotObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseLine::JKQTPGeoBaseLine(JKQTPlotter *parent):
|
||||
JKQTPGeoBaseLine(parent->getPlotter())
|
||||
JKQTPGeoBaseLine::JKQTPGeoBaseLine(JKQTBasePlotter *parent, DrawMode drawMode):
|
||||
JKQTPPlotObject(drawMode, parent)
|
||||
{
|
||||
|
||||
}
|
||||
@ -78,38 +67,28 @@ QColor JKQTPGeoBaseLine::getKeyLabelColor() const {
|
||||
}
|
||||
|
||||
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTBasePlotter* parent):
|
||||
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTBasePlotter* parent, DrawMode drawMode):
|
||||
JKQTPGeoBaseLine(color, lineWidth, style, parent, drawMode)
|
||||
{
|
||||
setFillColor(fillColor);
|
||||
setFillStyle(fillStyle);
|
||||
}
|
||||
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTPlotter* parent):
|
||||
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, JKQTBasePlotter* parent, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, Qt::SolidPattern, parent, drawMode)
|
||||
{
|
||||
setFillColor(fillColor);
|
||||
setFillStyle(fillStyle);
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent):
|
||||
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, JKQTBasePlotter* parent, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, Qt::SolidLine, Qt::SolidPattern, parent, drawMode)
|
||||
{
|
||||
setFillColor(fillColor);
|
||||
setFillStyle(Qt::SolidPattern);
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, JKQTPlotter* parent):
|
||||
JKQTPGeoBaseLine(color, lineWidth, Qt::SolidLine, parent)
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTBasePlotter* parent, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, 2.0, Qt::SolidLine, Qt::SolidPattern, parent, drawMode)
|
||||
{
|
||||
setFillColor(fillColor);
|
||||
setFillStyle(Qt::SolidPattern);
|
||||
}
|
||||
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTPlotter* parent):
|
||||
JKQTPGeoBaseLine(color, 2.0, Qt::SolidLine, parent)
|
||||
{
|
||||
setFillColor(fillColor);
|
||||
setFillStyle(Qt::SolidPattern);
|
||||
}
|
||||
|
||||
void JKQTPGeoBaseFilled::setAlpha(float alpha)
|
||||
@ -144,8 +123,8 @@ void JKQTPGeoBaseFilled::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& re
|
||||
}
|
||||
|
||||
|
||||
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, Qt::PenStyle style, JKQTBasePlotter *parent):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, Qt::PenStyle style, JKQTBasePlotter *parent, DrawMode drawMode):
|
||||
JKQTPPlotObject(drawMode, parent)
|
||||
{
|
||||
setLineColor(color);
|
||||
setLineWidth(lineWidth);
|
||||
@ -153,20 +132,8 @@ JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(QColor color, doubl
|
||||
setHeadDecoratorStyle(headStyle);
|
||||
}
|
||||
|
||||
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, Qt::PenStyle style, JKQTPlotter *parent):
|
||||
JKQTPGeoBaseDecoratedHeadLine(color, lineWidth, headStyle, style, parent->getPlotter())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(JKQTBasePlotter *parent):
|
||||
JKQTPPlotObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(JKQTPlotter *parent):
|
||||
JKQTPPlotObject(parent->getPlotter())
|
||||
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(JKQTBasePlotter *parent, DrawMode drawMode):
|
||||
JKQTPPlotObject(drawMode, parent)
|
||||
{
|
||||
|
||||
}
|
||||
@ -197,9 +164,8 @@ QColor JKQTPGeoBaseDecoratedHeadLine::getKeyLabelColor() const
|
||||
}
|
||||
|
||||
|
||||
|
||||
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, Qt::PenStyle style, JKQTBasePlotter *parent):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, Qt::PenStyle style, JKQTBasePlotter *parent, DrawMode drawMode):
|
||||
JKQTPPlotObject(drawMode, parent)
|
||||
{
|
||||
setLineColor(color);
|
||||
setLineWidth(lineWidth);
|
||||
@ -208,20 +174,8 @@ JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(QColor color, double lineWi
|
||||
setHeadDecoratorStyle(headStyle);
|
||||
}
|
||||
|
||||
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, Qt::PenStyle style, JKQTPlotter *parent):
|
||||
JKQTPGeoBaseDecoratedLine(color, lineWidth, headStyle, tailStyle, style, parent->getPlotter())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(JKQTBasePlotter *parent):
|
||||
JKQTPPlotObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(JKQTPlotter *parent):
|
||||
JKQTPPlotObject(parent->getPlotter())
|
||||
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(JKQTBasePlotter *parent, DrawMode drawMode):
|
||||
JKQTPPlotObject(drawMode, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -46,23 +46,13 @@ public:
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
explicit JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr);
|
||||
/*! \brief class contructor
|
||||
explicit JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
\param color color of drawing
|
||||
\param style line style of drawing
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
explicit JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent);
|
||||
/*! \brief class contructor
|
||||
|
||||
*/
|
||||
explicit JKQTPGeoBaseLine(JKQTBasePlotter* parent);
|
||||
/*! \brief class contructor
|
||||
explicit JKQTPGeoBaseLine(JKQTBasePlotter* parent, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
*/
|
||||
explicit JKQTPGeoBaseLine(JKQTPlotter* parent);
|
||||
|
||||
|
||||
|
||||
@ -99,24 +89,13 @@ public:
|
||||
\param style line style of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
explicit JKQTPGeoBaseDecoratedHeadLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr);
|
||||
/*! \brief class contructor
|
||||
explicit JKQTPGeoBaseDecoratedHeadLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
\param color color of drawing
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param headStyle style of the head decoration
|
||||
\param style line style of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
explicit JKQTPGeoBaseDecoratedHeadLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, Qt::PenStyle style, JKQTPlotter* parent);
|
||||
/*! \brief class contructor
|
||||
|
||||
*/
|
||||
explicit JKQTPGeoBaseDecoratedHeadLine(JKQTBasePlotter* parent);
|
||||
/*! \brief class contructor
|
||||
explicit JKQTPGeoBaseDecoratedHeadLine(JKQTBasePlotter* parent, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
*/
|
||||
explicit JKQTPGeoBaseDecoratedHeadLine(JKQTPlotter* parent);
|
||||
|
||||
|
||||
|
||||
@ -154,21 +133,9 @@ public:
|
||||
\param style line style of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
explicit JKQTPGeoBaseDecoratedLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr);
|
||||
/*! \brief class contructor
|
||||
|
||||
\param color color of drawing
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param headStyle style of the head decoration
|
||||
\param tailStyle style of the tail decoration
|
||||
\param style line style of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
explicit JKQTPGeoBaseDecoratedLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, Qt::PenStyle style, JKQTPlotter* parent);
|
||||
explicit JKQTPGeoBaseDecoratedLine(QColor color, double lineWidth, JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, Qt::PenStyle style=Qt::SolidLine, JKQTBasePlotter* parent=nullptr, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/*! \brief class contructor */
|
||||
explicit JKQTPGeoBaseDecoratedLine(JKQTBasePlotter* parent);
|
||||
/*! \brief class contructor */
|
||||
explicit JKQTPGeoBaseDecoratedLine(JKQTPlotter* parent);
|
||||
explicit JKQTPGeoBaseDecoratedLine(JKQTBasePlotter* parent, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
|
||||
|
||||
@ -204,17 +171,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoBaseFilled: public JKQTPGeoBaseLine, public
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
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
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTPlotter* parent);
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style=Qt::SolidLine, Qt::BrushStyle fillStyle=Qt::SolidPattern, JKQTBasePlotter* parent=nullptr, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/*! \brief class contructor
|
||||
|
||||
\param color color of drawing
|
||||
@ -223,7 +180,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoBaseFilled: public JKQTPGeoBaseLine, public
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent);
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, JKQTBasePlotter* parent, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/*! \brief class contructor
|
||||
|
||||
\param color color of drawing
|
||||
@ -231,14 +188,14 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoBaseFilled: public JKQTPGeoBaseLine, public
|
||||
\param lineWidth lineWidth of drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, JKQTPlotter* parent);
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, JKQTBasePlotter* parent, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/*! \brief class contructor
|
||||
|
||||
\param color color of drawing
|
||||
\param fillColor color of the filling in the drawing
|
||||
\param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTPlotter* parent);
|
||||
JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTBasePlotter *parent, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
/** \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;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "jkqtplotter/graphs/jkqtpgeolines.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtcommon/jkqtpgeometrytools.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
@ -46,13 +47,9 @@ JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter* parent, double x1, double y1, double x2,
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, double x1, double y1, double x2, double y2):
|
||||
JKQTPGeoBaseDecoratedLine(parent)
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, double x1_, double y1_, double x2_, double y2_):
|
||||
JKQTPGeoBaseDecoratedLine(parent), x1(x1_), y1(y1_), x2(x2_), y2(y2_)
|
||||
{
|
||||
this->x1=x1;
|
||||
this->y1=y1;
|
||||
this->x2=x2;
|
||||
this->y2=y2;
|
||||
setHeadDecoratorStyle(JKQTPNoDecorator);
|
||||
setTailDecoratorStyle(JKQTPNoDecorator);
|
||||
}
|
||||
@ -62,6 +59,54 @@ JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter *parent, double x1, double y1, double x2,
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, const QPointF &p1, const QPointF &p2, QColor color, double lineWidth, Qt::PenStyle style):
|
||||
JKQTPGeoLine(parent, p1.x(), p1.y(), p2.x(), p2.y(), color, lineWidth, style)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter *parent, const QPointF &p1, const QPointF &p2, QColor color, double lineWidth, Qt::PenStyle style):
|
||||
JKQTPGeoLine(parent, p1.x(), p1.y(), p2.x(), p2.y(), color, lineWidth, style)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, const QPointF &p1, const QPointF &p2):
|
||||
JKQTPGeoLine(parent, p1.x(), p1.y(), p2.x(), p2.y())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter *parent, const QPointF &p1, const QPointF &p2):
|
||||
JKQTPGeoLine(parent, p1.x(), p1.y(), p2.x(), p2.y())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, const QLineF &line, QColor color, double lineWidth, Qt::PenStyle style):
|
||||
JKQTPGeoLine(parent, line.x1(), line.y1(), line.x2(), line.y2(), color, lineWidth, style)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter *parent, const QLineF &line, QColor color, double lineWidth, Qt::PenStyle style):
|
||||
JKQTPGeoLine(parent, line.x1(), line.y1(), line.x2(), line.y2(), color, lineWidth, style)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, const QLineF &line):
|
||||
JKQTPGeoLine(parent, line.x1(), line.y1(), line.x2(), line.y2())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter *parent, const QLineF &line):
|
||||
JKQTPGeoLine(parent, line.x1(), line.y1(), line.x2(), line.y2())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool JKQTPGeoLine::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
||||
minx=qMin(x1, x2);
|
||||
maxx=qMax(x1, x2);
|
||||
@ -90,14 +135,53 @@ void JKQTPGeoLine::draw(JKQTPEnhancedPainter& painter) {
|
||||
painter.setBrush(getLineColor());
|
||||
QPointF xx1(transformX(x1),transformY(y1));
|
||||
QPointF xx2(transformX(x2), transformY(y2));
|
||||
const double angle1=atan2(xx2.y()-xx1.y(), xx2.x()-xx1.x());
|
||||
const double angle2=atan2(xx1.y()-xx2.y(), xx1.x()-xx2.x());
|
||||
if ( QLineF(xx1, xx2).length()>0) {
|
||||
QPointF lx1=xx1, lx2=xx2;
|
||||
JKQTPPlotLineDecorator(painter, xx1.x(), xx1.y(), angle1, getTailDecoratorStyle(), calcTailDecoratorSize(getLinePen(painter, getParent()).widthF()), &lx1);
|
||||
JKQTPPlotLineDecorator(painter, xx2.x(), xx2.y(), angle2, getHeadDecoratorStyle(), calcHeadDecoratorSize(getLinePen(painter, getParent()).widthF()), &lx2);
|
||||
// draw corrected line
|
||||
painter.drawLine(QLineF(lx1, lx2));
|
||||
|
||||
if ((getDrawMode()==DrawAsGraphicElement) || (getParent()->getXAxis()->isLinearAxis() && getParent()->getYAxis()->isLinearAxis())) {
|
||||
// for linear axes, we can simply draw a line
|
||||
const double angle1=atan2(xx2.y()-xx1.y(), xx2.x()-xx1.x());
|
||||
const double angle2=atan2(xx1.y()-xx2.y(), xx1.x()-xx2.x());
|
||||
QPointF lx1=xx1, lx2=xx2;
|
||||
JKQTPPlotLineDecorator(painter, xx1.x(), xx1.y(), angle1, getTailDecoratorStyle(), calcTailDecoratorSize(getLinePen(painter, getParent()).widthF()), &lx1);
|
||||
JKQTPPlotLineDecorator(painter, xx2.x(), xx2.y(), angle2, getHeadDecoratorStyle(), calcHeadDecoratorSize(getLinePen(painter, getParent()).widthF()), &lx2);
|
||||
// draw corrected line
|
||||
painter.drawLine(QLineF(lx1, lx2));
|
||||
} else {
|
||||
QLineF line(QPointF(x1,y1), QPointF(x2,y2));
|
||||
const double xmin=parent->getXAxis()->getMin();
|
||||
const double xmax=parent->getXAxis()->getMax();
|
||||
const double ymin=parent->getYAxis()->getMin();
|
||||
const double ymax=parent->getYAxis()->getMax();
|
||||
const QRectF bbox(QPointF(xmin, ymin), QPointF(xmax, ymax));
|
||||
bool drawHead=bbox.contains(line.p2());
|
||||
bool drawTail=bbox.contains(line.p1());
|
||||
|
||||
if (JKQTPClipLine(line, bbox)) {
|
||||
|
||||
// for non-linear axes, a line might not be drawn as a line, so we need to segment the line (i.e. linear function in coordinate space)
|
||||
// and transform each node to draw the corresponding non-linear curve in pixel-space!
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QVector<QPointF> points=JKQTPSplitLineIntoPoints(line, fTransform);
|
||||
points=JKQTPSimplyfyLineSegemnts(points);
|
||||
if (points.size()>1) {
|
||||
xx1=points[0];
|
||||
QPointF xx1p=points[1];
|
||||
xx2=points[points.size()-1];
|
||||
QPointF xx2p=points[points.size()-2];
|
||||
//QPointF lx1=xx1, lx2=xx2;
|
||||
const double angle1=atan2(xx1p.y()-xx1.y(), xx1p.x()-xx1.x());
|
||||
const double angle2=atan2(xx2p.y()-xx2.y(), xx2p.x()-xx2.x());
|
||||
if (drawTail) JKQTPPlotLineDecorator(painter, xx1.x(), xx1.y(), angle1, getTailDecoratorStyle(), calcTailDecoratorSize(getLinePen(painter, getParent()).widthF()));//, &lx1);
|
||||
if (drawHead) JKQTPPlotLineDecorator(painter, xx2.x(), xx2.y(), angle2, getHeadDecoratorStyle(), calcHeadDecoratorSize(getLinePen(painter, getParent()).widthF()));//, &lx2);
|
||||
//points[0]=lx1;
|
||||
//points[points.size()-1]=lx2;
|
||||
painter.drawPolyline(points.data(), points.size());
|
||||
/*for (auto& p: points) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), JKQTPPlus, 5, 1, QColor("green"), QColor("darkgreen"));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
addHitTestData(x1, y1);
|
||||
addHitTestData(x2, y2);
|
||||
}
|
||||
@ -143,6 +227,41 @@ double JKQTPGeoLine::getY2() const
|
||||
return this->y2;
|
||||
}
|
||||
|
||||
QPointF JKQTPGeoLine::getP1() const
|
||||
{
|
||||
return QPointF(x1,y1);
|
||||
}
|
||||
|
||||
void JKQTPGeoLine::setP1(const QPointF &p)
|
||||
{
|
||||
x1=p.x();
|
||||
y1=p.y();
|
||||
}
|
||||
|
||||
QPointF JKQTPGeoLine::getP2() const
|
||||
{
|
||||
return QPointF(x2,y2);
|
||||
}
|
||||
|
||||
void JKQTPGeoLine::setP2(const QPointF &p)
|
||||
{
|
||||
x2=p.x();
|
||||
y2=p.y();
|
||||
}
|
||||
|
||||
QLineF JKQTPGeoLine::getLine() const
|
||||
{
|
||||
return QLineF(getP1(), getP2());
|
||||
}
|
||||
|
||||
void JKQTPGeoLine::setLine(const QLineF &line)
|
||||
{
|
||||
x1=line.p1().x();
|
||||
x2=line.p2().x();
|
||||
y1=line.p1().y();
|
||||
y2=line.p2().y();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -317,22 +436,44 @@ void JKQTPGeoInfiniteLine::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (doDraw) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
QLineF l(QPointF(transformX(x1), transformY(y1)), QPointF(transformX(x2), transformY(y2)));
|
||||
if (l.length()>0) {
|
||||
painter.drawLine(l);
|
||||
addHitTestData(x, y, formatHitTestDefaultLabel(x,y)+
|
||||
QString(", \\ensuremath{\\mathrm{\\mathbf{d}}y/\\mathrm{\\mathbf{d}}x\\;=\\;%1/%2\\;=\\;%3\\;=\\;%4\\degree}").arg(jkqtp_floattolatexqstr(dy, 3)).arg(jkqtp_floattolatexqstr(dx, 3)).arg(jkqtp_floattolatexqstr(dy/dx, 3)).arg(jkqtp_floattolatexqstr(atan2(dy,dx), 1)));
|
||||
addHitTestData(x1, y1);
|
||||
addHitTestData(x2, y2);
|
||||
QLineF line(QPointF(transformX(x1), transformY(y1)), QPointF(transformX(x2), transformY(y2)));
|
||||
if (line.length()>0) {
|
||||
QPointF xx1;
|
||||
double angle1;
|
||||
if ((getDrawMode()==DrawAsGraphicElement) || (getParent()->getXAxis()->isLinearAxis() && getParent()->getYAxis()->isLinearAxis())) {
|
||||
painter.drawLine(line);
|
||||
xx1=QPointF(transformX(x),transformY(y));
|
||||
angle1=atan2(line.dy(), line.dx());
|
||||
} else {
|
||||
// for non-linear axes, a line might not be drawn as a line, so we need to segment the line (i.e. linear function in coordinate space)
|
||||
// and transform each node to draw the corresponding non-linear curve in pixel-space!
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QVector<QPointF> points=JKQTPSplitLineIntoPoints(QLineF(x1,y1,x2,y2), fTransform);
|
||||
points=JKQTPSimplyfyLineSegemnts(points);
|
||||
if (points.size()>1) {
|
||||
xx1=points[0];
|
||||
const QPointF xx1p=points[1];
|
||||
angle1=atan2(xx1p.y()-xx1.y(), xx1p.x()-xx1.x());
|
||||
painter.drawPolyline(points.data(), points.size());
|
||||
/*for (auto& p: points) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), JKQTPPlus, 5, 1, QColor("green"), QColor("darkgreen"));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
// draw line-end decorator
|
||||
if (two_sided==false && x>=xmin && x<=xmax && y>=ymin && y<=ymax) {
|
||||
painter.save(); auto __finalpainttwosided=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getLineColor());
|
||||
QPointF xx1(transformX(x),transformY(y));
|
||||
const double angle1=atan2(l.dy(), l.dx());
|
||||
JKQTPPlotLineDecorator(painter, xx1.x(), xx1.y(), angle1, getHeadDecoratorStyle(), calcHeadDecoratorSize(getLinePen(painter, getParent()).widthF()));
|
||||
}
|
||||
|
||||
|
||||
addHitTestData(x, y, formatHitTestDefaultLabel(x,y)+
|
||||
QString(", \\ensuremath{\\mathrm{\\mathbf{d}}y/\\mathrm{\\mathbf{d}}x\\;=\\;%1/%2\\;=\\;%3\\;=\\;%4\\degree}").arg(jkqtp_floattolatexqstr(dy, 3)).arg(jkqtp_floattolatexqstr(dx, 3)).arg(jkqtp_floattolatexqstr(dy/dx, 3)).arg(jkqtp_floattolatexqstr(atan2(dy,dx), 1)));
|
||||
addHitTestData(x1, y1);
|
||||
addHitTestData(x2, y2);
|
||||
}
|
||||
|
||||
}
|
||||
@ -389,6 +530,17 @@ bool JKQTPGeoInfiniteLine::getTwoSided() const
|
||||
return this->two_sided;
|
||||
}
|
||||
|
||||
QPointF JKQTPGeoInfiniteLine::getP() const
|
||||
{
|
||||
return QPointF(x,y);
|
||||
}
|
||||
|
||||
void JKQTPGeoInfiniteLine::setP(const QPointF &p)
|
||||
{
|
||||
x=p.x();
|
||||
y=p.y();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -460,23 +612,51 @@ void JKQTPGeoPolyLines::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (points.size()>=2) {
|
||||
reserveHitTestData(points.size());
|
||||
|
||||
QVector<QPointF> path=transform(points);
|
||||
double angle1, angle2;
|
||||
QPointF xx1, xx2;
|
||||
bool doDrawDecorator=false;
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getLineColor());
|
||||
if ((getDrawMode()==DrawAsGraphicElement) || (getParent()->getXAxis()->isLinearAxis() && getParent()->getYAxis()->isLinearAxis())) {
|
||||
QVector<QPointF> path=transform(points);
|
||||
angle1=atan2(path[1].y()-path[0].y(), path[1].x()-path[0].x());
|
||||
angle2=atan2(path[path.size()-2].y()-path[path.size()-1].y(), path[path.size()-2].x()-path[path.size()-1].x());
|
||||
xx1=path[0];
|
||||
xx2=path[path.size()-1];
|
||||
// draw corrected line
|
||||
painter.drawPolyline(path.data(), path.size());
|
||||
doDrawDecorator=true;
|
||||
} else {
|
||||
// for non-linear axes, a line might not be drawn as a line, so we need to segment the line (i.e. linear function in coordinate space)
|
||||
// and transform each node to draw the corresponding non-linear curve in pixel-space!
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QVector<QPointF> points_poly=JKQTPSplitPolylineIntoPoints(points, fTransform);
|
||||
points_poly=JKQTPSimplyfyLineSegemnts(points_poly);
|
||||
if (points_poly.size()>1) {
|
||||
xx1=points_poly[0];
|
||||
const QPointF xx1p=points_poly[1];
|
||||
angle1=atan2(xx1p.y()-xx1.y(), xx1p.x()-xx1.x());
|
||||
xx2=points_poly[points_poly.size()-1];
|
||||
const QPointF xx2p=points_poly[points_poly.size()-2];
|
||||
angle2=atan2(xx2p.y()-xx2.y(), xx2p.x()-xx2.x());
|
||||
painter.drawPolyline(points_poly.data(), points_poly.size());
|
||||
doDrawDecorator=true;
|
||||
/*for (auto& p: points_poly) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), JKQTPPlus, 5, 1, QColor("green"), QColor("darkgreen"));
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// potentially draw line-end decorators/arrows
|
||||
const double angle1=atan2(path[1].y()-path[0].y(), path[1].x()-path[0].x());
|
||||
const double angle2=atan2(path[path.size()-2].y()-path[path.size()-1].y(), path[path.size()-2].x()-path[path.size()-1].x());
|
||||
QPointF xx1=path[0], xx2=path[path.size()-1];
|
||||
QPointF lx1=xx1, lx2=xx2;
|
||||
JKQTPPlotLineDecorator(painter, xx1.x(), xx1.y(), angle1, getTailDecoratorStyle(), calcTailDecoratorSize(getLinePen(painter, getParent()).widthF()), &lx1);
|
||||
JKQTPPlotLineDecorator(painter, xx2.x(), xx2.y(), angle2, getHeadDecoratorStyle(), calcHeadDecoratorSize(getLinePen(painter, getParent()).widthF()), &lx2);
|
||||
path[0]=lx1;
|
||||
path[path.size()-1]=lx2;
|
||||
if (doDrawDecorator) {
|
||||
JKQTPPlotLineDecorator(painter, xx1.x(), xx1.y(), angle1, getTailDecoratorStyle(), calcTailDecoratorSize(getLinePen(painter, getParent()).widthF()));
|
||||
JKQTPPlotLineDecorator(painter, xx2.x(), xx2.y(), angle2, getHeadDecoratorStyle(), calcHeadDecoratorSize(getLinePen(painter, getParent()).widthF()));
|
||||
}
|
||||
|
||||
|
||||
// draw corrected line
|
||||
painter.drawPolyline(path.data(), path.size());
|
||||
for (const auto& p:points) {
|
||||
addHitTestData(p.x(), p.y());
|
||||
}
|
||||
@ -502,6 +682,50 @@ void JKQTPGeoPolyLines::appendPoint(const double x, const double y) {
|
||||
points.append(QPointF(x, y));
|
||||
}
|
||||
|
||||
int JKQTPGeoPolyLines::getPointCount() const
|
||||
{
|
||||
return points.size();
|
||||
}
|
||||
|
||||
const QPointF &JKQTPGeoPolyLines::getPoint(int i) const
|
||||
{
|
||||
return points[i];
|
||||
}
|
||||
|
||||
QPointF &JKQTPGeoPolyLines::getPoint(int i)
|
||||
{
|
||||
return points[i];
|
||||
}
|
||||
|
||||
void JKQTPGeoPolyLines::setPoint(int i, const QPointF &point)
|
||||
{
|
||||
points[i]=point;
|
||||
}
|
||||
|
||||
void JKQTPGeoPolyLines::removePoint(int i)
|
||||
{
|
||||
points.remove(i);
|
||||
}
|
||||
|
||||
QVector<QPointF>::iterator JKQTPGeoPolyLines::pointsBegin()
|
||||
{
|
||||
return points.begin();
|
||||
}
|
||||
|
||||
QVector<QPointF>::iterator JKQTPGeoPolyLines::pointsEnd()
|
||||
{
|
||||
return points.end();
|
||||
}
|
||||
|
||||
QVector<QPointF>::const_iterator JKQTPGeoPolyLines::pointsCBegin() const
|
||||
{
|
||||
return points.cbegin();
|
||||
}
|
||||
|
||||
QVector<QPointF>::const_iterator JKQTPGeoPolyLines::pointsCEnd() const
|
||||
{
|
||||
return points.cend();
|
||||
}
|
||||
|
||||
|
||||
JKQTPGeoArc::JKQTPGeoArc(JKQTBasePlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style):
|
||||
@ -514,7 +738,6 @@ JKQTPGeoArc::JKQTPGeoArc(JKQTBasePlotter* parent, double x, double y, double wid
|
||||
this->width=width;
|
||||
this->height=height;
|
||||
this->angle=0;
|
||||
this->controlPoints=180;
|
||||
}
|
||||
|
||||
JKQTPGeoArc::JKQTPGeoArc(JKQTPlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style):
|
||||
@ -524,23 +747,12 @@ JKQTPGeoArc::JKQTPGeoArc(JKQTPlotter* parent, double x, double y, double width,
|
||||
|
||||
|
||||
void JKQTPGeoArc::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPainterPath rect;
|
||||
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
const QPolygonF rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0,angleStart,angleStop, angle);
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.drawPath(rect);
|
||||
|
||||
}
|
||||
|
||||
void JKQTPGeoArc::setControlPoints(const unsigned int &__value)
|
||||
{
|
||||
this->controlPoints = __value;
|
||||
}
|
||||
|
||||
unsigned int JKQTPGeoArc::getControlPoints() const
|
||||
{
|
||||
return this->controlPoints;
|
||||
painter.drawPolyline(rect);
|
||||
}
|
||||
|
||||
void JKQTPGeoArc::setAngleStart(double __value)
|
||||
@ -583,6 +795,16 @@ double JKQTPGeoArc::getY() const
|
||||
return this->y;
|
||||
}
|
||||
|
||||
QPointF JKQTPGeoArc::getCenter() const
|
||||
{
|
||||
return QPointF(x, y);
|
||||
}
|
||||
|
||||
void JKQTPGeoArc::setCenter(const QPointF ¢er)
|
||||
{
|
||||
x=center.x();
|
||||
y=center.y();
|
||||
}
|
||||
void JKQTPGeoArc::setWidth(double __value)
|
||||
{
|
||||
this->width = __value;
|
||||
@ -603,6 +825,16 @@ double JKQTPGeoArc::getHeight() const
|
||||
return this->height;
|
||||
}
|
||||
|
||||
QSizeF JKQTPGeoArc::getSize() const
|
||||
{
|
||||
return QSizeF(width,height);
|
||||
}
|
||||
|
||||
void JKQTPGeoArc::setSize(const QSizeF &size)
|
||||
{
|
||||
width=size.width();
|
||||
height=size.height();
|
||||
}
|
||||
void JKQTPGeoArc::setAngle(double __value)
|
||||
{
|
||||
this->angle = __value;
|
||||
@ -616,7 +848,7 @@ double JKQTPGeoArc::getAngle() const
|
||||
|
||||
bool JKQTPGeoArc::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
||||
QPolygonF rect;
|
||||
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
rect=QPolygonF(JKQTPSplitEllipseIntoPoints(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, 180));
|
||||
minx=rect.boundingRect().left();
|
||||
maxx=rect.boundingRect().right();
|
||||
if (minx>maxx) std::swap(minx, maxx);
|
||||
@ -629,7 +861,7 @@ bool JKQTPGeoArc::getXMinMax(double& minx, double& maxx, double& smallestGreater
|
||||
|
||||
bool JKQTPGeoArc::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
||||
QPolygonF rect;
|
||||
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
rect=QPolygonF(JKQTPSplitEllipseIntoPoints(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, 180));
|
||||
miny=rect.boundingRect().bottom();
|
||||
maxy=rect.boundingRect().top();
|
||||
if (miny>maxy) std::swap(miny, maxy);
|
||||
|
@ -32,104 +32,204 @@
|
||||
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw a line, optionally line-end decorations (aka arrows) are pssible, but switched off by default.
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html JKQTPGeoLine_HeadTail.png
|
||||
|
||||
|
||||
\image html plot_geoline.png
|
||||
|
||||
|
||||
You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
|
||||
\code
|
||||
line->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
|
||||
line->setTailDecoratorStyle(JKQTPCircleDecorator);
|
||||
\endcode
|
||||
|
||||
This results in arrows drawn at the start (aka x1/y1, =tail) and end (aka x2/y2, =head) of the line.
|
||||
|
||||
|
||||
\note The convenience class JKQTPGeoArrow activates line-end decorations (aka arows) by default and allows to select them in the constructor.
|
||||
|
||||
\see JKQTPGeoArrow, \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
|
||||
|
||||
/** \brief This JKQTPPlotObject is used to draw a line, optionally line-end decorations (aka arrows) are pssible, but switched off by default.
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* \image html JKQTPGeoLine_HeadTail.png
|
||||
*
|
||||
*
|
||||
* \image html plot_geoline.png
|
||||
*
|
||||
* \note This class support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the line is drawn as a curves, instead of straight
|
||||
* a straight line. In the mode
|
||||
* JKQTPPlotObject::DrawMode::DrawAsGraphicElement the line is drawn as a straight line.
|
||||
*
|
||||
* You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
|
||||
* \code
|
||||
* line->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
|
||||
* line->setTailDecoratorStyle(JKQTPCircleDecorator);
|
||||
* \endcode
|
||||
*
|
||||
* This results in arrows drawn at the start (aka x1/y1, =tail) and end (aka x2/y2, =head) of the line.
|
||||
*
|
||||
*
|
||||
* \note The convenience class JKQTPGeoArrow activates line-end decorations (aka arows) by default and allows to select them in the constructor.
|
||||
*
|
||||
* \see JKQTPGeoArrow, \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
|
||||
*
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoLine: public JKQTPGeoBaseDecoratedLine {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
\param parent the parent plotter object
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoLine(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2, QColor color, double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
\param parent the parent plotter object
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoLine(JKQTPlotter* parent, double x1, double y1, double x2, double y2, QColor color, double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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
|
||||
*
|
||||
*/
|
||||
JKQTPGeoLine(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2);
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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
|
||||
*/
|
||||
JKQTPGeoLine(JKQTPlotter* parent, double x1, double y1, double x2, double y2);
|
||||
|
||||
|
||||
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param p1 first point of line (tail)
|
||||
* \param p2 second point of line (head)
|
||||
* \param color color of line
|
||||
* \param lineWidth width of line
|
||||
* \param style line style
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoLine(JKQTBasePlotter* parent, const QPointF& p1, const QPointF& p2, QColor color, double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param p1 first point of line (tail)
|
||||
* \param p2 second point of line (head)
|
||||
* \param color color of line
|
||||
* \param lineWidth width of line
|
||||
* \param style line style
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoLine(JKQTPlotter* parent, const QPointF& p1, const QPointF& p2, QColor color, double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param p1 first point of line (tail)
|
||||
* \param p2 second point of line (head)
|
||||
*
|
||||
*/
|
||||
JKQTPGeoLine(JKQTBasePlotter* parent, const QPointF& p1, const QPointF& p2);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param p1 first point of line (tail)
|
||||
* \param p2 second point of line (head)
|
||||
*/
|
||||
JKQTPGeoLine(JKQTPlotter* parent, const QPointF& p1, const QPointF& p2);
|
||||
|
||||
|
||||
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param line the line
|
||||
* \param color color of line
|
||||
* \param lineWidth width of line
|
||||
* \param style line style
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoLine(JKQTBasePlotter* parent, const QLineF& line, QColor color, double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param line the line
|
||||
* \param color color of line
|
||||
* \param lineWidth width of line
|
||||
* \param style line style
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoLine(JKQTPlotter* parent, const QLineF& line, QColor color, double lineWidth=1, Qt::PenStyle style=Qt::SolidLine);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param line the line
|
||||
*
|
||||
*/
|
||||
JKQTPGeoLine(JKQTBasePlotter* parent, const QLineF& line);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param line the line
|
||||
*/
|
||||
JKQTPGeoLine(JKQTPlotter* parent, const QLineF& line);
|
||||
|
||||
|
||||
|
||||
/** \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 */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the line will possibly be represented as a curve,
|
||||
* instead of a straight line.
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc x1 */
|
||||
/** \copydoc x1 */
|
||||
void setX1(double __value);
|
||||
/*! \copydoc x1 */
|
||||
/** \copydoc x1 */
|
||||
double getX1() const;
|
||||
/*! \copydoc y1 */
|
||||
/** \copydoc y1 */
|
||||
void setY1(double __value);
|
||||
/*! \copydoc y1 */
|
||||
/** \copydoc y1 */
|
||||
double getY1() const;
|
||||
/*! \copydoc x2 */
|
||||
/** \copydoc x2 */
|
||||
void setX2(double __value);
|
||||
/*! \copydoc x2 */
|
||||
/** \copydoc x2 */
|
||||
double getX2() const;
|
||||
/*! \copydoc y2 */
|
||||
/** \copydoc y2 */
|
||||
void setY2(double __value);
|
||||
/*! \copydoc y2 */
|
||||
/** \copydoc y2 */
|
||||
double getY2() const;
|
||||
|
||||
/** \brief return line-start/tail (x1,y1) as QPointF */
|
||||
QPointF getP1() const;
|
||||
/** \brief set line-start/tail (x1,y1) as QPointF */
|
||||
void setP1(const QPointF& p);
|
||||
/** \brief return line-end/head (x2,y2) as QPointF */
|
||||
QPointF getP2() const;
|
||||
/** \brief set line-end/head (x2,y2) as QPointF */
|
||||
void setP2(const QPointF& p);
|
||||
/** \brief return the line as a QLineF object */
|
||||
QLineF getLine() const;
|
||||
/** \brief define the line as a QLineF object */
|
||||
void setLine(const QLineF& line);
|
||||
protected:
|
||||
/** \brief x-coordinate of first point of line */
|
||||
double x1;
|
||||
@ -143,45 +243,45 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoLine: public JKQTPGeoBaseDecoratedLine {
|
||||
};
|
||||
|
||||
|
||||
/*! \brief This convenience specialisation of JKQTPGeoLine is used to draw a line with decorations (e.g. arrows)
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
This class does not add any functionality on top of JKQTPGeoLine, just activates line-end markers by default!
|
||||
|
||||
\image html JKQTPGeoLine_HeadTail.png
|
||||
|
||||
\image html plot_geoarrows.png
|
||||
|
||||
\see JKQTPLineDecoratorStyle, JKQTPGeoLine, \ref JKQTPlotterGeometricArrows and \ref JKQTPlotterGeometricGraphs
|
||||
|
||||
*/
|
||||
/** \brief This convenience specialisation of JKQTPGeoLine is used to draw a line with decorations (e.g. arrows)
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* This class does not add any functionality on top of JKQTPGeoLine, just activates line-end markers by default!
|
||||
*
|
||||
* \image html JKQTPGeoLine_HeadTail.png
|
||||
*
|
||||
* \image html plot_geoarrows.png
|
||||
*
|
||||
* \see JKQTPLineDecoratorStyle, JKQTPGeoLine, \ref JKQTPlotterGeometricArrows and \ref JKQTPlotterGeometricGraphs
|
||||
*
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoArrow: public JKQTPGeoLine {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
\param parent the parent plotter object
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoArrow(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2, QColor color, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator, double lineWidth=1.0, Qt::PenStyle style=Qt::SolidLine);
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
\param parent the parent plotter object
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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
|
||||
* \param parent the parent plotter object
|
||||
*/
|
||||
JKQTPGeoArrow(JKQTPlotter* parent, double x1, double y1, double x2, double y2, QColor color, JKQTPLineDecoratorStyle headStyle=JKQTPDefaultLineDecorator, JKQTPLineDecoratorStyle tailStyle=JKQTPNoDecorator, double lineWidth=1.0, Qt::PenStyle style=Qt::SolidLine);
|
||||
|
||||
@ -191,44 +291,50 @@ public:
|
||||
|
||||
|
||||
|
||||
/*! \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
|
||||
|
||||
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 .
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
|
||||
|
||||
/** \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
|
||||
*
|
||||
*
|
||||
* \note This class support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the line is drawn as a curves, instead of straight
|
||||
* a straight line. In the mode
|
||||
* JKQTPPlotObject::DrawMode::DrawAsGraphicElement the line is drawn as a straight line.
|
||||
*
|
||||
* 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 .
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
|
||||
*
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoInfiniteLine: public JKQTPGeoBaseDecoratedHeadLine {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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);
|
||||
|
||||
@ -238,29 +344,38 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoInfiniteLine: public JKQTPGeoBaseDecoratedH
|
||||
/** \copydoc JKQTPPlotObject::getYMinMax() */
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the line will possibly be represented as a curve,
|
||||
* instead of a straight line.
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc x */
|
||||
/** \copydoc x */
|
||||
void setX(double __value);
|
||||
/*! \copydoc x */
|
||||
/** \copydoc x */
|
||||
double getX() const;
|
||||
/*! \copydoc y */
|
||||
/** \copydoc y */
|
||||
void setY(double __value);
|
||||
/*! \copydoc y */
|
||||
/** \copydoc y */
|
||||
double getY() const;
|
||||
/*! \copydoc dx */
|
||||
/** \copydoc dx */
|
||||
void setDx(double __value);
|
||||
/*! \copydoc dx */
|
||||
/** \copydoc dx */
|
||||
double getDx() const;
|
||||
/*! \copydoc dy */
|
||||
/** \copydoc dy */
|
||||
void setDy(double __value);
|
||||
/*! \copydoc dy */
|
||||
/** \copydoc dy */
|
||||
double getDy() const;
|
||||
/*! \copydoc two_sided */
|
||||
/** \copydoc two_sided */
|
||||
void setTwoSided(bool __value);
|
||||
/*! \copydoc two_sided */
|
||||
/** \copydoc two_sided */
|
||||
bool getTwoSided() const;
|
||||
/** \brief return point (x,y) on the line as QPointF */
|
||||
QPointF getP() const;
|
||||
/** \brief set point (x,y) on the line as QPointF */
|
||||
void setP(const QPointF& p);
|
||||
protected:
|
||||
/** \brief x-coordinate of a point on the line */
|
||||
double x;
|
||||
@ -276,58 +391,65 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoInfiniteLine: public JKQTPGeoBaseDecoratedH
|
||||
};
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw a poly line
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html plot_geolines.png
|
||||
|
||||
You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
|
||||
\code
|
||||
polyLine->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
|
||||
polyLine->setTailDecoratorStyle(JKQTPCircleDecorator);
|
||||
\endcode
|
||||
|
||||
This results in arrows drawn at the start (=tail) and end (=head) of the poly-line:
|
||||
\image html geo_arrow_polylines.png
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
|
||||
|
||||
/** \brief This JKQTPPlotObject is used to draw a poly line
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* \image html plot_geolines.png
|
||||
*
|
||||
* \note This class support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the points of the poly-line will be possibly
|
||||
* connected by curves, instead of straight lines. In the mode
|
||||
* JKQTPPlotObject::DrawMode::DrawAsGraphicElement the points are connected by straight
|
||||
* lines, independent of the linearity or non-linearity of the coordinate axes.
|
||||
*
|
||||
* You can also activate line-end decorators (aka arrows) for this poly-line, by using code like this:
|
||||
* \code
|
||||
* polyLine->setHeadDecoratorStyle(JKQTPFilledDoubleArrow);
|
||||
* polyLine->setTailDecoratorStyle(JKQTPCircleDecorator);
|
||||
* \endcode
|
||||
*
|
||||
* This results in arrows drawn at the start (=tail) and end (=head) of the poly-line:
|
||||
*
|
||||
* \image html geo_arrow_polylines.png
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs and \ref JKQTPlotterGeometricArrows
|
||||
*
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolyLines: public JKQTPGeoBaseDecoratedLine {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\param points points on the polygon
|
||||
\param color color of line
|
||||
\param lineWidth width of line
|
||||
\param style line style
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\param points points on the polygon
|
||||
\param color color of line
|
||||
\param lineWidth width of line
|
||||
\param style line style
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\param color color of line
|
||||
\param lineWidth width of line
|
||||
\param style line style
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\param color color of line
|
||||
\param lineWidth width of line
|
||||
\param style line style
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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);
|
||||
|
||||
@ -337,62 +459,95 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolyLines: public JKQTPGeoBaseDecoratedLine
|
||||
/** \copydoc JKQTPPlotObject::getYMinMax() */
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the points of the poly-line will be possibly
|
||||
* connected by curves, instead of straight lines. In the mode
|
||||
* JKQTPPlotObject::DrawMode::DrawAsGraphicElement the points are connected by straight
|
||||
* lines, independent of the linearity or non-linearity of the coordinate axes.
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc points */
|
||||
/** \copydoc points */
|
||||
void setPoints(const QVector<QPointF> & __value);
|
||||
/*! \copydoc points */
|
||||
/** \copydoc points */
|
||||
QVector<QPointF> getPoints() const;
|
||||
|
||||
/** \brief append a point to the polygon */
|
||||
/** \brief append a point to the polygon \see points */
|
||||
void appendPoint(const QPointF& p);
|
||||
|
||||
/** \brief append a point to the polygon */
|
||||
/** \brief append a point to the polygon \see points */
|
||||
void appendPoint(const double x, const double y);
|
||||
|
||||
/** \brief returns the number of points \see points */
|
||||
int getPointCount() const;
|
||||
/** \brief returns the i-th of point \see points */
|
||||
const QPointF& getPoint(int i) const;
|
||||
/** \brief returns the i-th of point \see points */
|
||||
QPointF& getPoint(int i);
|
||||
/** \brief overwrites the i-th point \see points */
|
||||
void setPoint(int i, const QPointF& point);
|
||||
/** \brief deletes the i-the point \see points */
|
||||
void removePoint(int i);
|
||||
/** \brief returns an iterator to the first point \see points */
|
||||
QVector<QPointF>::iterator pointsBegin();
|
||||
/** \brief returns an iterator after the last point \see points */
|
||||
QVector<QPointF>::iterator pointsEnd();
|
||||
/** \brief returns a constant iterator to the first point \see points */
|
||||
QVector<QPointF>::const_iterator pointsCBegin() const;
|
||||
/** \brief returns a constant iterator after the last point \see points */
|
||||
QVector<QPointF>::const_iterator pointsCEnd() const;
|
||||
protected:
|
||||
/** \brief list with all points on the poly-line */
|
||||
QVector<QPointF> points;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw an arc
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html plot_geoarc.png
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs
|
||||
/** \brief This JKQTPPlotObject is used to draw an arc
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
*
|
||||
* A pie on linear and log-log axes (start angle: 10deg and end-angle 110deg):
|
||||
*
|
||||
* \image html plot_geopie.png
|
||||
*
|
||||
* \note This class support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that arcs are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for arcs on non-linear axes could be found!
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs, JKQTPGeoChord, JKQTPGeoPie, JKQTPGeoEllipse
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoArc: public JKQTPGeoBaseLine {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
/** \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
\param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
\param color color of line
|
||||
\param lineWidth width of line
|
||||
\param style line style
|
||||
* \param parent the parent plotter object
|
||||
* \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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
* \param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
* \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
|
||||
/** \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
\param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
\param color color of line
|
||||
\param lineWidth width of line
|
||||
\param style line style
|
||||
* \param parent the parent plotter object
|
||||
* \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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
* \param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
* \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);
|
||||
@ -403,40 +558,50 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoArc: public JKQTPGeoBaseLine {
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that arcs are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for arcs on non-linear axes could be found!
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc controlPoints */
|
||||
void setControlPoints(const unsigned int & __value);
|
||||
/*! \copydoc controlPoints */
|
||||
unsigned int getControlPoints() const;
|
||||
/*! \copydoc angleStart */
|
||||
|
||||
/** \copydoc angleStart */
|
||||
void setAngleStart(double __value);
|
||||
/*! \copydoc angleStart */
|
||||
/** \copydoc angleStart */
|
||||
double getAngleStart() const;
|
||||
/*! \copydoc angleStop */
|
||||
/** \copydoc angleStop */
|
||||
void setAngleStop(double __value);
|
||||
/*! \copydoc angleStop */
|
||||
/** \copydoc angleStop */
|
||||
double getAngleStop() const;
|
||||
/*! \copydoc x */
|
||||
/** \copydoc x */
|
||||
void setX(double __value);
|
||||
/*! \copydoc x */
|
||||
/** \copydoc x */
|
||||
double getX() const;
|
||||
/*! \copydoc y */
|
||||
/** \copydoc y */
|
||||
void setY(double __value);
|
||||
/*! \copydoc y */
|
||||
/** \copydoc y */
|
||||
double getY() const;
|
||||
/*! \copydoc width */
|
||||
/** \brief returns the center point of the arc */
|
||||
QPointF getCenter() const;
|
||||
/** \brief sets the center point of the arc */
|
||||
void setCenter(const QPointF& center);
|
||||
/** \copydoc width */
|
||||
void setWidth(double __value);
|
||||
/*! \copydoc width */
|
||||
/** \copydoc width */
|
||||
double getWidth() const;
|
||||
/*! \copydoc height */
|
||||
/** \copydoc height */
|
||||
void setHeight(double __value);
|
||||
/*! \copydoc height */
|
||||
/** \copydoc height */
|
||||
double getHeight() const;
|
||||
/*! \copydoc angle */
|
||||
/** \brief returns the size (width and height) of the arc */
|
||||
QSizeF getSize() const;
|
||||
/** \brief sets the size (width and height) of the arc */
|
||||
void setSize(const QSizeF& size);
|
||||
/** \copydoc angle */
|
||||
void setAngle(double __value);
|
||||
/*! \copydoc angle */
|
||||
/** \copydoc angle */
|
||||
double getAngle() const;
|
||||
protected:
|
||||
/** \brief x-coordinate of a center of the rectangle */
|
||||
@ -453,8 +618,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoArc: public JKQTPGeoBaseLine {
|
||||
double angleStart;
|
||||
/** \brief if we only draw an arc, this is the ending angle in degrees */
|
||||
double angleStop;
|
||||
/** \brief number of steps/control points to draw the ellipse */
|
||||
unsigned int controlPoints;
|
||||
|
||||
|
||||
/** \brief closing mode for arcs: secand or pie */
|
||||
/** \brief returns the transformation matrix used for this rectangle */
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "jkqtplotter/graphs/jkqtpgeoshapes.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtcommon/jkqtpgeometrytools.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
@ -31,8 +32,8 @@
|
||||
|
||||
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent, drawMode)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
@ -41,18 +42,13 @@ JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter* parent, double x, double y
|
||||
this->height=height;
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent->getPlotter(), x, y, width, height, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
angle=0;
|
||||
this->width=width;
|
||||
this->height=height;
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent, drawMode)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
@ -61,18 +57,13 @@ JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, double x, double y
|
||||
this->height=height;
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent->getPlotter(), x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
this->angle=angle;
|
||||
this->width=width;
|
||||
this->height=height;
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent, drawMode)
|
||||
{
|
||||
this->angle=0;
|
||||
this->width=fabs(topright.x()-bottomleft.x());
|
||||
@ -81,14 +72,33 @@ JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, QPointF bottomleft
|
||||
this->y=bottomleft.y()+this->height/2.0;
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent->getPlotter(), bottomleft, topright, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
this->angle=0;
|
||||
this->width=fabs(topright.x()-bottomleft.x());
|
||||
this->height=fabs(topright.y()-bottomleft.y());
|
||||
this->x=bottomleft.x()+this->width/2.0;
|
||||
this->y=bottomleft.y()+this->height/2.0;
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, const QPointF ¢er, const QSizeF &size, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, JKQTPPlotObject::DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent, center.x(), center.y(), size.width(), size.height(), angle, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, const QPointF ¢er, const QSizeF &size, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, JKQTPPlotObject::DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent->getPlotter(), center, size, angle, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, const QPointF ¢er, const QSizeF &size, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, JKQTPPlotObject::DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent, center.x(), center.y(), size.width(), size.height(), color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, const QPointF ¢er, const QSizeF &size, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, JKQTPPlotObject::DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent->getPlotter(), center, size, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QTransform JKQTPGeoRectangle::getTransform() {
|
||||
@ -129,6 +139,7 @@ QPolygonF JKQTPGeoRectangle::getPolygon() {
|
||||
rect.append(m.map(QPointF(0-width/2.0, 0+height/2.0)));
|
||||
rect.append(m.map(QPointF(0+width/2.0, 0+height/2.0)));
|
||||
rect.append(m.map(QPointF(0+width/2.0, 0-height/2.0)));
|
||||
rect.append(m.map(QPointF(0-width/2.0, 0-height/2.0)));
|
||||
rect.translate(x,y);
|
||||
return rect;
|
||||
}
|
||||
@ -138,8 +149,11 @@ void JKQTPGeoRectangle::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPolygonF poly=getPolygon();
|
||||
reserveHitTestData(poly.size());
|
||||
QPolygonF rect;
|
||||
for (int i=0; i<poly.size(); i++) {
|
||||
rect.append(QPointF(transformX(poly[i].x()), transformY(poly[i].y())));
|
||||
if ((getDrawMode()==DrawAsGraphicElement) || (getParent()->getXAxis()->isLinearAxis() && getParent()->getYAxis()->isLinearAxis())) {
|
||||
rect=transform(poly);
|
||||
} else {
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
rect=JKQTPSplitPolylineIntoPoints(poly, fTransform);
|
||||
}
|
||||
for (const auto& p:poly) {
|
||||
addHitTestData(p.x(), p.y());
|
||||
@ -172,6 +186,17 @@ double JKQTPGeoRectangle::getY() const
|
||||
return this->y;
|
||||
}
|
||||
|
||||
QPointF JKQTPGeoRectangle::getCenter() const
|
||||
{
|
||||
return QPointF(x, y);
|
||||
}
|
||||
|
||||
void JKQTPGeoRectangle::setCenter(const QPointF ¢er)
|
||||
{
|
||||
x=center.x();
|
||||
y=center.y();
|
||||
}
|
||||
|
||||
void JKQTPGeoRectangle::setWidth(double __value)
|
||||
{
|
||||
this->width = __value;
|
||||
@ -192,6 +217,17 @@ double JKQTPGeoRectangle::getHeight() const
|
||||
return this->height;
|
||||
}
|
||||
|
||||
QSizeF JKQTPGeoRectangle::getSize() const
|
||||
{
|
||||
return QSizeF(width,height);
|
||||
}
|
||||
|
||||
void JKQTPGeoRectangle::setSize(const QSizeF &size)
|
||||
{
|
||||
width=size.width();
|
||||
height=size.height();
|
||||
}
|
||||
|
||||
void JKQTPGeoRectangle::setAngle(double __value)
|
||||
{
|
||||
this->angle = __value;
|
||||
@ -202,33 +238,44 @@ double JKQTPGeoRectangle::getAngle() const
|
||||
return this->angle;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGeoRectangle::setBottomleftrectangle(double x, double y, double width, double height) {
|
||||
void JKQTPGeoRectangle::setBottomLeftRectangle(double x, double y, double width, double height)
|
||||
{
|
||||
this->x=x+width/2.0;
|
||||
this->y=y+height/2.0;
|
||||
this->width=width;
|
||||
this->height=height;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGeoRectangle::setBottomLeftRectangle(const QRectF &rect) {
|
||||
setBottomLeftRectangle(rect.x(), rect.y(), rect.width(), rect.height());
|
||||
}
|
||||
|
||||
QRectF JKQTPGeoRectangle::getBottomLeftRectangle() const
|
||||
{
|
||||
return QRectF(x-width/2.0, y-height/2.0, width, height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent, drawMode)
|
||||
{
|
||||
this->points=points;
|
||||
}
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoPolygon(parent->getPlotter(), points, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
this->points=points;
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter* parent, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter* parent, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent, drawMode)
|
||||
{
|
||||
}
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter* parent, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter* parent, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoPolygon(parent->getPlotter(), color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
}
|
||||
|
||||
@ -272,16 +319,32 @@ bool JKQTPGeoPolygon::getYMinMax(double& miny, double& maxy, double& smallestGre
|
||||
|
||||
void JKQTPGeoPolygon::draw(JKQTPEnhancedPainter& painter) {
|
||||
clearHitTestData();
|
||||
reserveHitTestData(points.size());
|
||||
QPolygonF path=transformToPolygon(points);
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
painter.drawPolygon(path);
|
||||
for (const auto& p:points) {
|
||||
addHitTestData(p.x(), p.y());
|
||||
}
|
||||
if (points.size()>=2) {
|
||||
reserveHitTestData(points.size());
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
if ((getDrawMode()==DrawAsGraphicElement) || (getParent()->getXAxis()->isLinearAxis() && getParent()->getYAxis()->isLinearAxis())) {
|
||||
const QPolygonF path=transformToPolygon(points);
|
||||
painter.drawPolygon(path);
|
||||
} else {
|
||||
// for non-linear axes, a line might not be drawn as a line, so we need to segment the line (i.e. linear function in coordinate space)
|
||||
// and transform each node to draw the corresponding non-linear curve in pixel-space!
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QVector<QPointF> polyp=points;
|
||||
if (polyp.first()!=polyp.last()) polyp.push_back(polyp.first());
|
||||
QPolygonF path=JKQTPSplitPolylineIntoPoints(polyp, fTransform);
|
||||
path=JKQTPSimplyfyLineSegemnts(path);
|
||||
painter.drawPolygon(path);
|
||||
}
|
||||
|
||||
|
||||
for (const auto& p:points) {
|
||||
addHitTestData(p.x(), p.y());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPGeoPolygon::setPoints(const QVector<QPointF> &__value)
|
||||
@ -302,65 +365,116 @@ void JKQTPGeoPolygon::appendPoint(const double x, const double y) {
|
||||
points.append(QPointF(x, y));
|
||||
}
|
||||
|
||||
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoRectangle(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
||||
int JKQTPGeoPolygon::getPointCount() const
|
||||
{
|
||||
controlPoints=180;
|
||||
return points.size();
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoRectangle(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
||||
const QPointF &JKQTPGeoPolygon::getPoint(int i) const
|
||||
{
|
||||
controlPoints=180;
|
||||
return points[i];
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoRectangle(parent, x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle)
|
||||
QPointF &JKQTPGeoPolygon::getPoint(int i)
|
||||
{
|
||||
controlPoints=180;
|
||||
return points[i];
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoRectangle(parent, x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle)
|
||||
void JKQTPGeoPolygon::setPoint(int i, const QPointF &point)
|
||||
{
|
||||
controlPoints=180;
|
||||
points[i]=point;
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoRectangle(parent, bottomleft, topright, color, lineWidth, style, fillColor, fillStyle)
|
||||
void JKQTPGeoPolygon::removePoint(int i)
|
||||
{
|
||||
controlPoints=180;
|
||||
points.remove(i);
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoRectangle(parent, bottomleft, topright, color, lineWidth, style, fillColor, fillStyle)
|
||||
QVector<QPointF>::iterator JKQTPGeoPolygon::pointsBegin()
|
||||
{
|
||||
controlPoints=180;
|
||||
return points.begin();
|
||||
}
|
||||
|
||||
QVector<QPointF>::iterator JKQTPGeoPolygon::pointsEnd()
|
||||
{
|
||||
return points.end();
|
||||
}
|
||||
|
||||
QVector<QPointF>::const_iterator JKQTPGeoPolygon::pointsCBegin() const
|
||||
{
|
||||
return points.cbegin();
|
||||
}
|
||||
|
||||
QVector<QPointF>::const_iterator JKQTPGeoPolygon::pointsCEnd() const
|
||||
{
|
||||
return points.cend();
|
||||
}
|
||||
|
||||
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoEllipse(parent->getPlotter(), x, y, width, height, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent, x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoEllipse(parent->getPlotter(), x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoRectangle(parent, bottomleft, topright, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoEllipse(parent->getPlotter(), bottomleft, topright, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGeoEllipse::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPainterPath rect;
|
||||
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,0,360,angle, controlPoints));
|
||||
rect.closeSubpath();
|
||||
drawInternal(painter, 0, 0, InternalDrawMode::Ellipse);
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGeoEllipse::drawInternal(JKQTPEnhancedPainter& painter, double angleStart, double angleStop, JKQTPGeoEllipse::InternalDrawMode mode)
|
||||
{
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
painter.drawPath(rect);
|
||||
|
||||
}
|
||||
|
||||
void JKQTPGeoEllipse::setControlPoints(const unsigned int &__value)
|
||||
{
|
||||
this->controlPoints = __value;
|
||||
}
|
||||
auto fTransform=std::bind([](const JKQTPPlotObject* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QPolygonF rect;
|
||||
if(mode==InternalDrawMode::Ellipse) {
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0,0,360, angle);
|
||||
} else if (mode==InternalDrawMode::Pie) {
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0,angleStart,angleStop, angle);
|
||||
rect.append(transform(x,y));
|
||||
} else if (mode==InternalDrawMode::Chord) {
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0,angleStart,angleStop, angle);
|
||||
}
|
||||
painter.drawPolygon(rect);
|
||||
|
||||
|
||||
unsigned int JKQTPGeoEllipse::getControlPoints() const
|
||||
{
|
||||
return this->controlPoints;
|
||||
}
|
||||
|
||||
|
||||
@ -369,33 +483,22 @@ unsigned int JKQTPGeoEllipse::getControlPoints() const
|
||||
|
||||
|
||||
|
||||
JKQTPGeoPie::JKQTPGeoPie(JKQTBasePlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoEllipse(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
||||
JKQTPGeoPie::JKQTPGeoPie(JKQTBasePlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoEllipse(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
this->angleStart=angleStart;
|
||||
this->angleStop=angleStop;
|
||||
}
|
||||
|
||||
JKQTPGeoPie::JKQTPGeoPie(JKQTPlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoEllipse(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
||||
JKQTPGeoPie::JKQTPGeoPie(JKQTPlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoPie(parent->getPlotter(), x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
this->angleStart=angleStart;
|
||||
this->angleStop=angleStop;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGeoPie::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPainterPath rect;
|
||||
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
rect.lineTo(transform(x,y));
|
||||
rect.closeSubpath();
|
||||
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePenForRects(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
painter.drawPath(rect);
|
||||
|
||||
drawInternal(painter, angleStart, angleStop, InternalDrawMode::Pie);
|
||||
}
|
||||
|
||||
void JKQTPGeoPie::setAngleStart(double __value)
|
||||
@ -419,8 +522,7 @@ double JKQTPGeoPie::getAngleStop() const
|
||||
}
|
||||
|
||||
bool JKQTPGeoPie::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
||||
QPolygonF rect;
|
||||
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
QPolygonF rect=QPolygonF(JKQTPSplitEllipseIntoPoints(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, 180));
|
||||
rect.append(QPointF(x,y));
|
||||
minx=rect.boundingRect().left();
|
||||
maxx=rect.boundingRect().right();
|
||||
@ -433,8 +535,7 @@ bool JKQTPGeoPie::getXMinMax(double& minx, double& maxx, double& smallestGreater
|
||||
}
|
||||
|
||||
bool JKQTPGeoPie::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
||||
QPolygonF rect;
|
||||
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
QPolygonF rect=QPolygonF(JKQTPSplitEllipseIntoPoints(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, 180));
|
||||
rect.append(QPointF(x,y));
|
||||
miny=rect.boundingRect().bottom();
|
||||
maxy=rect.boundingRect().top();
|
||||
@ -449,35 +550,25 @@ bool JKQTPGeoPie::getYMinMax(double& miny, double& maxy, double& smallestGreater
|
||||
|
||||
|
||||
|
||||
JKQTPGeoChord::JKQTPGeoChord(JKQTBasePlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoPie(parent, x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle)
|
||||
JKQTPGeoChord::JKQTPGeoChord(JKQTBasePlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoPie(parent, x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPGeoChord::JKQTPGeoChord(JKQTPlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
||||
JKQTPGeoPie(parent, x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle)
|
||||
JKQTPGeoChord::JKQTPGeoChord(JKQTPlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle, DrawMode drawMode):
|
||||
JKQTPGeoChord(parent->getPlotter(), x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle, drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGeoChord::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPainterPath rect;
|
||||
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
rect.closeSubpath();
|
||||
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
painter.drawPath(rect);
|
||||
|
||||
drawInternal(painter, angleStart, angleStop, InternalDrawMode::Chord);
|
||||
}
|
||||
|
||||
bool JKQTPGeoChord::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
||||
QPolygonF rect;
|
||||
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
const QPolygonF rect=QPolygonF(JKQTPSplitEllipseIntoPoints(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, 180));
|
||||
minx=rect.boundingRect().left();
|
||||
maxx=rect.boundingRect().right();
|
||||
if (minx>maxx) std::swap(minx, maxx);
|
||||
@ -488,8 +579,7 @@ bool JKQTPGeoChord::getXMinMax(double& minx, double& maxx, double& smallestGreat
|
||||
}
|
||||
|
||||
bool JKQTPGeoChord::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
||||
QPolygonF rect;
|
||||
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
||||
const QPolygonF rect=QPolygonF(JKQTPSplitEllipseIntoPoints(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, 180));
|
||||
miny=rect.boundingRect().bottom();
|
||||
maxy=rect.boundingRect().top();
|
||||
if (miny>maxy) std::swap(miny, maxy);
|
||||
|
@ -33,98 +33,154 @@
|
||||
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw a rectangle
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html plot_georectangle.png
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs
|
||||
/** \brief This JKQTPPlotObject is used to draw a rectangle
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* \image html plot_georectangle.png
|
||||
*
|
||||
* \note This class support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the corner points of the rectangle will be possibly
|
||||
* connected by curves, instead of straight lines. In the mode
|
||||
* JKQTPPlotObject::DrawMode::DrawAsGraphicElement the corners are connected by straight
|
||||
* lines, independent of the linearity or non-linearity of the coordinate axes.
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoRectangle: public JKQTPGeoBaseFilled {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, 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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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);
|
||||
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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param center center of rectangle
|
||||
* \param size width and heigt 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, const QPointF& center, const QSizeF& size, double angle, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param center center of rectangle
|
||||
* \param size width and heigt 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, const QPointF& center, const QSizeF& size, double angle, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param center center of rectangle
|
||||
* \param size width and heigt 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, const QPointF& center, const QSizeF& size, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param center center of rectangle
|
||||
* \param size width and heigt 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, const QPointF& center, const QSizeF& size, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
|
||||
|
||||
@ -133,7 +189,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoRectangle: public JKQTPGeoBaseFilled {
|
||||
/** \copydoc JKQTPPlotObject::getYMinMax() */
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the corner points of the rectangle will be possibly
|
||||
* connected by curves, instead of straight lines.
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc x */
|
||||
@ -144,6 +205,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoRectangle: public JKQTPGeoBaseFilled {
|
||||
void setY(double __value);
|
||||
/*! \copydoc y */
|
||||
double getY() const;
|
||||
/** \brief returns the center point of the rectangle */
|
||||
QPointF getCenter() const;
|
||||
/** \brief sets the center point of the rectangle */
|
||||
void setCenter(const QPointF& center);
|
||||
/*! \copydoc width */
|
||||
void setWidth(double __value);
|
||||
/*! \copydoc width */
|
||||
@ -152,13 +217,28 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoRectangle: public JKQTPGeoBaseFilled {
|
||||
void setHeight(double __value);
|
||||
/*! \copydoc height */
|
||||
double getHeight() const;
|
||||
/*! \copydoc angle */
|
||||
/** \brief returns the size (width and height) of the rectangle */
|
||||
QSizeF getSize() const;
|
||||
/** \brief sets the size (width and height) of the rectangle */
|
||||
void setSize(const QSizeF& size);
|
||||
/*! \copydoc angle */
|
||||
void setAngle(double __value);
|
||||
/*! \copydoc angle */
|
||||
double getAngle() const;
|
||||
/** \brief set the rectangle using the bottom-left corner, as well as its width and height */
|
||||
void setBottomleftrectangle(double x, double y, double width, double height);
|
||||
protected:
|
||||
void setBottomLeftRectangle(double x, double y, double width, double height);
|
||||
/** \brief set the rectangle using the bottom-left corner, as well as its width and height */
|
||||
void setBottomLeftRectangle(const QRectF& rect);
|
||||
/** \brief returns the rectangle using the bottom-left corner, as well as its width and height, ignoring the rotation angle!!!
|
||||
*
|
||||
* This is equivalent to
|
||||
* \code
|
||||
* QRectF result(x-width/2.0, y-height/2.0, width, height);
|
||||
* \endcode
|
||||
*/
|
||||
QRectF getBottomLeftRectangle() const;
|
||||
|
||||
protected:
|
||||
/** \brief x-coordinate of a center of the rectangle */
|
||||
double x;
|
||||
/** \brief y-coordinate of a center of the rectangle */
|
||||
@ -176,62 +256,64 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw a polygon
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html plot_geopolygon.png
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs
|
||||
|
||||
/** \brief This JKQTPPlotObject is used to draw a polygon
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* \image html plot_geopolygon.png
|
||||
*
|
||||
* \note This function support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the points of the polygon will be possibly
|
||||
* connected by curves, instead of straight lines.
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs
|
||||
*
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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);
|
||||
JKQTPGeoPolygon(JKQTPlotter* parent, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
|
||||
/** \copydoc JKQTPPlotObject::getXMinMax() */
|
||||
@ -239,7 +321,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
|
||||
/** \copydoc JKQTPPlotObject::getYMinMax() */
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve. If set,
|
||||
* and non-linear axes are chosen, the points of the polygon will be possibly
|
||||
* connected by curves, instead of straight lines.
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc points */
|
||||
@ -247,172 +334,225 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
|
||||
/*! \copydoc points */
|
||||
QVector<QPointF> getPoints() const;
|
||||
|
||||
/** \brief append a point to the polygon */
|
||||
/** \brief append a point to the polygon \see points */
|
||||
void appendPoint(const QPointF& p);
|
||||
|
||||
/** \brief append a point to the polygon */
|
||||
/** \brief append a point to the polygon \see points */
|
||||
void appendPoint(const double x, const double y);
|
||||
|
||||
/** \brief returns the number of points \see points */
|
||||
int getPointCount() const;
|
||||
/** \brief returns the i-th of point \see points */
|
||||
const QPointF& getPoint(int i) const;
|
||||
/** \brief returns the i-th of point \see points */
|
||||
QPointF& getPoint(int i);
|
||||
/** \brief overwrites the i-th point \see points */
|
||||
void setPoint(int i, const QPointF& point);
|
||||
/** \brief deletes the i-the point \see points */
|
||||
void removePoint(int i);
|
||||
/** \brief returns an iterator to the first point \see points */
|
||||
QVector<QPointF>::iterator pointsBegin();
|
||||
/** \brief returns an iterator after the last point \see points */
|
||||
QVector<QPointF>::iterator pointsEnd();
|
||||
/** \brief returns a constant iterator to the first point \see points */
|
||||
QVector<QPointF>::const_iterator pointsCBegin() const;
|
||||
/** \brief returns a constant iterator after the last point \see points*/
|
||||
QVector<QPointF>::const_iterator pointsCEnd() const;
|
||||
|
||||
protected:
|
||||
/** \brief list with all points on the polygon */
|
||||
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>
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs
|
||||
/** \brief This JKQTPPlotObject is used to draw an ellipse
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* \image html plot_geoellipse.png
|
||||
*
|
||||
* \image html plot_geoellipse_rotated.png
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that ellipses are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for ellipses on non-linear axes could be found! In the mode
|
||||
* JKQTPPlotObject::DrawMode::DrawAsGraphicElement the points are connected by straight
|
||||
* lines, independent of the linearity or non-linearity of the coordinate axes.
|
||||
*
|
||||
* \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>
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs, JKQTPGeoPie, JKQTPGeoChord, JKQTPGeoArc
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoEllipse: public JKQTPGeoRectangle {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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);
|
||||
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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 object
|
||||
\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, QColor color=QColor("black"), double lineWidth=1, Qt::PenStyle style=Qt::SolidLine, QColor fillColor=QColor("transparent"), Qt::BrushStyle fillStyle=Qt::SolidPattern, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param x x-coordinate of center of ellipse
|
||||
* \param y y-coordinate of center of ellipse
|
||||
* \param width width of rectangle
|
||||
* \param height of rectangle
|
||||
* \param angle rotation angle of the ellipse
|
||||
* \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, 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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param x x-coordinate of center of ellipse
|
||||
* \param y y-coordinate of center of ellipse
|
||||
* \param width width of rectangle
|
||||
* \param height of rectangle
|
||||
* \param angle rotation angle of the ellipse
|
||||
* \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, 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 object
|
||||
\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, 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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param bottomleft bottom left corner of ellipse
|
||||
* \param topright top right corner of ellipse
|
||||
* \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, 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 object
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param bottomleft bottom left corner of ellipse
|
||||
* \param topright top right corner of ellipse
|
||||
* \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, 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);
|
||||
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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that ellipses are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for ellipses on non-linear axes could be found!*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc controlPoints */
|
||||
void setControlPoints(const unsigned int & __value);
|
||||
/*! \copydoc controlPoints */
|
||||
unsigned int getControlPoints() const;
|
||||
protected:
|
||||
/** \brief number of steps/control points to draw the ellipse */
|
||||
unsigned int controlPoints;
|
||||
|
||||
/** \brief drawing modes for drawInternal() */
|
||||
enum class InternalDrawMode {
|
||||
Ellipse,
|
||||
Pie,
|
||||
Chord
|
||||
};
|
||||
|
||||
/** \brief inertnal draw function, can draw an ellipse, a pie or a chord! */
|
||||
void drawInternal(JKQTPEnhancedPainter& painter, double angleStart=0, double angleStop=0, InternalDrawMode mode=InternalDrawMode::Ellipse);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw a pie
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html plot_geopie.png
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs
|
||||
/** \brief This JKQTPPlotObject is used to draw a pie
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
*
|
||||
* A pie on linear and log-log axes (start angle: 10deg and end-angle 110deg):
|
||||
* \image html plot_geopie.png
|
||||
*
|
||||
* Here is the code to generate the plots above:
|
||||
* \code
|
||||
* plot->addGraph(new JKQTPGeoRectangle(plot,3.5,0.5,0.9,0.9, QColor("silver"), 1, Qt::PenStyle::DashLine));
|
||||
* plot->addGraph(new JKQTPGeoEllipse(plot,3.5,0.5,0.9,0.9, QColor("silver"), 1, Qt::PenStyle::DashLine));
|
||||
* plot->addGraph(new JKQTPGeoPie(plot,3.5,0.5,0.9,0.9, 10, 110 , QColor("blue"), 4, Qt::PenStyle::SolidLine,QColor("lightblue")));
|
||||
* plot->addGraph(new JKQTPGeoSymbol(plot, 3.5,0.5, JKQTPCircle, 5, QColor("grey")));
|
||||
* plot->addGraph(new JKQTPGeoLine(plot, 3.5,0.5,3.5+0.5*cos(10.0/180.0*JKQTPSTATISTICS_PI),0.5+0.5*sin(10.0/180.0*JKQTPSTATISTICS_PI), QColor("grey")));
|
||||
* plot->addGraph(new JKQTPGeoText(plot, 3.5+0.55*cos(10.0/180.0*JKQTPSTATISTICS_PI),0.5+0.55*sin(10.0/180.0*JKQTPSTATISTICS_PI), "10\\degree", 10, QColor("grey")));
|
||||
* plot->addGraph(new JKQTPGeoLine(plot, 3.5,0.5,3.5+0.5*cos(110.0/180.0*JKQTPSTATISTICS_PI),0.5+0.5*sin(110.0/180.0*JKQTPSTATISTICS_PI), QColor("grey")));
|
||||
* plot->addGraph(new JKQTPGeoText(plot, 3.5+0.55*cos(110.0/180.0*JKQTPSTATISTICS_PI),0.5+0.55*sin(110.0/180.0*JKQTPSTATISTICS_PI), "110\\degree", 10, QColor("grey")));
|
||||
* \endcode
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that pies are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for pies on non-linear axes could be found!
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs, JKQTPGeoEllipse, JKQTPGeoChord, JKQTPGeoArc
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPie: public JKQTPGeoEllipse {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
\param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
* \param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
* \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 object
|
||||
\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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
\param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
* \param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
* \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);
|
||||
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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
|
||||
/** \copydoc JKQTPPlotObject::getXMinMax() */
|
||||
@ -421,7 +561,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPie: public JKQTPGeoEllipse {
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that pies are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for pies on non-linear axes could be found!*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/*! \copydoc angleStart */
|
||||
@ -442,55 +586,66 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPie: public JKQTPGeoEllipse {
|
||||
|
||||
|
||||
|
||||
/*! \brief This JKQTPPlotObject is used to draw a chord
|
||||
\ingroup jkqtplotter_geoplots
|
||||
|
||||
\image html plot_geochord.png
|
||||
|
||||
\see \ref JKQTPlotterGeometricGraphs
|
||||
/** \brief This JKQTPPlotObject is used to draw a chord
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*
|
||||
* A chord on linear and log-log axes (start angle: 10deg and end-angle 110deg):
|
||||
*
|
||||
* \image html plot_geochord.png
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that chords are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for chords on non-linear axes could be found!
|
||||
*
|
||||
* \see \ref JKQTPlotterGeometricGraphs, JKQTPGeoPie, JKQTPGeoEllipse, JKQTPGeoArc
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGeoChord: public JKQTPGeoPie {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! \brief class constructor
|
||||
|
||||
\param parent the parent plotter object
|
||||
\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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
\param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
\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
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
* \param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
* \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 object
|
||||
\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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
\param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
\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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \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 angleStart if we only draw an arc, this is the starting angle in degrees
|
||||
* \param angleStop if we only draw an arc, this is the ending angle in degrees
|
||||
* \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);
|
||||
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, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
/** \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 */
|
||||
/** \brief plots the graph to the plotter object specified as parent
|
||||
*
|
||||
* \note This function support the JKQTPPlotObject::DrawMode::DrawAsMathematicalCurve only.
|
||||
* This means that chords are always treated as mathematical curves, as no meaningful
|
||||
* parametrization for chords on non-linear axes could be found!
|
||||
*/
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
};
|
||||
|
||||
|
@ -53,23 +53,13 @@ JKQTPImageBase::JKQTPImageBase(JKQTBasePlotter *parent):
|
||||
}
|
||||
|
||||
JKQTPImageBase::JKQTPImageBase(double x, double y, double width, double height, JKQTPlotter* parent):
|
||||
JKQTPGraph(parent)
|
||||
JKQTPImageBase(x, y, width, height, parent->getPlotter())
|
||||
{
|
||||
title="";
|
||||
this->width=width;
|
||||
this->height=height;
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
}
|
||||
|
||||
JKQTPImageBase::JKQTPImageBase(JKQTPlotter *parent):
|
||||
JKQTPGraph(parent)
|
||||
JKQTPImageBase(parent->getPlotter())
|
||||
{
|
||||
title="";
|
||||
this->width=0;
|
||||
this->height=0;
|
||||
this->x=0;
|
||||
this->y=0;
|
||||
}
|
||||
|
||||
void JKQTPImageBase::drawKeyMarker(JKQTPEnhancedPainter& /*painter*/, QRectF& /*rect*/) {
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
|
||||
JKQTPViolinplotVerticalElement::JKQTPViolinplotVerticalElement(JKQTBasePlotter* parent):
|
||||
JKQTPPlotObject(parent)
|
||||
JKQTPPlotObject(DrawAsGraphicElement, parent)
|
||||
{
|
||||
pos=JKQTP_NAN;
|
||||
median=JKQTP_NAN;
|
||||
|
@ -43,21 +43,12 @@ JKQTPPlotElement::JKQTPPlotElement(JKQTBasePlotter* parent):
|
||||
setParent(parent);
|
||||
}
|
||||
|
||||
JKQTPPlotElement::JKQTPPlotElement(JKQTPlotter *parent):
|
||||
JKQTPPlotElement(parent->getPlotter())
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPGraph::JKQTPGraph(JKQTBasePlotter* parent):
|
||||
JKQTPPlotElement(parent)
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPGraph::JKQTPGraph(JKQTPlotter *parent):
|
||||
JKQTPPlotElement(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QImage JKQTPPlotElement::generateKeyMarker(QSize size)
|
||||
{
|
||||
@ -305,23 +296,11 @@ QPainterPath JKQTPPlotElement::transformToLinePath(const QVector<QPointF> &x) co
|
||||
|
||||
|
||||
JKQTPXYGraph::JKQTPXYGraph(JKQTBasePlotter* parent):
|
||||
JKQTPGraph(parent)
|
||||
JKQTPGraph(parent), xColumn(-1), yColumn(-1), sortData(Unsorted)
|
||||
{
|
||||
sortData=Unsorted;
|
||||
xColumn=-1;
|
||||
yColumn=-1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
JKQTPXYGraph::JKQTPXYGraph(JKQTPlotter *parent):
|
||||
JKQTPGraph(parent)
|
||||
{
|
||||
sortData=Unsorted;
|
||||
xColumn=-1;
|
||||
yColumn=-1;
|
||||
|
||||
}
|
||||
|
||||
bool JKQTPXYGraph::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
||||
bool start=true;
|
||||
@ -514,12 +493,6 @@ JKQTPSingleColumnGraph::JKQTPSingleColumnGraph(JKQTBasePlotter *parent):
|
||||
}
|
||||
|
||||
|
||||
JKQTPSingleColumnGraph::JKQTPSingleColumnGraph(JKQTPlotter *parent):
|
||||
JKQTPSingleColumnGraph(parent->getPlotter())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void JKQTPSingleColumnGraph::setDataColumn(int __value)
|
||||
{
|
||||
this->dataColumn = __value;
|
||||
@ -686,16 +659,21 @@ bool JKQTPXYGraph::getIndexRange(int& imin, int& imax) const
|
||||
|
||||
|
||||
|
||||
JKQTPPlotObject::JKQTPPlotObject(JKQTBasePlotter *parent):
|
||||
JKQTPPlotElement(parent)
|
||||
JKQTPPlotObject::JKQTPPlotObject(DrawMode drawMode, JKQTBasePlotter *parent):
|
||||
JKQTPPlotElement(parent), m_drawMode(drawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPPlotObject::JKQTPPlotObject(JKQTPlotter *parent):
|
||||
JKQTPPlotElement(parent)
|
||||
{
|
||||
|
||||
void JKQTPPlotObject::setDrawMode(JKQTPPlotObject::DrawMode mode)
|
||||
{
|
||||
m_drawMode=mode;
|
||||
}
|
||||
|
||||
JKQTPPlotObject::DrawMode JKQTPPlotObject::getDrawMode() const
|
||||
{
|
||||
return m_drawMode;
|
||||
}
|
||||
|
||||
JKQTPPlotObject::~JKQTPPlotObject()
|
||||
|
@ -65,8 +65,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPlotElement: public QObject {
|
||||
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPPlotElement(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPPlotElement(JKQTPlotter* parent);
|
||||
|
||||
/** \brief default wirtual destructor */
|
||||
virtual ~JKQTPPlotElement() = default;
|
||||
@ -196,8 +194,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPlotElement: public QObject {
|
||||
QString label;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
/** \brief tool routine that transforms an x-coordinate (plot coordinate --> pixels) for this plot element */
|
||||
@ -218,6 +214,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPlotElement: public QObject {
|
||||
return QPointF(transformX(x.x()), transformY(x.y()));
|
||||
}
|
||||
|
||||
|
||||
/** \brief tool routine that back-transforms a QPointF according to the parent's transformation rules (pixels --> plot coordinate) */
|
||||
inline QPointF backTransform(const QPointF& x) const {
|
||||
return QPointF(backtransformX(x.x()), backtransformY(x.y()));
|
||||
@ -227,6 +224,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPlotElement: public QObject {
|
||||
inline QPointF transform(double x, double y) const {
|
||||
return transform(QPointF(x,y));
|
||||
}
|
||||
|
||||
/** \brief tool routine that back-transforms a QPointF according to the parent's transformation rules (pixels --> plot coordinate) */
|
||||
inline QPointF backTransform(double x, double y) const {
|
||||
return backTransform(QPointF(x,y));
|
||||
@ -250,6 +248,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPlotElement: public QObject {
|
||||
QVector<double> transformY(const QVector<double>& x) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** \brief clear the internal datastore for hitTest()
|
||||
*
|
||||
* \note This function has to be called at the start of draw()
|
||||
@ -382,8 +382,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraph: public JKQTPPlotElement {
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPGraph(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPGraph(JKQTPlotter* parent);
|
||||
|
||||
/** \brief default wirtual destructor */
|
||||
virtual ~JKQTPGraph() = default ;
|
||||
@ -428,28 +426,66 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraph: public JKQTPPlotElement {
|
||||
|
||||
|
||||
/** \brief this is the virtual base class of all JKQTPPlotElement's in a JKQTPlotter plot that
|
||||
* represent geometric forms or annotations. They have extended coordinate transform capabilities, because
|
||||
* in addition to using the plot coordinates, you can also choose to use different other
|
||||
* coordinate systems
|
||||
* \ingroup jkqtplotter_basegraphs
|
||||
* represent geometric forms or annotations.
|
||||
* \ingroup jkqtplotter_basegraphs
|
||||
*
|
||||
* \see \ref jkqtplotter_graphsgroup_classstructure
|
||||
* \see \ref jkqtplotter_graphsgroup_classstructure, \ref JKQTPlotterGeometricGraphs
|
||||
*
|
||||
* \section JKQTPPlotObject_coordinates Coordinate Systems
|
||||
* JKQTPPlotObject's have extended coordinate transform capabilities, because in addition to using
|
||||
* the plot coordinates, you can also choose to use different other coordinate systems.
|
||||
*
|
||||
* \section JKQTPPlotObject_DrawMode Draw Modes
|
||||
*
|
||||
* \copydetails m_drawMode
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPPlotObject: public JKQTPPlotElement {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/** \brief indicates how to draw the geometric object */
|
||||
enum DrawMode {
|
||||
DrawAsGraphicElement, /*!< \brief draw lines as lines (i.e. graphic elements) \image html JKQTPPlotObject_DrawAsGraphicElement.png */
|
||||
DrawAsMathematicalCurve /*!< \brief draw lines as the mathematically correct curve \image html JKQTPPlotObject_DrawAsMathematicalCurve.png */
|
||||
};
|
||||
Q_ENUM(DrawMode)
|
||||
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPPlotObject(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPPlotObject(JKQTPlotter* parent);
|
||||
explicit JKQTPPlotObject(DrawMode drawMode=DrawAsGraphicElement, JKQTBasePlotter* parent=nullptr);
|
||||
|
||||
/** \brief default wirtual destructor */
|
||||
virtual ~JKQTPPlotObject() ;
|
||||
|
||||
|
||||
/** \copybrief m_drawMode
|
||||
*
|
||||
* \return the currently set DrawMode
|
||||
* \see m_drawMode, DrawMode
|
||||
*/
|
||||
DrawMode getDrawMode() const;
|
||||
public slots:
|
||||
/** \copybrief m_drawMode
|
||||
*
|
||||
* \param mode the DrawMode to use from now on
|
||||
* \see m_drawMode, DrawMode
|
||||
*/
|
||||
void setDrawMode(DrawMode mode);
|
||||
protected:
|
||||
|
||||
/** \brief indicated whether to draw lines as graphic elements (even on non-linear coordinate systems),
|
||||
* or as mathematically correct curves
|
||||
*
|
||||
* It is possible to define in which ways the forms shall be treated/drawn into non-linear
|
||||
* coordinate systems (e.g. semi-log or log-log plots). Imagine drawing a line from (x1,y1) to (x2,y2)
|
||||
* In a linear coordinate system, this is always a line, but in a non-linear system, the line might
|
||||
* have to be represented by a curve instead. Depending on how you want to use the JKQTPPlotObject you
|
||||
* can choose to still draw it as a line connecting the points (x1,y1) and (x2,y2), or as the -
|
||||
* mathematically correct - curve connecting these two points:
|
||||
*
|
||||
* \image html JKQTPPlotObject_DrawAsMathematicalCurve.png
|
||||
*
|
||||
* \image html JKQTPPlotObject_DrawAsGraphicElement.png
|
||||
*
|
||||
* \see DrawMode, setDrawMode(), getDrawMode()
|
||||
*/
|
||||
DrawMode m_drawMode;
|
||||
|
||||
};
|
||||
|
||||
@ -490,8 +526,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXYGraph: public JKQTPGraph {
|
||||
|
||||
/** \brief class constructor */
|
||||
JKQTPXYGraph(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
JKQTPXYGraph(JKQTPlotter* parent);
|
||||
|
||||
/** \brief get the maximum and minimum x-value of the graph
|
||||
*
|
||||
@ -615,7 +649,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSingleColumnGraph: public JKQTPGraph {
|
||||
|
||||
/** \brief class constructor */
|
||||
JKQTPSingleColumnGraph(JKQTBasePlotter* parent=nullptr);
|
||||
JKQTPSingleColumnGraph(JKQTPlotter* parent);
|
||||
|
||||
/*! \copydoc dataColumn */
|
||||
void setDataColumn(int __value);
|
||||
|
BIN
screenshots/geometric_loglog_DrawAsGraphicElement.png
Normal file
After Width: | Height: | Size: 112 KiB |
BIN
screenshots/geometric_loglog_DrawAsMathematicalCurve.png
Normal file
After Width: | Height: | Size: 106 KiB |