diff --git a/JKQtFastPlotterBuildAllExamples.pro b/JKQtFastPlotterBuildAllExamples.pro deleted file mode 100644 index 7cbcb1ed41..0000000000 --- a/JKQtFastPlotterBuildAllExamples.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += jkqtfastplotterlib \ - jkqtfastplotter_test - -jkqtfastplotterlib.file = $$PWD/lib/jkqtfastplotterlib.pro -jkqtfastplotter_test.file = $$PWD/test/jkqtfastplotter_test/jkqtfastplotter_test_and_lib.pro diff --git a/JKQtPlotterBuildAllExamples.pro b/JKQtPlotterBuildAllExamples.pro index f4b14b9f97..ae549b9569 100644 --- a/JKQtPlotterBuildAllExamples.pro +++ b/JKQtPlotterBuildAllExamples.pro @@ -4,7 +4,8 @@ SUBDIRS += jkqtplotterlib \ jkqtmathtext_simpletest \ jkqtplot_test \ jkqtplotter_simpletest \ - test_multiplot + test_multiplot \ + jkqtfastplotter_test jkqtplotterlib.file = lib/jkqtplotterlib.pro @@ -24,6 +25,9 @@ jkqtplotter_simpletest.depends = jkqtplotterlib test_multiplot.file = test/test_multiplot/test_multiplot.pro test_multiplot.depends = jkqtplotterlib +jkqtfastplotter_test.file = $$PWD/test/jkqtfastplotter_test/jkqtfastplotter_test.pro +jkqtfastplotter_test.depends = jkqtplotterlib + defineTest(addSimpleTest) { test_name = $$1 SUBDIRS += jkqtplotter_simpletest_$${test_name} diff --git a/appveyor.yml b/appveyor.yml index 1279278907..715a0b9556 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -54,13 +54,6 @@ build_script: - echo "Build..." - call %MAKETOOL% - cd .. - #### Fast Plotter ######## - - mkdir build_fast_plotter - - cd build_fast_plotter - - echo "Call QMake (Fast Plotter)..." - - qmake.exe ..\JKQtFastPlotterBuildAllExamples.pro - - echo "Build (Fast Plotter)..." - - call %MAKETOOL% artifacts: - path: build\lib\release\*.a @@ -71,15 +64,7 @@ artifacts: name: dll %QTVER%%QTABI% - path: build\test\**\*.exe name: Test %QTVER%%QTABI% - #### Fast Plotter ######## - - path: build_fast_plotter\lib\release\*.a - name: (FP) lib %QTVER%%QTABI% - - path: build_fast_plotter\lib\release\*.lib - name: (FP) lib %QTVER%%QTABI% - - path: build_fast_plotter\lib\release\*.dll - name: (FP) dll %QTVER%%QTABI% - - path: build_fast_plotter\test\**\*.exe - name: (FP) Test %QTVER%%QTABI% + # # remote desktop connection on init # init: diff --git a/lib/README.md b/lib/README.md new file mode 100644 index 0000000000..711f609f78 --- /dev/null +++ b/lib/README.md @@ -0,0 +1,24 @@ +# JKQtPlotter +## LIB subdirectory + +This directory contains all files necessary to build a library with the JKQtPlotter and JKQtFastPlotter classes inside. There are several ways to add these to your program: + +### QMake +#### simply include all necessary files +If you use QMake and simply want to include all necessary files into your project, include one of these `PRI`-files into your QMake Project: +- `jkqtplotter.pri` contains all files in this library, including `JKQtFastPlotter` and `JKQtMathText` +- `jkqtfastplotter.pri` contains only those files from this directory which are necessary to build `JKQtFastPlotter` +- `jkqtmathtext.pri` contains only those files from this directory which are necessary to build `JKQtMathText` + +#### Build (static) libraries +There are also `.PRO`-files with the same names as the `.PRI`-files above, that can be used to build the full library, or a limited subset. They will produce a static link library that you can include into your projects, e.g. with the following QMake-snippet: + +```qmake +# include JKQtPlotter library +DEPENDPATH += . /lib +INCLUDEPATH += /lib +CONFIG (debug, debug|release):LIBS += -L/lib/debug -ljkqtplotterlib +CONFIG (release):LIBS += -L/lib/release -ljkqtplotterlib +``` + +This snippet assumes that you built the libraries with the provided `.PRO`-files. \ No newline at end of file diff --git a/lib/jkqtfastplotterlib.pro b/lib/jkqtfastplotterlib.pro index 735b7bfa5e..03aa4f4d89 100644 --- a/lib/jkqtfastplotterlib.pro +++ b/lib/jkqtfastplotterlib.pro @@ -1,6 +1,6 @@ TARGET = jkqtfastplotterlib TEMPLATE = lib -CONFIG+=staticlib dll +CONFIG+=staticlib include(jkqtfastplotter.pri) diff --git a/lib/jkqtplotter.pri b/lib/jkqtplotter.pri index ba5152e424..403baf9df8 100644 --- a/lib/jkqtplotter.pri +++ b/lib/jkqtplotter.pri @@ -10,74 +10,78 @@ DEFINES += _CRT_NO_VA_START_VALIDATION } -HEADERS += $$PWD/jkqtplotter/jkqtpbaseplotter.h \ - $$PWD/jkqtplotter/jkqtpdatastorage.h \ - $$PWD/jkqtplotter/jkqtpgraphsbase.h \ - $$PWD/jkqtplotter/jkqtpgraphs.h \ +HEADERS += \ + $$PWD/jkqtfastplotter/jkqtfastplotter.h \ + $$PWD/jkqtmathtext/jkqtmathtext.h \ $$PWD/jkqtplotter/jkqtpbaseelements.h \ - $$PWD/jkqtplotter/jkqtplotter.h \ - $$PWD/jkqtplottertools/jkqtptools.h \ - $$PWD/jkqtplottertools/jkqttools.h \ - $$PWD/jkqtplotter/jkqtpgraphsimage.h \ - $$PWD/jkqtplottertools/jkqtpimagetools.h \ + $$PWD/jkqtplotter/jkqtpbaseplotter.h \ + $$PWD/jkqtplotter/jkqtpdatastorage.h \ + $$PWD/jkqtplotter/jkqtpelementsoverlay.h \ + $$PWD/jkqtplotter/jkqtpgraphs.h \ $$PWD/jkqtplotter/jkqtpgraphsbarchart.h \ + $$PWD/jkqtplotter/jkqtpgraphsbase.h \ $$PWD/jkqtplotter/jkqtpgraphsboxplot.h \ $$PWD/jkqtplotter/jkqtpgraphsevaluatedfunction.h \ $$PWD/jkqtplotter/jkqtpgraphsfilledcurve.h \ + $$PWD/jkqtplotter/jkqtpgraphsgeometric.h \ + $$PWD/jkqtplotter/jkqtpgraphsimage.h \ $$PWD/jkqtplotter/jkqtpgraphsimpulses.h \ $$PWD/jkqtplotter/jkqtpgraphsparsedfunction.h \ - $$PWD/jkqtplotter/jkqtpelementsoverlay.h \ - $$PWD/jkqtplotter/jkqtpgraphsgeometric.h \ $$PWD/jkqtplotter/jkqtpgraphspeakstream.h \ - $$PWD/jkqtplottertools/jkqtpmathparser.h \ - $$PWD/jkqtplottertools/jkqtp_imexport.h \ - $$PWD/jkqtplottergui/jkqtpgraphsmodel.h \ + $$PWD/jkqtplotter/jkqtplotter.h \ $$PWD/jkqtplottergui/jkqtpcomboboxes.h \ - $$PWD/jkqtplottergui/jkqtpenhancedtableview.h \ $$PWD/jkqtplottergui/jkqtpenhancedspinboxes.h \ + $$PWD/jkqtplottergui/jkqtpenhancedtableview.h \ + $$PWD/jkqtplottergui/jkqtpgraphsmodel.h \ $$PWD/jkqtplottergui/jkvanishqtoolbar.h \ - $$PWD/jkqtmathtext/jkqtmathtext.h \ + $$PWD/jkqtplottertools/jkqtp_imexport.h \ $$PWD/jkqtplottertools/jkqtpdrawingtools.h \ + $$PWD/jkqtplottertools/jkqtpenhancedpainter.h \ $$PWD/jkqtplottertools/jkqtphighrestimer.h \ - $$PWD/jkqtplottertools/jkqtpenhancedpainter.h + $$PWD/jkqtplottertools/jkqtpimagetools.h \ + $$PWD/jkqtplottertools/jkqtpmathparser.h \ + $$PWD/jkqtplottertools/jkqtptools.h \ + $$PWD/jkqtplottertools/jkqttools.h -SOURCES += $$PWD/jkqtplotter/jkqtpbaseplotter.cpp \ - $$PWD/jkqtplotter/jkqtpdatastorage.cpp \ - $$PWD/jkqtplotter/jkqtpgraphsbase.cpp \ - $$PWD/jkqtplotter/jkqtpgraphs.cpp \ +SOURCES += \ + $$PWD/jkqtfastplotter/jkqtfastplotter.cpp \ + $$PWD/jkqtmathtext/jkqtmathtext.cpp \ $$PWD/jkqtplotter/jkqtpbaseelements.cpp \ - $$PWD/jkqtplotter/jkqtplotter.cpp \ - $$PWD/jkqtplottertools/jkqtptools.cpp \ - $$PWD/jkqtplottertools/jkqttools.cpp \ - $$PWD/jkqtplotter/jkqtpgraphsimage.cpp \ - $$PWD/jkqtplottertools/jkqtpimagetools.cpp \ + $$PWD/jkqtplotter/jkqtpbaseplotter.cpp \ + $$PWD/jkqtplotter/jkqtpdatastorage.cpp \ + $$PWD/jkqtplotter/jkqtpelementsoverlay.cpp \ + $$PWD/jkqtplotter/jkqtpgraphs.cpp \ $$PWD/jkqtplotter/jkqtpgraphsbarchart.cpp \ + $$PWD/jkqtplotter/jkqtpgraphsbase.cpp \ $$PWD/jkqtplotter/jkqtpgraphsboxplot.cpp \ $$PWD/jkqtplotter/jkqtpgraphsevaluatedfunction.cpp \ $$PWD/jkqtplotter/jkqtpgraphsfilledcurve.cpp \ + $$PWD/jkqtplotter/jkqtpgraphsgeometric.cpp \ + $$PWD/jkqtplotter/jkqtpgraphsimage.cpp \ $$PWD/jkqtplotter/jkqtpgraphsimpulses.cpp \ $$PWD/jkqtplotter/jkqtpgraphsparsedfunction.cpp \ - $$PWD/jkqtplotter/jkqtpelementsoverlay.cpp \ - $$PWD/jkqtplotter/jkqtpgraphsgeometric.cpp \ $$PWD/jkqtplotter/jkqtpgraphspeakstream.cpp \ - $$PWD/jkqtplottertools/jkqtpmathparser.cpp \ - $$PWD/jkqtplottergui/jkqtpgraphsmodel.cpp \ + $$PWD/jkqtplotter/jkqtplotter.cpp \ $$PWD/jkqtplottergui/jkqtpcomboboxes.cpp \ - $$PWD/jkqtplottergui/jkqtpenhancedtableview.cpp \ $$PWD/jkqtplottergui/jkqtpenhancedspinboxes.cpp \ + $$PWD/jkqtplottergui/jkqtpenhancedtableview.cpp \ + $$PWD/jkqtplottergui/jkqtpgraphsmodel.cpp \ $$PWD/jkqtplottergui/jkvanishqtoolbar.cpp \ - $$PWD/jkqtmathtext/jkqtmathtext.cpp \ $$PWD/jkqtplottertools/jkqtpdrawingtools.cpp \ + $$PWD/jkqtplottertools/jkqtpenhancedpainter.cpp \ $$PWD/jkqtplottertools/jkqtphighrestimer.cpp \ - $$PWD/jkqtplottertools/jkqtpenhancedpainter.cpp + $$PWD/jkqtplottertools/jkqtpimagetools.cpp \ + $$PWD/jkqtplottertools/jkqtpmathparser.cpp \ + $$PWD/jkqtplottertools/jkqtptools.cpp \ + $$PWD/jkqtplottertools/jkqttools.cpp RESOURCES += $$PWD/jkqtplotterressources/jkqtpbaseplotter.qrc INCLUDEPATH += $$PWD -QT += core gui xml svg +QT += core gui xml svg opengl #win32:LIBS += -lgdi32 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport diff --git a/lib/jkqtplotter/jkqtpdatastorage.cpp b/lib/jkqtplotter/jkqtpdatastorage.cpp index 7ffdf5e2ff..f5b493625f 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.cpp +++ b/lib/jkqtplotter/jkqtpdatastorage.cpp @@ -42,6 +42,7 @@ JKQTPcolumn::JKQTPcolumn() valid=false; } +//////////////////////////////////////////////////////////////////////////////////////////////// JKQTPcolumn::JKQTPcolumn(JKQTPdatastore *datastore, const QString &name, size_t datastoreItem, size_t datastoreOffset) { this->datastore=datastore; @@ -52,11 +53,13 @@ JKQTPcolumn::JKQTPcolumn(JKQTPdatastore *datastore, const QString &name, size_t } +//////////////////////////////////////////////////////////////////////////////////////////////// JKQTPcolumn::~JKQTPcolumn() { } +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPcolumn::getRows() const { if (!valid || !datastore) return 0; JKQTPdatastoreItem* i=datastore->getItem(datastoreItem); @@ -67,11 +70,11 @@ size_t JKQTPcolumn::getRows() const { //////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPcolumn::copyData(QVector ©To) const { - double* d=getPointer(0); + const double* d=getPointer(0); copyTo.clear(); size_t i, cnt=getRows(); if (cnt>0) { - copyTo.resize(cnt); + copyTo.resize(static_cast(cnt)); for (i=0; i JKQTPcolumn::copyData() //////////////////////////////////////////////////////////////////////////////////////////////// -double *JKQTPcolumn::getPointer(size_t n) const +const double *JKQTPcolumn::getPointer(size_t n) const +{ + if (!datastore) return nullptr; + if (!datastore->getItem(datastoreItem)) return nullptr; + return datastore->getItem(datastoreItem)->getPointer(datastoreOffset, n); +} + +//////////////////////////////////////////////////////////////////////////////////////////////// +double *JKQTPcolumn::getPointer(size_t n) { if (!datastore) return nullptr; if (!datastore->getItem(datastoreItem)) return nullptr; @@ -257,6 +268,7 @@ JKQTPdatastore::JKQTPdatastore() clear(); } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::clear(){ maxItemID=0; maxColumnsID=0; @@ -274,6 +286,7 @@ void JKQTPdatastore::clear(){ columns.clear(); } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::deleteAllColumns(const QString& name, bool removeItems) { QList ids; QMapIterator it(columns); @@ -288,6 +301,7 @@ void JKQTPdatastore::deleteAllColumns(const QString& name, bool removeItems) { } } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::deleteAllPrefixedColumns(QString prefix, bool removeItems) { QList ids; QMapIterator it(columns); @@ -303,6 +317,7 @@ void JKQTPdatastore::deleteAllPrefixedColumns(QString prefix, bool removeItems) } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::deleteColumn(size_t column, bool removeItems) { if (removeItems) { size_t dsitem=columns[column].get_datastoreItem(); @@ -322,6 +337,7 @@ void JKQTPdatastore::deleteColumn(size_t column, bool removeItems) { columns.remove(column); } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getColumnNum(const QString& name) { if (columns.size()<=0) return -1; QMapIterator it(columns); @@ -332,6 +348,7 @@ int JKQTPdatastore::getColumnNum(const QString& name) { return -1; } +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::ensureColumnNum(const QString& name) { if (columns.size()<=0) return -1; QMapIterator it(columns); @@ -342,16 +359,19 @@ size_t JKQTPdatastore::ensureColumnNum(const QString& name) { return addColumn(0, name); } +//////////////////////////////////////////////////////////////////////////////////////////////// JKQTPcolumn JKQTPdatastore::getColumn(size_t i) const { return columns.value(i); } +//////////////////////////////////////////////////////////////////////////////////////////////// JKQTPcolumn JKQTPdatastore::getColumn(int i) const { return columns.value(i); } +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addCopiedItem(JKQTPdatastoreItemFormat dataformat, double* data, size_t columnsnum, size_t rows) { JKQTPdatastoreItem* it=nullptr; if ((dataformat==JKQTPsingleColumn)||(columnsnum==1)) { @@ -378,14 +398,14 @@ size_t JKQTPdatastore::addCopiedItem(JKQTPdatastoreItemFormat dataformat, double -/** \brief add a new columns/item with \a rows rows to the datastore and return its ID. The item uses internal memory management. */ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addItem(size_t rows) { /*items.push_back(new JKQTPdatastoreItem(1, rows)); return items.size()-1;*/ return addItem(new JKQTPdatastoreItem(1, rows)); }; -/** \brief add a new item with \a rows rows and \a columns columns to the datastore and return its ID. The item uses internal memory management. */ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addItem(size_t columnsnum, size_t rows) { /*items.push_back(new JKQTPdatastoreItem(columnsnum, rows)); return items.size()-1;*/ @@ -399,20 +419,21 @@ size_t JKQTPdatastore::addItem(double* data, size_t rows) { return addItem(new JKQTPdatastoreItem(JKQTPsingleColumn, data, 1, rows)); } +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addInternalItem(double *data, size_t rows) { JKQTPdatastoreItem* dsi=new JKQTPdatastoreItem(JKQTPsingleColumn, data, 1, rows, true); return addItem(dsi); }; -/** \brief add an external memory block to the datastore. It contains \a rows rows and \a columns columns. \a dataformat determined the memory layout*/ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addItem(JKQTPdatastoreItemFormat dataformat, double* data, size_t columnsnum, size_t rows) { /*items.push_back(new JKQTPdatastoreItem(dataformat, data, columnsnum, rows)); return items.size()-1;*/ return addItem(new JKQTPdatastoreItem(dataformat, data, columnsnum, rows)); }; -/** \brief add one external array to the datastore. It contains \a rows rows. The data is copied and the copy managed internally */ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addCopiedItem(const double* data, size_t rows) { JKQTPdatastoreItem* it=new JKQTPdatastoreItem(1, rows); if (data) { @@ -426,7 +447,7 @@ size_t JKQTPdatastore::addCopiedItem(const double* data, size_t rows) { return addItem(it); }; -/** \brief add a new columns which references a specified item and a specified column therein. */ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addColumnForItem(size_t itemID, size_t columnInItem, const QString& name) { /*JKQTPcolumn c(this, name, itemID, columnInItem); columns.push_back(c); @@ -434,7 +455,7 @@ size_t JKQTPdatastore::addColumnForItem(size_t itemID, size_t columnInItem, cons return addColumn(JKQTPcolumn(this, name, itemID, columnInItem)); }; -/** \brief add a new columns with \a rows rows to the datastore and return its column ID. The new item uses internal memory management. */ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addColumn(size_t rows, const QString& name) { //items.push_back(new JKQTPdatastoreItem(1, rows)); //return addColumnForItem(items.size()-1, 0, name); @@ -442,7 +463,7 @@ size_t JKQTPdatastore::addColumn(size_t rows, const QString& name) { return addColumnForItem(item, 0, name); }; -/** \brief add one external column to the datastore. It contains \a rows rows. This returns its logical column ID.*/ +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addColumn(double* data, size_t rows, const QString& name) { //items.push_back(new JKQTPdatastoreItem(JKQTPsingleColumn, data, 1, rows)); //std::cout<<"added item\n"; @@ -451,7 +472,8 @@ size_t JKQTPdatastore::addColumn(double* data, size_t rows, const QString& name) size_t it=addItem(new JKQTPdatastoreItem(JKQTPsingleColumn, data, 1, rows)); return addColumnForItem(it, 0, name); }; -/** \brief add one external column to the datastore. It contains \a rows rows. This returns its logical column ID.*/ + +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addInternalColumn(double* data, size_t rows, const QString& name) { //items.push_back(new JKQTPdatastoreItem(JKQTPsingleColumn, data, 1, rows)); //std::cout<<"added item\n"; @@ -469,6 +491,7 @@ size_t JKQTPdatastore::addInternalColumn(double* data, size_t rows, const QStrin +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::copyColumn(size_t old_column, size_t start, size_t stride, const QString& name) { JKQTPcolumn old=columns[old_column]; @@ -486,49 +509,14 @@ size_t JKQTPdatastore::copyColumn(size_t old_column, size_t start, size_t stride return n; } +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::copyColumn(size_t old_column, const QString& name) { return copyColumn(old_column, 0, 1, name); } -#ifdef JKQTPLOTTER_OPENCV_INTERFACE -namespace JKQTPdatastore_Helper { - template - void copyDataFromMat(double* data, const cv::Mat& mat, int channel) { - size_t r=0; - const int channels=mat.channels(); - for (int iy=0; iy(iy); - for (int ix=0; ix(&(row[ix*channels+channel]))); - r++; - } - } - } -} - -size_t JKQTPdatastore::copyCvMatToColumn(const cv::Mat& mat, const QString &name, int channel) -{ - const size_t N=static_cast(mat.cols*mat.rows); - double* d=static_cast(malloc(static_cast(N)*sizeof(double))); - - if (CV_MAT_DEPTH(mat.type())==CV_64F) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else if (CV_MAT_DEPTH(mat.type())==CV_32F) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else if (CV_MAT_DEPTH(mat.type())==CV_32S) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else if (CV_MAT_DEPTH(mat.type())==CV_16S) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else if (CV_MAT_DEPTH(mat.type())==CV_16U) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else if (CV_MAT_DEPTH(mat.type())==CV_8S) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else if (CV_MAT_DEPTH(mat.type())==CV_8U) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); - else throw std::runtime_error("datatype of cv::Mat not supported by JKQTPdatastore::copyImageToColumn()"); - - size_t itemid=addInternalItem(d, N); - return addColumnForItem(itemid, 0, name); - -} -#endif - - +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::addLinearColumn(size_t rows, double start, double end, const QString& name) { double delta=(end-start)/(double)(rows-1); JKQTPdatastoreItem* it=new JKQTPdatastoreItem(1, rows); @@ -543,6 +531,7 @@ size_t JKQTPdatastore::addLinearColumn(size_t rows, double start, double end, co } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextLowerIndex(size_t column, size_t row, int start, int end) const { const JKQTPcolumn& col=columns[column]; @@ -570,11 +559,13 @@ int JKQTPdatastore::getNextLowerIndex(size_t column, size_t row, int start, int } } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextLowerIndex(size_t column, size_t row) const { return getNextLowerIndex(column, row, 0, columns[column].getRows()-1); } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextHigherIndex(size_t column, size_t row, int start, int end) const { const JKQTPcolumn& col=columns[column]; @@ -599,19 +590,23 @@ int JKQTPdatastore::getNextHigherIndex(size_t column, size_t row, int start, int } } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextHigherIndex(size_t column, size_t row) const { return getNextHigherIndex(column, row, 0, columns[column].getRows()-1); } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextLowerIndex(int column, size_t row, int start, int end) const { return getNextLowerIndex(static_cast(column), row, start, end); } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextLowerIndex(int column, size_t row) const { return getNextLowerIndex(static_cast(column), row); } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextHigherIndex(int column, size_t row, int start, int end) const { return getNextHigherIndex(static_cast(column), row, start, end); } @@ -619,6 +614,7 @@ int JKQTPdatastore::getNextHigherIndex(int column, size_t row, int start, int en +//////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPdatastore::getMaxRows() { size_t res=0; /*for (size_t i=0; i userColumns, QString separator, QString decimal_separator, QString comment, QString aroundStrings, char floatformat) { //std::cout< userColumns, QString se f.close(); } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::saveMatlab(QString filename, QSet userColumns) { //std::cout< userColumns) { f.close(); } +//////////////////////////////////////////////////////////////////////////////////////////////// QStringList JKQTPdatastore::getColumnNames() const { QStringList names; QMapIterator it(columns); @@ -675,6 +674,7 @@ QStringList JKQTPdatastore::getColumnNames() const { return names; } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::saveMatlab(QTextStream &txt, QSet userColumns) { //std::cout< userColumns) { } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::saveCSV(QTextStream& txt, QSet userColumns, QString separator, QString decimal_separator, QString comment, QString aroundStrings, char floatformat) { //std::cout< userColumns, QString se } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastore::saveSYLK(QString filename, QSet userColumns, QString floatformat) { Q_UNUSED(floatformat) // find out the decimal and the thousand separator @@ -833,6 +835,7 @@ void JKQTPdatastore::saveSYLK(QString filename, QSet userColumns, QString f } +//////////////////////////////////////////////////////////////////////////////////////////////// QList > JKQTPdatastore::getData(QStringList *columnNames, QSet userColumns) { QStringList cl; @@ -863,6 +866,7 @@ QList > JKQTPdatastore::getData(QStringList *columnNames, QSet userColumns, QString floatformat) { Q_UNUSED(floatformat) // find out the decimal and the thousand separator @@ -921,6 +925,7 @@ void JKQTPdatastore::saveDIF(QString filename, QSet userColumns, QString fl } +//////////////////////////////////////////////////////////////////////////////////////////////// JKQTPdatastoreModel::JKQTPdatastoreModel(JKQTPdatastore *datastore, QObject *parent): QAbstractTableModel(parent) { @@ -928,28 +933,32 @@ JKQTPdatastoreModel::JKQTPdatastoreModel(JKQTPdatastore *datastore, QObject *par reloadModel(); } +//////////////////////////////////////////////////////////////////////////////////////////////// JKQTPdatastoreModel::~JKQTPdatastoreModel() { } +//////////////////////////////////////////////////////////////////////////////////////////////// QVariant JKQTPdatastoreModel::data(const QModelIndex &index, int role) const { int row=index.row(); int column=index.column(); if (datastore) { if (role==Qt::DisplayRole || role==Qt::EditRole) { - int col=datastore->getColumnIDs().value(column, -1); - if (col>-1 && row>=0 && row<(int64_t)datastore->getColumn(col).getRows()) { - return datastore->get(col, row); + int col=static_cast(datastore->getColumnIDs().value(column, -1)); + if (col>-1 && row>=0 && row(datastore->getColumn(col).getRows())) { + return datastore->get(col, static_cast(row)); } } } return QVariant(); } +//////////////////////////////////////////////////////////////////////////////////////////////// Qt::ItemFlags JKQTPdatastoreModel::flags(const QModelIndex &/*index*/) const { return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } +//////////////////////////////////////////////////////////////////////////////////////////////// QVariant JKQTPdatastoreModel::headerData(int section, Qt::Orientation orientation, int role) const { if (datastore) { if (role==Qt::DisplayRole) { @@ -966,20 +975,23 @@ QVariant JKQTPdatastoreModel::headerData(int section, Qt::Orientation orientatio return QVariant(); } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastoreModel::rowCount(const QModelIndex &/*parent*/) const { if (datastore) { - return datastore->getMaxRows(); + return static_cast(datastore->getMaxRows()); } return 0; } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastoreModel::columnCount(const QModelIndex &/*parent*/) const { if (datastore) { - return datastore->getColumnCount(); + return static_cast(datastore->getColumnCount()); } return 0; } +//////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPdatastoreModel::reloadModel() { #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) @@ -990,6 +1002,7 @@ void JKQTPdatastoreModel::reloadModel() #endif } +//////////////////////////////////////////////////////////////////////////////////////////////// int JKQTPdatastore::getNextHigherIndex(int column, size_t row) const { return getNextHigherIndex(static_cast(column), row); } diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 274910a152..c6151eadac 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -279,19 +279,7 @@ class LIB_EXPORT JKQTPdatastore{ size_t itemid=addInternalItem(d, N); return addColumnForItem(itemid, 0, name); } -#ifdef JKQTPLOTTER_OPENCV_INTERFACE - /** \brief add one external column to the datastore. It will be filled with the contents of vector \a data. - * - * \tparam TContainer datatype of the container, which need to support standard C++ iterators and the function \c size(). The contents needs to be convertible to double. - * \param mat OpenCV-marix to store here - * \param name name for the column - * \param channel to copy from \a mat - * \return the ID of the newly created column - * - * \note You need to define the Macro JKQTPLOTTER_OPENCV_INTERFACE when compiling this lib to enabled this function. - */ - size_t copyCvMatToColumn(const cv::Mat& mat, const QString& name=QString(""), int channel=0); -#endif + /** \brief add one external column to the datastore. It will be filled with the contents of vector \a data. * @@ -633,7 +621,8 @@ class LIB_EXPORT JKQTPcolumn { bool valid; protected: - JKQTPGET_MACRO(JKQTPdatastore*, datastore) + inline JKQTPdatastore* get_datastore() { return datastore; } + inline const JKQTPdatastore* get_datastore() const { return datastore; } public: JKQTPcolumn(); /** \brief class constructor that binds the column to a specific datastore object. @@ -648,7 +637,16 @@ class LIB_EXPORT JKQTPcolumn { /** \brief class destructor */ ~JKQTPcolumn() ; - JKQTPGET_SET_MACRO(QString, name) + /** \brief sets the property name to the specified \a __value. \details Description of the parameter name is:
\copybrief name.
\see name for more information */ + inline void set_name (const QString& __value) + { + this->name = __value; + } + /** \brief returns the property name. \see name for more information */ + inline QString get_name () const + { + return this->name; + } /** \brief returns the number of rows in this column (accesses the datastore) */ size_t getRows() const; @@ -670,9 +668,10 @@ class LIB_EXPORT JKQTPcolumn { * column. */ inline double getValue(int n) const; - /** \brief gets a pointer to the n-th value in the column - */ - double* getPointer(size_t n=0) const ; + /** \brief gets a pointer to the n-th value in the column */ + double* getPointer(size_t n=0) ; + /** \brief gets a pointer to the n-th value in the column */ + const double* getPointer(size_t n=0) const; /** \brief sets the \a n'th value from the column * @@ -724,8 +723,13 @@ class LIB_EXPORT JKQTPcolumn { /** \brief set all values in the column to a specific \a value */ void setAll(double value); - JKQTPGET_MACRO(size_t, datastoreItem) - JKQTPGET_MACRO(size_t, datastoreOffset) + + /** \brief returns the property datastoreItem. \details Description of the parameter datastoreItem is:
\copybrief datastoreItem.
. \see datastoreItem for more information */ \ + inline size_t get_datastoreItem() const \ + { return this->datastoreItem; } + /** \brief returns the property datastoreOffset. \details Description of the parameter datastoreOffset is:
\copybrief datastoreOffset.
. \see datastoreOffset for more information */ \ + inline size_t get_datastoreOffset() const \ + { return this->datastoreOffset; } }; @@ -780,8 +784,12 @@ class LIB_EXPORT JKQTPdatastoreItem { /** \brief change the size of all columns to the givne number of rows. The data will be lost */ void resizeColumns(size_t rows); - JKQTPGET_MACRO(size_t, rows) - JKQTPGET_MACRO(size_t, columns) + /** \brief returns the property rows. \details Description of the parameter rows is:
\copybrief rows.
. \see rows for more information */ \ + inline size_t get_rows() const + { return rows; } + /** \brief returns the property columns. \details Description of the parameter columns is:
\copybrief columns.
. \see columns for more information */ \ + inline size_t get_columns() const + { return columns; } /** \brief returns the data at the position (\a column, \a row ). The column index specifies the column inside THIS item, not the global column number. */ @@ -810,6 +818,19 @@ class LIB_EXPORT JKQTPdatastoreItem { } return nullptr; } + + /** \brief returns the data at the position (\a column, \a row ). The column index specifies the column inside THIS item, not the global column number. */ + inline const double* getPointer(size_t column, size_t row) const { + if (data!=nullptr) switch(dataformat) { + case JKQTPsingleColumn: + return &(data[row]); + case JKQTPmatrixColumn: + return &(data[column*rows+row]); + case JKQTPmatrixRow: + return &(data[row*columns+column]); + } + return nullptr; + } /** \brief set the data at the position (\a column, \a row ) to \a value. The column index specifies the column inside THIS item, not the global column number. */ inline void set(size_t column, size_t row, double value) { if (data!=nullptr) switch(dataformat) { diff --git a/lib/jkqtplotter/jkqtpopencvinterface.h b/lib/jkqtplotter/jkqtpopencvinterface.h new file mode 100644 index 0000000000..f71520f9fe --- /dev/null +++ b/lib/jkqtplotter/jkqtpopencvinterface.h @@ -0,0 +1,93 @@ +/* + Copyright (c) 2018 Jan W. Krieger () + + + + 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 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 . +*/ + + + +/** + * \defgroup jkqtpopencvinterface OPenCV Interfaceing Tools + * \ingroup jkqtplotter + * + * Classes and functions in this group allow JKQtPlotter to directly work with OpenCV data structures. + */ + +/** \file jkqtpopencvinterface.h + * \ingroup jkqtpopencvinterface + */ + +#include "jkqtplottertools/jkqtp_imexport.h" +#include "jkqtplotter/jkqtpdatastore.h" +#include + +#ifndef JKQTPOPENCVINTERFACE_H +#define JKQTPOPENCVINTERFACE_H + + +/** \brief add one external column to the datastore. It will be filled with the contents of vector \a data. + * + * \param datastore the datastore to which the OpenCV matrix shuld be added (as column) + * \param mat OpenCV-marix to store here + * \param name name for the column + * \param channel to copy from \a mat + * \return the ID of the newly created column + * + * \note You need to define the Macro JKQTPLOTTER_OPENCV_INTERFACE when compiling this lib to enabled this function. + */ +inline size_t JKQTPcopyCvMatToColumn(JKQTPdatastore* datastore, const cv::Mat& mat, const QString& name=QString(""), int channel=0); + + + + + +//////////////////////////////////////////////////////////////////////////////////////// +namespace JKQTPdatastore_Helper { + template + inline void copyDataFromMat(double* data, const cv::Mat& mat, int channel) { + size_t r=0; + const int channels=mat.channels(); + for (int iy=0; iy(iy); + for (int ix=0; ix(&(row[ix*channels+channel]))); + r++; + } + } + } +} + +inline size_t JKQTPcopyCvMatToColumn(JKQTPdatastore* datastore, const cv::Mat& mat, const QString &name, int channel) +{ + const size_t N=static_cast(mat.cols*mat.rows); + double* d=static_cast(malloc(static_cast(N)*sizeof(double))); + + if (CV_MAT_DEPTH(mat.type())==CV_64F) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else if (CV_MAT_DEPTH(mat.type())==CV_32F) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else if (CV_MAT_DEPTH(mat.type())==CV_32S) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else if (CV_MAT_DEPTH(mat.type())==CV_16S) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else if (CV_MAT_DEPTH(mat.type())==CV_16U) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else if (CV_MAT_DEPTH(mat.type())==CV_8S) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else if (CV_MAT_DEPTH(mat.type())==CV_8U) JKQTPdatastore_Helper::copyDataFromMat(d, mat, channel); + else throw std::runtime_error("datatype of cv::Mat not supported by JKQTPdatastore::copyImageToColumn()"); + + size_t itemid=datastore->addInternalItem(d, N); + return datastore->addColumnForItem(itemid, 0, name); +} + + + +#endif // JKQTPOPENCVINTERFACE_H diff --git a/lib/jkqtplottertools/jkqtpenhancedpainter.h b/lib/jkqtplottertools/jkqtpenhancedpainter.h index 6383d86dae..a0c48b0302 100644 --- a/lib/jkqtplottertools/jkqtpenhancedpainter.h +++ b/lib/jkqtplottertools/jkqtpenhancedpainter.h @@ -41,6 +41,7 @@ */ class LIB_EXPORT JKQTPEnhancedPainter : public QPainter { + Q_GADGET public: JKQTPEnhancedPainter(QPaintDevice* device); JKQTPEnhancedPainter(); diff --git a/lib/jkqtplottertools/jkqtpmathparser.cpp b/lib/jkqtplottertools/jkqtpmathparser.cpp index dc07950a5d..caae0846eb 100644 --- a/lib/jkqtplottertools/jkqtpmathparser.cpp +++ b/lib/jkqtplottertools/jkqtpmathparser.cpp @@ -31,555 +31,555 @@ /****************************************************************************************** - * default-Funktionen f�r den Parser + * default-function implementations for math parser ******************************************************************************************/ - -JKQTPMathParser::jkmpResult fFloatToStr(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - std::ostringstream ost; - r.type=JKQTPMathParser::jkmpString; - if (n!=1) p->jkmpError("floattostr accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("floattostr needs double argument"); - ost<jkmpError("floattostr accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("floattostr needs double argument"); + ost<jkmpError("inttostr accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("inttostr needs double argument"); - ost<jkmpError("inttostr accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("inttostr needs double argument"); + ost<jkmpError("booltostr accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpBool) p->jkmpError("floattostr needs bool argument"); - r.str=(r.boolean)?"true":"false"; - return r; -} + JKQTPMathParser::jkmpResult fBoolToStr(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + std::ostringstream ost; + r.type=JKQTPMathParser::jkmpString; + if (n!=1) p->jkmpError("booltostr accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpBool) p->jkmpError("floattostr needs bool argument"); + r.str=(r.boolean)?"true":"false"; + return r; + } -JKQTPMathParser::jkmpResult fToSystemPathSeparator(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpString; - if (n!=1) p->jkmpError("tosystempathseparator accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("tosystempathseparator needs string argument"); - r.str=""; - for (size_t i=0; ijkmpError("setdefault accepts 2 argument"); - if (params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("setdefault needs a string as first argument"); - r=params[1]; - if (p->variableExists(params[0].str)) { - r=p->getVariable(params[0].str); - } - - return r; -} - - -JKQTPMathParser::jkmpResult fStrDate(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpString; - std::string f="%Y-%m-%d"; - if (n>1) p->jkmpError("strdate accepts 0 or 1 argumentment"); - if (n>0 && params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("strdate needs a string as first argument"); - if (n>0) f=params[0].str; - char re[1024]; - time_t rawtime; - struct tm* timeinfo; - time(&rawtime); - timeinfo=localtime(&rawtime); - strftime(re, 1024, f.c_str(), timeinfo); - r.str=re; - - return r; -} - -JKQTPMathParser::jkmpResult fCMDParam(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpString; - std::string def=""; - if (n<1 || n>2) p->jkmpError("cmdparam(name, default) accepts 1 or 2 argument"); - if (params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("cmdparam needs a string as first argument"); - if (n>1 && params[1].type!=JKQTPMathParser::jkmpString) p->jkmpError("cmdparam needs a string as second argument"); - if (n>1) def=params[1].str; - - r.str=p->getArgCVParam(params[0].str, def); - return r; -} - - -JKQTPMathParser::jkmpResult fSinc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sinc accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sinc needs double argument"); - //r.num=sin(params[0].num)/params[0].num; - - double x=params[0].num; - static double const taylor_0_bound = 3*DBL_MIN ; - static double const taylor_2_bound = sqrt(taylor_0_bound); - static double const taylor_n_bound = sqrt(taylor_2_bound); - - double result = 1; - if (fabs(x) >= taylor_n_bound) - { - result= sin(x)/x; - } - else - { - // approximation by taylor series in x at 0 up to order 0 - - if (fabs(x) >= taylor_0_bound) - { - double x2 = x*x; - - // approximation by taylor series in x at 0 up to order 2 - result -= x2/static_cast(6); - - if (fabs(x) >= taylor_2_bound) - { - // approximation by taylor series in x at 0 up to order 4 - result += (x2*x2)/static_cast(120); - } + JKQTPMathParser::jkmpResult fToSystemPathSeparator(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpString; + if (n!=1) p->jkmpError("tosystempathseparator accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("tosystempathseparator needs string argument"); + r.str=""; + for (size_t i=0; ijkmpError("tanc accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tanc needs double argument"); - r.num=(params[0].num==0)?1.0:tan(params[0].num)/params[0].num; - return r; -} - -JKQTPMathParser::jkmpResult fSin(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sin accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sin needs double argument"); - r.num=sin(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fCos(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("cos accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("cos needs double argument"); - r.num=cos(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fTan(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("tan accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tan needs double argument"); - r.num=tan(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fExp(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("exp accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("exp needs double argument"); - r.num=exp(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fLog(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("log accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("log needs double argument"); - r.num=log(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fLog10(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("log10 accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("log10 needs double argument"); - r.num=log10(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fLog2(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("log2 accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("log2 needs double argument"); - r.num=log2(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fSqrt(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sqrt accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sqrt needs double argument"); - r.num=sqrt(params[0].num); - return r; -} -JKQTPMathParser::jkmpResult fCbrt(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("cbrt accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("cbrt needs double argument"); - r.num=cbrt(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fSqr(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sqr accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sqr needs double argument"); - r.num=params[0].num*params[0].num; - return r; -} - -JKQTPMathParser::jkmpResult fAbs(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("abs accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("abs needs double argument"); - r.num=fabs(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fIf(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - if (n!=3) p->jkmpError("If accepts 3 argument"); - if (params[0].type!=JKQTPMathParser::jkmpBool) p->jkmpError("If needs bool as first argument"); - if (params[0].boolean) return params[1]; else return params[2]; -} - -JKQTPMathParser::jkmpResult fASin(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("asin accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("asin needs double argument"); - r.num=asin(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fACos(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("acos accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("acos needs double argument"); - r.num=acos(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fATan(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("atan accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("atan needs double argument"); - r.num=atan(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fATan2(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("atan2 accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("atan2 needs double argument"); - r.num=atan2(params[0].num, params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult fSinh(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sinh accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sinh needs double argument"); - r.num=sinh(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fCosh(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("cosh accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("cosh needs double argument"); - r.num=cosh(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fTanh(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("tanh accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tanh needs double argument"); - r.num=tanh(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fErf(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("erf accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("erf needs double argument"); - r.num=erf(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fErfc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("erfc accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("erfc needs double argument"); - r.num=erfc(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult flGamma(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("lgamma accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("lgamma needs double argument"); - r.num=lgamma(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult ftGamma(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("tgamma accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tgamma needs double argument"); - r.num=tgamma(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fJ0(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("j0 accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j0 needs double argument"); - r.num=j0(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fJ1(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("j1 accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j1 needs double argument"); - r.num=j1(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fY0(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("y0 accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y0 needs double argument"); - r.num=y0(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fY1(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("y1 accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y1 needs double argument"); - r.num=y1(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fYn(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("yn accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("yn needs double argument"); - r.num=yn((int)params[0].num, params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult fJn(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("jn accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("jn needs double argument"); - r.num=jn((int)params[0].num, params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult fSRand(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("srand accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("srand needs double argument"); - r.num=0; - srand((unsigned int)params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fRand(JKQTPMathParser::jkmpResult* /*params*/, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=0) p->jkmpError("rand accepts 0 argument"); - r.num=double(rand())/double(RAND_MAX); - return r; -} - -JKQTPMathParser::jkmpResult fCeil(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("ceil accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("ceil needs double argument"); - r.num=ceil(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fFloor(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("floor accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("floor needs double argument"); - r.num=floor(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fTrunc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("trunc accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("trunc needs double argument"); - r.num=trunc(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fRound(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("round accepts 1 argument"); - if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("round needs double argument"); - r.num=round(params[0].num); - return r; -} - -JKQTPMathParser::jkmpResult fFMod(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("fmod accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("fmod needs double argument"); - r.num=fmod((int)params[0].num, params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult fMin(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("min accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("min needs double argument"); - r.num=fmin((int)params[0].num, params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult fMax(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("max accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("max needs double argument"); - r.num=fmax((int)params[0].num, params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult QFSPIMLightsheetEvaluationItem_fGauss(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("gauss accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("gauss needs double argument"); - r.num=exp(-2*params[0].num*params[0].num/params[1].num/params[1].num); - return r; -} - -JKQTPMathParser::jkmpResult fSlit(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=2) p->jkmpError("slit accepts 2 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("slit needs double argument"); - r.num=((params[0].num>=-1.0*params[1].num/2)&&(params[0].num<=params[1].num/2))?1.0:0.0; - return r; -} - -JKQTPMathParser::jkmpResult fTheta(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("theta accepts 1 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("theta needs double argument"); - r.num=(params[0].num>=0)?1.0:0.0; - return r; -} - -JKQTPMathParser::jkmpResult fSigmoid(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sigmoid accepts 1 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("sigmoid needs double argument"); - r.num=1.0/(1+exp(-1.0*params[0].num)); - return r; -} - -JKQTPMathParser::jkmpResult fSign(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ - JKQTPMathParser::jkmpResult r; - r.type=JKQTPMathParser::jkmpDouble; - if (n!=1) p->jkmpError("sign accepts 1 argument"); - if ((params[0].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("sign needs double argument"); - r.num=0.0; - if (params[0].num<0) { r.num=-1; } - else if (params[0].num>0) { r.num=+1; } - return r; -} - - - -inline std::string strip(std::string s) { - std::string r; - for (size_t i=0; ijkmpError("setdefault accepts 2 argument"); + if (params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("setdefault needs a string as first argument"); + r=params[1]; + if (p->variableExists(params[0].str)) { + r=p->getVariable(params[0].str); + } + + return r; + } + + + JKQTPMathParser::jkmpResult fStrDate(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpString; + std::string f="%Y-%m-%d"; + if (n>1) p->jkmpError("strdate accepts 0 or 1 argumentment"); + if (n>0 && params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("strdate needs a string as first argument"); + if (n>0) f=params[0].str; + char re[1024]; + time_t rawtime; + struct tm* timeinfo; + time(&rawtime); + timeinfo=localtime(&rawtime); + strftime(re, 1024, f.c_str(), timeinfo); + r.str=re; + + return r; + } + + JKQTPMathParser::jkmpResult fCMDParam(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpString; + std::string def=""; + if (n<1 || n>2) p->jkmpError("cmdparam(name, default) accepts 1 or 2 argument"); + if (params[0].type!=JKQTPMathParser::jkmpString) p->jkmpError("cmdparam needs a string as first argument"); + if (n>1 && params[1].type!=JKQTPMathParser::jkmpString) p->jkmpError("cmdparam needs a string as second argument"); + if (n>1) def=params[1].str; + + r.str=p->getArgCVParam(params[0].str, def); + return r; + } + + + JKQTPMathParser::jkmpResult fSinc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sinc accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sinc needs double argument"); + //r.num=sin(params[0].num)/params[0].num; + + double x=params[0].num; + static double const taylor_0_bound = 3*DBL_MIN ; + static double const taylor_2_bound = sqrt(taylor_0_bound); + static double const taylor_n_bound = sqrt(taylor_2_bound); + + double result = 1; + if (fabs(x) >= taylor_n_bound) + { + result= sin(x)/x; + } + else + { + // approximation by taylor series in x at 0 up to order 0 + + if (fabs(x) >= taylor_0_bound) + { + double x2 = x*x; + + // approximation by taylor series in x at 0 up to order 2 + result -= x2/static_cast(6); + + if (fabs(x) >= taylor_2_bound) + { + // approximation by taylor series in x at 0 up to order 4 + result += (x2*x2)/static_cast(120); + } + } + + + } + + r.num=result; + + return r; + } + + JKQTPMathParser::jkmpResult fTanc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("tanc accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tanc needs double argument"); + r.num=(params[0].num==0)?1.0:tan(params[0].num)/params[0].num; + return r; + } + + JKQTPMathParser::jkmpResult fSin(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sin accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sin needs double argument"); + r.num=sin(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fCos(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("cos accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("cos needs double argument"); + r.num=cos(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fTan(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("tan accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tan needs double argument"); + r.num=tan(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fExp(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("exp accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("exp needs double argument"); + r.num=exp(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fLog(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("log accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("log needs double argument"); + r.num=log(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fLog10(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("log10 accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("log10 needs double argument"); + r.num=log10(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fLog2(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("log2 accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("log2 needs double argument"); + r.num=log2(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fSqrt(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sqrt accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sqrt needs double argument"); + r.num=sqrt(params[0].num); + return r; + } + JKQTPMathParser::jkmpResult fCbrt(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("cbrt accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("cbrt needs double argument"); + r.num=cbrt(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fSqr(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sqr accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sqr needs double argument"); + r.num=params[0].num*params[0].num; + return r; + } + + JKQTPMathParser::jkmpResult fAbs(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("abs accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("abs needs double argument"); + r.num=fabs(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fIf(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + if (n!=3) p->jkmpError("If accepts 3 argument"); + if (params[0].type!=JKQTPMathParser::jkmpBool) p->jkmpError("If needs bool as first argument"); + if (params[0].boolean) return params[1]; else return params[2]; + } + + JKQTPMathParser::jkmpResult fASin(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("asin accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("asin needs double argument"); + r.num=asin(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fACos(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("acos accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("acos needs double argument"); + r.num=acos(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fATan(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("atan accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("atan needs double argument"); + r.num=atan(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fATan2(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("atan2 accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("atan2 needs double argument"); + r.num=atan2(params[0].num, params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult fSinh(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sinh accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("sinh needs double argument"); + r.num=sinh(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fCosh(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("cosh accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("cosh needs double argument"); + r.num=cosh(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fTanh(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("tanh accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tanh needs double argument"); + r.num=tanh(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fErf(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("erf accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("erf needs double argument"); + r.num=erf(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fErfc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("erfc accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("erfc needs double argument"); + r.num=erfc(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult flGamma(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("lgamma accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("lgamma needs double argument"); + r.num=lgamma(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult ftGamma(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("tgamma accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("tgamma needs double argument"); + r.num=tgamma(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fJ0(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("j0 accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j0 needs double argument"); + r.num=j0(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fJ1(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("j1 accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j1 needs double argument"); + r.num=j1(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fY0(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("y0 accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y0 needs double argument"); + r.num=y0(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fY1(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("y1 accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y1 needs double argument"); + r.num=y1(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fYn(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("yn accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("yn needs double argument"); + r.num=yn((int)params[0].num, params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult fJn(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("jn accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("jn needs double argument"); + r.num=jn((int)params[0].num, params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult fSRand(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("srand accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("srand needs double argument"); + r.num=0; + srand((unsigned int)params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fRand(JKQTPMathParser::jkmpResult* /*params*/, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=0) p->jkmpError("rand accepts 0 argument"); + r.num=double(rand())/double(RAND_MAX); + return r; + } + + JKQTPMathParser::jkmpResult fCeil(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("ceil accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("ceil needs double argument"); + r.num=ceil(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fFloor(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("floor accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("floor needs double argument"); + r.num=floor(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fTrunc(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("trunc accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("trunc needs double argument"); + r.num=trunc(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fRound(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("round accepts 1 argument"); + if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("round needs double argument"); + r.num=round(params[0].num); + return r; + } + + JKQTPMathParser::jkmpResult fFMod(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("fmod accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("fmod needs double argument"); + r.num=fmod((int)params[0].num, params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult fMin(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("min accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("min needs double argument"); + r.num=fmin((int)params[0].num, params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult fMax(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("max accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("max needs double argument"); + r.num=fmax((int)params[0].num, params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult QFSPIMLightsheetEvaluationItem_fGauss(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("gauss accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("gauss needs double argument"); + r.num=exp(-2*params[0].num*params[0].num/params[1].num/params[1].num); + return r; + } + + JKQTPMathParser::jkmpResult fSlit(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=2) p->jkmpError("slit accepts 2 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("slit needs double argument"); + r.num=((params[0].num>=-1.0*params[1].num/2)&&(params[0].num<=params[1].num/2))?1.0:0.0; + return r; + } + + JKQTPMathParser::jkmpResult fTheta(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("theta accepts 1 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("theta needs double argument"); + r.num=(params[0].num>=0)?1.0:0.0; + return r; + } + + JKQTPMathParser::jkmpResult fSigmoid(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sigmoid accepts 1 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("sigmoid needs double argument"); + r.num=1.0/(1+exp(-1.0*params[0].num)); + return r; + } + + JKQTPMathParser::jkmpResult fSign(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){ + JKQTPMathParser::jkmpResult r; + r.type=JKQTPMathParser::jkmpDouble; + if (n!=1) p->jkmpError("sign accepts 1 argument"); + if ((params[0].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("sign needs double argument"); + r.num=0.0; + if (params[0].num<0) { r.num=-1; } + else if (params[0].num>0) { r.num=+1; } + return r; + } + + + + inline std::string strip(std::string s) { + std::string r; + for (size_t i=0; i #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpopencvinterface.h" #include #ifndef M_PI @@ -63,7 +64,7 @@ int main(int argc, char* argv[]) // 3. make data available to JKQtPlotter by adding it to the internal datastore. // In this step the contents of one channel of the openCV cv::Mat is copied into a column // of the datastore in row-major order - size_t cAiryDisk=ds->copyCvMatToColumn(airydisk, "imagedata"); + size_t cAiryDisk=JKQTPcopyCvMatToColumn(ds, airydisk, "imagedata"); // 4. create a graph (JKQTPColumnMathImage) with the column created above as data diff --git a/test/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.cpp b/test/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.cpp index 77f9ca30b4..477c491ba4 100644 --- a/test/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.cpp +++ b/test/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.cpp @@ -3,6 +3,7 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphs.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpopencvinterface.h" #include #ifndef M_PI @@ -52,7 +53,7 @@ int main(int argc, char* argv[]) // 3. make data available to JKQtPlotter by adding it to the internal datastore. // In this step the contents of one channel of the openCV cv::Mat is copied into a column // of the datastore in row-major order - size_t cAiryDisk=ds->copyCvMatToColumn(airydisk, "imagedata"); + size_t cAiryDisk=JKQTPcopyCvMatToColumn(ds, airydisk, "imagedata"); // 4. create a graph (JKQTPColumnMathImage) with the column created above as data diff --git a/test/simpletest_rgbimageplot_opencv/README.md b/test/simpletest_rgbimageplot_opencv/README.md index ef0e4f5614..8581b224cc 100644 --- a/test/simpletest_rgbimageplot_opencv/README.md +++ b/test/simpletest_rgbimageplot_opencv/README.md @@ -4,9 +4,9 @@ ## Simple RGB image plot, showing a 3-channel OpenCV cv::Mat This project (see `./test/simpletest_imageplot_opencv/`) simply creates a JKQtPlotter widget (as a new window) and adds a color-coded image plot of a mathematical function (here the Airy disk). The image is generated as an OpenCV cv::Mat image and then copied into a single column of the internal datasdtore (JKQTPMathImage could be directly used without the internal datastore). -To copy the data a special OpenCV Interface function `JKQTPdatastore::copyCvMatToColumn()` is used, that copies the data from a cv::Mat directly into a column. +To copy the data a special OpenCV Interface function `JKQTPcopyCvMatToColumn()` is used, that copies the data from a cv::Mat directly into a column. -The function `JKQTPdatastore::copyCvMatToColumn()` is only available, when the preprocessore macro `JKQTPLOTTER_OPENCV_INTERFACE` is defined when compiling the JKQtPlotter library. +The function `JKQTPcopyCvMatToColumn()` is available from the (non-default) header-only extension from `jkqtplotter/jkqtpopencvinterface.h`. This header provides facilities to interface JKQtPlotter with OPenCV. The source code of the main application is (see [`jkqtplotter_simpletest_imageplot_opencv.cpp`](https://github.com/jkriege2/JKQtPlotter/blob/master/test/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.cpp): ```c++ @@ -14,6 +14,7 @@ The source code of the main application is (see [`jkqtplotter_simpletest_imagepl #include #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpopencvinterface.h" #include #include @@ -41,9 +42,9 @@ int main(int argc, char* argv[]) // 3. make data available to JKQtPlotter by adding it to the internal datastore. // In this step the contents of each channel of the openCV cv::Mat is copied into a column // of the datastore in row-major order - size_t cPictureR=ds->copyCvMatToColumn(picture, "R-channel", 2); - size_t cPictureG=ds->copyCvMatToColumn(picture, "G-channel", 1); - size_t cPictureB=ds->copyCvMatToColumn(picture, "B-channel", 0); + size_t cPictureR=JKQTPcopyCvMatToColumn(ds, picture, "R-channel", 2); + size_t cPictureG=JKQTPcopyCvMatToColumn(ds, picture, "G-channel", 1); + size_t cPictureB=JKQTPcopyCvMatToColumn(ds, picture, "B-channel", 0); // 4. create a graph (JKQTPColumnRGBMathImage) with the columns created above as data diff --git a/test/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp b/test/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp index 639d938408..31f0beff80 100644 --- a/test/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp +++ b/test/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp @@ -3,6 +3,7 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphs.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpopencvinterface.h" #include @@ -29,9 +30,9 @@ int main(int argc, char* argv[]) // 3. make data available to JKQtPlotter by adding it to the internal datastore. // In this step the contents of each channel of the openCV cv::Mat is copied into a column // of the datastore in row-major order - size_t cPictureR=ds->copyCvMatToColumn(picture, "R-channel", 2); - size_t cPictureG=ds->copyCvMatToColumn(picture, "G-channel", 1); - size_t cPictureB=ds->copyCvMatToColumn(picture, "B-channel", 0); + size_t cPictureR=JKQTPcopyCvMatToColumn(ds, picture, "R-channel", 2); + size_t cPictureG=JKQTPcopyCvMatToColumn(ds, picture, "G-channel", 1); + size_t cPictureB=JKQTPcopyCvMatToColumn(ds, picture, "B-channel", 0); // 4. create a graph (JKQTPColumnRGBMathImage) with the columns created above as data