diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 7cdbf6d2da..ef58b019d8 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -115,6 +115,14 @@ if(JKQtPlotter_BUILD_TOOLS)
)
add_dependencies(JKQTPlotter_GenerateDocImages JKQTPlotter_GenerateDocImages_listerrorindicators)
+ add_custom_target(JKQTPlotter_GenerateDocImages_listpalettes
+ COMMENT "Building JKQTPlotter Documentation Images: listpalettes"
+ COMMAND ${JKQTPlotter_GenerateDocImages_COMMAND} --listpalettes --iconsize=256 --outputdir="${JKQTPlotter_GenerateDocImages_OutputDir}/palettes/"
+ WORKING_DIRECTORY ${JKQtPlotter_QT_BINDIR}
+ DEPENDS jkqtplotter_doc_imagegenerator
+ )
+ add_dependencies(JKQTPlotter_GenerateDocImages JKQTPlotter_GenerateDocImages_listpalettes)
+
add_custom_target(JKQTPlotter_GenerateDocImages_listaxisstyleprops
COMMENT "Building JKQTPlotter Documentation Images: listaxisstyleprops"
COMMAND ${JKQTPlotter_GenerateDocImages_COMMAND} --listaxisstyleprops --background=lightgrey --iconsize=50 --outputdir="${JKQTPlotter_GenerateDocImages_OutputDir}/axisstyle/"
@@ -125,11 +133,11 @@ if(JKQtPlotter_BUILD_TOOLS)
add_custom_target(JKQTPlotter_GenerateDocImages_liststyles
COMMENT "Building JKQTPlotter Documentation Images: liststyles"
- COMMAND ${JKQTPlotter_GenerateDocImages_COMMAND} --liststyles --iconsize=500 --outputdir="${JKQTPlotter_GenerateDocImages_OutputDir}/styles/" --doctomodify="${JKQTPlotter_GenerateDocImages_dox}/jkqtplotter_styling.dox"
+ COMMAND ${JKQTPlotter_GenerateDocImages_COMMAND} --liststyles --iconsize=1200 --outputdir="${JKQTPlotter_GenerateDocImages_OutputDir}/styles/" --doctomodify="${JKQTPlotter_GenerateDocImages_dox}/jkqtplotter_styling.dox"
WORKING_DIRECTORY ${JKQtPlotter_QT_BINDIR}
DEPENDS jkqtplotter_doc_imagegenerator
)
- add_dependencies(JKQTPlotter_GenerateDocImages JKQTPlotter_GenerateDocImages_listaxisstyleprops)
+ add_dependencies(JKQTPlotter_GenerateDocImages JKQTPlotter_GenerateDocImages_liststyles)
endif(JKQtPlotter_BUILD_TOOLS)
diff --git a/doc/dox/jkqtplotter_styling.dox b/doc/dox/jkqtplotter_styling.dox
index 6ca6eb26c1..8406ecb5ae 100644
--- a/doc/dox/jkqtplotter_styling.dox
+++ b/doc/dox/jkqtplotter_styling.dox
@@ -48,21 +48,25 @@ Here is a table with all available ready-made styles:
:/JKQTPlotter/styles/legacy_default_style.ini
| \image html legacy_default_style.ini.png
diff --git a/doc/images/styles/blackandwhite.ini.png b/doc/images/styles/blackandwhite.ini.png
index ba4e2f6f72..6d77c6c0f6 100644
Binary files a/doc/images/styles/blackandwhite.ini.png and b/doc/images/styles/blackandwhite.ini.png differ
diff --git a/doc/images/styles/blackandwhite.ini.symbols.png b/doc/images/styles/blackandwhite.ini.symbols.png
index 4040a3ca57..e42e34fd65 100644
Binary files a/doc/images/styles/blackandwhite.ini.symbols.png and b/doc/images/styles/blackandwhite.ini.symbols.png differ
diff --git a/doc/images/styles/blueprint.ini.png b/doc/images/styles/blueprint.ini.png
index 551bffb87b..bebdf2db8f 100644
Binary files a/doc/images/styles/blueprint.ini.png and b/doc/images/styles/blueprint.ini.png differ
diff --git a/doc/images/styles/blueprint.ini.symbols.png b/doc/images/styles/blueprint.ini.symbols.png
index abe82bb288..38fb5d8f1d 100644
Binary files a/doc/images/styles/blueprint.ini.symbols.png and b/doc/images/styles/blueprint.ini.symbols.png differ
diff --git a/doc/images/styles/cyberpunk.ini.png b/doc/images/styles/cyberpunk.ini.png
new file mode 100644
index 0000000000..92e45e6708
Binary files /dev/null and b/doc/images/styles/cyberpunk.ini.png differ
diff --git a/doc/images/styles/cyberpunk.ini.symbols.png b/doc/images/styles/cyberpunk.ini.symbols.png
new file mode 100644
index 0000000000..a48e914240
Binary files /dev/null and b/doc/images/styles/cyberpunk.ini.symbols.png differ
diff --git a/doc/images/styles/dark.ini.png b/doc/images/styles/dark.ini.png
index 7206820ade..8ed6b46784 100644
Binary files a/doc/images/styles/dark.ini.png and b/doc/images/styles/dark.ini.png differ
diff --git a/doc/images/styles/dark.ini.symbols.png b/doc/images/styles/dark.ini.symbols.png
index 8e930d6e45..d64ba7944c 100644
Binary files a/doc/images/styles/dark.ini.symbols.png and b/doc/images/styles/dark.ini.symbols.png differ
diff --git a/doc/images/styles/default.ini.png b/doc/images/styles/default.ini.png
index 02c4b4d3b0..aeee0d7639 100644
Binary files a/doc/images/styles/default.ini.png and b/doc/images/styles/default.ini.png differ
diff --git a/doc/images/styles/default.ini.symbols.png b/doc/images/styles/default.ini.symbols.png
index b66130b574..993c8ef047 100644
Binary files a/doc/images/styles/default.ini.symbols.png and b/doc/images/styles/default.ini.symbols.png differ
diff --git a/doc/images/styles/legacy_default_style.ini.png b/doc/images/styles/legacy_default_style.ini.png
index d6d7128ff2..515bd30de7 100644
Binary files a/doc/images/styles/legacy_default_style.ini.png and b/doc/images/styles/legacy_default_style.ini.png differ
diff --git a/doc/images/styles/legacy_default_style.ini.symbols.png b/doc/images/styles/legacy_default_style.ini.symbols.png
index b66130b574..47ff40ef15 100644
Binary files a/doc/images/styles/legacy_default_style.ini.symbols.png and b/doc/images/styles/legacy_default_style.ini.symbols.png differ
diff --git a/doc/images/styles/seaborn.ini.png b/doc/images/styles/seaborn.ini.png
index 5377447a3c..6c58772e2f 100644
Binary files a/doc/images/styles/seaborn.ini.png and b/doc/images/styles/seaborn.ini.png differ
diff --git a/doc/images/styles/seaborn.ini.symbols.png b/doc/images/styles/seaborn.ini.symbols.png
index 5f3e20e3c2..dbd18db5c7 100644
Binary files a/doc/images/styles/seaborn.ini.symbols.png and b/doc/images/styles/seaborn.ini.symbols.png differ
diff --git a/doc/images/styles/simple_arrowsaxes.ini.png b/doc/images/styles/simple_arrowsaxes.ini.png
index 4530b1a145..574041440d 100644
Binary files a/doc/images/styles/simple_arrowsaxes.ini.png and b/doc/images/styles/simple_arrowsaxes.ini.png differ
diff --git a/doc/images/styles/simple_arrowsaxes.ini.symbols.png b/doc/images/styles/simple_arrowsaxes.ini.symbols.png
index af224f507b..8c2caff1d3 100644
Binary files a/doc/images/styles/simple_arrowsaxes.ini.symbols.png and b/doc/images/styles/simple_arrowsaxes.ini.symbols.png differ
diff --git a/doc/images/styles/simple_axesoffset.ini.png b/doc/images/styles/simple_axesoffset.ini.png
index fab87a2958..4605f2f7e3 100644
Binary files a/doc/images/styles/simple_axesoffset.ini.png and b/doc/images/styles/simple_axesoffset.ini.png differ
diff --git a/doc/images/styles/simple_axesoffset.ini.symbols.png b/doc/images/styles/simple_axesoffset.ini.symbols.png
index af224f507b..8c2caff1d3 100644
Binary files a/doc/images/styles/simple_axesoffset.ini.symbols.png and b/doc/images/styles/simple_axesoffset.ini.symbols.png differ
diff --git a/doc/images/styles/simple_axesoffset_plotbox.ini.png b/doc/images/styles/simple_axesoffset_plotbox.ini.png
index b41bb0ded7..37693a413d 100644
Binary files a/doc/images/styles/simple_axesoffset_plotbox.ini.png and b/doc/images/styles/simple_axesoffset_plotbox.ini.png differ
diff --git a/doc/images/styles/simple_axesoffset_plotbox.ini.symbols.png b/doc/images/styles/simple_axesoffset_plotbox.ini.symbols.png
index af224f507b..8c2caff1d3 100644
Binary files a/doc/images/styles/simple_axesoffset_plotbox.ini.symbols.png and b/doc/images/styles/simple_axesoffset_plotbox.ini.symbols.png differ
diff --git a/doc/images/styles/simple_gridandticks.ini.png b/doc/images/styles/simple_gridandticks.ini.png
index 2e5194eea2..f3fd478923 100644
Binary files a/doc/images/styles/simple_gridandticks.ini.png and b/doc/images/styles/simple_gridandticks.ini.png differ
diff --git a/doc/images/styles/simple_gridandticks.ini.symbols.png b/doc/images/styles/simple_gridandticks.ini.symbols.png
index af224f507b..8c2caff1d3 100644
Binary files a/doc/images/styles/simple_gridandticks.ini.symbols.png and b/doc/images/styles/simple_gridandticks.ini.symbols.png differ
diff --git a/examples/styling/CMakeLists.txt b/examples/styling/CMakeLists.txt
index f723f2289f..6de93f2462 100644
--- a/examples/styling/CMakeLists.txt
+++ b/examples/styling/CMakeLists.txt
@@ -8,11 +8,11 @@ message( STATUS ".. Building Example ${EXAMPLE_NAME}" )
# Set up source files
set(SOURCES test_styling.cpp test_styling_main.cpp jkqtpstyleplaintextedit.cpp)
-set(HEADERS test_styling.h jkqtpstyleplaintextedit.h )
+set(HEADERS test_styling.h build_test_graphs.h jkqtpstyleplaintextedit.h )
set(RESOURCES )
set(UIS test_styling.ui )
-add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS})
+add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS})
target_link_libraries(${EXENAME} JKQTPExampleToolsLib)
target_include_directories(${EXENAME} PRIVATE ../../lib)
if(JKQtPlotter_BUILD_STATIC_LIBS)
diff --git a/examples/styling/build_test_graphs.h b/examples/styling/build_test_graphs.h
new file mode 100644
index 0000000000..0c625d365b
--- /dev/null
+++ b/examples/styling/build_test_graphs.h
@@ -0,0 +1,322 @@
+#ifndef BUILD_TEST_GRAPHS_H
+#define BUILD_TEST_GRAPHS_H
+
+#include "jkqtplotter/graphs/jkqtpscatter.h"
+#include "jkqtplotter/graphs/jkqtpbarchart.h"
+#include "jkqtplotter/graphs/jkqtpimage.h"
+#include "jkqtplotter/graphs/jkqtpgeometric.h"
+#include "jkqtplotter/graphs/jkqtpgeoannotations.h"
+#include "jkqtplotter/graphs/jkqtpboxplot.h"
+#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
+#include "jkqtplotter/graphs/jkqtpimpulses.h"
+#include "jkqtplotter/jkqtpbaseplotter.h"
+
+#define DEFAULT_PLOT_SIZE QSize(4,2)
+
+inline void setupGridPrintingAndDatastores(QVector& plots, QSize size) {
+ // connect plots
+ for (auto plt: plots) {
+
+ for (int x=0; xaddGridPrintingPlotter(x,y, plots[y*size.width()+x]);
+ }
+ }
+ plt->setGridPrinting(true);
+
+ // use same datastore for each plot
+ if (plt!=plots.first()) plt->useExternalDatastore(plots.first()->getDatastore());
+ }
+}
+
+inline void buildPlots(QVector& plots) {
+
+ // 0. get a pointer to the internal datastore (for convenience)
+ JKQTPDatastore* ds=plots.first()->getDatastore();
+
+ // 1. clear old graphs/data
+ for (auto plt: plots) {
+ plt->clearGraphs(true);
+ }
+ ds->clear();
+
+ // 2. now we create data for a simple plot (a sine curve)
+ QVector X, Y1, Y2, img, X3, Y3, Y3err, Xbar, Ybar, Ybar2, Ybar3, Y4, Y5, XImp, YImp, XBP, MinBP, Q25BP, MeanBP, MedianBP, Q75BP, MaxBP;
+ const int Ndata=50;
+ for (int i=0; i0 && i%16==0) {
+ Xbar<addCopiedColumn(X, "x");
+ size_t columnY1=ds->addCopiedColumn(Y1, "y1");
+ size_t columnY2=ds->addCopiedColumn(Y2, "y2");
+ size_t columnImg=ds->addCopiedColumn(img, "img");
+ size_t columnX3=ds->addCopiedColumn(X3, "x3");
+ size_t columnY3=ds->addCopiedColumn(Y3, "y3");
+ size_t columnY3err=ds->addCopiedColumn(Y3err, "y3err");
+ size_t columnXbar=ds->addCopiedColumn(Xbar, "xbar");
+ size_t columnYbar=ds->addCopiedColumn(Ybar, "ybar");
+ size_t columnYbar2=ds->addCopiedColumn(Ybar2, "Ybar2");
+ size_t columnYbar3=ds->addCopiedColumn(Ybar3, "Ybar3");
+ size_t columnY4=ds->addCopiedColumn(Y4, "y4");
+ size_t columnY5=ds->addCopiedColumn(Y5, "y5");
+ size_t columnXImp=ds->addCopiedColumn(XImp, "ximp");
+ size_t columnYImp=ds->addCopiedColumn(YImp, "yimp");
+
+ size_t columnXBP=ds->addCopiedColumn(XBP, "XBP");
+ size_t columnMinBP=ds->addCopiedColumn(MinBP, "MinBP");
+ size_t columnQ25BP=ds->addCopiedColumn(Q25BP, "Q25BP");
+ size_t columnMeanBP=ds->addCopiedColumn(MeanBP, "MeanBP");
+ size_t columnMedianBP=ds->addCopiedColumn(MedianBP, "MedianBP");
+ size_t columnQ75BP=ds->addCopiedColumn(Q75BP, "Q75BP");
+ size_t columnMaxBP=ds->addCopiedColumn(MaxBP, "MaxBP");
+
+ // 4. create diverse graphs in the plot:
+ JKQTPFilledCurveXGraph* graphf4=new JKQTPFilledCurveXGraph(plots[2]);
+ graphf4->setXColumn(columnX);
+ graphf4->setYColumn(columnY4);
+ graphf4->setTitle(QObject::tr("filled exp-function"));
+ plots[2]->addGraph(graphf4);
+
+ JKQTPFilledCurveXGraph* graphf5=new JKQTPFilledCurveXGraph(plots[2]);
+ graphf5->setXColumn(columnX);
+ graphf5->setYColumn(columnY5);
+ graphf5->setTitle(QObject::tr("other filled exp-function"));
+ plots[2]->addGraph(graphf5);
+
+
+ JKQTPColumnMathImage* graphI=new JKQTPColumnMathImage(plots.last());
+ graphI->setImageColumn(columnImg);
+ graphI->setNx(Ndata);
+ graphI->setNy(Ndata);
+ graphI->setColorBarTopVisible(true);
+ graphI->setColorBarRightVisible(true);
+ graphI->setX(0.5);
+ graphI->setY(-2.0);
+ graphI->setWidth(5);
+ graphI->setHeight(1);
+ graphI->setTitle(QObject::tr("2{\\times}Gauss"));
+ plots.last()->addGraph(graphI);
+
+ JKQTPXYLineErrorGraph* graph1=new JKQTPXYLineErrorGraph(plots[0]);
+ graph1->setXColumn(columnX3);
+ graph1->setYColumn(columnY3);
+ graph1->setYErrorColumn(columnY3err);
+ graph1->setDrawLine(true);
+ graph1->setYErrorStyle(JKQTPErrorBarsLines);
+ graph1->setSymbolType(JKQTPNoSymbol);
+ graph1->setTitle(QObject::tr("sine \\pm errors graph"));
+ plots[0]->addGraph(graph1);
+
+ JKQTPXYLineGraph* graph2=new JKQTPXYLineGraph(plots[0]);
+ graph2->setXColumn(columnX);
+ graph2->setYColumn(columnY1);
+ graph2->setSymbolType(JKQTPNoSymbol);
+ graph2->setTitle(QObject::tr("sine graph $f(x)=\\sin(x)$"));
+ plots[0]->addGraph(graph2);
+
+ JKQTPXYLineGraph* graph3=new JKQTPXYLineGraph(plots[0]);
+ graph3->setXColumn(columnX);
+ graph3->setYColumn(columnY2);
+ graph3->setSymbolType(JKQTPNoSymbol);
+ //graph2->setTitle(QObject::tr("sine{\\cdot}exp graph $f(x)=\\sin(x)\\cdot\\exp\\left(-\\frac{x}{5}\\right)$"));
+ graph3->setTitle(QObject::tr("sine*exp graph"));
+ plots[0]->addGraph(graph3);
+
+
+ JKQTPImpulsesVerticalGraph* graphi2=new JKQTPImpulsesVerticalGraph(plots[0]);
+ graphi2->setXColumn(columnXImp);
+ graphi2->setYColumn(columnYImp);
+ graphi2->setTitle(QObject::tr("impulses"));
+ plots[0]->addGraph(graphi2);
+
+
+
+ JKQTPXYLineErrorGraph* graph1s=new JKQTPXYLineErrorGraph(plots[1]);
+ graph1s->setXColumn(columnX3);
+ graph1s->setYColumn(columnY3);
+ graph1s->setYErrorColumn(columnY3err);
+ graph1s->setDrawLine(false);
+ graph1s->setYErrorStyle(JKQTPErrorBars);
+ graph1s->setTitle(QObject::tr("sine \\pm errors graph"));
+ plots[1]->addGraph(graph1s);
+
+ JKQTPXYScatterGraph* graph2s=new JKQTPXYScatterGraph(plots[1]);
+ graph2s->setXColumn(columnX);
+ graph2s->setYColumn(columnY1);
+ graph2s->setTitle(QObject::tr("sine graph $f(x)=\\sin(x)$"));
+ plots[1]->addGraph(graph2s);
+
+ JKQTPXYScatterGraph* graph3s=new JKQTPXYScatterGraph(plots[1]);
+ graph3s->setXColumn(columnX);
+ graph3s->setYColumn(columnY2);
+ graph3s->setTitle(QObject::tr("sine*exp graph"));
+ plots[1]->addGraph(graph3s);
+
+ JKQTPBarVerticalGraph* graphb=new JKQTPBarVerticalGraph(plots[3]);
+ graphb->setXColumn(columnXbar);
+ graphb->setYColumn(columnYbar);
+ graphb->setTitle(QObject::tr("barchart"));
+ plots[3]->addGraph(graphb);
+
+ JKQTPBarVerticalGraph* graphb2=new JKQTPBarVerticalGraph(plots[3]);
+ graphb2->setXColumn(columnXbar);
+ graphb2->setYColumn(columnYbar2);
+ graphb2->setTitle(QObject::tr("2^{nd} barchart"));
+ plots[3]->addGraph(graphb2);
+
+ JKQTPBarVerticalGraph* graphb3=new JKQTPBarVerticalGraph(plots[3]);
+ graphb3->setXColumn(columnXbar);
+ graphb3->setYColumn(columnYbar3);
+ graphb3->setTitle(QObject::tr("3^{nd} barchart"));
+ plots[3]->addGraph(graphb3);
+ graphb3->autoscaleBarWidthAndShiftSeparatedGroups();
+
+
+ JKQTPBoxplotVerticalGraph* graphBP=new JKQTPBoxplotVerticalGraph(plots[plots.size()/2]);
+ graphBP->setPositionColumn(columnXBP);
+ graphBP->setMinColumn(columnMinBP);
+ graphBP->setPercentile25Column(columnQ25BP);
+ graphBP->setMeanColumn(columnMeanBP);
+ graphBP->setMedianColumn(columnMedianBP);
+ graphBP->setPercentile75Column(columnQ75BP);
+ graphBP->setMaxColumn(columnMaxBP);
+ plots[plots.size()/2]->addGraph(graphBP);
+
+ auto plotgeo=*(plots.rbegin()+1);
+ JKQTPGeoSymbol* annotSym=new JKQTPGeoSymbol(plotgeo, -1.5, 3);
+ plotgeo->addGraph(annotSym);
+
+ JKQTPGeoText* annotTxt=new JKQTPGeoText(plotgeo, annotSym->getX()+0.5, annotSym->getY(), "Annotation $\\int_{0}^{2\\pi}\\sin(x)\\;\\mathrm{d}x$");
+ plotgeo->addGraph(annotTxt);
+
+ JKQTPGeoEllipse* geoEll=new JKQTPGeoEllipse(plotgeo, 1.5,0.5,3.5,1.2);
+ geoEll->setAngle(-25);
+ plotgeo->addGraph(geoEll);
+
+ plotgeo->addGraph(new JKQTPGeoArrow(plotgeo, geoEll->getCenter(),annotSym->getP()-QPointF(0.5,0.5)));
+
+ plotgeo->addGraph(new JKQTPGeoLine(plotgeo, geoEll->getCenter(),QPointF(annotSym->getX(),annotSym->getY()-2.0)));
+
+ // 6. autoscale the plot so the graph is contained
+ for (auto plt: plots) {
+ plt->zoomToFit();
+ plt->getXAxis()->setAxisLabel("x-axis");
+ plt->getYAxis()->setAxisLabel("y-axis");
+ }
+ plots[0]->getYAxis()->setRange(plots[0]->getYAxis()->getMin(), 8);
+ plots[1]->getYAxis()->setRange(plots[1]->getYAxis()->getMin(), 8);
+ plots[3]->getYAxis()->setRange(plots[3]->getYAxis()->getMin(), 2.5);
+ plotgeo->setMaintainAspectRatio(true);
+ plotgeo->setMaintainAxisAspectRatio(true);
+ plotgeo->getXAxis()->setRange(-2.5,4);
+ plotgeo->getYAxis()->setRange(-2.5,4);
+
+
+ plots[0]->setPlotLabel("Line Graphs");
+ plots[1]->setPlotLabel("Scatter Graphs");
+ plots[2]->setPlotLabel("Filled Graphs");
+ plots[3]->setPlotLabel("Bar Charts");
+ plots[plots.size()/2]->setPlotLabel("Boxplots");
+ plotgeo->setPlotLabel("Geometry & Annotations");
+ plots.last()->setPlotLabel("Image Plot");
+
+}
+
+inline void buildLineSymbolSampler(JKQTBasePlotter* plotExtra, JKQTBasePlotter* baseplot) {
+ plotExtra->clearGraphs(true);
+ plotExtra->setBackgroundColor(baseplot->getBackgroundColor());
+ plotExtra->setExportBackgroundColor(baseplot->getExportBackgroundColor());
+ plotExtra->setPlotBackgroundColor(baseplot->getPlotBackgroundColor());
+ plotExtra->getXAxis()->setDrawMode1(JKQTPCADMnone);
+ plotExtra->getXAxis()->setDrawMode2(JKQTPCADMnone);
+ plotExtra->getYAxis()->setDrawMode1(JKQTPCADMnone);
+ plotExtra->getYAxis()->setDrawMode2(JKQTPCADMnone);
+ double x=1;
+ double xlineend=6;
+ double y=1;
+ double xmax=15;
+ int cnt=0;
+ const QColor defaultColor=baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.first();
+ for (auto s: baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphSymbols) {
+ plotExtra->addGraph(new JKQTPGeoSymbol(plotExtra, x, y, s, 12, defaultColor, defaultColor.lighter() ));
+ x+=1;
+ xmax=qMax(x, xmax);
+ if (cnt>0 && cnt%25==0) {
+ x=1;
+ y+=1.0;
+ }
+ cnt++;
+ }
+ y=y+1;
+ double ycoltest=y;
+ for (auto s: baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphPenStyles) {
+ JKQTPGeoLine* l;
+ plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra, 1,y,xlineend,y)); l->setStyle(defaultColor, 2, s);
+ plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra, 1,y-0.25,xlineend,y-0.25)); l->setStyle(defaultColor.darker(), 1, s);
+ y+=0.75;
+ }
+ x=xlineend+1;
+ const int cntFillTests=qMax(baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size());
+ double dx=(xmax-xlineend-1.0)/static_cast(cntFillTests);
+ for (int i=0; igetCurrentPlotterStyle().graphsStyle.defaultGraphColors.value(i%baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), Qt::black);
+ const auto fs=baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.value(i%baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size(), Qt::SolidPattern);
+ JKQTPGeoLine* l;
+ plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra, x,ycoltest,x,y-0.5)); l->setStyle(col,5);
+ JKQTPGeoRectangle* r;
+ plotExtra->addGraph(r=new JKQTPGeoRectangle(plotExtra, x+dx/2,(ycoltest+y-0.5)/2.0, dx*0.5, y-ycoltest-0.5));
+ r->setStyle(col,1, Qt::SolidLine, JKQTPGetDerivedColor(baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphStyle.fillColorDerivationMode, col), fs);
+ x+=dx;
+ }
+ plotExtra->zoomToFit();
+ plotExtra->setX(0, plotExtra->getXMax()+2);
+ plotExtra->setY(0, plotExtra->getYMax()+1);
+ plotExtra->setGrid(false);
+ plotExtra->setPlotLabel("default symbols/lines/colors");
+
+}
+
+#endif // BUILD_TEST_GRAPHS_H
diff --git a/examples/styling/test_styling.cpp b/examples/styling/test_styling.cpp
index 195bb83c99..60c9200fbe 100644
--- a/examples/styling/test_styling.cpp
+++ b/examples/styling/test_styling.cpp
@@ -1,14 +1,7 @@
#include "test_styling.h"
+#include "build_test_graphs.h"
#include "ui_test_styling.h"
#include "jkqtplotter/jkqtplotter.h"
-#include "jkqtplotter/graphs/jkqtpscatter.h"
-#include "jkqtplotter/graphs/jkqtpbarchart.h"
-#include "jkqtplotter/graphs/jkqtpimage.h"
-#include "jkqtplotter/graphs/jkqtpgeometric.h"
-#include "jkqtplotter/graphs/jkqtpgeoannotations.h"
-#include "jkqtplotter/graphs/jkqtpboxplot.h"
-#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
-#include "jkqtplotter/graphs/jkqtpimpulses.h"
#include
#include
@@ -20,18 +13,29 @@ TestStyling::TestStyling(QWidget *parent) :
{
// set up the GUI
ui->setupUi(this);
- ui->splitter->setStretchFactor(0,1);
+ ui->splitter->setStretchFactor(0,2);
ui->splitter->setStretchFactor(1,1);
+ plots=QVector{ui->plot1, ui->plot2, ui->plot3, ui->plot4, ui->plot5, ui->plot6, ui->plot7, ui->plot8};
+ for (auto p: plots) {
+ bplots<getPlotter();
+ }
+
+ // connect plots
+ setupGridPrintingAndDatastores(bplots, QSize(4,2));
+
+
// initialize a simple plot
initPlot();
// connect GUI to JKQTPlotter
- connect(ui->chkGrid, SIGNAL(toggled(bool)), ui->plot, SLOT(setGrid(bool)));
- connect(ui->chkLogX, SIGNAL(toggled(bool)), ui->plot->getXAxis(), SLOT(setLogAxis(bool)));
- connect(ui->chkLogY, SIGNAL(toggled(bool)), ui->plot->getYAxis(), SLOT(setLogAxis(bool)));
- connect(ui->chkDebugBoxes, SIGNAL(toggled(bool)), ui->plot->getPlotter(), SLOT(enableDebugShowRegionBoxes(bool)));
- connect(ui->chkDebugTextBoxes, SIGNAL(toggled(bool)), ui->plot->getPlotter(), SLOT(enableDebugShowTextBoxes(bool)));
+ for (auto plt: plots) {
+ connect(ui->chkGrid, SIGNAL(toggled(bool)), plt, SLOT(setGrid(bool)));
+ connect(ui->chkLogX, SIGNAL(toggled(bool)), plt->getXAxis(), SLOT(setLogAxis(bool)));
+ connect(ui->chkLogY, SIGNAL(toggled(bool)), plt->getYAxis(), SLOT(setLogAxis(bool)));
+ connect(ui->chkDebugBoxes, SIGNAL(toggled(bool)), plt->getPlotter(), SLOT(enableDebugShowRegionBoxes(bool)));
+ connect(ui->chkDebugTextBoxes, SIGNAL(toggled(bool)), plt->getPlotter(), SLOT(enableDebugShowTextBoxes(bool)));
+ }
// store JKQTPlotter plotterStyle to a temporary INI-file
// and then load that temporary file into the plainTextEdit,
@@ -41,7 +45,7 @@ TestStyling::TestStyling(QWidget *parent) :
QString tmpfn=QDir::tempPath()+"/jkqtplotter_config.tmp";
{
QSettings settings(tmpfn, QSettings::IniFormat);
- ui->plot->saveCurrentPlotterStyle(settings);
+ ui->plot1->saveCurrentPlotterStyle(settings);
}
on_btnLoad_clicked(tmpfn);
QFile::remove(tmpfn);
@@ -53,7 +57,6 @@ TestStyling::~TestStyling()
if (!plotExtra.isNull()) {
plotExtra->close();
plotExtra.clear();
- plotExtra->setWindowTitle("2: symbols/lines");
}
}
@@ -73,9 +76,11 @@ void TestStyling::on_btnUpdate_clicked()
}
{
QSettings settings(tmpfn, QSettings::IniFormat);
- ui->plot->loadCurrentPlotterStyle(settings);
+ for (auto plt: plots) {
+ plt->loadCurrentPlotterStyle(settings);
+ }
initPlot();
- ui->chkDebugBoxes->setChecked(ui->plot->getPlotter()->isDebugShowRegionBoxesEnabled());
+ ui->chkDebugBoxes->setChecked(ui->plot1->getPlotter()->isDebugShowRegionBoxesEnabled());
}
QFile::remove(tmpfn);
QApplication::restoreOverrideCursor();
@@ -112,9 +117,9 @@ void TestStyling::on_btnSave_clicked()
QTextStream out(&data);
out << ui->plainTextEdit->toPlainText();
}
- QPixmap img=ui->plot->grab();
+ QPixmap img=ui->plot1->grab();
img.save(fn+".png", "png");
- ui->plot->saveImage(fn+".export.png", false);
+ ui->plot1->saveImage(fn+".export.png", false);
}
}
@@ -123,221 +128,30 @@ void TestStyling::on_btnSave_clicked()
void TestStyling::initPlot()
{
- ui->plot->setPlotUpdateEnabled(false);
-
- // 0. get a pointer to the internal datastore (for convenience)
- JKQTPDatastore* ds=ui->plot->getDatastore();
-
- // 1. clear old graphs/data
- ui->plot->clearGraphs(true);
- ds->clear();
-
- // 2. now we create data for a simple plot (a sine curve)
- QVector X, Y1, Y2, img, X3, Y3, Y3err, Xbar, Ybar, Ybar2, Y4, Y5, XImp, YImp;
- const int Ndata=100;
- for (int i=0; i0 && i%20==0) {
- Xbar<setPlotUpdateEnabled(true);
+ plt->redrawPlot();
+ plt->setPlotUpdateEnabled(false);
}
- // 3. make data available to JKQTPlotter by adding it to the internal datastore.
- // Note: In this step the data is copied (of not specified otherwise), so you can
- // reuse X and Y afterwards!
- // the variables columnX and columnY will contain the internal column ID of the newly
- // created columns with names "x" and "y" and the (copied) data from X and Y.
- size_t columnX=ds->addCopiedColumn(X, "x");
- size_t columnY1=ds->addCopiedColumn(Y1, "y1");
- size_t columnY2=ds->addCopiedColumn(Y2, "y2");
- size_t columnImg=ds->addCopiedColumn(img, "img");
- size_t columnX3=ds->addCopiedColumn(X3, "x3");
- size_t columnY3=ds->addCopiedColumn(Y3, "y3");
- size_t columnY3err=ds->addCopiedColumn(Y3err, "y3err");
- size_t columnXbar=ds->addCopiedColumn(Xbar, "xbar");
- size_t columnYbar=ds->addCopiedColumn(Ybar, "ybar");
- size_t columnYbar2=ds->addCopiedColumn(Ybar2, "Ybar2");
- size_t columnY4=ds->addCopiedColumn(Y4, "y4");
- size_t columnY5=ds->addCopiedColumn(Y5, "y5");
- size_t columnXImp=ds->addCopiedColumn(XImp, "ximp");
- size_t columnYImp=ds->addCopiedColumn(YImp, "yimp");
+ buildPlots(bplots);
- // 4. create diverse graphs in the plot:
- JKQTPFilledCurveXGraph* graphf4=new JKQTPFilledCurveXGraph(ui->plot);
- graphf4->setXColumn(columnX);
- graphf4->setYColumn(columnY4);
- graphf4->setTitle(QObject::tr("filled exp-function"));
- ui->plot->addGraph(graphf4);
-
- JKQTPFilledCurveXGraph* graphf5=new JKQTPFilledCurveXGraph(ui->plot);
- graphf5->setXColumn(columnX);
- graphf5->setYColumn(columnY5);
- graphf5->setTitle(QObject::tr("other filled exp-function"));
- ui->plot->addGraph(graphf5);
-
- JKQTPColumnMathImage* graphI=new JKQTPColumnMathImage(ui->plot);
- graphI->setImageColumn(columnImg);
- graphI->setNx(Ndata);
- graphI->setNy(Ndata);
- graphI->setColorBarTopVisible(true);
- graphI->setColorBarRightVisible(true);
- graphI->setX(0.5);
- graphI->setY(-2.0);
- graphI->setWidth(5);
- graphI->setHeight(1);
- graphI->setTitle(QObject::tr("2{\\times}Gauss"));
- ui->plot->addGraph(graphI);
-
- JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(ui->plot);
- graph1->setXColumn(columnX);
- graph1->setYColumn(columnY1);
- graph1->setTitle(QObject::tr("sine graph $f(x)=\\sin(x)$"));
- ui->plot->addGraph(graph1);
-
- JKQTPXYLineGraph* graph2=new JKQTPXYLineGraph(ui->plot);
- graph2->setXColumn(columnX);
- graph2->setYColumn(columnY2);
- graph2->setSymbolType(JKQTPNoSymbol);
- //graph2->setTitle(QObject::tr("sine{\\cdot}exp graph $f(x)=\\sin(x)\\cdot\\exp\\left(-\\frac{x}{5}\\right)$"));
- graph2->setTitle(QObject::tr("sine*exp graph"));
- ui->plot->addGraph(graph2);
-
- JKQTPXYLineErrorGraph* graph3=new JKQTPXYLineErrorGraph(ui->plot);
- graph3->setXColumn(columnX3);
- graph3->setYColumn(columnY3);
- graph3->setYErrorColumn(columnY3err);
- graph3->setDrawLine(true);
- graph3->setYErrorStyle(JKQTPErrorBarsPolygons);
- graph3->setTitle(QObject::tr("sine \\pm errors graph"));
- ui->plot->addGraph(graph3);
-
- JKQTPBarVerticalGraph* graphb=new JKQTPBarVerticalGraph(ui->plot);
- graphb->setXColumn(columnXbar);
- graphb->setYColumn(columnYbar);
- graphb->setTitle(QObject::tr("barchart"));
- ui->plot->addGraph(graphb);
-
- JKQTPBarVerticalGraph* graphb2=new JKQTPBarVerticalGraph(ui->plot);
- graphb2->setXColumn(columnXbar);
- graphb2->setYColumn(columnYbar2);
- graphb2->setTitle(QObject::tr("2^{nd} barchart"));
- ui->plot->addGraph(graphb2);
- graphb2->autoscaleBarWidthAndShiftSeparatedGroups();
-
- JKQTPImpulsesVerticalGraph* graphi2=new JKQTPImpulsesVerticalGraph(ui->plot);
- graphi2->setXColumn(columnXImp);
- graphi2->setYColumn(columnYImp);
- graphi2->setTitle(QObject::tr("impulses"));
- ui->plot->addGraph(graphi2);
-
- JKQTPBoxplotHorizontalElement* graphBP=new JKQTPBoxplotHorizontalElement(ui->plot);
- graphBP->setData(-2, 7, 10,12,13,17,22);
- ui->plot->addGraph(graphBP);
-
- JKQTPGeoSymbol* annotSym=new JKQTPGeoSymbol(ui->plot, 15, -3);
- ui->plot->addGraph(annotSym);
-
- JKQTPGeoText* annotTxt=new JKQTPGeoText(ui->plot, 15.1, -3, "Annotation $\\int_{0}^{2\\pi}\\sin(x)\\;\\mathrm{d}x$");
- ui->plot->addGraph(annotTxt);
-
- JKQTPGeoEllipse* geoEll=new JKQTPGeoEllipse(ui->plot, 5,-3,5,1);
- geoEll->setAngle(-25);
- ui->plot->addGraph(geoEll);
-
- ui->plot->addGraph(new JKQTPGeoArrow(ui->plot, 5,-3,10,-3.5));
-
- ui->plot->addGraph(new JKQTPGeoLine(ui->plot, 5,-3,10,-4));
-
- // 6. autoscale the plot so the graph is contained
- ui->plot->zoomToFit();
-
- ui->plot->getPlotter()->setPlotLabel("Sine Plots - User-Interaction Example");
- ui->plot->getXAxis()->setAxisLabel("x-axis");
- ui->plot->getYAxis()->setAxisLabel("y-axis");
-
- ui->plot->setPlotUpdateEnabled(true);
- ui->plot->redrawPlot();
+ for (auto plt: plots) {
+ plt->setPlotUpdateEnabled(true);
+ plt->redrawPlot();
+ }
if (!plotExtra) {
plotExtra=new JKQTPlotter;
+ plotExtra->setWindowTitle("2: symbols/lines");
plotExtra->show();
plotExtra->resize(width(),300);
plotExtra->move(pos().x(), pos().y()+height()+32);
}
plotExtra->setPlotUpdateEnabled(false);
- plotExtra->clearGraphs(true);
- plotExtra->getPlotter()->setBackgroundColor(ui->plot->getPlotter()->getBackgroundColor());
- plotExtra->getPlotter()->setExportBackgroundColor(ui->plot->getPlotter()->getExportBackgroundColor());
- plotExtra->getPlotter()->setPlotBackgroundColor(ui->plot->getPlotter()->getPlotBackgroundColor());
- plotExtra->getXAxis()->setDrawMode1(JKQTPCADMnone);
- plotExtra->getXAxis()->setDrawMode2(JKQTPCADMnone);
- plotExtra->getYAxis()->setDrawMode1(JKQTPCADMnone);
- plotExtra->getYAxis()->setDrawMode2(JKQTPCADMnone);
- double x=1;
- double xlineend=6;
- double y=1;
- double xmax=15;
- int cnt=0;
- for (auto s: ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphSymbols) {
- plotExtra->addGraph(new JKQTPGeoSymbol(plotExtra.data(), x, y, s, 12, QColor("red"), QColor("salmon") ));
- x+=1;
- xmax=qMax(x, xmax);
- if (cnt>0 && cnt%25==0) {
- x=1;
- y+=1.0;
- }
- cnt++;
- }
- y=y+1;
- double ycoltest=y;
- for (auto s: ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphPenStyles) {
- JKQTPGeoLine* l;
- plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra.data(), 1,y,xlineend,y)); l->setStyle(QColor("red"), 2, s);
- plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra.data(), 1,y-0.25,xlineend,y-0.25)); l->setStyle(QColor("maroon"), 1, s);
- y+=0.75;
- }
- x=xlineend+1;
- const int cntFillTests=qMax(ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size());
- double dx=(xmax-xlineend-1.0)/static_cast(cntFillTests);
- for (int i=0; iplot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.value(i%ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), Qt::black);
- const auto fs=ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.value(i%ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size(), Qt::SolidPattern);
- JKQTPGeoLine* l;
- plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra.data(), x,ycoltest,x,y-0.5)); l->setStyle(col,5);
- JKQTPGeoRectangle* r;
- plotExtra->addGraph(r=new JKQTPGeoRectangle(plotExtra.data(), x+dx/2,(ycoltest+y-0.5)/2.0, dx*0.5, y-ycoltest-0.5));
- r->setStyle(col,1, Qt::SolidLine, JKQTPGetDerivedColor(ui->plot->getPlotter()->getCurrentPlotterStyle().graphsStyle.defaultGraphStyle.fillColorDerivationMode, col), fs);
- x+=dx;
- }
- plotExtra->zoomToFit();
- plotExtra->setX(0, plotExtra->getXMax()+2);
- plotExtra->setY(0, plotExtra->getYMax()+1);
- plotExtra->setGrid(false);
- plotExtra->getPlotter()->setPlotLabel("default symbols/lines/colors");
+
+ buildLineSymbolSampler(plotExtra->getPlotter(), bplots[0]);
+
plotExtra->setPlotUpdateEnabled(true);
plotExtra->redrawPlot();
}
diff --git a/examples/styling/test_styling.h b/examples/styling/test_styling.h
index 0c6998f71e..4cd3e35f9f 100644
--- a/examples/styling/test_styling.h
+++ b/examples/styling/test_styling.h
@@ -27,6 +27,8 @@ class TestStyling : public QMainWindow
Ui::TestStyling *ui;
void initPlot();
QPointer plotExtra;
+ QVector plots;
+ QVector bplots;
};
#endif // TEST_STYLING_H
diff --git a/examples/styling/test_styling.ui b/examples/styling/test_styling.ui
index 58fed86f13..dfe58926ac 100644
--- a/examples/styling/test_styling.ui
+++ b/examples/styling/test_styling.ui
@@ -6,21 +6,65 @@
0
0
- 1068
- 691
+ 1547
+ 976
1: Tutorial/TestApp: JKQTPlotter Styling
-
+
-
Qt::Horizontal
-
+
+ false
+
+
+
+
-
+
+
+ -
+
+
+
+ 200
+ 0
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+ 200
+ 0
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
-
@@ -219,8 +263,8 @@
0
0
- 1068
- 17
+ 1547
+ 22
diff --git a/tools/jkqtplotter_doc_imagegenerator/CMakeLists.txt b/tools/jkqtplotter_doc_imagegenerator/CMakeLists.txt
index a00d0e4e10..8745ef1544 100644
--- a/tools/jkqtplotter_doc_imagegenerator/CMakeLists.txt
+++ b/tools/jkqtplotter_doc_imagegenerator/CMakeLists.txt
@@ -10,12 +10,14 @@ message( STATUS ".. Building Tool ${EXAMPLE_NAME}" )
set(SOURCES
${EXAMPLE_NAME}.cpp
)
-set(HEADERS )
+set(HEADERS
+ ${CMAKE_CURRENT_LIST_DIR}/../../examples/styling/build_test_graphs.h
+)
set(RESOURCES )
set(UIS )
add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS})
-target_include_directories(${EXENAME} PRIVATE ../../lib)
+target_include_directories(${EXENAME} PRIVATE ../../lib ${CMAKE_CURRENT_LIST_DIR}/../../examples/styling/)
if(JKQtPlotter_BUILD_STATIC_LIBS)
target_link_libraries(${EXENAME} JKQTPlotterLib)
elseif(JKQtPlotter_BUILD_SHARED_LIBS)
diff --git a/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp b/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp
index 6aaad040ef..a86150f907 100644
--- a/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp
+++ b/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp
@@ -15,6 +15,7 @@
#include
#include
#include
+#include
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
#include
#include
@@ -25,15 +26,7 @@
#include "jkqtcommon/jkqtpdrawingtools.h"
#include "jkqtcommon/jkqtpenhancedpainter.h"
#include "jkqtplotter/jkqtpbaseplotter.h"
-#include "jkqtplotter/graphs/jkqtplines.h"
-#include "jkqtplotter/graphs/jkqtpscatter.h"
-#include "jkqtplotter/graphs/jkqtpbarchart.h"
-#include "jkqtplotter/graphs/jkqtpimage.h"
-#include "jkqtplotter/graphs/jkqtpgeometric.h"
-#include "jkqtplotter/graphs/jkqtpgeoannotations.h"
-#include "jkqtplotter/graphs/jkqtpboxplot.h"
-#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
-#include "jkqtplotter/graphs/jkqtpimpulses.h"
+#include "build_test_graphs.h"
#include
#if __cplusplus >= 202002L
# include
@@ -55,6 +48,21 @@ void startPainting(QImage& img, JKQTPEnhancedPainter& p, int iconsize, QColor ba
startPainting(img, p, iconsize,iconsize,backgroundColor);
}
+void startPaintingChecker(QImage& img, JKQTPEnhancedPainter& p, int iconsizex, int iconsizey, int check_size, QColor backgroundColor1, QColor backgroundColor2) {
+ img=QImage(QSize(iconsizex,iconsizey),QImage::Format_ARGB32_Premultiplied);
+ img.fill(backgroundColor1);
+ p.begin(&img);
+ p.setRenderHint(QPainter::Antialiasing);
+ p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
+ for (int y=0; y(i);
+ QImage img;
+ JKQTPEnhancedPainter p;
+ startPaintingChecker(img, p, iconsize.width(),iconsize.height(), iconsize.height()/6, QColor("white"), QColor("silver"));
+
+ p.drawImage(0,0,JKQTPImageTools::GetPaletteImage(i,iconsize.width(), iconsize.height()));
+ stopPaintingAndSave(img, p, outputDir.absoluteFilePath("palette_"+JKQTPImageTools::JKQTPMathImageColorPalette2String(s)+".png"));
+ }
+}
+
void doListErrorIndicators(const QDir& outputDir, int iconsize, QColor backgroundColor) {
JKQTBasePlotter plot(true);
@@ -389,221 +409,39 @@ void doListAxisStyling(const QDir& outputDir, int iconsize, QColor backgroundCol
plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,0,plot.getWidth(),plot.getHeight()).save(outputDir.absoluteFilePath("axis_unit_scaling_pi.png"), "png");
}
-void plotStyle(JKQTBasePlotter& plot) {
+void plotStyle(const QSettings& style, QSize examplePlotSize, const QString& examplePlotFilename, QSize samplePlotSize, const QString& samplePlotFilename ) {
+ JKQTBasePlotter plotExtra(true);
- // 0. get a pointer to the internal datastore (for convenience)
- JKQTPDatastore* ds=plot.getDatastore();
-
- // 1. clear old graphs/data
- plot.clearGraphs(true);
- ds->clear();
-
- // 2. now we create data for a simple plot (a sine curve)
- QVector X, Y1, Y2, img, X3, Y3, Y3err, Xbar, Ybar, Ybar2, Y4, Y5, XImp, YImp;
- const int Ndata=100;
- for (int i=0; i0 && i%20==0) {
- Xbar< plots;
+ for (int x=0; xgetDatastore());
+ }
}
}
- auto fgauss=[](double x, double y, double x0, double y0, double sx, double sy) {
- return exp(-2.0*(x-x0)*(x-x0)/sx/sx-2.0*(y-y0)*(y-y0)/sy/sy);
- };
- for (int i=0; iloadCurrentPlotterStyle(style);
+ p->setWidgetSize(QSize(examplePlotSize.width()/DEFAULT_PLOT_SIZE.width(),examplePlotSize.height()/DEFAULT_PLOT_SIZE.height()));
}
+ plotExtra.setWidgetSize(samplePlotSize);
+ setupGridPrintingAndDatastores(plots, DEFAULT_PLOT_SIZE);
+ buildPlots(plots);
+ buildLineSymbolSampler(&plotExtra, plots.first());
- // 3. make data available to JKQTPlotter by adding it to the internal datastore.
- // Note: In this step the data is copied (of not specified otherwise), so you can
- // reuse X and Y afterwards!
- // the variables columnX and columnY will contain the internal column ID of the newly
- // created columns with names "x" and "y" and the (copied) data from X and Y.
- size_t columnX=ds->addCopiedColumn(X, "x");
- size_t columnY1=ds->addCopiedColumn(Y1, "y1");
- size_t columnY2=ds->addCopiedColumn(Y2, "y2");
- size_t columnImg=ds->addCopiedColumn(img, "img");
- size_t columnX3=ds->addCopiedColumn(X3, "x3");
- size_t columnY3=ds->addCopiedColumn(Y3, "y3");
- size_t columnY3err=ds->addCopiedColumn(Y3err, "y3err");
- size_t columnXbar=ds->addCopiedColumn(Xbar, "xbar");
- size_t columnYbar=ds->addCopiedColumn(Ybar, "ybar");
- size_t columnYbar2=ds->addCopiedColumn(Ybar2, "Ybar2");
- size_t columnY4=ds->addCopiedColumn(Y4, "y4");
- size_t columnY5=ds->addCopiedColumn(Y5, "y5");
- size_t columnXImp=ds->addCopiedColumn(XImp, "ximp");
- size_t columnYImp=ds->addCopiedColumn(YImp, "yimp");
+ //QSize(examplePlotSize.width()*DEFAULT_PLOT_SIZE.width(),examplePlotSize.height()*DEFAULT_PLOT_SIZE.height())
+ plots.first()->grabPixelImage(examplePlotSize, false).save(examplePlotFilename);
+ //plots.first()->saveAsPixelImage(examplePlotFilename, false);
+ plotExtra.grabPixelImage(samplePlotSize, false).save(samplePlotFilename);
- // 4. create diverse graphs in the plot:
- JKQTPFilledCurveXGraph* graphf4=new JKQTPFilledCurveXGraph(&plot);
- graphf4->setXColumn(columnX);
- graphf4->setYColumn(columnY4);
- graphf4->setTitle(QObject::tr("filled exp-function"));
- plot.addGraph(graphf4);
- JKQTPFilledCurveXGraph* graphf5=new JKQTPFilledCurveXGraph(&plot);
- graphf5->setXColumn(columnX);
- graphf5->setYColumn(columnY5);
- graphf5->setTitle(QObject::tr("other filled exp-function"));
- plot.addGraph(graphf5);
-
- JKQTPColumnMathImage* graphI=new JKQTPColumnMathImage(&plot);
- graphI->setImageColumn(columnImg);
- graphI->setNx(Ndata);
- graphI->setNy(Ndata);
- graphI->setColorBarTopVisible(true);
- graphI->setColorBarRightVisible(true);
- graphI->setX(0.5);
- graphI->setY(-2.0);
- graphI->setWidth(5);
- graphI->setHeight(1);
- graphI->setTitle(QObject::tr("2{\\times}Gauss"));
- plot.addGraph(graphI);
-
- JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(&plot);
- graph1->setXColumn(columnX);
- graph1->setYColumn(columnY1);
- graph1->setTitle(QObject::tr("sine graph $f(x)=\\sin(x)$"));
- plot.addGraph(graph1);
-
- JKQTPXYLineGraph* graph2=new JKQTPXYLineGraph(&plot);
- graph2->setXColumn(columnX);
- graph2->setYColumn(columnY2);
- graph2->setSymbolType(JKQTPNoSymbol);
- //graph2->setTitle(QObject::tr("sine{\\cdot}exp graph $f(x)=\\sin(x)\\cdot\\exp\\left(-\\frac{x}{5}\\right)$"));
- graph2->setTitle(QObject::tr("sine*exp graph"));
- plot.addGraph(graph2);
-
- JKQTPXYLineErrorGraph* graph3=new JKQTPXYLineErrorGraph(&plot);
- graph3->setXColumn(columnX3);
- graph3->setYColumn(columnY3);
- graph3->setYErrorColumn(columnY3err);
- graph3->setDrawLine(true);
- graph3->setYErrorStyle(JKQTPErrorBarsPolygons);
- graph3->setTitle(QObject::tr("sine \\pm errors graph"));
- plot.addGraph(graph3);
-
- JKQTPBarVerticalGraph* graphb=new JKQTPBarVerticalGraph(&plot);
- graphb->setXColumn(columnXbar);
- graphb->setYColumn(columnYbar);
- graphb->setTitle(QObject::tr("barchart"));
- plot.addGraph(graphb);
-
- JKQTPBarVerticalGraph* graphb2=new JKQTPBarVerticalGraph(&plot);
- graphb2->setXColumn(columnXbar);
- graphb2->setYColumn(columnYbar2);
- graphb2->setTitle(QObject::tr("2^{nd} barchart"));
- plot.addGraph(graphb2);
- graphb2->autoscaleBarWidthAndShiftSeparatedGroups();
-
- JKQTPImpulsesVerticalGraph* graphi2=new JKQTPImpulsesVerticalGraph(&plot);
- graphi2->setXColumn(columnXImp);
- graphi2->setYColumn(columnYImp);
- graphi2->setTitle(QObject::tr("impulses"));
- plot.addGraph(graphi2);
-
- JKQTPBoxplotHorizontalElement* graphBP=new JKQTPBoxplotHorizontalElement(&plot);
- graphBP->setData(-2, 7, 10,12,13,17,22);
- plot.addGraph(graphBP);
-
- JKQTPGeoSymbol* annotSym=new JKQTPGeoSymbol(&plot, 15, -3);
- plot.addGraph(annotSym);
-
- JKQTPGeoText* annotTxt=new JKQTPGeoText(&plot, 15.1, -3, "Annotation $\\int_{0}^{2\\pi}\\sin(x)\\;\\mathrm{d}x$");
- plot.addGraph(annotTxt);
-
- JKQTPGeoEllipse* geoEll=new JKQTPGeoEllipse(&plot, 5,-3,5,1);
- geoEll->setAngle(-25);
- plot.addGraph(geoEll);
-
- plot.addGraph(new JKQTPGeoArrow(&plot, 5,-3,10,-3.5));
-
- plot.addGraph(new JKQTPGeoLine(&plot, 5,-3,10,-4));
-
- // 6. autoscale the plot so the graph is contained
- plot.zoomToFit();
-
- plot.setPlotLabel("Sine Plots - User-Interaction Example");
- plot.getXAxis()->setAxisLabel("x-axis");
- plot.getYAxis()->setAxisLabel("y-axis");
-
- plot.redrawPlot();
+ for (int i=plots.size()-1; i>=0; i--) {
+ delete plots[i];
+ }
}
-void plotStyleSymbols(JKQTBasePlotter& plotExtra, const JKQTBasePlotter& plot) {
- plotExtra.clearGraphs(true);
- plotExtra.setBackgroundColor(plot.getBackgroundColor());
- plotExtra.setExportBackgroundColor(plot.getExportBackgroundColor());
- plotExtra.setPlotBackgroundColor(plot.getPlotBackgroundColor());
- plotExtra.getXAxis()->setDrawMode1(JKQTPCADMnone);
- plotExtra.getXAxis()->setDrawMode2(JKQTPCADMnone);
- plotExtra.getYAxis()->setDrawMode1(JKQTPCADMnone);
- plotExtra.getYAxis()->setDrawMode2(JKQTPCADMnone);
- double x=1;
- double xlineend=6;
- double y=1;
- double xmax=15;
- int cnt=0;
- for (auto s: plot.getCurrentPlotterStyle().graphsStyle.defaultGraphSymbols) {
- plotExtra.addGraph(new JKQTPGeoSymbol(&plotExtra, x, y, s, 12 ));
- const auto col=plot.getCurrentPlotterStyle().graphsStyle.defaultGraphColors.value(0, Qt::black);
- dynamic_cast(plotExtra.getGraph(cnt))->setSymbolColor(col);
- dynamic_cast(plotExtra.getGraph(cnt))->setSymbolFillColor(col);
- x+=1;
- xmax=qMax(x, xmax);
- if (cnt>0 && cnt%25==0) {
- x=1;
- y+=1.0;
- }
- cnt++;
- }
- y=y+1;
- double ycoltest=y;
- for (auto s: plot.getCurrentPlotterStyle().graphsStyle.defaultGraphPenStyles) {
- JKQTPGeoLine* l;
- plotExtra.addGraph(l=new JKQTPGeoLine(&plotExtra, 1,y,xlineend,y)); l->setStyle(QColor("red"), 2, s);
- const auto col=plot.getCurrentPlotterStyle().graphsStyle.defaultGraphColors.value(0, Qt::black);
- dynamic_cast(plotExtra.getGraph(cnt))->setLineColor(col);
- y+=0.75;
- }
- x=xlineend+1;
- const int cntFillTests=qMax(plot.getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), plot.getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size());
- double dx=(xmax-xlineend-1.0)/static_cast(cntFillTests);
- for (int i=0; isetStyle(col,5);
- JKQTPGeoRectangle* r;
- plotExtra.addGraph(r=new JKQTPGeoRectangle(&plotExtra, x+dx/2,(ycoltest+y-0.5)/2.0, dx*0.5, y-ycoltest-0.5));
- r->setStyle(col,1, Qt::SolidLine, JKQTPGetDerivedColor(plot.getCurrentPlotterStyle().graphsStyle.defaultGraphStyle.fillColorDerivationMode, col), fs);
- x+=dx;
- }
- plotExtra.zoomToFit();
- plotExtra.setX(0, plotExtra.getXMax()+2);
- plotExtra.setY(0, plotExtra.getYMax()+1);
- plotExtra.setGrid(false);
- plotExtra.setPlotLabel("default symbols/lines/colors");
- plotExtra.redrawPlot();
-}
void doListStyles(const QDir& outputDir, const QStringList& doctomodify, int iconsize, QColor backgroundColor) {
@@ -612,19 +450,17 @@ void doListStyles(const QDir& outputDir, const QStringList& doctomodify, int ico
{
QTextStream shtml(&doc);
shtml<<"\n \n Style-file\n | Screenshot\n | Symbols\n";
- for (auto& f: dir.entryList()) {
+ auto files=dir.entryList();
+ if (files.indexOf("default.ini")>=0) {
+ files.swapItemsAt(0,files.indexOf("default.ini"));
+ }
+ for (auto& f: files) {
qDebug()<<"plotting example for style "<\n"
<<" "< \n"
@@ -677,6 +513,8 @@ int main(int argc, char* argv[])
parser.addOption(listerrorindicatorsOption);
QCommandLineOption listaxisstylepropsOption("listaxisstyleprops", "generate example images for JKQTPCALabelType and other coordinate axis properties.");
parser.addOption(listaxisstylepropsOption);
+ QCommandLineOption listpalettesOption("listpalettes", "generate example images for all predefined palettes.");
+ parser.addOption(listpalettesOption);
QCommandLineOption liststylesOption("liststyles", "generate example images for all predefined style INI files.");
parser.addOption(liststylesOption);
QCommandLineOption iconsizeOption("iconsize", "typical size of the generatued images.", "iconsize", "24");
@@ -688,6 +526,7 @@ int main(int argc, char* argv[])
const QDir outputDir(parser.value(outputDirectoryOption));
const QStringList doctomodify(parser.value(doctomodifyectoryOption).split(","));
const bool listsymbols=parser.isSet(listsymbolsOption);
+ const bool listpalettes=parser.isSet(listpalettesOption);
const bool listlinedecorators=parser.isSet(listlinedecoratorsOption);
const bool listerrorindicators=parser.isSet(listerrorindicatorsOption);
const bool listaxisstyleprops=parser.isSet(listaxisstylepropsOption);
@@ -702,6 +541,7 @@ int main(int argc, char* argv[])
if (listerrorindicators) doListErrorIndicators(outputDir, iconsize, backgroundColor);
if (listaxisstyleprops) doListAxisStyling(outputDir, iconsize, backgroundColor);
if (liststyles) doListStyles(outputDir, doctomodify, iconsize, backgroundColor);
+ if (listpalettes) doListPalettes(outputDir, QSize(iconsize,qMax(5,iconsize/16)));
return EXIT_SUCCESS;
}
| | |