From f60632746974160fedd192ddc06ff57b2e74a072 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 4 Feb 2024 21:42:53 +0100 Subject: [PATCH] RENAMED JKQTPDatastore::addColumnCalculatedFromColumn() to JKQTPDatastore::addCalculatedColumnFromColumn(), which is more in line with the other add...()-function names. Aliases with the old function names remain for compatibility --- doc/dox/whatsnew.dox | 1 + .../barchart_customdrawfunctor.cpp | 2 +- .../barchart_errorbars/barchart_errorbars.cpp | 4 ++-- .../barchart_functorfill.cpp | 2 +- .../barchart_twocolor/barchart_twocolor.cpp | 2 +- examples/datastore/datastore.cpp | 4 ++-- .../filledgraphs_errors.cpp | 12 +++++------ examples/multithreaded/multithreaded_thread.h | 2 +- examples/second_axis/second_axis.cpp | 16 +++++++-------- lib/jkqtplotter/jkqtpdatastorage.cpp | 4 ++-- lib/jkqtplotter/jkqtpdatastorage.h | 20 ++++++++++++------- .../jkqtplotter_doc_imagegenerator.cpp | 8 ++++---- 12 files changed, 42 insertions(+), 35 deletions(-) diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 55aafa90b6..c1fc57bbb8 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -78,6 +78,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
  • IMPROVED: documentation of styles: automatized doc image generation.
  • IMPROVED: axis labeling: there were some minor differences between compilers
  • IMPROVED: jkqtp_floattounitstr()/jkqtp_floattolatexunitstr(): add all SI-Prefixes from 10^-30...10^30
  • +
  • RENAMED JKQTPDatastore::addColumnCalculatedFromColumn() to JKQTPDatastore::addCalculatedColumnFromColumn(), which is more in line with the other add...()-function names. Aliases with the old function names remain for compatibility
  • NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request #68 Wiggle Plots from user:xichaoqiang
  • NEW/BREAKING CHANGE: data tooltip can now also be shown when "just" moving the mouse (so far this was only possible when dragging the mouse with a button pressed). This also removes JKQtPlotter::getActMouseLeftAsToolTip() and adds JKQtPlotter::getActMouseMoveToolTip() instead! Also the default toolbars and context menus changed!
  • NEW: new "seaborn" style for plots, see \ref jkqtpplotter_styling
  • diff --git a/examples/barchart_customdrawfunctor/barchart_customdrawfunctor.cpp b/examples/barchart_customdrawfunctor/barchart_customdrawfunctor.cpp index e0268a923d..0c421841e2 100644 --- a/examples/barchart_customdrawfunctor/barchart_customdrawfunctor.cpp +++ b/examples/barchart_customdrawfunctor/barchart_customdrawfunctor.cpp @@ -21,7 +21,7 @@ void doExample(JKQTPlotter& plot, const QString& title) // 2. now we create two columns for key and value size_t columnK=ds->addLinearColumn(7, 0, 6, "k"); - size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return jkqtp_sign(2.0*x-2.5)*qMax(2.0,fabs(2.0*x-2.5)); }, "v"); + size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return jkqtp_sign(2.0*x-2.5)*qMax(2.0,fabs(2.0*x-2.5)); }, "v"); // 3. load a stylesheet plot.loadCurrentPlotterStyle(QSettings(":/JKQTPlotter/styles/seaborn.ini", QSettings::IniFormat)); diff --git a/examples/barchart_errorbars/barchart_errorbars.cpp b/examples/barchart_errorbars/barchart_errorbars.cpp index 0b9639532c..c238f7dc7f 100644 --- a/examples/barchart_errorbars/barchart_errorbars.cpp +++ b/examples/barchart_errorbars/barchart_errorbars.cpp @@ -22,8 +22,8 @@ void doExample(JKQTPlotter& plot, const QString& title) // 2. now we create three columns for key and value size_t columnK=ds->addLinearColumn(6, 0.4*JKQTPSTATISTICS_PI, 2.2*JKQTPSTATISTICS_PI,"k"); - size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return cos(x); }, "v"); - size_t columnE=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return 0.05+0.06*(1.0+sin(x)); }, "error"); + size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return cos(x); }, "v"); + size_t columnE=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return 0.05+0.06*(1.0+sin(x)); }, "error"); // 3. create a graph in the plot, which plots the dataset with symmetric: TCHART* graph1=new TCHART(&plot); diff --git a/examples/barchart_functorfill/barchart_functorfill.cpp b/examples/barchart_functorfill/barchart_functorfill.cpp index 31783d4b62..ead1c12621 100644 --- a/examples/barchart_functorfill/barchart_functorfill.cpp +++ b/examples/barchart_functorfill/barchart_functorfill.cpp @@ -21,7 +21,7 @@ void doExample(JKQTPlotter& plot, const QString& title) // 2. now we create two columns for key and value size_t columnK=ds->addLinearColumn(11, 0, 10, "k"); - size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return 5.0+x; }, "v"); + size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return 5.0+x; }, "v"); // 3. create graph in the plot, which plots the dataset: JKQTPBarGraphBase* graph=new TCHART(&plot); diff --git a/examples/barchart_twocolor/barchart_twocolor.cpp b/examples/barchart_twocolor/barchart_twocolor.cpp index d248bb0d74..2a7f02600c 100644 --- a/examples/barchart_twocolor/barchart_twocolor.cpp +++ b/examples/barchart_twocolor/barchart_twocolor.cpp @@ -22,7 +22,7 @@ void doExample(JKQTPlotter& plot, const QString& title) // 2. now we create two columns for key and value size_t columnK=ds->addLinearColumn(15, 0.5*JKQTPSTATISTICS_PI, 3.0*JKQTPSTATISTICS_PI,"k"); - size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return cos(x); }, "v"); + size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return cos(x); }, "v"); // 3. create graph in the plot, which plots the dataset: JKQTPBarGraphBase* graph=new TCHART(&plot); diff --git a/examples/datastore/datastore.cpp b/examples/datastore/datastore.cpp index 855b7bba82..183653c7c1 100644 --- a/examples/datastore/datastore.cpp +++ b/examples/datastore/datastore.cpp @@ -125,8 +125,8 @@ int main(int argc, char* argv[]) datastore->setPixel(imgColumn2, ix, iy, sin(ix*iy/30.0)); } } - // the loop above can be written more compact using addColumnCalculatedFromColumn(): - //imgColumn=datastore->addColumnCalculatedFromColumn(colLinXY.first, colLinXY.second, [](double x, double y)->double { return cos((x-15.0))/(x-15.0)*cos((y-2.0))/(x-2.0); }, "image value"); + // the loop above can be written more compact using addCalculatedColumnFromColumn(): + //imgColumn=datastore->addCalculatedColumnFromColumn(colLinXY.first, colLinXY.second, [](double x, double y)->double { return cos((x-15.0))/(x-15.0)*cos((y-2.0))/(x-2.0); }, "image value"); // finally we can use a JKQTPXYParametrizedScatterGraph to display the data from our three columns // by using colLinXY->first and colLinXY->second as positions for symbols that are colored, based // on the respective value in imgColumn: diff --git a/examples/filledgraphs_errors/filledgraphs_errors.cpp b/examples/filledgraphs_errors/filledgraphs_errors.cpp index d3f156b0d0..8764c5aebb 100644 --- a/examples/filledgraphs_errors/filledgraphs_errors.cpp +++ b/examples/filledgraphs_errors/filledgraphs_errors.cpp @@ -24,12 +24,12 @@ void doExample(JKQTPlotter& plot, const QString& title) size_t columnK=ds->addLinearColumn(9, 0.1*JKQTPSTATISTICS_PI, 1.0*JKQTPSTATISTICS_PI,"k"); size_t columnK2=ds->addLinearColumn(9, 1.1*JKQTPSTATISTICS_PI, 2.0*JKQTPSTATISTICS_PI,"k2"); size_t columnK3=ds->addLinearColumn(9, 2.1*JKQTPSTATISTICS_PI, 3.0*JKQTPSTATISTICS_PI,"k2"); - size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return sin(x); }, "v"); - size_t columnV2=ds->addColumnCalculatedFromColumn(columnK2, [](double x) { return -sin(x); }, "v2"); - size_t columnV3=ds->addColumnCalculatedFromColumn(columnK3, [](double x) { return sin(x); }, "v3"); - size_t columnE=ds->addColumnCalculatedFromColumn(columnV, [](double x) { return 0.2*x; }, "error"); - size_t columnE2=ds->addColumnCalculatedFromColumn(columnV2, [](double x) { return 0.2*x; }, "error"); - size_t columnE3=ds->addColumnCalculatedFromColumn(columnV3, [](double x) { return 0.2*x; }, "error"); + size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return sin(x); }, "v"); + size_t columnV2=ds->addCalculatedColumnFromColumn(columnK2, [](double x) { return -sin(x); }, "v2"); + size_t columnV3=ds->addCalculatedColumnFromColumn(columnK3, [](double x) { return sin(x); }, "v3"); + size_t columnE=ds->addCalculatedColumnFromColumn(columnV, [](double x) { return 0.2*x; }, "error"); + size_t columnE2=ds->addCalculatedColumnFromColumn(columnV2, [](double x) { return 0.2*x; }, "error"); + size_t columnE3=ds->addCalculatedColumnFromColumn(columnV3, [](double x) { return 0.2*x; }, "error"); // 3. create a graph in the plot, which plots the dataset with symmetric: TCHART* graph1=new TCHART(&plot); diff --git a/examples/multithreaded/multithreaded_thread.h b/examples/multithreaded/multithreaded_thread.h index dda3ae7526..73b3ace7d2 100644 --- a/examples/multithreaded/multithreaded_thread.h +++ b/examples/multithreaded/multithreaded_thread.h @@ -37,7 +37,7 @@ public: JKQTPXYLineGraph* g; plot.addGraph(g=new JKQTPXYLineGraph(&plot)); g->setXColumn(colX); - g->setYColumn(plot.getDatastore()->addColumnCalculatedFromColumn(colX, [&](double x) { return cos(x+double(i+plotIndex)/8.0*JKQTPSTATISTICS_PI)+rng.generateDouble()*0.2-0.1;})); + g->setYColumn(plot.getDatastore()->addCalculatedColumnFromColumn(colX, [&](double x) { return cos(x+double(i+plotIndex)/8.0*JKQTPSTATISTICS_PI)+rng.generateDouble()*0.2-0.1;})); g->setTitle(labeltemplate.arg(i+plotIndex+1)); g->setDrawLine(true); g->setSymbolType(JKQTPNoSymbol); diff --git a/examples/second_axis/second_axis.cpp b/examples/second_axis/second_axis.cpp index fefa9dc211..f47ce5ba5f 100644 --- a/examples/second_axis/second_axis.cpp +++ b/examples/second_axis/second_axis.cpp @@ -19,10 +19,10 @@ void exampleSecondYAxis(JKQTPlotter& plot, const QString& title) // 2. now we create two columns for key and value size_t columnX=ds->addLinearColumn(40, 0,10,"x"); - size_t columnY1=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x; }, "y1"); - size_t columnY2=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return cos(x); }, "y2"); - size_t columnY3=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x*x; }, "y3"); - size_t columnY4=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return sqrt(x); }, "y3"); + size_t columnY1=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return x; }, "y1"); + size_t columnY2=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return cos(x); }, "y2"); + size_t columnY3=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return x*x; }, "y3"); + size_t columnY4=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return sqrt(x); }, "y3"); // 3. create a second y-axis and set its formating options, so it only draws an axis on the right auto yAxisRef2=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis)); @@ -113,10 +113,10 @@ void exampleSecondXAxis(JKQTPlotter& plot, const QString& title) JKQTPDatastore* ds=plot.getDatastore(); size_t columnY=ds->addLinearColumn(30, 0,12,"y"); - size_t columnX1=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return x; }, "x1"); - size_t columnX2=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return cos(x); }, "x2"); - size_t columnX3=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return x*x; }, "x3"); - size_t columnX4=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return sqrt(x); }, "x4"); + size_t columnX1=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return x; }, "x1"); + size_t columnX2=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return cos(x); }, "x2"); + size_t columnX3=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return x*x; }, "x3"); + size_t columnX4=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return sqrt(x); }, "x4"); JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(&plot); graph1->setXColumn(columnX1); diff --git a/lib/jkqtplotter/jkqtpdatastorage.cpp b/lib/jkqtplotter/jkqtpdatastorage.cpp index 7eaa0e4982..4411a02654 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.cpp +++ b/lib/jkqtplotter/jkqtpdatastorage.cpp @@ -814,7 +814,7 @@ size_t JKQTPDatastore::addCalculatedImageColumn(size_t cols, size_t rows, const } //////////////////////////////////////////////////////////////////////////////////////////////// -size_t JKQTPDatastore::addColumnCalculatedFromColumn(size_t otherColumn, const std::function &f, const QString &name) +size_t JKQTPDatastore::addCalculatedColumnFromColumn(size_t otherColumn, const std::function &f, const QString &name) { const JKQTPColumn& oc=columns.value(otherColumn); JKQTPDatastoreItem* it=new JKQTPDatastoreItem(1, oc.getRows()); @@ -826,7 +826,7 @@ size_t JKQTPDatastore::addColumnCalculatedFromColumn(size_t otherColumn, const s } //////////////////////////////////////////////////////////////////////////////////////////////// -size_t JKQTPDatastore::addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function &f, const QString &name) +size_t JKQTPDatastore::addCalculatedColumnFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function &f, const QString &name) { const JKQTPColumn& ocx=columns.value(otherColumnX); const JKQTPColumn& ocy=columns.value(otherColumnY); diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 835e3d6135..b59837ca9f 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -124,7 +124,7 @@ enum class JKQTPDatastoreItemFormat { *
  • addLinearGridColumns() adds two columns which represent x- and y- coordinates of points * on a rectangular grid (useful for calculating image data) *
  • addCalculatedColumn() calculates a column, based on row numbers and a C++ functor - *
  • addColumnCalculatedFromColumn() calculates a column, based on another column data + *
  • addCalculatedColumnFromColumn() calculates a column, based on another column data *
  • addCopiedMap() copies data from a std::map/QMap into two columns *
  • ... several more functions for specific cases exist. *
  • Also note that there are even library extensions that allow to import data directly from OpenCV matrices: JKQTPCopyCvMatToColumn() @@ -1252,7 +1252,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{ * x-coordinates are linearly distributed between \a startX and \a endX and the x-coordinates are linearly * distributed between \a startY and \a endY . * - * \see addLogGridColumns(), addDecadeLogGridColumns(), addColumnCalculatedFromColumn(), JKQTPXYParametrizedScatterGraph, \ref JKQTPlotterBasicJKQTPDatastore + * \see addLogGridColumns(), addDecadeLogGridColumns(), addCalculatedColumnFromColumn(), JKQTPXYParametrizedScatterGraph, \ref JKQTPlotterBasicJKQTPDatastore */ std::pair addLinearGridColumns(size_t width, double startX, double endX, size_t height, double startY, double endY, const QString& nameX=QString(""), const QString& nameY=QString("")); @@ -1267,7 +1267,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{ * return newColumn; * \endcode * - * \see addColumnCalculatedFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore + * \see addCalculatedColumnFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore */ size_t addCalculatedColumn(size_t rows, const std::function& f, const QString& name=QString("")); /** \brief add a column with \a rows entries, that is calculated by calling \a f for each entry @@ -1280,7 +1280,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{ * return newColumn; * \endcode * - * \see addColumnCalculatedFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore + * \see addCalculatedColumnFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore */ size_t addCalculatedColumn(size_t rows, const std::function& f, const QString& name=QString("")); /** \brief add an image column with width \a cols and height \a rows (i.e. \a rows * \a cols entries), that is calculated by calling \a f for each entry @@ -1295,7 +1295,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{ * return newColumn; * \endcode * - * \see addColumnCalculatedFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore + * \see addCalculatedColumnFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore */ size_t addCalculatedImageColumn(size_t cols, size_t rows, const std::function& f, const QString& name=QString("")); /** \brief add a column with the same number of entries, as in the other column \a otherColumn , that are calculated by calling \a f for each entry in \a otherColumn @@ -1310,7 +1310,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{ * * \see addCalculatedColumn(), \ref JKQTPlotterBasicJKQTPDatastore */ - size_t addColumnCalculatedFromColumn(size_t otherColumn, const std::function& f, const QString& name=QString("")); + size_t addCalculatedColumnFromColumn(size_t otherColumn, const std::function& f, const QString& name=QString("")); + inline size_t addColumnCalculatedFromColumn(size_t otherColumn, const std::function& f, const QString& name=QString("")) { + return addCalculatedColumnFromColumn(otherColumn, f, name); + } /** \brief add a column with the same number of entries, as in the other column \a otherColumn , that are calculated by calling \a f for each pair of entries in \a otherColumnX and \a otherColumnY * * Pseudocode: @@ -1323,7 +1326,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{ * * \see addCalculatedColumn(), \ref JKQTPlotterBasicJKQTPDatastore */ - size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function& f, const QString& name=QString("")); + size_t addCalculatedColumnFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function& f, const QString& name=QString("")); + inline size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function& f, const QString& name=QString("")) { + return addCalculatedColumnFromColumn(otherColumnX, otherColumnY, f, name); + } /** \brief returns the number of (logical) columns currently managed by the datastore */ inline size_t getColumnCount() const { return static_cast(columns.size()); } diff --git a/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp b/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp index fc0ea210de..c9bc2b6f45 100644 --- a/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp +++ b/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp @@ -637,9 +637,9 @@ void doListKeyPositions(const QDir& outputDir, int iconsize, QColor /*background const size_t colX=plot.getDatastore()->addLinearColumn(30,0,1); - const size_t colY1=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [](double x) { return x; }); - const size_t colY2=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [](double x) { return x*x; }); - const size_t colY3=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [](double x) { return sqrt(x); }); + const size_t colY1=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [](double x) { return x; }); + const size_t colY2=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [](double x) { return x*x; }); + const size_t colY3=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [](double x) { return sqrt(x); }); JKQTPXYLineGraph* g; plot.addGraph(g=new JKQTPXYLineGraph(&plot)); g->setTitle("linear"); @@ -688,7 +688,7 @@ void doListKeyLayouts(const QDir& outputDir, int iconsize, QColor /*backgroundCo JKQTPXYLineGraph* g; const size_t colX=plot.getDatastore()->addLinearColumn(70,0,1); for (int i=0; i<8; i++) { - const size_t colY1=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [i](double x) { return pow(x, pow(2,(i-4)/4.0)); }); + const size_t colY1=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [i](double x) { return pow(x, pow(2,(i-4)/4.0)); }); plot.addGraph(g=new JKQTPXYLineGraph(&plot)); g->setTitle(QString::number(i+1)+": $f(x)=x^{"+QString::number(pow(2,(i-4)/4.0), 'f', 2)+"}$"); g->setDrawLine(true);