diff --git a/cmake/jkqtplotter_common_compilersettings.cmake b/cmake/jkqtplotter_common_compilersettings.cmake index 39f54df466..3ad3137e9a 100644 --- a/cmake/jkqtplotter_common_compilersettings.cmake +++ b/cmake/jkqtplotter_common_compilersettings.cmake @@ -10,13 +10,10 @@ if(MINGW) elseif(MSVC) # COMPILER-SETTINGS FOR MS VISUAL C++ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") - # To enable M_PI, M_E,... - add_definitions(/D_USE_MATH_DEFINES) - # To Prevent Errors with min() and max() - add_definitions(/DNOMINMAX) # To fix error: C2338: va_start argument must not # have reference type and must not be parenthesized add_definitions(/D_CRT_NO_VA_START_VALIDATION) + add_definitions(/DNOMINMAX) endif() if(NOT APPLE) diff --git a/cmake/jkqtplotter_deployqt.cmake b/cmake/jkqtplotter_deployqt.cmake index 7235cd51e2..772c5d053f 100644 --- a/cmake/jkqtplotter_deployqt.cmake +++ b/cmake/jkqtplotter_deployqt.cmake @@ -22,6 +22,8 @@ function(jkqtplotter_deployqt TARGET_NAME) COMMAND "${CMAKE_COMMAND}" -E env PATH="${CMAKE_CXX_COMPILER_BINPATH}\;${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}" --compiler-runtime + -xml + -printsupport ${WINDEPLOYQTOPTION} \"$\" COMMENT "Running windeployqt ... " diff --git a/examples/advplotstyling/advplotstyling.cpp b/examples/advplotstyling/advplotstyling.cpp index 607d067546..69d737c56a 100644 --- a/examples/advplotstyling/advplotstyling.cpp +++ b/examples/advplotstyling/advplotstyling.cpp @@ -23,11 +23,11 @@ int main(int argc, char* argv[]) QVector X, Yline, Yfilled, Yfilled2, Ybarsempty, Ybarsfilled; const int Ndata=20; // number of plot points in each curve for (int i=0; isetPixel(cPotential, ix, iy, Q1/(4.0*M_PI*eps0)/r1+Q2/(4.0*M_PI*eps0)/r2+Q3/(4.0*M_PI*eps0)/r3+Q4/(4.0*M_PI*eps0)/r4); + ds->setPixel(cPotential, ix, iy, Q1/(4.0*JKQTPSTATISTICS_PI*eps0)/r1+Q2/(4.0*JKQTPSTATISTICS_PI*eps0)/r2+Q3/(4.0*JKQTPSTATISTICS_PI*eps0)/r3+Q4/(4.0*JKQTPSTATISTICS_PI*eps0)/r4); x+=dx; } y+=dx; } - // the following code will plot a dipole potential instead of the quadrupole after 5s - // this tests the recognition of altered data + // the following code will plot a dipole JKQTPSTATISTICS_PIntial instead of tJKQTPSTATISTICS_PIuadrupole after 5sJKQTPSTATISTICS_PI // this tests theJKQTPSTATISTICS_PIognition of altered data #ifdef ANIMATE JKQTPlotter* pplot=&plot; ContourPlotAnimator animation(ds,pplot,NX,NY,w,h,dx,cPotential); @@ -104,11 +99,11 @@ int main(int argc, char* argv[]) QVector reldists; reldists<<0.1<<0.25<<0.5<<1<<1.5<<2<<2.5<<3; // finally contour levels with +1 and -1 sign are added to show the positive and negative potential: for (auto reldist: reldists) { - const double level=fabs(Q1/(4.0*M_PI*eps0)/(Q1_x0*reldist)); + const double level=fabs(Q1/(4.0*JKQTPSTATISTICS_PI*eps0)/(Q1_x0*reldist)); graph->addContourLevel(-level); graph->addContourLevel(level); - // set a special color for some lines: + // set a special color for some JKQTPSTATISTICS_PIs: //if (reldist==1) { // graph->setOverrideColor(-level, QColor("yellow")); // graph->setOverrideColor(level, QColor("yellow")); diff --git a/examples/contourplot/contourplotanimator.cpp b/examples/contourplot/contourplotanimator.cpp index c39617cf0e..86e0309fbb 100644 --- a/examples/contourplot/contourplotanimator.cpp +++ b/examples/contourplot/contourplotanimator.cpp @@ -37,7 +37,7 @@ void ContourPlotAnimator::step() { const double r2=sqrt((x-Q2_x0)*(x-Q2_x0)+(y-Q2_y0)*(y-Q2_y0)); const double r3=sqrt((x-Q3_x0)*(x-Q3_x0)+(y-Q3_y0)*(y-Q3_y0)); const double r4=sqrt((x-Q4_x0)*(x-Q4_x0)+(y-Q4_y0)*(y-Q4_y0)); - ds->setPixel(cPotential, ix, iy, Q1/(4.0*M_PI*eps0)/r1+Q2/(4.0*M_PI*eps0)/r2+Q3/(4.0*M_PI*eps0)/r3+Q4/(4.0*M_PI*eps0)/r4); + ds->setPixel(cPotential, ix, iy, Q1/(4.0*JKQTPSTATISTICS_PI*eps0)/r1+Q2/(4.0*JKQTPSTATISTICS_PI*eps0)/r2+Q3/(4.0*JKQTPSTATISTICS_PI*eps0)/r3+Q4/(4.0*JKQTPSTATISTICS_PI*eps0)/r4); x+=dx; } y+=dx; @@ -45,7 +45,7 @@ void ContourPlotAnimator::step() { pplot->redrawPlot(); qDebug()<<"animation step: angle="< "<setWindowTitle("JKQTPColumnContourPlot ["+QString::number(1.0/(timerFR.elapsed()/1000.0))+"fps]"); - angle+=(2.0/180.0*M_PI); + angle+=(2.0/180.0*JKQTPSTATISTICS_PI); timerFR.start(); QTimer::singleShot(1, this,SLOT(step())); } diff --git a/examples/contourplot/contourplotanimator.h b/examples/contourplot/contourplotanimator.h index b2b4b2abd2..cd7bd7e801 100644 --- a/examples/contourplot/contourplotanimator.h +++ b/examples/contourplot/contourplotanimator.h @@ -7,9 +7,6 @@ #include #include "jkqtplotter/jkqtplotter.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif class ContourPlotAnimator: public QObject { Q_OBJECT diff --git a/examples/datastore/datastore.cpp b/examples/datastore/datastore.cpp index a025b84f53..4bb7ef00ee 100644 --- a/examples/datastore/datastore.cpp +++ b/examples/datastore/datastore.cpp @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) QVector X, Y; const int Ndata=100; for (int i=0; iaddLinearColumn(50, 0, 4.0*M_PI, "cos curve: x-data"); + //size_t XCol=datastore->addLinearColumn(50, 0, 4.0*JKQTPSTATISTICS_PI, "cos curve: x-data"); //size_t YCol=datastore->addColumn(datastore->getRows(XCol), "cos curve: y-data"); //for (size_t i=0; igetRows(XCol); i++) { // datastore->set(YCol, i, cos(datastore->get(XCol, i))); @@ -39,14 +39,14 @@ int main(int argc, char* argv[]) size_t YCol=datastore->addColumn("cos curve: y-data"); auto biXCol=datastore->backInserter(XCol); auto biYCol=datastore->backInserter(YCol); - for (double x=0; x<4.0*M_PI; x+=4.0*M_PI/50.0) { + for (double x=0; x<4.0*JKQTPSTATISTICS_PI; x+=4.0*JKQTPSTATISTICS_PI/50.0) { *biXCol=x; *biYCol=cos(x); ++biXCol; ++biYCol; } // 2.3 combining with addLinearColumn() you can also use C++ STL algorithms: - //size_t XCol=datastore->addLinearColumn(50, 0, 4.0*M_PI, "cos curve: x-data"); + //size_t XCol=datastore->addLinearColumn(50, 0, 4.0*JKQTPSTATISTICS_PI, "cos curve: x-data"); //size_t YCol=datastore->addColumn("cos curve: y-data"); //std::transform(datastore->begin(XCol), datastore->end(XCol), datastore->backInserter(YCol), cos); // 2.4. Just for fun we can now sort the data: diff --git a/examples/datastore_statistics_2d/CMakeLists.txt b/examples/datastore_statistics_2d/CMakeLists.txt index 4a753c1d81..2ce11344ad 100644 --- a/examples/datastore_statistics_2d/CMakeLists.txt +++ b/examples/datastore_statistics_2d/CMakeLists.txt @@ -15,9 +15,9 @@ set(UIS ) add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS}) target_include_directories(${EXENAME} PRIVATE ../../lib) if(JKQtPlotter_BUILD_STATIC_LIBS) - target_link_libraries(${EXENAME} JKQTPlotterLib) + target_link_libraries(${EXENAME} JKQTPlotterLib Qt5::PrintSupport Qt5::Xml) elseif(JKQtPlotter_BUILD_SHARED_LIBS) - target_link_libraries(${EXENAME} JKQTPlotterSharedLib) + target_link_libraries(${EXENAME} JKQTPlotterSharedLib Qt5::PrintSupport Qt5::Xml) endif() diff --git a/examples/distributionplot/test_distributionplot.cpp b/examples/distributionplot/test_distributionplot.cpp index 956ddabdca..67ea1a671b 100644 --- a/examples/distributionplot/test_distributionplot.cpp +++ b/examples/distributionplot/test_distributionplot.cpp @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) JKQTPXFunctionLineGraph* graphTheoDist=new JKQTPXFunctionLineGraph(&plot); // define the gaussian function used for the random number generator graphTheoDist->setPlotFunctionFunctor([&th_mean,&th_std](double x) -> double { - return 1.0/(th_std*sqrt(2.0*M_PI))*exp(-0.5*(x-th_mean)*(x-th_mean)/th_std/th_std); + return 1.0/(th_std*sqrt(2.0*JKQTPSTATISTICS_PI))*exp(-0.5*(x-th_mean)*(x-th_mean)/th_std/th_std); }); // set title: graphTheoDist->setTitle(QString("Theoretical Distribution $\\mu=%1, \\sigma=%2$").arg(th_mean,0, 'f', 1).arg(th_std,0, 'f', 1)); diff --git a/examples/functionplot/functionplot.cpp b/examples/functionplot/functionplot.cpp index c59280b5f9..95f1160ea5 100644 --- a/examples/functionplot/functionplot.cpp +++ b/examples/functionplot/functionplot.cpp @@ -49,7 +49,7 @@ int main(int argc, char* argv[]) JKQTPXFunctionLineGraph* func2=new JKQTPXFunctionLineGraph(plot); func2->setPlotFunctionFunctor([](double x, void* params) { QVector* p=static_cast*>(params); - return p->at(0)*sin(2.0*M_PI*x*p->at(1)); + return p->at(0)*sin(2.0*JKQTPSTATISTICS_PI*x*p->at(1)); }); // here we set the parameters p0, p1 func2->setParamsV(5, 0.2); @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) JKQTPXFunctionLineGraph* func3=new JKQTPXFunctionLineGraph(plot); func3->setPlotFunctionFunctor([](double x, void* params) { QMap* p=static_cast*>(params); - return p->value("amplitude")*sin(2.0*M_PI*x*p->value("frequency")); + return p->value("amplitude")*sin(2.0*JKQTPSTATISTICS_PI*x*p->value("frequency")); }); // here we set the parameters p0, p1 QMap params3; diff --git a/examples/imageplot/imageplot.cpp b/examples/imageplot/imageplot.cpp index 49a7e02516..af873de518 100644 --- a/examples/imageplot/imageplot.cpp +++ b/examples/imageplot/imageplot.cpp @@ -9,10 +9,6 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/graphs/jkqtpimage.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - int main(int argc, char* argv[]) { @@ -44,8 +40,8 @@ int main(int argc, char* argv[]) x=-w/2.0; for (int ix=0; ixaddCopiedImageAsColumn(airydisk, NX, NY, "imagedata"); diff --git a/examples/imageplot_modifier/imageplot_modifier.cpp b/examples/imageplot_modifier/imageplot_modifier.cpp index 7e9a564894..0789f3ff26 100644 --- a/examples/imageplot_modifier/imageplot_modifier.cpp +++ b/examples/imageplot_modifier/imageplot_modifier.cpp @@ -9,11 +9,6 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/graphs/jkqtpimage.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - - int main(int argc, char* argv[]) { QApplication app(argc, argv); @@ -37,7 +32,7 @@ int main(int argc, char* argv[]) x=-static_cast(NX)/2.0; for (int ix=0; ixaddCopiedImageAsColumn(image, NX, NY, "imagedata"); diff --git a/examples/imageplot_nodatastore/imageplot_nodatastore.cpp b/examples/imageplot_nodatastore/imageplot_nodatastore.cpp index 05c87a6640..63c0177501 100644 --- a/examples/imageplot_nodatastore/imageplot_nodatastore.cpp +++ b/examples/imageplot_nodatastore/imageplot_nodatastore.cpp @@ -9,11 +9,6 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/graphs/jkqtpimage.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - - int main(int argc, char* argv[]) { QApplication app(argc, argv); @@ -43,15 +38,15 @@ int main(int argc, char* argv[]) x=-w/2.0; for (int ix=0; ix(static_cast(ix)-NX/2)*dx; double y=static_cast(static_cast(iy)-NY/2)*dy; const double r=sqrt(x*x+y*y); - const double v=2.0*M_PI*NA*r/wavelength; + const double v=2.0*JKQTPSTATISTICS_PI*NA*r/wavelength; if (ix==NX/2 && iy==NY/2) return 1.0; - else return pow(2.0*j1(v)/v, 2); + else return pow(2.0*jkqtp_j1(v)/v, 2); }, "imagedata"); - // 3. create a graph (JKQTPColumnMathImage) with the column created above as data + // 3. create a grapJKQTPSTATISTICS_PIKQTPColumnMathImage) with the column created above as data // The data is color-coded with the color-palette JKQTPMathImageMATLAB // the converted range of data is determined automatically because setAutoImageRange(true) JKQTPColumnMathImage* graph=new JKQTPColumnMathImage(plot); diff --git a/examples/impulsesplot/impulsesplot.cpp b/examples/impulsesplot/impulsesplot.cpp index 3708d30f62..ca079c182f 100644 --- a/examples/impulsesplot/impulsesplot.cpp +++ b/examples/impulsesplot/impulsesplot.cpp @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) // 2. now we create data for a simple plot (a sine curve with lin. increasing errors) QVector X, Y; for (int i=0; igetPlotter(), p, QColor("black"), 1.5, Qt::SolidLine, QColor(128,128,0,128)); //plotGeo->getPlotter()->addGraph(poly); diff --git a/examples/jkqtplot_test/TestWidgetGraphs.cpp b/examples/jkqtplot_test/TestWidgetGraphs.cpp index 304fb42633..44a69be223 100644 --- a/examples/jkqtplot_test/TestWidgetGraphs.cpp +++ b/examples/jkqtplot_test/TestWidgetGraphs.cpp @@ -67,7 +67,7 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) : for (unsigned int i=0; iaddGraphWithXError(cy12, cx1, cy13, "$\\cos(x)$ with errors", JKQTPFilledCurveY, JKQTPErrorPolygons); for (unsigned int i=0; igetXAxis()->addAxisTickLabel(i+1, QString("$\\pi_{%1}\\cdot 10^{%2}$").arg(i+1).arg(i+1-N3)); diff --git a/examples/jkqtplot_test/TestWidgetImages.cpp b/examples/jkqtplot_test/TestWidgetImages.cpp index 04e153c115..f6ade688f2 100644 --- a/examples/jkqtplot_test/TestWidgetImages.cpp +++ b/examples/jkqtplot_test/TestWidgetImages.cpp @@ -49,7 +49,7 @@ TestWidgetImages::TestWidgetImages(QWidget *parent) : bool* bimg2=(bool*)calloc(100*100,sizeof(bool)); for (int x=0; x<100; x++) { for (int y=0; y<100; y++) { - img2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/20); + img2[y*100+x]=sin(2*JKQTPSTATISTICS_PI*sqrt(1.0+x*x+y*y)/20); img2M[y*100+x]=abs(y-x); bimg2[y*100+x]=static_cast(rand())/static_cast(RAND_MAX)>0.9; } diff --git a/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp b/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp index 711f80cdae..fbfec2e562 100644 --- a/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp +++ b/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp @@ -30,12 +30,12 @@ TestWidgetParamScatterPlots::TestWidgetParamScatterPlots(QWidget *parent) : dataI< photons1, photons2; for (int i=0; i<1000; i++) { double x=double(i)/1000.0; - const double p=0.33*fabs(sin(x*4.0*M_PI))*fabs(sin(x*4.0*M_PI)); + const double p=0.33*fabs(sin(x*4.0*JKQTPSTATISTICS_PI))*fabs(sin(x*4.0*JKQTPSTATISTICS_PI)); if (static_cast(rand())/static_cast(RAND_MAX)<=p) photons1<(rand())/static_cast(RAND_MAX)<=p) photons2< histogram; const int Ndata=60; for(int n=0; n(Ndata)*static_cast(n)-0.5; + const double x=3.0*JKQTPSTATISTICS_PI/static_cast(Ndata)*static_cast(n)-0.5; const double y=2.0*(1.0+cos(x)); const double yd=y+d(gen); dataX.push_back(x); diff --git a/examples/parametriccurve/parametriccurve.cpp b/examples/parametriccurve/parametriccurve.cpp index 92f888d816..b76c5373fd 100644 --- a/examples/parametriccurve/parametriccurve.cpp +++ b/examples/parametriccurve/parametriccurve.cpp @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) // in addition the radius is stored in column R QVector X, Y, R; const int Ndata=500; // number of plot points in each curve - const double phiMax=4.0*M_PI; + const double phiMax=4.0*JKQTPSTATISTICS_PI; const double a=1; const double k=0.2; for (double phi=-phiMax; phi<=phiMax; phi+=phiMax/double(Ndata)) { diff --git a/examples/paramscatterplot/paramscatterplot.cpp b/examples/paramscatterplot/paramscatterplot.cpp index 1c0d969ddf..6677c5c985 100644 --- a/examples/paramscatterplot/paramscatterplot.cpp +++ b/examples/paramscatterplot/paramscatterplot.cpp @@ -23,7 +23,7 @@ int main(int argc, char* argv[]) QVector X, Y1, Y2, Y3, Y4, Y5, Y6, Y7, P, C, S, RGB, LW; const int Ndata=10; // number of plot points in each curve for (int i=0; i X, Y; const int Ndata=100; for (int i=0; i X, Y1, Y2, Y3, Y4, Y5; const int Ndata=7; // number of plot points in each curve for (int i=0; i<=Ndata; i++) { - const double x=0.0+double(i)*0.6*M_PI; + const double x=0.0+double(i)*0.6*JKQTPSTATISTICS_PI; X< X, Y1, Y2, img, X3, Y3, Y3err, Xbar, Ybar, Ybar2; const int Ndata=100; for (int i=0; i X1, X2; const int Ndata=10; // number of plot points in each curve for (int i=0; iNdata/2) X2< X, Y1, Y2, EY2; const int Ndata=100; for (int i=0; i JKQTPImageTools::getDefaultLUTs() { else if (r < 0.0) r = 0.0; - double g = 255.0 * std::sin(M_PI*v); + double g = 255.0 * std::sin(JKQTPSTATISTICS_PI*v); double b = 255.0 - 765.0 * v; if (b < 0.0) @@ -318,7 +318,7 @@ QMap JKQTPImageTools::getDefaultLUTs() { else if (r < 0.0) r = 0.0; - double g = 255.0 * std::sin(M_PI*v); + double g = 255.0 * std::sin(JKQTPSTATISTICS_PI*v); double b = 255.0 - 765.0 * v; if (b < 0.0) @@ -396,9 +396,9 @@ QMap JKQTPImageTools::getDefaultLUTs() { if (r > 255.0) r = 255.0; - double g = 255.0*sin(M_PI*v); + double g = 255.0*sin(JKQTPSTATISTICS_PI*v); - double b = 255.0*cos(0.5*M_PI*v); + double b = 255.0*cos(0.5*JKQTPSTATISTICS_PI*v); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } @@ -419,9 +419,9 @@ QMap JKQTPImageTools::getDefaultLUTs() { if (r > 255.0) r = 255.0; - double g = 255.0*sin(M_PI*v); + double g = 255.0*sin(JKQTPSTATISTICS_PI*v); - double b = 255.0*cos(0.5*M_PI*v); + double b = 255.0*cos(0.5*JKQTPSTATISTICS_PI*v); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } @@ -601,11 +601,11 @@ QMap JKQTPImageTools::getDefaultLUTs() { if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; - double g = sin(M_PI/2.0*v); + double g = sin(JKQTPSTATISTICS_PI/2.0*v); if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; - double b = cos(M_PI/2.0*v); + double b = cos(JKQTPSTATISTICS_PI/2.0*v); if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; @@ -628,11 +628,11 @@ QMap JKQTPImageTools::getDefaultLUTs() { if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; - double g = sin(M_PI/2.0*v); + double g = sin(JKQTPSTATISTICS_PI/2.0*v); if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; - double b = cos(M_PI/2.0*v); + double b = cos(JKQTPSTATISTICS_PI/2.0*v); if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; @@ -703,7 +703,7 @@ QMap JKQTPImageTools::getDefaultLUTs() { if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); - double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; + double r = (v < 0.5) ? 128.0*sin(JKQTPSTATISTICS_PI*(2.0*v-0.5))+128.0 : 255.0; if (r > 255.0) r = 255.0; @@ -725,7 +725,7 @@ QMap JKQTPImageTools::getDefaultLUTs() { if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); - double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; + double r = (v < 0.5) ? 128.0*sin(JKQTPSTATISTICS_PI*(2.0*v-0.5))+128.0 : 255.0; if (r > 255.0) r = 255.0; @@ -789,7 +789,7 @@ QMap JKQTPImageTools::getDefaultLUTs() { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*qBound(0.0,sqrt(v),1.0); double g = 255.0*qBound(0.0,v*v*v,1.0); - double b = 255.0*qBound(0.0,sin(2.0*M_PI*v),1.0); + double b = 255.0*qBound(0.0,sin(2.0*JKQTPSTATISTICS_PI*v),1.0); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } diff --git a/lib/jkqtcommon/jkqtpdrawingtools.cpp b/lib/jkqtcommon/jkqtpdrawingtools.cpp index 0a5b2dd04f..a7bb4482b0 100644 --- a/lib/jkqtcommon/jkqtpdrawingtools.cpp +++ b/lib/jkqtcommon/jkqtpdrawingtools.cpp @@ -261,12 +261,12 @@ QPolygonF jkqtpRotateRect(QRectF r, double angle) { QVector JKQTPDrawEllipse(double x, double y, double a, double b, double angle_start, double angle_end, double alpha, int controlPoints, QPointF* x_start, QPointF* x_end) { QVector result; - double start=angle_start*M_PI/180.0; - double stop=angle_end*M_PI/180.0; + double start=angle_start*JKQTPSTATISTICS_PI/180.0; + double stop=angle_end*JKQTPSTATISTICS_PI/180.0; double step=(stop-start)/static_cast(controlPoints); while (fabs(stop-start)/step<10) step=step/2.0; - double sina=sin(1.0*alpha/180.0*M_PI); - double cosa=cos(1.0*alpha/180.0*M_PI); + double sina=sin(1.0*alpha/180.0*JKQTPSTATISTICS_PI); + double cosa=cos(1.0*alpha/180.0*JKQTPSTATISTICS_PI); QPointF xp(x+a*cos(start)*cosa-b*sin(start)*sina, y+a*cos(start)*sina+b*sin(start)*cosa); result.append(xp); if (x_start) *x_start = xp; @@ -276,7 +276,7 @@ QVector JKQTPDrawEllipse(double x, double y, double a, double b, double double sint=sin(t); xp=QPointF( x+a*cost*cosa-b*sint*sina, y+a*cost*sina+b*sint*cosa); result.append(xp); - //std::cout<<"t="<(i)+0.5)*angle; star5cordsx[i*2]=sin(a); @@ -287,7 +287,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym static double star6cordsy[12]; if (star6_items==0) { star6_items=6; - double angle=360.0/double(star6_items)/180.0*M_PI; + double angle=360.0/double(star6_items)/180.0*JKQTPSTATISTICS_PI; for (int i=0; i(i)+0.5)*angle; star6cordsx[i*2]=sin(a); @@ -301,7 +301,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym static double star8cordsy[16]; if (star8_items==0) { star8_items=8; - double angle=360.0/double(star8_items)/180.0*M_PI; + double angle=360.0/double(star8_items)/180.0*JKQTPSTATISTICS_PI; for (int i=0; i(i)+0.5)*angle; star8cordsx[i*2]=sin(a); @@ -398,7 +398,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym QPainterPath path; QRectF rectangle3(x-w2/2.0, y-w2/2.0, w2, w2); path.addEllipse(rectangle3); - path.moveTo(QPointF(x+w2/2.0*cos(45.0/180.0*M_PI),y-w2/2.0*cos(45.0/180.0*M_PI))); + path.moveTo(QPointF(x+w2/2.0*cos(45.0/180.0*JKQTPSTATISTICS_PI),y-w2/2.0*cos(45.0/180.0*JKQTPSTATISTICS_PI))); path.lineTo(QPointF(x+w2,y-w2)); path.moveTo(QPointF(x+w2-w2/2.0,y-w2)); path.lineTo(QPointF(x+w2,y-w2)); diff --git a/lib/jkqtcommon/jkqtpmathparser.cpp b/lib/jkqtcommon/jkqtpmathparser.cpp index 8ac3b93bf6..2ccebdcd0c 100644 --- a/lib/jkqtcommon/jkqtpmathparser.cpp +++ b/lib/jkqtcommon/jkqtpmathparser.cpp @@ -20,6 +20,8 @@ #define COMPILING_THIS_JKMATHPARSER +#define _USE_MATH_DEFINES +#include #include "jkqtcommon/jkqtpmathparser.h" // class's header file #include #include @@ -122,7 +124,7 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil time_t rawtime; struct tm* timeinfo; time(&rawtime); - timeinfo=localtime(&rawtime); + localtime_s(timeinfo, &rawtime); strftime(re, 1024, f.c_str(), timeinfo); r.str=re; @@ -403,7 +405,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil 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); +#if Q_CC_MSVC + r.num = _j0(params[0].num); +#else + r.num = j0(params[0].num); +#endif return r; } @@ -412,7 +418,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil 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); +#if Q_CC_MSVC + r.num=_j1(params[0].num); +#else + r.num=j1(params[0].num); +#endif return r; } @@ -421,7 +431,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil 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); +#if Q_CC_MSVC + r.num=_y0(params[0].num); +#else + r.num=y0(params[0].num); +#endif return r; } @@ -430,7 +444,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil 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); +#if Q_CC_MSVC + r.num=_y1(params[0].num); +#else + r.num=y1(params[0].num); +#endif return r; } @@ -439,7 +457,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil 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(static_cast(params[0].num), params[1].num); +#if Q_CC_MSVC + r.num=_yn(static_cast(params[0].num), params[1].num); +#else + r.num=yn(static_cast(params[0].num), params[1].num); +#endif return r; } @@ -448,7 +470,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil 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(static_cast(params[0].num), params[1].num); +#if Q_CC_MSVC + r.num=_jn(static_cast(params[0].num), params[1].num); +#else + r.num=jn(static_cast(params[0].num), params[1].num); +#endif return r; } diff --git a/lib/jkqtcommon/jkqtpmathparser.h b/lib/jkqtcommon/jkqtpmathparser.h index 1344509c4a..b6d3aa3431 100644 --- a/lib/jkqtcommon/jkqtpmathparser.h +++ b/lib/jkqtcommon/jkqtpmathparser.h @@ -37,7 +37,6 @@ */ #include -#include #include #include #include diff --git a/lib/jkqtcommon/jkqtpmathtools.h b/lib/jkqtcommon/jkqtpmathtools.h index b74bc59dc4..b6ee9e9fa8 100644 --- a/lib/jkqtcommon/jkqtpmathtools.h +++ b/lib/jkqtcommon/jkqtpmathtools.h @@ -33,6 +33,17 @@ +/*! \brief \f$ \pi=3.14159... \f$ + \ingroup jkqtptools_math_basic + +*/ +#ifdef M_PI +# define JKQTPSTATISTICS_PI M_PI +#else +# define JKQTPSTATISTICS_PI 3.14159265358979323846 +#endif + + /*! \brief \f$ \sqrt{2\pi}=2.50662827463 \f$ \ingroup jkqtptools_math_basic @@ -316,6 +327,77 @@ inline T jkqtp_inversePropSaveDefault(const T& v) { return jkqtp_inversePropSave(v, std::numeric_limits::epsilon()*100.0); } +/*! \brief j0() function (without compiler issues) + \ingroup jkqtptools_math_basic + +*/ +inline double jkqtp_j0(double x) { +#if Q_CC_MSVC + return _j0(x); +#else + return j0(x); +#endif +} + +/*! \brief j1() function (without compiler issues) + \ingroup jkqtptools_math_basic + +*/ +inline double jkqtp_j1(double x) { +#if Q_CC_MSVC + return _j1(x); +#else + return j1(x); +#endif +} + +/*! \brief y0() function (without compiler issues) + \ingroup jkqtptools_math_basic + +*/ +inline double jkqtp_y0(double x) { +#if Q_CC_MSVC + return _y0(x); +#else + return y0(x); +#endif +} + +/*! \brief y1() function (without compiler issues) + \ingroup jkqtptools_math_basic + +*/ +inline double jkqtp_y1(double x) { +#if Q_CC_MSVC + return _y1(x); +#else + return y1(x); +#endif +} + +/*! \brief jn() function (without compiler issues) + \ingroup jkqtptools_math_basic + +*/ +inline double jkqtp_jn(int n, double x) { +#if Q_CC_MSVC + return _jn(n,x); +#else + return jn(n,x); +#endif +} + +/*! \brief yn() function (without compiler issues) + \ingroup jkqtptools_math_basic + +*/ +inline double jkqtp_yn(int n, double x) { +#if Q_CC_MSVC + return _yn(n,x); +#else + return yn(n,x); +#endif +} /** \brief calculate the distance between two QPointF points * \ingroup jkqtptools_math_basic @@ -344,10 +426,10 @@ inline bool JKQTPIsOKFloat(T v) { /** \brief evaluates a gaussian propability density function * \ingroup jkqtptools_math_basic * - * \f[ f(x,\mu, \sigma)=\frac{1}{\sqrt{2\pi\sigma^2}}\cdot\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) + * \f[ f(x,\mu, \sigma)=\frac{1}{\sqrt{2\pi\sigma^2}}\cdot\eJKQTPSTATISTICS_PIeft(-\frac{(x-\mu)^2}{2\sigma^2}\right) */ inline double jkqtp_gaussdist(double x, double mu=0.0, double sigma=1.0) { - return exp(-0.5*jkqtp_sqr(x-mu)/jkqtp_sqr(sigma))/sqrt(2.0*M_PI*sigma*sigma); + return exp(-0.5*jkqtp_sqr(x-mu)/jkqtp_sqr(sigma))/sqrt(2.0*JKQTPSTATISTICS_PI*sigma*sigma); } /*! \brief evaluate a polynomial \f$ f(x)=\sum\limits_{i=0}^Pp_ix^i \f$ with \f$ p_i \f$ taken from the range \a firstP ... \a lastP diff --git a/lib/jkqtcommon/jkqtpstatkde.cpp b/lib/jkqtcommon/jkqtpstatkde.cpp index 5ae42ec6ab..544c66211f 100644 --- a/lib/jkqtcommon/jkqtpstatkde.cpp +++ b/lib/jkqtcommon/jkqtpstatkde.cpp @@ -28,7 +28,7 @@ double jkqtpstatKernel1DGaussian(double t) { double jkqtpstatKernel1DCauchy(double t) { - return 1.0/(M_PI*(1.0+t*t)); + return 1.0/(JKQTPSTATISTICS_PI*(1.0+t*t)); } @@ -71,13 +71,13 @@ double jkqtpstatKernel1DTricube(double t) { double jkqtpstatKernel1DCosine(double t) { - return (fabs(t)<1.0)?(M_PI/4.0*cos(t*M_PI/2.0)):0.0; + return (fabs(t)<1.0)?(JKQTPSTATISTICS_PI/4.0*cos(t*JKQTPSTATISTICS_PI/2.0)):0.0; } double jkqtpstatKernel2DGaussian(double tx, double ty) { - return exp(-0.5*(tx*tx+ty*ty))/(2.0*M_PI); + return exp(-0.5*(tx*tx+ty*ty))/(2.0*JKQTPSTATISTICS_PI); } double jkqtpstatKernel2DUniform(double tx, double ty) { diff --git a/lib/jkqtfastplotter/jkqtfastplotter.h b/lib/jkqtfastplotter/jkqtfastplotter.h index b46add2613..c34cd18d1a 100644 --- a/lib/jkqtfastplotter/jkqtfastplotter.h +++ b/lib/jkqtfastplotter/jkqtfastplotter.h @@ -35,7 +35,7 @@ #include #include #include - +#include "jkqtcommon/jkqtpmathtools.h" #ifdef DEBUG_TIMING # include "jkqtcommon/jkqtphighrestimer.h" #endif @@ -2067,7 +2067,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i else if (r < 0.0) r = 0.0; - double g = 255.0 * std::sin(M_PI*v); + double g = 255.0 * std::sin(JKQTPSTATISTICS_PI*v); double b = 255.0 - 765.0 * v; if (b < 0.0) @@ -2144,9 +2144,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i if (r > 255.0) r = 255.0; - double g = 255.0*sin(M_PI*v); + double g = 255.0*sin(JKQTPSTATISTICS_PI*v); - double b = 255.0*cos(0.5*M_PI*v); + double b = 255.0*cos(0.5*JKQTPSTATISTICS_PI*v); lut_rainbow[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } @@ -2243,11 +2243,11 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; - double g = sin(M_PI/2.0*v); + double g = sin(JKQTPSTATISTICS_PI/2.0*v); if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; - double b = cos(M_PI/2.0*v); + double b = cos(JKQTPSTATISTICS_PI/2.0*v); if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; @@ -2292,7 +2292,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i if ((*plut)!=nullptr) { for (size_t l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { double v=l/static_cast(JKQTFastPlotter::LUTSIZE); - double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; + double r = (v < 0.5) ? 128.0*sin(JKQTPSTATISTICS_PI*(2.0*v-0.5))+128.0 : 255.0; if (r > 255.0) r = 255.0; diff --git a/lib/jkqtplotter/jkqtpcoordinateaxes.cpp b/lib/jkqtplotter/jkqtpcoordinateaxes.cpp index 2f9cd96cea..08b4a8a182 100644 --- a/lib/jkqtplotter/jkqtpcoordinateaxes.cpp +++ b/lib/jkqtplotter/jkqtpcoordinateaxes.cpp @@ -1239,10 +1239,10 @@ void JKQTPVerticalAxis::drawTickLabel1(JKQTPEnhancedPainter &painter, double xx, } else if (axisStyle.tickLabelAngle!=0) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (axisStyle.tickLabelAngle>0) { - painter.translate(lx-strikeoutPos+(width)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos-width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)); + painter.translate(lx-strikeoutPos+(width)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), yy+strikeoutPos-width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)); painter.rotate(axisStyle.tickLabelAngle); } else { - painter.translate(lx+strikeoutPos+(width-strikeoutPos)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos+width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)); + painter.translate(lx+strikeoutPos+(width-strikeoutPos)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), yy+strikeoutPos+width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)); painter.rotate(axisStyle.tickLabelAngle); } getParentMathText()->draw(painter, 0,0); @@ -1281,7 +1281,7 @@ void JKQTPVerticalAxis::drawTickLabel2(JKQTPEnhancedPainter &painter, double xx, painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); double shiftx=0; if (axisStyle.tickLabelAngle>0) { - shiftx=strikeoutPos*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI); + shiftx=strikeoutPos*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI); } else { } @@ -1832,10 +1832,10 @@ void JKQTPHorizontalAxis::drawTickLabel1(JKQTPEnhancedPainter &painter, double x if (axisStyle.tickLabelAngle!=0) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (axisStyle.tickLabelAngle>0) { - painter.translate(xx-fabs(ascent*sin(axisStyle.tickLabelAngle/180.0*M_PI)/2.0), lx0+fabs(ascent*cos(axisStyle.tickLabelAngle/180.0*M_PI))); + painter.translate(xx-fabs(ascent*sin(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI)/2.0), lx0+fabs(ascent*cos(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI))); painter.rotate(axisStyle.tickLabelAngle); } else { - painter.translate(xx+fabs(ascent*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), lx0+ascent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI))+fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI))); + painter.translate(xx+fabs(ascent*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), lx0+ascent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI))+fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI))); painter.rotate(axisStyle.tickLabelAngle); } getParentMathText()->draw(painter, 0,0); @@ -1862,10 +1862,10 @@ void JKQTPHorizontalAxis::drawTickLabel2(JKQTPEnhancedPainter &painter, double x if (axisStyle.tickLabelAngle!=0) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (axisStyle.tickLabelAngle>0) { - painter.translate(xx+fabs(descent*sin(axisStyle.tickLabelAngle/180.0*M_PI)/2.0), lx0-fabs(descent*cos(axisStyle.tickLabelAngle/180.0*M_PI))); + painter.translate(xx+fabs(descent*sin(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI)/2.0), lx0-fabs(descent*cos(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI))); painter.rotate(-axisStyle.tickLabelAngle); } else { - painter.translate(xx-fabs(descent*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), lx0-descent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI))-fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI))); + painter.translate(xx-fabs(descent*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), lx0-descent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI))-fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI))); painter.rotate(-axisStyle.tickLabelAngle); } getParentMathText()->draw(painter, 0,0); diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 17dc5e9527..02e829ba0c 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -108,7 +108,7 @@ enum class JKQTPDatastoreItemFormat { * QVector X, Y; * const int Ndata=100; * for (int i=0; i X, Y; * const int Ndata=100; * for (int i=0; i X, Y; * const int Ndata=100; * for (int i=0; i