From 847fcb7a35a22070c0baa5b712d6f318bb651746 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sat, 26 Jan 2019 12:28:44 +0100 Subject: [PATCH] improved code (cont...&-parameters, diverse refactoring for C++1//modernC++, diverse corrections ...) --- .../jkqtfastplotter_test_testmain.cpp | 4 +- .../jkqtplot_test/TestWidgetContourPlots.cpp | 2 +- .../jkqtplot_test/TestWidgetFunctionPlots.cpp | 12 +- examples/jkqtplot_test/TestWidgetGraphs.cpp | 20 +- examples/jkqtplot_test/TestWidgetImages.cpp | 6 +- .../TestWidgetParamScatterPlots.cpp | 2 +- .../jkqtplot_test/TestWidgetPeaksPlots.cpp | 4 +- .../jkqtplot_test/TestWidgetRGBImages.cpp | 10 +- .../simpletest_parsedfunctionplot/README.md | 2 +- ...tplotter_simpletest_parsedfunctionplot.cpp | 2 +- examples/simpletest_speed/README.md | 2 +- examples/simpletest_speed/speedtestplot.cpp | 2 +- examples/simpletest_ui/README.md | 2 +- .../simpletest_ui/formwithjkqtplotter.cpp | 2 +- lib/jkqtfastplotter/jkqtfastplotter.cpp | 140 +- lib/jkqtfastplotter/jkqtfastplotter.h | 288 +- lib/jkqtmathtext/jkqtmathtext.cpp | 8733 ++++++++--------- lib/jkqtmathtext/jkqtmathtext.h | 20 +- lib/jkqtplotter/jkqtpbaseelements.cpp | 177 +- lib/jkqtplotter/jkqtpbaseelements.h | 28 +- lib/jkqtplotter/jkqtpbaseplotter.cpp | 99 +- lib/jkqtplotter/jkqtpbaseplotter.h | 391 +- lib/jkqtplotter/jkqtpdatastorage.cpp | 23 +- lib/jkqtplotter/jkqtpdatastorage.h | 14 +- lib/jkqtplotter/jkqtpelementsoverlay.cpp | 4 +- lib/jkqtplotter/jkqtpelementsoverlay.h | 4 +- lib/jkqtplotter/jkqtpgraphsbase.cpp | 16 +- lib/jkqtplotter/jkqtpgraphsgeometric.cpp | 4 +- lib/jkqtplotter/jkqtpgraphsgeometric.h | 4 +- lib/jkqtplotter/jkqtpgraphsimage.cpp | 482 +- lib/jkqtplotter/jkqtpgraphsimage.h | 92 +- lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp | 4 +- lib/jkqtplotter/jkqtplotter.cpp | 90 +- lib/jkqtplotter/jkqtplotter.h | 61 +- lib/jkqtplottergui/jkqtpenhancedtableview.h | 2 +- lib/jkqtplottertools/jkqtpdrawingtools.cpp | 2 +- lib/jkqtplottertools/jkqttools.cpp | 12 +- lib/jkqtplottertools/jkqttools.h | 12 +- 38 files changed, 5374 insertions(+), 5400 deletions(-) diff --git a/examples/jkqtfastplotter_test/jkqtfastplotter_test_testmain.cpp b/examples/jkqtfastplotter_test/jkqtfastplotter_test_testmain.cpp index f79f325201..1f89ae5ef4 100644 --- a/examples/jkqtfastplotter_test/jkqtfastplotter_test_testmain.cpp +++ b/examples/jkqtfastplotter_test/jkqtfastplotter_test_testmain.cpp @@ -40,11 +40,11 @@ TestMain::TestMain(QWidget *parent) : pl2->set_yAxisLabelVisible(false); pl2->setPlotBorderLeft(10); pl2->setPlotBorderRight(2); - w->connect(pl1, SIGNAL(replotting()), pl2, SLOT(replotPlot())); + w->connect(pl1, SIGNAL(replotting()), pl2, SLOT(redrawPlot())); gl->addWidget(pl2, 0, 1); JKQTFastPlotter* pl3=new JKQTFastPlotter(w); pl3->set_synchronizeX(pl1); - w->connect(pl1, SIGNAL(replotting()), pl3, SLOT(replotPlot())); + w->connect(pl1, SIGNAL(replotting()), pl3, SLOT(redrawPlot())); gl->addWidget(pl3, 1, 0); diff --git a/examples/jkqtplot_test/TestWidgetContourPlots.cpp b/examples/jkqtplot_test/TestWidgetContourPlots.cpp index a1d0886d4b..318657bdf1 100644 --- a/examples/jkqtplot_test/TestWidgetContourPlots.cpp +++ b/examples/jkqtplot_test/TestWidgetContourPlots.cpp @@ -108,7 +108,7 @@ TestWidgetContourPlots::TestWidgetContourPlots(QWidget *parent) : plotContour->zoom(-0.1,1.1,-0.1,1.1); plotContour->setPlotUpdateEnabled(true); - plotContour->replotPlot(); + plotContour->redrawPlot(); diff --git a/examples/jkqtplot_test/TestWidgetFunctionPlots.cpp b/examples/jkqtplot_test/TestWidgetFunctionPlots.cpp index 6ce25d5da7..0db2f4e24d 100644 --- a/examples/jkqtplot_test/TestWidgetFunctionPlots.cpp +++ b/examples/jkqtplot_test/TestWidgetFunctionPlots.cpp @@ -24,7 +24,7 @@ TestWidgetFunctionPlots::TestWidgetFunctionPlots(QWidget *parent) : pfunc->set_drawErrorPolygons(true); pfunc->set_style(Qt::DashLine); plotFuncPlt->addGraph(pfunc); - plotFuncPlt->replotPlot(); + plotFuncPlt->redrawPlot(); pfuncErrorStyle=new JKQTPErrorPlotstyleComboBox(this); pfuncErrorStyle->setCurrentIndex(3); @@ -88,29 +88,29 @@ void TestWidgetFunctionPlots::setPFuncStyle() if (pfuncErrorStyle->getErrorStyle()==JKQTPErrorPolygons) pfunc->set_drawErrorPolygons(true); pfunc->set_drawLine(chkPFuncDrawLine->isChecked()); pfunc->set_displaySamplePoints(chkPFuncDrawSamples->isChecked()); - plotFuncPlt->replotPlot(); + plotFuncPlt->redrawPlot(); } void TestWidgetFunctionPlots::setPFuncMinPoint(int value) { pfunc->set_minSamples(value); - plotFuncPlt->replotPlot(); + plotFuncPlt->redrawPlot(); } void TestWidgetFunctionPlots::setPFuncMaxRefine(int value) { pfunc->set_maxRefinementDegree(value); - plotFuncPlt->replotPlot(); + plotFuncPlt->redrawPlot(); } void TestWidgetFunctionPlots::setPFunc(const QString &expression) { pfunc->set_function(expression); - plotFuncPlt->replotPlot(); + plotFuncPlt->redrawPlot(); } void TestWidgetFunctionPlots::setPFuncE(const QString &expression) { pfunc->set_errorFunction(expression); - plotFuncPlt->replotPlot(); + plotFuncPlt->redrawPlot(); } diff --git a/examples/jkqtplot_test/TestWidgetGraphs.cpp b/examples/jkqtplot_test/TestWidgetGraphs.cpp index 65cc468d67..7f7d0e4e9f 100644 --- a/examples/jkqtplot_test/TestWidgetGraphs.cpp +++ b/examples/jkqtplot_test/TestWidgetGraphs.cpp @@ -294,7 +294,7 @@ void TestWidgetGraphs::moveovl() { ovlCnt=0; ovlTime.start(); } - plot->update_overlays(); + plot->redrawOverlays(); QTimer::singleShot(10, this, SLOT(moveovl())); } @@ -312,7 +312,7 @@ void TestWidgetGraphs::setErrorStyle(int /*index*/) if (ey) { ey->set_yErrorStyle(String2JKQTPErrorPlotstyle(cmb->itemData(cmb->currentIndex()).toString())); } - plot->replotPlot(); + plot->redrawPlot(); } } @@ -325,7 +325,7 @@ void TestWidgetGraphs::setESSymbol(int /*index*/) exy->set_symbol(String2JKQTPGraphSymbols(cmb->itemData(cmb->currentIndex()).toString())); } - plot->replotPlot(); + plot->redrawPlot(); } } @@ -335,7 +335,7 @@ void TestWidgetGraphs::setSortOrder2(int index) if (index==0) pltePlot2->set_sortData(JKQTPXYGraph::Unsorted); if (index==1) pltePlot2->set_sortData(JKQTPXYLineGraph::SortedX); if (index==2) pltePlot2->set_sortData(JKQTPXYLineGraph::SortedY); - plotBot->replotPlot(); + plotBot->redrawPlot(); } void TestWidgetGraphs::setKeyLayout2(JKQTPKeyLayout layout) @@ -343,9 +343,9 @@ void TestWidgetGraphs::setKeyLayout2(JKQTPKeyLayout layout) plot->getPlotter()->setKeyLayout(layout); plotBot->getPlotter()->setKeyLayout(layout); plotBot2->getPlotter()->setKeyLayout(layout); - plot->replotPlot(); - plotBot->replotPlot(); - plotBot2->replotPlot(); + plot->redrawPlot(); + plotBot->redrawPlot(); + plotBot2->redrawPlot(); } void TestWidgetGraphs::setKeyPos2(JKQTPKeyPosition layout) @@ -353,7 +353,7 @@ void TestWidgetGraphs::setKeyPos2(JKQTPKeyPosition layout) plot->getPlotter()->setKeyPosition(layout); plotBot->getPlotter()->setKeyPosition(layout); plotBot2->getPlotter()->setKeyPosition(layout); - plot->replotPlot(); - plotBot->replotPlot(); - plotBot2->replotPlot(); + plot->redrawPlot(); + plotBot->redrawPlot(); + plotBot2->redrawPlot(); } diff --git a/examples/jkqtplot_test/TestWidgetImages.cpp b/examples/jkqtplot_test/TestWidgetImages.cpp index 9864745124..788401d649 100644 --- a/examples/jkqtplot_test/TestWidgetImages.cpp +++ b/examples/jkqtplot_test/TestWidgetImages.cpp @@ -117,17 +117,17 @@ TestWidgetImages::TestWidgetImages(QWidget *parent) : void TestWidgetImages::setImgPalette(int index) { pimg3->set_palette(index); - plotImg->replotPlot(); + plotImg->redrawPlot(); } void TestWidgetImages::setImgPalette1(int index) { pimg2->set_palette(index); - plotImg->replotPlot(); + plotImg->redrawPlot(); } void TestWidgetImages::setImgModifier(int index) { pimg3->set_modifierMode(JKQTPMathImage::ModifierMode(index)); - plotImg->replotPlot(); + plotImg->redrawPlot(); } diff --git a/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp b/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp index 7f532d86de..549dc09a2f 100644 --- a/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp +++ b/examples/jkqtplot_test/TestWidgetParamScatterPlots.cpp @@ -96,5 +96,5 @@ TestWidgetParamScatterPlots::TestWidgetParamScatterPlots(QWidget *parent) : void TestWidgetParamScatterPlots::setPSPSymmErrors(bool checked) { pltePSPCol->set_yErrorSymmetric(checked); - plotPSP->replotPlot(); + plotPSP->redrawPlot(); } diff --git a/examples/jkqtplot_test/TestWidgetPeaksPlots.cpp b/examples/jkqtplot_test/TestWidgetPeaksPlots.cpp index bbadd9c098..a68226125b 100644 --- a/examples/jkqtplot_test/TestWidgetPeaksPlots.cpp +++ b/examples/jkqtplot_test/TestWidgetPeaksPlots.cpp @@ -65,12 +65,12 @@ void TestWidgetPeaksPlots::setDrawBaseline(bool checked) { graphPeakStream1->set_drawBaseline(checked); graphPeakStream2->set_drawBaseline(checked); - plotPeaks->replotPlot(); + plotPeaks->redrawPlot(); } void TestWidgetPeaksPlots::setYPeaks(bool checked) { graphPeakStream1->set_yPeaks(checked); graphPeakStream2->set_yPeaks(checked); - plotPeaks->replotPlot(); + plotPeaks->redrawPlot(); } diff --git a/examples/jkqtplot_test/TestWidgetRGBImages.cpp b/examples/jkqtplot_test/TestWidgetRGBImages.cpp index f215163964..506a432f23 100644 --- a/examples/jkqtplot_test/TestWidgetRGBImages.cpp +++ b/examples/jkqtplot_test/TestWidgetRGBImages.cpp @@ -153,19 +153,19 @@ void TestWidgetRGBImages::setRGBColorBars(bool checked) { rgbimg->set_colorbarsSideBySide(checked); rgbimg2->set_colorbarsSideBySide(checked); - plotImgRGB->replotPlot(); + plotImgRGB->redrawPlot(); } void TestWidgetRGBImages::setRGBMode1(int mode) { rgbimg->set_rgbMode((JKQTPRGBMathImageRGBMode)mode); - plotImgRGB->replotPlot(); + plotImgRGB->redrawPlot(); } void TestWidgetRGBImages::setRGBMode2(int mode) { rgbimg2->set_rgbMode((JKQTPRGBMathImageRGBMode)mode); - plotImgRGB->replotPlot(); + plotImgRGB->redrawPlot(); } void TestWidgetRGBImages::updateRGBChannels() @@ -191,13 +191,13 @@ void TestWidgetRGBImages::updateRGBChannels() rgbimg->set_dataB(nullptr); rgbimg2->set_imageBColumn(-1); } - plotImgRGB->replotPlot(); + plotImgRGB->redrawPlot(); } void TestWidgetRGBImages::setRGBModifier(int item) { rgbimg->set_modifierMode(JKQTPMathImage::ModifierMode(item)); rgbimg2->set_modifierMode(JKQTPMathImage::ModifierMode(item)); - plotImgRGB->replotPlot(); + plotImgRGB->redrawPlot(); } diff --git a/examples/simpletest_parsedfunctionplot/README.md b/examples/simpletest_parsedfunctionplot/README.md index d2acfd1a6d..a20caefad2 100644 --- a/examples/simpletest_parsedfunctionplot/README.md +++ b/examples/simpletest_parsedfunctionplot/README.md @@ -31,7 +31,7 @@ In the example in [`test/simpletest_parsedfunctionplot/simpletest_parsedfunction [=]() { parsedFunc->set_title("user function: \\verb{"+edit->text()+"}"); parsedFunc->set_function(edit->text()); - plot->replotPlot(); + plot->redrawPlot(); }; QObject::connect(edit, &QLineEdit::returnPressed, updateGraphFunctor); QObject::connect(edit, &QLineEdit::editingFinished, updateGraphFunctor); diff --git a/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.cpp b/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.cpp index d19cc6e60e..e0a9c9b92e 100644 --- a/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.cpp +++ b/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.cpp @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) parsedFunc->set_function(edit->text()); parsedFunc->set_paramsV(spinP1->value(), spinP2->value()); parsedFunc->set_displaySamplePoints(check->isChecked()); - plot->replotPlot(); + plot->redrawPlot(); }; QObject::connect(edit, &QLineEdit::returnPressed, updateGraphFunctor); QObject::connect(edit, &QLineEdit::editingFinished, updateGraphFunctor); diff --git a/examples/simpletest_speed/README.md b/examples/simpletest_speed/README.md index 6e48de77c8..11caaa8e42 100644 --- a/examples/simpletest_speed/README.md +++ b/examples/simpletest_speed/README.md @@ -37,7 +37,7 @@ void SpeedTestPlot::plotNewData() // set new x-range and replot setX(X[0], X[NDATA-1]); - replotPlot(); + redrawPlot(); // calculate and update FPS-rate in window title auto tlastalst=t_lastplot; diff --git a/examples/simpletest_speed/speedtestplot.cpp b/examples/simpletest_speed/speedtestplot.cpp index 4601a7af5b..57a9b73366 100644 --- a/examples/simpletest_speed/speedtestplot.cpp +++ b/examples/simpletest_speed/speedtestplot.cpp @@ -92,7 +92,7 @@ void SpeedTestPlot::plotNewData() // set new x-range and replot setX(X[0], X[NDATA-1]); - replotPlot(); + redrawPlot(); // calculate and update FPS-rate in window title auto tlastalst=t_lastplot; diff --git a/examples/simpletest_ui/README.md b/examples/simpletest_ui/README.md index 04b6a5e2a6..912304efdf 100644 --- a/examples/simpletest_ui/README.md +++ b/examples/simpletest_ui/README.md @@ -126,7 +126,7 @@ void FormWithJKQTPlotter::on_btnReplot_clicked() { graph->set_function(ui->edtEquation->text()); graph->set_title(ui->edtEquation->text()); - ui->plot->replotPlot(); + ui->plot->redrawPlot(); } ``` diff --git a/examples/simpletest_ui/formwithjkqtplotter.cpp b/examples/simpletest_ui/formwithjkqtplotter.cpp index d8812a858d..edbffd41da 100644 --- a/examples/simpletest_ui/formwithjkqtplotter.cpp +++ b/examples/simpletest_ui/formwithjkqtplotter.cpp @@ -48,5 +48,5 @@ void FormWithJKQTPlotter::on_btnReplot_clicked() { graph->set_function(ui->edtEquation->text()); graph->set_title(ui->edtEquation->text()); - ui->plot->replotPlot(); + ui->plot->redrawPlot(); } diff --git a/lib/jkqtfastplotter/jkqtfastplotter.cpp b/lib/jkqtfastplotter/jkqtfastplotter.cpp index 37dcb4008d..8e20cdd19b 100644 --- a/lib/jkqtfastplotter/jkqtfastplotter.cpp +++ b/lib/jkqtfastplotter/jkqtfastplotter.cpp @@ -36,14 +36,14 @@ * \internal */ #define JKQTFPPROPERTYsave(settings, group, var, varname) \ - if (var!=def_##var) settings.setValue(group+varname, var); + if ((var)!=def_##var) (settings).setValue((group)+(varname), var); /** * \brief loads the given property from the given settings object * \ingroup jkqtfastplotter * \internal */ #define JKQTFPPROPERTYload(settings, group, var, varname, varconvert) \ - var=settings.value(group+varname, var).varconvert; + var=(settings).value((group)+(varname), var).varconvert; JKQTFPPlot::JKQTFPPlot(JKQTFastPlotter* parent): @@ -55,9 +55,7 @@ JKQTFPPlot::JKQTFPPlot(JKQTFastPlotter* parent): } JKQTFPPlot::~JKQTFPPlot() -{ - -}; += default;; void JKQTFPPlot::replot() { if (parent) parent->update_data(); @@ -127,7 +125,7 @@ JKQTFastPlotter::JKQTFastPlotter(QWidget *parent) : connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImage())); addAction(actCopyImage); setContextMenuPolicy(Qt::ActionsContextMenu); - replotPlot(); + redrawPlot(); setMouseTracking(true); } @@ -138,14 +136,14 @@ void JKQTFastPlotter::clearPlots(bool remove) { } } plots.clear(); - replotPlot(); + redrawPlot(); } void JKQTFastPlotter::addPlot(JKQTFPPlot* g) { g->setParent(this); plots.append(g); - replotPlot(); + redrawPlot(); } @@ -153,7 +151,7 @@ void JKQTFastPlotter::deletePlot(int i, bool remove) { if (i>=0 && i=0 && iaccept(); updateGeometry(); } @@ -553,7 +551,7 @@ void JKQTFastPlotter::draw(QPainter* painter, QColor background, QSize* size) { backgroundColor=oldb; } -void JKQTFastPlotter::replotPlot() { +void JKQTFastPlotter::redrawPlot() { calcPlotScaling(); if (!doDrawing) { doFullRepaint=true; @@ -572,7 +570,7 @@ void JKQTFastPlotter::replotPlot() { update_data(); } -void JKQTFastPlotter::replotPlot_immediate() { +void JKQTFastPlotter::redrawPlot_immediate() { calcPlotScaling(); if (!doDrawing) { doFullRepaint=true; @@ -593,7 +591,7 @@ void JKQTFastPlotter::replotPlot_immediate() { void JKQTFastPlotter::update_data() { if (doFullRepaint) { // as doFullRepaint is set false in updtae_plot() this is NO endles loop!!!!!!! - replotPlot(); + redrawPlot(); return; } if (!doDrawing) return; @@ -618,7 +616,7 @@ void JKQTFastPlotter::update_data() { void JKQTFastPlotter::update_data_immediate() { if (doFullRepaint) { // as doFullRepaint is set false in updtae_plot() this is NO endles loop!!!!!!! - replotPlot_immediate(); + redrawPlot_immediate(); return; } if (!doDrawing) return; @@ -782,7 +780,7 @@ void JKQTFastPlotter::setXRange(double min, double max, bool logarithmic) { xMax=max; xAxisLog=logarithmic; calcPlotScaling(); - replotPlot(); + redrawPlot(); } void JKQTFastPlotter::setYRange(double min, double max, bool logarithmic) { @@ -790,7 +788,7 @@ void JKQTFastPlotter::setYRange(double min, double max, bool logarithmic) { yMax=max; yAxisLog=logarithmic; calcPlotScaling(); - replotPlot(); + redrawPlot(); } void JKQTFastPlotter::setXYRange(double xmin, double xmax, double ymin, double ymax, bool xlogarithmic, bool ylogarithmic) { @@ -801,7 +799,7 @@ void JKQTFastPlotter::setXYRange(double xmin, double xmax, double ymin, double y yMax=ymax; yAxisLog=ylogarithmic; calcPlotScaling(); - replotPlot(); + redrawPlot(); } /* @@ -815,7 +813,7 @@ void JKQTFastPlotter::synchronizeX(JKQTFastPlotter* toWhere) { plotBorderRight=toWhere->get_internalPlotBorderRight(); std::cout<<"syncX: xMin="<get_internalPlotBorderBottom(); std::cout<<"syncY: yMin="<N=N; @@ -892,7 +890,7 @@ void JKQTFPLinePlot::drawGraph(QPainter& painter) { path.moveTo(parent->x2p(x[0]), parent->y2p(y[0])); //std::cout<<"plotting graph, starting @ ("<x2p(x[0])<<", "<y2p(y[0])<<")\n"; } - for (unsigned int i=1; ix2p(x[i]), parent->y2p(y[i])); //std::cout<<"-> ("<x2p(x[i])<<", "<y2p(y[i])<<")\n"; } @@ -900,13 +898,13 @@ void JKQTFPLinePlot::drawGraph(QPainter& painter) { if (N>0){ epath.moveTo(parent->x2p(x[0]), parent->y2p(y[0]+yerr[0])); } - for (unsigned int i=1; ix2p(x[i]), parent->y2p(y[i]+yerr[i])); } if (N>0){ epath.moveTo(parent->x2p(x[0]), parent->y2p(y[0]-yerr[0])); } - for (unsigned int i=1; ix2p(x[i]), parent->y2p(y[i]-yerr[i])); } } @@ -946,7 +944,7 @@ void JKQTFPLinePlot::drawGraph(QPainter& painter) { -JKQTFPVCrossPlot::JKQTFPVCrossPlot(JKQTFastPlotter* parent, unsigned int N, double* x, double* y, QColor color, Qt::PenStyle style, double width): +JKQTFPVCrossPlot::JKQTFPVCrossPlot(JKQTFastPlotter* parent, int N, double* x, double* y, QColor color, Qt::PenStyle style, double width): JKQTFPLinePlot(parent, N, x, y, color, style, width) { crossWidth=5; @@ -974,7 +972,7 @@ void JKQTFPVCrossPlot::drawGraph(QPainter& painter) { pe.setJoinStyle(Qt::RoundJoin); QPainterPath path, epath; if (datatype==JKQTFPLPPointer) { - for (unsigned int i=0; ix2p(x[i])-crossWidth/2.0, parent->y2p(y[i]))); path.lineTo(QPointF(parent->x2p(x[i])+crossWidth/2.0, parent->y2p(y[i]))); path.moveTo(QPointF(parent->x2p(x[i]), parent->y2p(y[i])-crossWidth/2.0)); @@ -985,13 +983,13 @@ void JKQTFPVCrossPlot::drawGraph(QPainter& painter) { if (N>0){ epath.moveTo(parent->x2p(x[0]), parent->y2p(y[0]+yerr[0])); } - for (unsigned int i=1; ix2p(x[i]), parent->y2p(y[i]+yerr[i])); } if (N>0){ epath.moveTo(parent->x2p(x[0]), parent->y2p(y[0]-yerr[0])); } - for (unsigned int i=1; ix2p(x[i]), parent->y2p(y[i]-yerr[i])); } } @@ -1035,7 +1033,7 @@ void JKQTFPVCrossPlot::drawGraph(QPainter& painter) { -JKQTFPVBarPlot::JKQTFPVBarPlot(JKQTFastPlotter* parent, unsigned int N, double* x, double* y, QColor color, Qt::PenStyle style, double width): +JKQTFPVBarPlot::JKQTFPVBarPlot(JKQTFastPlotter* parent, int N, double* x, double* y, QColor color, Qt::PenStyle style, double width): JKQTFPLinePlot(parent, N, x, y, color, style, width) { } @@ -1058,7 +1056,7 @@ void JKQTFPVBarPlot::drawGraph(QPainter& painter) { painter.setPen(p); if (!parent->getYAxisLog()) { if (datatype==JKQTFPLPPointer) { - for (unsigned int i=0; ix2p(x[i]); QLineF l(xval, parent->y2p(0), xval, parent->y2p(y[i])); if (l.length()>0) painter.drawLine(l); @@ -1073,7 +1071,7 @@ void JKQTFPVBarPlot::drawGraph(QPainter& painter) { } else { double starty=parent->get_internalPlotBorderTop()+parent->getPlotHeight(); if (datatype==JKQTFPLPPointer) { - for (unsigned int i=0; iy2p(y[i]); if (!std::isnan(v) && !std::isinf(v)) { double xval=parent->x2p(x[i]); @@ -1163,7 +1161,7 @@ void JKQTFPQImagePlot::drawGraph(QPainter& painter) { -JKQTFPimagePlot::JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax, JKQTFPColorPalette palette): +JKQTFPimagePlot::JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, int width, int height, double xmin, double xmax, double ymin, double ymax, JKQTFPColorPalette palette): JKQTFPPlot(parent) { this->image=image; @@ -1182,7 +1180,7 @@ JKQTFPimagePlot::JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPIma this->rotation=0; } -JKQTFPimagePlot::JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, unsigned int width, unsigned int height, JKQTFPColorPalette palette): +JKQTFPimagePlot::JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, int width, int height, JKQTFPColorPalette palette): JKQTFPPlot(parent) { this->image=image; @@ -1253,12 +1251,12 @@ void JKQTFPimagePlot::drawGraph(QPainter& painter) { painter.setCompositionMode(QPainter::CompositionMode_SourceOver); QImage img(width, height, QImage::Format_ARGB32); switch(imageFormat) { - case JKQTFP_uint8: JKQTFPimagePlot_array2image((uint8_t*)image, width, height, img, palette, colorMin, colorMax); break; - case JKQTFP_uint16: JKQTFPimagePlot_array2image((uint16_t*)image, width, height, img, palette, colorMin, colorMax); break; - case JKQTFP_uint32: JKQTFPimagePlot_array2image((uint32_t*)image, width, height, img, palette, colorMin, colorMax); break; - case JKQTFP_int64: JKQTFPimagePlot_array2image((int64_t*)image, width, height, img, palette, colorMin, colorMax); break; - case JKQTFP_float: JKQTFPimagePlot_array2image((float*)image, width, height, img, palette, colorMin, colorMax); break; - case JKQTFP_double: JKQTFPimagePlot_array2image((double*)image, width, height, img, palette, colorMin, colorMax); break; + case JKQTFP_uint8: JKQTFPimagePlot_array2image(static_cast(image), width, height, img, palette, colorMin, colorMax); break; + case JKQTFP_uint16: JKQTFPimagePlot_array2image(static_cast(image), width, height, img, palette, colorMin, colorMax); break; + case JKQTFP_uint32: JKQTFPimagePlot_array2image(static_cast(image), width, height, img, palette, colorMin, colorMax); break; + case JKQTFP_int64: JKQTFPimagePlot_array2image(static_cast(image), width, height, img, palette, colorMin, colorMax); break; + case JKQTFP_float: JKQTFPimagePlot_array2image(static_cast(image), width, height, img, palette, colorMin, colorMax); break; + case JKQTFP_double: JKQTFPimagePlot_array2image(static_cast(image), width, height, img, palette, colorMin, colorMax); break; } if (img.isNull()) return; double pxmin=parent->x2p(xmin); @@ -1296,7 +1294,7 @@ void JKQTFPimagePlot::drawGraph(QPainter& painter) { -JKQTFPimageOverlayPlot::JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax, QColor color): +JKQTFPimageOverlayPlot::JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, int width, int height, double xmin, double xmax, double ymin, double ymax, QColor color): JKQTFPPlot(parent) { this->image=image; @@ -1314,7 +1312,7 @@ JKQTFPimageOverlayPlot::JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* im } -JKQTFPimageOverlayPlot::JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, unsigned int width, unsigned int height, QColor color): +JKQTFPimageOverlayPlot::JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, int width, int height, QColor color): JKQTFPPlot(parent) { this->image=image; @@ -1353,8 +1351,8 @@ void JKQTFPimageOverlayPlot::drawGraph(QPainter& painter) { if (showAsSymbols) { QList x,y; - for (unsigned int j=0; jwidth=width; @@ -1572,7 +1570,7 @@ JKQTFPRGBImageOverlayPlot::JKQTFPRGBImageOverlayPlot(JKQTFastPlotter *parent, vo this->rotation=0; } -JKQTFPRGBImageOverlayPlot::JKQTFPRGBImageOverlayPlot(JKQTFastPlotter *parent, void *imageRed, JKQTFPImageFormat imageFormat, unsigned int width, unsigned int height): +JKQTFPRGBImageOverlayPlot::JKQTFPRGBImageOverlayPlot(JKQTFastPlotter *parent, void *imageRed, JKQTFPImageFormat imageFormat, int width, int height): JKQTFPPlot(parent) { this->width=width; @@ -1628,28 +1626,28 @@ void JKQTFPRGBImageOverlayPlot::drawGraph(QPainter &painter) { QImage img(width, height, QImage::Format_ARGB32); img.fill(0); switch(imageFormatRed) { - case JKQTFP_uint8: JKQTFPRGBImageOverlayPlot_array2image((uint8_t*)imageRed, width, height, img, 0, colorMinRed, colorMaxRed); break; - case JKQTFP_uint16: JKQTFPRGBImageOverlayPlot_array2image((uint16_t*)imageRed, width, height, img, 0, colorMinRed, colorMaxRed); break; - case JKQTFP_uint32: JKQTFPRGBImageOverlayPlot_array2image((uint32_t*)imageRed, width, height, img, 0, colorMinRed, colorMaxRed); break; - case JKQTFP_int64: JKQTFPRGBImageOverlayPlot_array2image((int64_t*)imageRed, width, height, img, 0, colorMinRed, colorMaxRed); break; - case JKQTFP_float: JKQTFPRGBImageOverlayPlot_array2image((float*)imageRed, width, height, img, 0, colorMinRed, colorMaxRed); break; - case JKQTFP_double: JKQTFPRGBImageOverlayPlot_array2image((double*)imageRed, width, height, img, 0, colorMinRed, colorMaxRed); break; + case JKQTFP_uint8: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageRed), width, height, img, 0, colorMinRed, colorMaxRed); break; + case JKQTFP_uint16: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageRed), width, height, img, 0, colorMinRed, colorMaxRed); break; + case JKQTFP_uint32: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageRed), width, height, img, 0, colorMinRed, colorMaxRed); break; + case JKQTFP_int64: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageRed), width, height, img, 0, colorMinRed, colorMaxRed); break; + case JKQTFP_float: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageRed), width, height, img, 0, colorMinRed, colorMaxRed); break; + case JKQTFP_double: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageRed), width, height, img, 0, colorMinRed, colorMaxRed); break; } switch(imageFormatGreen) { - case JKQTFP_uint8: JKQTFPRGBImageOverlayPlot_array2image((uint8_t*)imageGreen, width, height, img, 1, colorMinGreen, colorMaxGreen); break; - case JKQTFP_uint16: JKQTFPRGBImageOverlayPlot_array2image((uint16_t*)imageGreen, width, height, img, 1, colorMinGreen, colorMaxGreen); break; - case JKQTFP_uint32: JKQTFPRGBImageOverlayPlot_array2image((uint32_t*)imageGreen, width, height, img, 1, colorMinGreen, colorMaxGreen); break; - case JKQTFP_int64: JKQTFPRGBImageOverlayPlot_array2image((int64_t*)imageGreen, width, height, img, 1, colorMinGreen, colorMaxGreen); break; - case JKQTFP_float: JKQTFPRGBImageOverlayPlot_array2image((float*)imageGreen, width, height, img, 1, colorMinGreen, colorMaxGreen); break; - case JKQTFP_double: JKQTFPRGBImageOverlayPlot_array2image((double*)imageGreen, width, height, img, 1, colorMinGreen, colorMaxGreen); break; + case JKQTFP_uint8: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageGreen), width, height, img, 1, colorMinGreen, colorMaxGreen); break; + case JKQTFP_uint16: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageGreen), width, height, img, 1, colorMinGreen, colorMaxGreen); break; + case JKQTFP_uint32: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageGreen), width, height, img, 1, colorMinGreen, colorMaxGreen); break; + case JKQTFP_int64: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageGreen), width, height, img, 1, colorMinGreen, colorMaxGreen); break; + case JKQTFP_float: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageGreen), width, height, img, 1, colorMinGreen, colorMaxGreen); break; + case JKQTFP_double: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageGreen), width, height, img, 1, colorMinGreen, colorMaxGreen); break; } switch(imageFormatBlue) { - case JKQTFP_uint8: JKQTFPRGBImageOverlayPlot_array2image((uint8_t*)imageBlue, width, height, img, 2, colorMinBlue, colorMaxBlue); break; - case JKQTFP_uint16: JKQTFPRGBImageOverlayPlot_array2image((uint16_t*)imageBlue, width, height, img, 2, colorMinBlue, colorMaxBlue); break; - case JKQTFP_uint32: JKQTFPRGBImageOverlayPlot_array2image((uint32_t*)imageBlue, width, height, img, 2, colorMinBlue, colorMaxBlue); break; - case JKQTFP_int64: JKQTFPRGBImageOverlayPlot_array2image((int64_t*)imageBlue, width, height, img, 2, colorMinBlue, colorMaxBlue); break; - case JKQTFP_float: JKQTFPRGBImageOverlayPlot_array2image((float*)imageBlue, width, height, img, 2, colorMinBlue, colorMaxBlue); break; - case JKQTFP_double: JKQTFPRGBImageOverlayPlot_array2image((double*)imageBlue, width, height, img, 2, colorMinBlue, colorMaxBlue); break; + case JKQTFP_uint8: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageBlue), width, height, img, 2, colorMinBlue, colorMaxBlue); break; + case JKQTFP_uint16: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageBlue), width, height, img, 2, colorMinBlue, colorMaxBlue); break; + case JKQTFP_uint32: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageBlue), width, height, img, 2, colorMinBlue, colorMaxBlue); break; + case JKQTFP_int64: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageBlue), width, height, img, 2, colorMinBlue, colorMaxBlue); break; + case JKQTFP_float: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageBlue), width, height, img, 2, colorMinBlue, colorMaxBlue); break; + case JKQTFP_double: JKQTFPRGBImageOverlayPlot_array2image(static_cast(imageBlue), width, height, img, 2, colorMinBlue, colorMaxBlue); break; } if (img.isNull()) return; double pxmin=parent->x2p(xmin); @@ -1669,7 +1667,7 @@ void JKQTFPRGBImageOverlayPlot::drawGraph(QPainter &painter) { } -void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, unsigned int width, unsigned int height){ +void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, int width, int height){ this->imageRed=imageRed; this->imageFormatRed=imageFormatRed; this->imageGreen=nullptr; @@ -1683,7 +1681,7 @@ void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imag replot(); } -void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, unsigned int width, unsigned int height) { +void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, int width, int height) { this->imageRed=imageRed; this->imageFormatRed=imageFormatRed; this->imageGreen=imageGreen; @@ -1698,7 +1696,7 @@ void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imag replot(); } -void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, unsigned int width, unsigned int height) { +void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, int width, int height) { this->imageRed=imageRed; this->imageFormatRed=imageFormatRed; this->imageGreen=imageGreen; @@ -1716,7 +1714,7 @@ void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imag } -void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax){ +void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, int width, int height, double xmin, double xmax, double ymin, double ymax){ this->imageRed=imageRed; this->imageFormatRed=imageFormatRed; this->imageRed=nullptr; @@ -1730,7 +1728,7 @@ void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imag replot(); } -void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax) { +void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, int width, int height, double xmin, double xmax, double ymin, double ymax) { this->imageRed=imageRed; this->imageFormatRed=imageFormatRed; this->imageGreen=imageGreen; @@ -1745,7 +1743,7 @@ void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imag replot(); } -void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax) { +void JKQTFPRGBImageOverlayPlot::set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, int width, int height, double xmin, double xmax, double ymin, double ymax) { this->imageRed=imageRed; this->imageFormatRed=imageFormatRed; this->imageGreen=imageGreen; diff --git a/lib/jkqtfastplotter/jkqtfastplotter.h b/lib/jkqtfastplotter/jkqtfastplotter.h index f8d87988df..edc59e2ed8 100644 --- a/lib/jkqtfastplotter/jkqtfastplotter.h +++ b/lib/jkqtfastplotter/jkqtfastplotter.h @@ -483,7 +483,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->plotBorderLeft != __value) { this->plotBorderLeft = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotBorderLeft. @@ -500,7 +500,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->plotBorderBottom != __value) { this->plotBorderBottom = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotBorderBottom. @@ -517,7 +517,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->plotBorderRight != __value) { this->plotBorderRight = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotBorderRight. @@ -534,7 +534,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->plotBorderTop != __value) { this->plotBorderTop = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotBorderTop. @@ -638,7 +638,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->backgroundColor != __value) { this->backgroundColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property backgroundColor. @@ -655,7 +655,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->plotBackgroundColor != __value) { this->plotBackgroundColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotBackgroundColor. @@ -672,7 +672,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->drawGrid != __value) { this->drawGrid = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property drawGrid. @@ -689,7 +689,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->gridColor != __value) { this->gridColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property gridColor. @@ -706,7 +706,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->gridStyle != __value) { this->gridStyle = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property gridStyle. @@ -723,7 +723,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->gridWidth != __value) { this->gridWidth = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property gridWidth. @@ -740,7 +740,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->labelFontSize != __value) { this->labelFontSize = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property labelFontSize. @@ -757,7 +757,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->labelFontName != __value) { this->labelFontName = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property labelFontName. @@ -774,7 +774,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->tickFontSize != __value) { this->tickFontSize = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property tickFontSize. @@ -791,7 +791,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->tickFontName != __value) { this->tickFontName = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property tickFontName. @@ -808,7 +808,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->tickLength != __value) { this->tickLength = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property tickLength. @@ -825,7 +825,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->drawSystemBox != __value) { this->drawSystemBox = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property drawSystemBox. @@ -842,7 +842,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->drawZeroAxes != __value) { this->drawZeroAxes = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property drawZeroAxes. @@ -859,7 +859,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->systemColor != __value) { this->systemColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property systemColor. @@ -876,7 +876,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->systemWidth != __value) { this->systemWidth = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property systemWidth. @@ -893,7 +893,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->xZeroTick != __value) { this->xZeroTick = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property xZeroTick. @@ -910,7 +910,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->yZeroTick != __value) { this->yZeroTick = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property yZeroTick. @@ -927,7 +927,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->xTickDistance != __value) { this->xTickDistance = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property xTickDistance. @@ -944,7 +944,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->yTickDistance != __value) { this->yTickDistance = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property yTickDistance. @@ -961,7 +961,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->xAxisLabel != __value) { this->xAxisLabel = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property xAxisLabel. @@ -978,7 +978,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->yAxisLabel != __value) { this->yAxisLabel = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property yAxisLabel. @@ -995,7 +995,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->aspectRatio != __value) { this->aspectRatio = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property aspectRatio. @@ -1012,7 +1012,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->maintainAspectRatio != __value) { this->maintainAspectRatio = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property maintainAspectRatio. @@ -1029,7 +1029,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->xAxisLabelVisible != __value) { this->xAxisLabelVisible = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property xAxisLabelVisible. @@ -1046,7 +1046,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->yAxisLabelVisible != __value) { this->yAxisLabelVisible = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property yAxisLabelVisible. @@ -1063,7 +1063,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->synchronizeX != __value) { this->synchronizeX = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property synchronizeX. @@ -1080,7 +1080,7 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { { if (this->synchronizeY != __value) { this->synchronizeY = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property synchronizeY. @@ -1120,9 +1120,9 @@ class LIB_EXPORT JKQTFastPlotter : public JKQTFASTPLOTTER_BASEWIDGET { /** \brief copy the current plot image to the clipboard */ void copyImage(); /** \brief replot everything (slowest possible plotting) */ - void replotPlot(); + void redrawPlot(); /** \brief replot everything (slowest possible plotting) and forces a repaint calling QWidget::repaint() */ - void replotPlot_immediate(); + void redrawPlot_immediate(); /** \brief replot only the data * * This internally calls QWidget::update(), so no immediate repaint() is forced! If you want an immediate update, @@ -1217,7 +1217,7 @@ class LIB_EXPORT JKQTFPLinePlot: public JKQTFPPlot { }; protected: /** \brief number of datapoints in the plot */ - unsigned int N; + int N; /** \brief pointer to x-coordinate data to display */ double* x; /** \brief pointer to y-coordinate data to display */ @@ -1255,7 +1255,7 @@ class LIB_EXPORT JKQTFPLinePlot: public JKQTFPPlot { \param style style of the graph \param width width of the plot (in pt) */ - JKQTFPLinePlot(JKQTFastPlotter* parent, unsigned int N, double* x, double* y, QColor color=QColor("red"), Qt::PenStyle style=Qt::SolidLine, double width=1) ; + JKQTFPLinePlot(JKQTFastPlotter* parent, int N, double* x, double* y, QColor color=QColor("red"), Qt::PenStyle style=Qt::SolidLine, double width=1) ; /*! \brief class constructor \param parent parent widget @@ -1270,7 +1270,7 @@ class LIB_EXPORT JKQTFPLinePlot: public JKQTFPPlot { /** \brief draw the graph */ virtual void drawGraph(QPainter& painter) override; - inline void set_data(double* x, double* y, unsigned int N) { + inline void set_data(double* x, double* y, int N) { this->x=x; this->y=y; this->yerr=nullptr; @@ -1279,7 +1279,7 @@ class LIB_EXPORT JKQTFPLinePlot: public JKQTFPPlot { replot(); }; - inline void set_data(double* x, double* y, double* yerr, unsigned int N) { + inline void set_data(double* x, double* y, double* yerr, int N) { this->x=x; this->y=y; this->yerr=yerr; @@ -1312,7 +1312,7 @@ class LIB_EXPORT JKQTFPLinePlot: public JKQTFPPlot { replot(); }; - inline unsigned int get_N() { + inline int get_N() { if (datatype==JKQTFPLPPointer) return N; if (datatype==JKQTFPLPVector) @@ -1487,7 +1487,7 @@ class LIB_EXPORT JKQTFPVCrossPlot: public JKQTFPLinePlot { \param style style of the graph \param width width of the plot (in pt) */ - JKQTFPVCrossPlot(JKQTFastPlotter* parent, unsigned int N, double* x, double* y, QColor color=QColor("red"), Qt::PenStyle style=Qt::SolidLine, double width=1) ; + JKQTFPVCrossPlot(JKQTFastPlotter* parent, int N, double* x, double* y, QColor color=QColor("red"), Qt::PenStyle style=Qt::SolidLine, double width=1) ; /*! \brief class constructor @@ -1546,7 +1546,7 @@ class LIB_EXPORT JKQTFPVBarPlot: public JKQTFPLinePlot { \param style style of the graph \param width width of the plot (in pt) */ - JKQTFPVBarPlot(JKQTFastPlotter* parent, unsigned int N, double* x, double* y, QColor color=QColor("red"), Qt::PenStyle style=Qt::SolidLine, double width=1) ; + JKQTFPVBarPlot(JKQTFastPlotter* parent, int N, double* x, double* y, QColor color=QColor("red"), Qt::PenStyle style=Qt::SolidLine, double width=1) ; /*! \brief class constructor @@ -2100,9 +2100,9 @@ enum JKQTFPColorPalette { \details Here, the color palettes are illustrated (left is the color for the minimum and right for the maximum). */ enum JKQTFPImageFormat { - JKQTFP_uint8=0, /*!< \image 8 bit unsigned int */ - JKQTFP_uint16=1, /*!< \image 16 bit unsigned int */ - JKQTFP_uint32=2, /*!< \image 32 bit unsigned int */ + JKQTFP_uint8=0, /*!< \image 8 bit int */ + JKQTFP_uint16=1, /*!< \image 16 bit int */ + JKQTFP_uint32=2, /*!< \image 32 bit int */ JKQTFP_float=3, /*!< \image float */ JKQTFP_double=4, /*!< \image double */ JKQTFP_int64=5 /*!< \image 64 bit signed int */ @@ -2124,7 +2124,7 @@ enum JKQTFPImageFormat { the according LUT won't be calculated and stored! */ template -inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &img, JKQTFPColorPalette palette, T minColor, T maxColor) +inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &img, JKQTFPColorPalette palette, double minColor, double maxColor) { if (!dbl) return; @@ -2142,7 +2142,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i if (minColor == maxColor) { for (int i=1; i max) @@ -2162,26 +2162,26 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i double delta=max-min; - unsigned int* lut_used=nullptr; - static unsigned int* lut_red=nullptr; - static unsigned int* lut_green=nullptr; - static unsigned int* lut_blue=nullptr; - static unsigned int* lut_gray=nullptr; - static unsigned int* lut_invred=nullptr; - static unsigned int* lut_invgreen=nullptr; - static unsigned int* lut_invblue=nullptr; - static unsigned int* lut_invgray=nullptr; - static unsigned int* lut_matlab=nullptr; - static unsigned int* lut_rygb=nullptr; - static unsigned int* lut_hsv=nullptr; - static unsigned int* lut_invhsv=nullptr; - static unsigned int* lut_rainbow=nullptr; - static unsigned int* lut_hot=nullptr; - static unsigned int* lut_ocean=nullptr; - static unsigned int* lut_trafficlight=nullptr; - static unsigned int* lut_bluemagentayellow=nullptr; - static unsigned int* lut_blueyellow=nullptr; - static unsigned int* lut_cyan=nullptr; + int* lut_used=nullptr; + static int* lut_red=nullptr; + static int* lut_green=nullptr; + static int* lut_blue=nullptr; + static int* lut_gray=nullptr; + static int* lut_invred=nullptr; + static int* lut_invgreen=nullptr; + static int* lut_invblue=nullptr; + static int* lut_invgray=nullptr; + static int* lut_matlab=nullptr; + static int* lut_rygb=nullptr; + static int* lut_hsv=nullptr; + static int* lut_invhsv=nullptr; + static int* lut_rainbow=nullptr; + static int* lut_hot=nullptr; + static int* lut_ocean=nullptr; + static int* lut_trafficlight=nullptr; + static int* lut_bluemagentayellow=nullptr; + static int* lut_blueyellow=nullptr; + static int* lut_cyan=nullptr; img = QImage(width, height, QImage::Format_ARGB32_Premultiplied); @@ -2191,9 +2191,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i { if (palette == JKQTFP_RED) { - unsigned int** plut=&lut_red; + int** plut=&lut_red; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2206,9 +2206,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_GREEN) { - unsigned int** plut=&lut_green; + int** plut=&lut_green; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2221,9 +2221,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_BLUE) { - unsigned int** plut=&lut_blue; + int** plut=&lut_blue; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2238,9 +2238,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i else if (palette == JKQTFP_GRAY) { - unsigned int** plut=&lut_gray; + int** plut=&lut_gray; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2255,9 +2255,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i else if (palette == JKQTFP_INVERTEDRED) { - unsigned int** plut=&lut_invred; + int** plut=&lut_invred; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2270,9 +2270,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_INVERTEDGREEN) { - unsigned int** plut=&lut_invgreen; + int** plut=&lut_invgreen; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2284,9 +2284,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_INVERTEDBLUE) { - unsigned int** plut=&lut_invblue; + int** plut=&lut_invblue; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2298,9 +2298,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_INVERTEDGRAY) { - unsigned int** plut=&lut_invgray; + int** plut=&lut_invgray; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=1.0-(l/static_cast(JKQTFPimagePlot_LUTSIZE)); @@ -2315,9 +2315,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i else if (palette == JKQTFP_MATLAB) { - unsigned int** plut=&lut_matlab; + int** plut=&lut_matlab; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2348,9 +2348,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_RYGB) //gnuplot: 30,-13,-23 { - unsigned int** plut=&lut_rygb; + int** plut=&lut_rygb; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2374,9 +2374,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_HSV) { - unsigned int** plut=&lut_hsv; + int** plut=&lut_hsv; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2400,9 +2400,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_INVERTED_HSV) { - unsigned int** plut=&lut_invhsv; + int** plut=&lut_invhsv; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2428,7 +2428,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i else if (palette == JKQTFP_RAINBOW) //gnuplot: 33,13,10 { if (lut_rainbow==nullptr) { - lut_rainbow=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); + lut_rainbow=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); //std::cout<<"!!! creating rainbow lut\n"; if (lut_rainbow!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { @@ -2449,9 +2449,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_HOT) //gnuplot: 21,22,23 { - unsigned int** plut=&lut_hot; + int** plut=&lut_hot; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2476,9 +2476,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_OCEAN) //gnuplot: 23,28,3 { - unsigned int** plut=&lut_ocean; + int** plut=&lut_ocean; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2497,9 +2497,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_BLUEMAGENTAYELLOW) //gnuplot: 30,31,32 { - unsigned int** plut=&lut_bluemagentayellow; + int** plut=&lut_bluemagentayellow; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2526,9 +2526,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_BLUEYELLOW) //gnuplot: 8,9,10 { - unsigned int** plut=&lut_blueyellow; + int** plut=&lut_blueyellow; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2553,9 +2553,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_CYAN) { - unsigned int** plut=&lut_cyan; + int** plut=&lut_cyan; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2579,9 +2579,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_TRAFFICLIGHT) { - unsigned int** plut=&lut_trafficlight; + int** plut=&lut_trafficlight; if ((*plut)==nullptr) { - (*plut)=(unsigned int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(unsigned int)); + (*plut)=(int*)malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(int)); if ((*plut)!=nullptr) { for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); @@ -2608,9 +2608,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i #endif if (lut_used!=nullptr) { // LUT found: collor the image accordingly - for (register int j=0; j JKQTFPimagePlot_LUTSIZE) ? JKQTFPimagePlot_LUTSIZE : v); line[i]=lut_used[v]; @@ -2668,9 +2668,9 @@ class LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { /** \brief format of the image */ JKQTFPImageFormat imageFormat; /** \brief width of image in pt */ - unsigned int width; + int width; /** \brief height of image in pt */ - unsigned int height; + int height; /** \brief minimum x value of the image */ double xmin; /** \brief maximum x value of the image */ @@ -2695,9 +2695,9 @@ class LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { /*! \brief class constructor */ - JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax, JKQTFPColorPalette palette=JKQTFP_MATLAB) ; + JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, int width, int height, double xmin, double xmax, double ymin, double ymax, JKQTFPColorPalette palette=JKQTFP_MATLAB) ; - JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, unsigned int width, unsigned int height, JKQTFPColorPalette palette=JKQTFP_MATLAB); + JKQTFPimagePlot(JKQTFastPlotter* parent, void* image, JKQTFPImageFormat imageFormat, int width, int height, JKQTFPColorPalette palette=JKQTFP_MATLAB); /** \brief draw the graph */ virtual void drawGraph(QPainter& painter) override; @@ -2741,7 +2741,7 @@ class LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { /*! \brief sets the property width to the specified \a __value. \details Description of the parameter width is:
\copydoc JKQTFPimagePlot::width
\see width for more information */ - inline virtual void set_width(const unsigned int & __value) + inline virtual void set_width(int __value) { if (this->width != __value) { this->width = __value; @@ -2751,14 +2751,14 @@ class LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { /*! \brief returns the property width. \details Description of the parameter width is:
\copydoc JKQTFPimagePlot::width
\see width for more information */ - inline virtual unsigned int get_width() const + inline virtual int get_width() const { return this->width; } /*! \brief sets the property height to the specified \a __value. \details Description of the parameter height is:
\copydoc JKQTFPimagePlot::height
\see height for more information */ - inline virtual void set_height(const unsigned int & __value) + inline virtual void set_height(int __value) { if (this->height != __value) { this->height = __value; @@ -2768,7 +2768,7 @@ class LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { /*! \brief returns the property height. \details Description of the parameter height is:
\copydoc JKQTFPimagePlot::height
\see height for more information */ - inline virtual unsigned int get_height() const + inline virtual int get_height() const { return this->height; } @@ -2898,7 +2898,7 @@ class LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { inline double get_colorMax() const { return this->colorMax; } - void set_image(void* image, JKQTFPImageFormat imageFormat, unsigned int width, unsigned int height) { + void set_image(void* image, JKQTFPImageFormat imageFormat, int width, int height) { this->image=image; this->imageFormat=imageFormat; this->width=width; @@ -2992,7 +2992,7 @@ inline void JKQTFPRGBImageOverlayPlot_array2image(T* dbl, int width, int height, if (minColor == maxColor) { for (int i=1; i max) @@ -3016,34 +3016,34 @@ inline void JKQTFPRGBImageOverlayPlot_array2image(T* dbl, int width, int height, if (min != max) { // LUT found: collor the image accordingly if (channel==0) { - for (register int j=0; j 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; line[i]=qRgb(v,qGreen(l),qBlue(l)); //if (i==j) qDebug()< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; line[i]=qRgb(qRed(l),v,qBlue(l)); //if (i==j) qDebug()< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; line[i]=qRgb(qRed(l),qGreen(l),v); //if (i==j) qDebug()<\copydoc JKQTFPRGBImageOverlayPlot::width \see width for more information */ - inline virtual void set_width(const unsigned int & __value) + inline virtual void set_width(int __value) { if (this->width != __value) { this->width = __value; @@ -3220,14 +3220,14 @@ class LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot { /*! \brief returns the property width. \details Description of the parameter width is:
\copydoc JKQTFPRGBImageOverlayPlot::width
\see width for more information */ - inline virtual unsigned int get_width() const + inline virtual int get_width() const { return this->width; } /*! \brief sets the property height to the specified \a __value. \details Description of the parameter height is:
\copydoc JKQTFPRGBImageOverlayPlot::height
\see height for more information */ - inline virtual void set_height(const unsigned int & __value) + inline virtual void set_height(int __value) { if (this->height != __value) { this->height = __value; @@ -3237,7 +3237,7 @@ class LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot { /*! \brief returns the property height. \details Description of the parameter height is:
\copydoc JKQTFPRGBImageOverlayPlot::height
\see height for more information */ - inline virtual unsigned int get_height() const + inline virtual int get_height() const { return this->height; } @@ -3351,12 +3351,12 @@ class LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot { inline double get_colorMaxBlue() const { return this->colorMaxBlue; } - void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, unsigned int width, unsigned int height); - void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, unsigned int width, unsigned int height); - void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, unsigned int width, unsigned int height); - void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax); - void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax); - void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax); + void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, int width, int height); + void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, int width, int height); + void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, int width, int height); + void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, int width, int height, double xmin, double xmax, double ymin, double ymax); + void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, int width, int height, double xmin, double xmax, double ymin, double ymax); + void set_image(void* imageRed, JKQTFPImageFormat imageFormatRed, void* imageGreen, JKQTFPImageFormat imageFormatGreen, void* imageBlue, JKQTFPImageFormat imageFormatBlue, int width, int height, double xmin, double xmax, double ymin, double ymax); public slots: inline void set_rotation(int rotation) { if (this->rotation!=rotation) { @@ -3496,9 +3496,9 @@ class LIB_EXPORT JKQTFPimageOverlayPlot: public JKQTFPPlot { /** \brief image to plot */ bool* image; /** \brief width of image in pt */ - unsigned int width; + int width; /** \brief height of image in pt */ - unsigned int height; + int height; /** \brief minimum x value of the image */ double xmin; /** \brief maximum x value of the image */ @@ -3519,14 +3519,14 @@ class LIB_EXPORT JKQTFPimageOverlayPlot: public JKQTFPPlot { /*! \brief class constructor */ - JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, unsigned int width, unsigned int height, double xmin, double xmax, double ymin, double ymax, QColor color=QColor("red")); + JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, int width, int height, double xmin, double xmax, double ymin, double ymax, QColor color=QColor("red")); - JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, unsigned int width, unsigned int height, QColor color=QColor("red")); + JKQTFPimageOverlayPlot(JKQTFastPlotter* parent, bool* image, int width, int height, QColor color=QColor("red")); /** \brief draw the graph */ virtual void drawGraph(QPainter& painter) override; - void set_data(bool* image, unsigned int width, unsigned int height) { + void set_data(bool* image, int width, int height) { this->image=image; this->width=width; this->height=height; @@ -3548,13 +3548,13 @@ class LIB_EXPORT JKQTFPimageOverlayPlot: public JKQTFPPlot { /*! \brief returns the property width. \details Description of the parameter width is:
\copydoc JKQTFPimageOverlayPlot::width
. \see width for more information */ - inline unsigned int get_width() const { + inline int get_width() const { return this->width; } /*! \brief returns the property height. \details Description of the parameter height is:
\copydoc JKQTFPimageOverlayPlot::height
. \see height for more information */ - inline unsigned int get_height() const { + inline int get_height() const { return this->height; } /*! \brief sets the property xmin to the specified \a __value. diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index 9c0fff7a28..d0b408934d 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -1,4370 +1,4363 @@ -/* - Copyright (c) 2008-2019 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 . -*/ - - - -#include "jkqtmathtext/jkqtmathtext.h" -#include -#include -#include -#include -#include -//#define jkqtp_QColor2String(color) QString(jkqtp_rgbtostring((color).red(), (color).green(), (color).blue(), (color).alpha()).c_str()) - -/** - * \brief saves the given property (for which also a def_property exists) into the given settings object - * \ingroup jkqtmathtext - * \internal - */ -#define JKQTMTPROPERTYsave(settings, group, var, varname) \ - if (var!=def_##var) settings.setValue(group+varname, var); -/** - * \brief loads the given property from the given settings object - * \ingroup jkqtmathtext - * \internal - */ -#define JKQTMTPROPERTYload(settings, group, var, varname, varconvert) \ - var=settings.value(group+varname, var).varconvert; - - -QPainterPath makeHBracePath(double x, double ybrace, double width, double bw, double cubicshrink=0.5, double cubiccontrolfac=0.3) { - double xl1=x-(width)*cubicshrink+bw*cubicshrink; - double xr2=x+(width)*cubicshrink-bw*cubicshrink; - double xl2=x-bw*cubicshrink; - double xr1=x+bw*cubicshrink; - - QPainterPath path; - path.moveTo(xl1-bw*cubicshrink, ybrace-bw*cubicshrink); - path.cubicTo(xl1-bw*cubicshrink, ybrace-bw*cubicshrink+bw*cubiccontrolfac, xl1-bw*cubiccontrolfac, ybrace, xl1, ybrace); - path.lineTo(xl2, ybrace); - path.cubicTo(xl2+bw*cubiccontrolfac, ybrace, (xl2+xr1)/2.0, ybrace+bw*cubicshrink-bw*cubiccontrolfac, (xl2+xr1)/2.0, ybrace+bw*cubicshrink); - path.cubicTo((xl2+xr1)/2.0, ybrace+bw*cubicshrink-bw*cubiccontrolfac, xr1-bw*cubiccontrolfac, ybrace, xr1, ybrace); - path.lineTo(xr2, ybrace); - path.cubicTo(xr2+bw*cubiccontrolfac, ybrace, xr2+bw*cubicshrink, ybrace-bw*cubicshrink+bw*cubiccontrolfac, xr2+bw*cubicshrink, ybrace-bw*cubicshrink); - return path; -} - - -QPainterPath makeArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true) { - double x1=x; - double x2=x+width; - double x3=x2-arrowW/2.0; - double y3u=y-arrowW/2.0; - double y3d=y+arrowW/2.0; - double x3l=x+arrowW/2.0; - - QPainterPath path; - path.moveTo(x1, y); - path.lineTo(x2, y); - if (right) { - path.moveTo(x3, y3u); - path.lineTo(x2, y); - path.lineTo(x3, y3d); - } - if (left) { - path.moveTo(x3l, y3u); - path.lineTo(x1, y); - path.lineTo(x3l, y3d); - } - return path; -} - - -QPainterPath makeDArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true) { - double x1=x; - double x2=x+width; - double dx=arrowW/4.0; - double y1=y-dx; - double y2=y+dx; - double x3=x2-arrowW/2.0; - double y3u=y-arrowW/2.0; - double y3d=y+arrowW/2.0; - double x3l=x+arrowW/2.0; - - QPainterPath path; - path.moveTo(x1+dx, y1); - path.lineTo(x2-dx, y1); - path.moveTo(x1+dx, y2); - path.lineTo(x2-dx, y2); - if (right) { - path.moveTo(x3, y3u); - path.lineTo(x2, y); - path.lineTo(x3, y3d); - } - if (left) { - path.moveTo(x3l, y3u); - path.lineTo(x1, y); - path.lineTo(x3l, y3d); - } - return path; -} - - - -// -------------------------------------------------------------------------------------------------- -// -- implementation of the MTnode's methods -// -------------------------------------------------------------------------------------------------- - -JKQTMathText::MTenvironment::MTenvironment() { - color=QColor("black"); - font=MTEroman; - fontSize=10; - bold=false; - italic=false; - smallCaps=false; - underlined=false; - overline=false; - strike=false; - insideMath=false; -} - -QFont JKQTMathText::MTenvironment::getFont(JKQTMathText* parent) const { - QFont f; - switch (font) { - case MTEsans: - if (insideMath) f.setFamily(parent->getFontMathSans()); - else f.setFamily(parent->getFontSans()); - break; - case MTEtypewriter: f.setFamily(parent->getFontTypewriter()); break; - case MTEscript: f.setFamily(parent->getFontScript()); break; - case MTEroman: - if (insideMath) f.setFamily(parent->getFontMathRoman()); - else f.setFamily(parent->getFontRoman()); - break; - case MTEcaligraphic: f.setFamily(parent->getFontCaligraphic()); break; - case MTEblackboard: f.setFamily(parent->getFontBlackboard()); break; - }; - f.setBold(bold); - f.setItalic(italic); - f.setUnderline(underlined); - f.setOverline(overline); - f.setStrikeOut(strike); - f.setCapitalization(QFont::MixedCase); - if (smallCaps) f.setCapitalization(QFont::SmallCaps); - f.setPointSizeF(fontSize); - f.setStyleStrategy(QFont::NoFontMerging); - return f; -} - -QString JKQTMathText::MTenvironment::toHtmlStart(MTenvironment defaultEv) const { - QString s; - s=s+"font-size: "+QLocale::c().toString(fontSize)+"pt; "; - if (insideMath) { - if (defaultEv.italic) { - if (!italic) s=s+"font-style: italic; "; - if (italic) s=s+"font-style: normal; "; - } else { - if (!italic) s=s+"font-style: italic; "; - } - } else { - if (!defaultEv.italic && italic) s=s+"font-style: italic; "; - } - if (bold && !defaultEv.bold) s=s+"font-weight: bold"; - - QStringList td; - if (underlined && !defaultEv.underlined) td<<"underline"; - if (overline && !defaultEv.overline) td<<"overline"; - if (strike && !defaultEv.strike) td<<"line-through"; - if (td.size()>0) s=s+"text-decoration: "+td.join(", "); - return ""; -} - -QString JKQTMathText::MTenvironment::toHtmlAfter(JKQTMathText::MTenvironment /*defaultEv*/) const { - return ""; -} - -JKQTMathText::MTnode::MTnode(JKQTMathText* parent) { - this->parent=parent; - drawBoxes=false; -} - -JKQTMathText::MTnode::~MTnode() -{ - -} - -void JKQTMathText::MTnode::getSize(QPainter &painter, JKQTMathText::MTenvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos) -{ - double w=width, b=baselineHeight, o=overallHeight, s=strikeoutPos; - getSizeInternal(painter, currentEv, w, b, o, s); - - if (w<1e5) width=w; - if (b<1e5) baselineHeight=b; - if (o<1e5) overallHeight=o; - if (s<1e5) strikeoutPos=s; -} - -bool JKQTMathText::MTnode::toHtml(QString &/*html*/, JKQTMathText::MTenvironment /*currentEv*/, JKQTMathText::MTenvironment /*defaultEv*/) { - return false; -} - - -void JKQTMathText::MTnode::doDrawBoxes(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - if (drawBoxes) { - painter.save(); - double w, oh, bh, sp; - getSize(painter, currentEv, w, bh, oh, sp); - QPen p=painter.pen(); - p.setColor("lightcoral"); - p.setWidthF(0.5); - painter.setPen(p); - QRectF r(x, y-bh, w, oh); - painter.drawRect(r); - p.setColor("lightblue"); - painter.setPen(p); - if (w>0) painter.drawLine(QLineF(x, y, x+w, y)); - p.setColor("green"); - painter.setPen(p); - painter.drawEllipse(x-3.0,y-3.0,6.0,6.0); - p.setColor("lightgreen"); - painter.setPen(p); - painter.drawLine(x-2.0, y, x+2.0, y); - painter.drawLine(x, y-2, x, y+2.0); - painter.restore(); - } -} - - -JKQTMathText::MTtextNode::MTtextNode(JKQTMathText* parent, QString textIn, bool addWhitespace, bool stripInnerWhitepace): - JKQTMathText::MTnode(parent) -{ - QString text=textIn; - - if (stripInnerWhitepace) { - text=""; - for (int i=0; itext=text; - // strip all whitespace from left - while (this->text.size()>1 && this->text[0].isSpace()) { - this->text=this->text.right(this->text.size()-1); - } - if (addWhitespace /*&& (this->text.size()>0)*/ && (!this->text[this->text.size()-1].isSpace())) this->text=this->text+" "; - //qDebug()<<"MTtextNode( text="< this->text="<text<<"]"; -} - -JKQTMathText::MTtextNode::~MTtextNode() { -} - -void JKQTMathText::MTtextNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - QFont f=currentEv.getFont(parent); - if (currentEv.insideMath && (text=="(" || text=="[" || text=="|" || text=="]" || text==")" || text=="<" || text==">" || - text==QString(QChar(0x2329)) || text==QString(QChar(0x232A)) || text==QString(QChar(0x2308)) || - text==QString(QChar(0x2309)) || text==QString(QChar(0x230A)) || text==QString(QChar(0x230B)))) { - f.setItalic(false); - f.setFamily(parent->getFontBraces()); - } - QString txt=textTransform(text, currentEv, true); - QFontMetricsF fm(f, painter.device()); - QRectF br=fm.boundingRect(txt); - QRectF tbr=parent->getTBR(f, txt, painter.device()); //fm.tightBoundingRect(txt); - if (txt=="|") { - br=fm.boundingRect("X"); - tbr=QRect(0,0,fm.width("X"), fm.ascent());//fm.boundingRect("X"); - br.setWidth(0.7*br.width()); - } - width=br.width();//width(text); - - if (txt.size()>0) { - if (txt[0].isSpace() /*&& br.width()<=0*/) width=width+fm.boundingRect("I").width(); - if (txt.size()>1 && txt[txt.size()-1].isSpace() /*&& (fm.boundingRect("a ").width()==fm.boundingRect("a").width())*/) width=width+fm.width("I"); - } - - //qDebug()<<"text: "<" || - text==QString(QChar(0x2329)) || text==QString(QChar(0x232A)) || text==QString(QChar(0x2308)) || - text==QString(QChar(0x2309)) || text==QString(QChar(0x230A)) || text==QString(QChar(0x230B)))) { - f.setItalic(false); - f.setFamily(parent->getFontBraces()); - } - - - if (onlyDigits && currentEv.insideMath) { - f.setItalic(false); - } - - painter.setFont(f); - - QPen p=painter.pen(); - p.setColor(currentEv.color); - painter.setPen(p); - double dx=0; - QFontMetricsF fm(f, painter.device()); - /*if (txt.size()>1 && txt[txt.size()-1].isSpace()) { - QFontMetricsF fm(f, painter.device()); - //if ((fm.width("a ")==fm.width("a"))) dx=fm.boundingRect("I").width(); - }*/ - - if (!hasDigits || !f.italic()) { - painter.drawText(QPointF(x+dx, y), txt);//.simplified()); - } else { - int i=0; - double xx=x+dx; - QFont ff=f; - QFontMetricsF fmff(ff, painter.device()); - ff.setItalic(false); - while (igetFontEncoding()==MTFEunicode) { - if (currentEv.insideMath) { - txt=""; - for (int i=0; i': txt+=QString(QString(" > ")); break; - case '=': txt+=QString(QString(" = ")); break; - case ';': txt+=QString(QString("; ")); break; - default: txt+=c; break; - } - } - txt=txt.replace(" ", " "); - } - } - if (currentEv.font==MTEblackboard && parent->getFontEncoding()==MTFEunicode) { - txt=""; - for (int i=0; igetFontEncoding()==MTFEunicode) { - txt=""; - for (int i=0; iname=name; - this->child=child; - this->parameters=parameters; - - JKQTMathText::MTenvironment ev; - if (!setupMTenvironment(ev)) { - parent->error_list.append(tr("unknown instruction '%1' found!").arg(name)); - } -} - -JKQTMathText::MTinstruction1Node::~MTinstruction1Node() { - if (child!=nullptr) delete child; -} - -QString JKQTMathText::MTinstruction1Node::getTypeName() const -{ - return QLatin1String("MTinstruction1Node(")+name+")"; -} - -void JKQTMathText::MTinstruction1Node::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - JKQTMathText::MTenvironment ev=currentEv; - - setupMTenvironment(ev); - - child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); - if (name=="colorbox" || name=="fbox" || name=="boxed") { - QFontMetricsF fm(ev.getFont(parent)); - double xw=fm.width("x"); - width+=xw; - overallHeight+=xw; - baselineHeight+=xw/2.0; - } -} - -double JKQTMathText::MTinstruction1Node::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - doDrawBoxes(painter, x, y, currentEv); - JKQTMathText::MTenvironment ev=currentEv; - - setupMTenvironment(ev); - - QPen oldPen=painter.pen(); - double shiftX=0; - if (name=="colorbox" || name=="fbox" || name=="boxed") { - QColor fcol=currentEv.color; - if (name=="colorbox") fcol=QColor(parameters.value(0, ev.color.name())); - //qDebug()<<"COLOR="<getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); - QPen p=painter.pen(); - QFontMetricsF fm(currentEv.getFont(parent)); - double xw=fm.width("x"); - p.setColor(fcol); - painter.setPen(p); - painter.drawRect(x,y-baselineHeight-xw/2,width+xw,overallHeight+xw); - shiftX=xw/2.0; - } - - double xnew= child->draw(painter, x+shiftX, y, ev); - painter.setPen(oldPen); - return xnew; -} - -bool JKQTMathText::MTinstruction1Node::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { - JKQTMathText::MTenvironment ev=currentEv; - - setupMTenvironment(ev); - - return child->toHtml(html, ev, defaultEv); -} - -void JKQTMathText::MTinstruction1Node::set_drawBoxes(bool draw) -{ - drawBoxes=draw; - child->set_drawBoxes(draw); -} - -bool JKQTMathText::MTinstruction1Node::setupMTenvironment(JKQTMathText::MTenvironment &ev) -{ - if (name=="bf" || name=="textbf" || name=="mathbf") ev.bold=true; - else if (name=="em") ev.italic=!ev.italic; - else if (name=="it" || name=="textit" || name=="mathit") ev.italic=true; - else if (name=="textcolor" || name=="mathcolor" || name=="color") ev.color=QColor(parameters.value(0, ev.color.name())); - else if (name=="equation") { ev.italic=true; ev.insideMath=true; } - else if (name=="sc" || name=="textsc" || name=="mathsc") ev.smallCaps=true; - else if (name=="ul" || name=="underline" || name=="underlined") ev.underlined=true; - else if (name=="ol" || name=="overline" || name=="overlined") ev.overline=true; - else if (name=="strike") ev.strike=true; - else if (name=="rm" || name=="textrm") { ev.font=JKQTMathText::MTEroman; } - else if (name=="mathrm" || name=="text" || name=="mbox" || name=="operatorname") { ev.font=JKQTMathText::MTEroman; ev.italic=false; } - else if (name=="mat") { ev.font=JKQTMathText::MTEroman; ev.italic=false; ev.bold=true; } - else if (name=="cal" || name=="textcal" || name=="mathcal") { ev.font=JKQTMathText::MTEcaligraphic; } - else if (name=="bb" || name=="textbb" || name=="mathbb") { ev.font=JKQTMathText::MTEblackboard; } - else if (name=="tt" || name=="texttt" || name=="mathtt") { ev.font=JKQTMathText::MTEtypewriter; } - else if (name=="sf" || name=="textsf" || name=="mathsf") { ev.font=JKQTMathText::MTEsans; } - else if (name=="script" || name=="textscript" || name=="mathscript") { ev.font=JKQTMathText::MTEscript; } - else if (name=="displaystyle") { ev.fontSize=ev.fontSize/0.8; } - else if (name=="scriptstyle") { ev.fontSize=ev.fontSize*0.8; } - else if (name=="scriptscriptstyle") { ev.fontSize=ev.fontSize*0.8*0.8; } - else { - return false; - } - - return true; -} - - - - -JKQTMathText::MTsubscriptNode::MTsubscriptNode(JKQTMathText* parent, MTnode* child): - JKQTMathText::MTnode(parent) -{ - this->child=child; -} - -JKQTMathText::MTsubscriptNode::~MTsubscriptNode() { - if (child!=nullptr) delete child; -} - -void JKQTMathText::MTsubscriptNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - JKQTMathText::MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); - - QFontMetricsF fm(ev.getFont(parent), painter.device()); - double shift=parent->get_sub_shift_factor()*parent->getTBR(ev.getFont(parent), "M", painter.device()).height(); - - child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); - - QFontMetricsF fmouter(currentEv.getFont(parent), painter.device()); - QRectF tbr=parent->getTBR(currentEv.getFont(parent), "M", painter.device()); - overallHeight=tbr.height()+shift+(overallHeight-baselineHeight); - baselineHeight=tbr.height(); - strikeoutPos=fmouter.strikeOutPos(); - if (currentEv.italic) width=width-double(fm.width(' '))*parent->get_italic_correction_factor(); -} - -double JKQTMathText::MTsubscriptNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - doDrawBoxes(painter, x, y, currentEv); - JKQTMathText::MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); - - QFontMetricsF fm(ev.getFont(parent), painter.device()); - - double shift=parent->get_sub_shift_factor()*parent->getTBR(ev.getFont(parent), "M", painter.device()).height(); - double xx=x; - if (currentEv.italic) xx=xx-double(fm.width(' '))*parent->get_italic_correction_factor(); - return child->draw(painter, xx, y+shift, ev);//+0.5*fm.boundingRect("A").width(); -} - -bool JKQTMathText::MTsubscriptNode::isSubOrSuper() -{ - return true; -} - -QString JKQTMathText::MTsubscriptNode::getTypeName() const -{ - return "MTsubscriptNode"; -} - - -bool JKQTMathText::MTsubscriptNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { - html=html+""; - bool ok=child->toHtml(html, currentEv, defaultEv); - html=html+""; - return ok; -} - -void JKQTMathText::MTsubscriptNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - child->set_drawBoxes(draw); - -} - - - - - -JKQTMathText::MTsqrtNode::MTsqrtNode(JKQTMathText* parent, MTnode* child, int degree): - JKQTMathText::MTnode(parent) -{ - this->child=child; - this->degree=degree; -} - -JKQTMathText::MTsqrtNode::~MTsqrtNode() { - if (child!=nullptr) delete child; -} - -void JKQTMathText::MTsqrtNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - QFontMetricsF fm(currentEv.getFont(parent), painter.device()); - - child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); - - overallHeight=overallHeight*1.2;//+fm.ascent()*0.1; - baselineHeight=baselineHeight*1.2;//+fm.ascent()*0.1; - width=width+fm.boundingRect("A").width()*2; // 1.53 -} - -double JKQTMathText::MTsqrtNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - doDrawBoxes(painter, x, y, currentEv); - double width=0, baselineHeight=0, overallHeight=0, sp=0; - child->getSize(painter, currentEv, width, baselineHeight, overallHeight, sp); - QFont f=currentEv.getFont(parent); - QFont fsmall=f; - QFontMetricsF fm(f, painter.device()); - double w=fm.boundingRect("A").width(); - double a=baselineHeight*1.15; - double d=overallHeight-baselineHeight; - //painter.save(); - QPen p=painter.pen(); - p.setColor(currentEv.color); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH,ceil(currentEv.fontSize/16.0))); - //painter.setPen(p); - QPainterPath path; - if (w>0) { - path.moveTo(x+0.1*w, y-0.4*a); - path.lineTo(x+0.33*w, y-0.4*a); - path.lineTo( x+0.66*w, y+0.5*d); - path.lineTo(x+w, y-a); - } - if (degree!=2) { - fsmall.setPointSizeF(fsmall.pointSizeF()/2.0); - fsmall.setItalic(false); - painter.setFont(fsmall); - painter.drawText(QPointF(x+0.33*w, y-0.55*a), QLocale::c().toString(degree)); - } - //painter.restore(); - double xnew=child->draw(painter, x+1.2*w, y, currentEv); - painter.save(); - painter.setPen(p); - if (w>0) { - path.lineTo( xnew+0.2*w, y-a); - path.lineTo(xnew+0.2*w, y-0.8*a); - painter.drawPath(path); - } - painter.restore(); - return xnew+0.33*w; -} - -bool JKQTMathText::MTsqrtNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { - html=html+"√"; - bool ok=child->toHtml(html, currentEv, defaultEv); - html=html+" "; - return ok; -} - -void JKQTMathText::MTsqrtNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - child->set_drawBoxes(draw); - -} - -QString JKQTMathText::MTsqrtNode::getTypeName() const -{ - return "MTsqrtNode"; -} - - - - - - -JKQTMathText::MTfracNode::MTfracNode(JKQTMathText* parent, MTnode* child_top, MTnode* child_bottom, MTfracMode mode): - JKQTMathText::MTnode(parent) -{ - this->child1=child_top; - this->child2=child_bottom; - this->mode=mode; -} - -JKQTMathText::MTfracNode::~MTfracNode() { - if (child1!=nullptr) delete child1; - if (child2!=nullptr) delete child2; -} - -QString JKQTMathText::MTfracNode::getTypeName() const -{ - return "MTfracNode"; -} - -void JKQTMathText::MTfracNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - QFontMetricsF fm(currentEv.getFont(parent), painter.device()); - JKQTMathText::MTenvironment ev1=currentEv; - JKQTMathText::MTenvironment ev2=currentEv; - - double xh=fm.xHeight(); //tightBoundingRect("x").height(); - double sp=xh; - double Ah=parent->getTBR(currentEv.getFont(parent), "M", painter.device()).height();//fm.ascent(); - double xw=fm.boundingRect("x").width(); - - if (mode==MTFMunderbrace || mode==MTFMoverbrace) { - ev2.fontSize=ev2.fontSize*parent->get_underbrace_factor(); - } else if (mode==MTFMunderset || mode==MTFMoverset) { - ev2.fontSize=ev2.fontSize*parent->get_underset_factor(); - } else if (mode==MTFMfrac) { - ev1.fontSize=ev1.fontSize*parent->get_frac_factor(); - ev2.fontSize=ev2.fontSize*parent->get_frac_factor(); - } else if (mode==MTFMtfrac) { - ev1.fontSize=ev1.fontSize*parent->get_frac_factor()*0.7; - ev2.fontSize=ev2.fontSize*parent->get_frac_factor()*0.7; - } - - - double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0; - double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos2=0; - child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1); - child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos2); - - overallHeight=0; - baselineHeight=0; - width=0; - if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) { - //std::cout<<"\nxh="< baselineHeight="<getTBR(f, "M", painter.device()).height();//fm.ascent(); - double bw=Ah/2.0; - - if (mode==MTFMunderbrace || mode==MTFMoverbrace) { - ev2.fontSize=ev2.fontSize*parent->get_underbrace_factor(); - } else if (mode==MTFMunderset || mode==MTFMoverset) { - ev2.fontSize=ev2.fontSize*parent->get_underset_factor(); - } else if (mode==MTFMfrac) { - ev1.fontSize=ev1.fontSize*parent->get_frac_factor(); - ev2.fontSize=ev2.fontSize*parent->get_frac_factor(); - } else if (mode==MTFMtfrac) { - ev1.fontSize=ev1.fontSize*parent->get_frac_factor()*0.7; - ev2.fontSize=ev2.fontSize*parent->get_frac_factor()*0.7; - } - - double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0; - double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0; - child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos); - child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos); - double ascent1=baselineHeight1; - double descent1=overallHeight1-baselineHeight1; - double ascent2=baselineHeight2; - double descent2=overallHeight2-baselineHeight2; - - double yline=y-xh*0.5; - - - //double overallHeight=overallHeight1+overallHeight2+xh; - //double baselineHeight=3.0*xh/2.0+overallHeight1; - double width=qMax(width1, width2); - - QPen p=painter.pen(); - p.setColor(ev1.color); - p.setStyle(Qt::SolidLine); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, lw)); - painter.save(); - painter.setPen(p); - if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) { - QLineF l(x+xw/4.0, yline, x+width+xw/2.0, yline); - if (l.length()>0) painter.drawLine(l); - child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->get_frac_shift_factor())-descent1, ev1); - child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->get_frac_shift_factor())+ascent2, ev2); - } else if (mode==MTFMstackrel) { - child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->get_frac_shift_factor())-descent1, ev1); - child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->get_frac_shift_factor())+ascent2, ev2); - } else if (mode==MTFMunderset) { - child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); - child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y+descent1+xh/6.0+ascent2, ev2); - } else if (mode==MTFMunderbrace) { - double ybrace=y+descent1+bw/2.0; - QPainterPath path=makeHBracePath(x+xw/2.0+(width1)/2.0, ybrace, width, bw); - painter.drawPath(path); - - child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); - child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y+descent1+bw+ascent2, ev2); - } else if (mode==MTFMoverset) { - child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); - child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y-ascent1-xh/6.0-descent2, ev2); - } else if (mode==MTFMoverbrace) { - double ybrace=y-ascent1-bw/2.0; - - painter.save(); - painter.translate(x+xw/2.0+(width1)/2.0, ybrace); - painter.rotate(180); - QPainterPath path=makeHBracePath(0,0, width, bw); - painter.drawPath(path); - painter.restore(); - - child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); - child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y-ascent1-bw-descent2, ev2); - } - painter.restore(); - - if (mode==MTFMstackrel) return x+width+ xw; - return x+width+xw; - -} - -bool JKQTMathText::MTfracNode::toHtml(QString &/*html*/, JKQTMathText::MTenvironment /*currentEv*/, JKQTMathText::MTenvironment /*defaultEv*/) { - bool ok=false; - - - - return ok; -} - -void JKQTMathText::MTfracNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - child1->set_drawBoxes(draw); - child2->set_drawBoxes(draw); - -} - - - - - - - - - -JKQTMathText::MTmatrixNode::MTmatrixNode(JKQTMathText* parent, QVector > children): - JKQTMathText::MTnode(parent) -{ - this->lines=children.size(); - this->columns=0; - for (int i=0; ithis->columns) this->columns=children[i].size(); - } - this->children=children; -} - -JKQTMathText::MTmatrixNode::~MTmatrixNode() { - for (int i=0; iget_frac_factor(); - - - QVector colwidth, rowheight; - //QVector > widths, heights, baselines; - - double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0; - //widths.resize(lines); - colwidth.resize(columns); for (int i=0; igetSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1); - /*widths[i].operator[](j)=width1; - baselines[i].operator[](j)=baselineHeight; - heights[i].operator[](j)=overallHeight1;*/ - if (overallHeight1>rowheight[i]) rowheight[i]=overallHeight1; - if (width1>colwidth[j]) colwidth[j]=width1; - } - } - - - overallHeight=(lines-1)*xw/2.0; - width=columns*xw; - for (int i=0; iget_frac_factor(); - - - QVector colwidth, rowheight, rowascent; - //QVector > widths, heights, baselines; - - double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos=0; - //widths.resize(lines); - colwidth.resize(columns); for (int i=0; igetSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos); - /*widths[i].operator[](j)=width1; - baselines[i].operator[](j)=baselineHeight; - heights[i].operator[](j)=overallHeight1;*/ - if (overallHeight1>rowheight[i]) rowheight[i]=overallHeight1; - if (baselineHeight1>rowascent[i]) rowascent[i]=baselineHeight1; - if (width1>colwidth[j]) colwidth[j]=width1; - } - } - - double overallHeight=(lines-1)*xw/2.0; - double width=(columns)*xw; - for (int i=0; i0) yy=yy+rowascent[0]; - for (int i=0; idraw(painter, xx, yy, ev1); - xx=xx+colwidth[j]+xw; - } - - if (idrawBoxes=draw; - for (int i=0; iset_drawBoxes(draw); - } - } - -} - - - - - - - - -JKQTMathText::MTdecoratedNode::MTdecoratedNode(JKQTMathText* parent, MTdecoration decoration, MTnode* child): - JKQTMathText::MTnode(parent) -{ - this->child=child; - this->decoration=decoration; -} - -JKQTMathText::MTdecoratedNode::~MTdecoratedNode() { - if (child!=nullptr) delete child; -} - -void JKQTMathText::MTdecoratedNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - QFontMetricsF fm(currentEv.getFont(parent), painter.device()); - double wc=fm.boundingRect("A").width(); - double dheightfactor=1.0+parent->get_decoration_height_factor()*2.0; - - child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); - - overallHeight=overallHeight*dheightfactor; - baselineHeight=baselineHeight*dheightfactor; - width=width+0.3*wc; -} - -double JKQTMathText::MTdecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - doDrawBoxes(painter, x, y, currentEv); - MTenvironment ev=currentEv; - double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0; - child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); - QFontMetricsF fm(ev.getFont(parent), painter.device()); - double w=width; - double wc=fm.boundingRect("A").width(); - //double ll=wc*0.8; - double a=baselineHeight; - //double d=overallHeight-baselineHeight; - double dheightfactor=parent->get_decoration_height_factor(); - double dpos=y-a*(1.0+dheightfactor); - double dposb=y+qMax((overallHeight-baselineHeight)*(1.0+dheightfactor), fm.xHeight()*dheightfactor); - double deltax=0;//(wc-ll)/2.0; - double dheight=dheightfactor*a; - - - if (ev.italic) deltax+=0.1*fm.boundingRect("A").width(); - QPen pold=painter.pen(); - QPen p=pold; - p.setColor(ev.color); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0)); - if (decoration==MTDbar) ev.overline=true; - double xnew=child->draw(painter, x, y, ev); - if (decoration==MTDvec) { - painter.setPen(p); - QPolygonF poly; - poly<0) painter.drawLine(l); - painter.setPen(pold); - } else if (decoration==MTDdoubleoverline) { - painter.setPen(p); - QLineF l(x+deltax, dpos, xnew+deltax-0.2*wc, dpos); - if (l.length()>0) painter.drawLine(l); - l=QLineF(x+deltax, dpos-2.0*p.widthF(), xnew+deltax-0.2*wc, dpos-2.0*p.widthF()); - if (l.length()>0) painter.drawLine(l); - painter.setPen(pold); - } else if (decoration==MTDunderline) { - painter.setPen(p); - QLineF l(x+deltax, dposb, xnew+deltax-0.2*wc, dposb); - if (l.length()>0) painter.drawLine(l); - painter.setPen(pold); - } else if (decoration==MTDdoubleunderline) { - painter.setPen(p); - QLineF l(x+deltax, dposb, xnew+deltax-0.2*wc, dposb); - if (l.length()>0) painter.drawLine(l); - l=QLineF(x+deltax, dposb+2.0*p.widthF(), xnew+deltax-0.2*wc, dposb+2.0*p.widthF()); - if (l.length()>0) painter.drawLine(l); - painter.setPen(pold); - } else if (decoration==MTDarrow) { - painter.setPen(p); - QLineF l(x+deltax, dpos+dheight/2.0, xnew+deltax-0.2*wc, dpos+dheight/2.0); - if (l.length()>0) painter.drawLine(l); - QPolygonF poly; - poly<toHtml(html, ev, defaultEv); - - return false; -} - -void JKQTMathText::MTdecoratedNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - child->set_drawBoxes(draw); - -} - -QString JKQTMathText::MTdecoratedNode::getTypeName() const -{ - return "MTdecoratedNode"; -} - - - - - - -JKQTMathText::MTsuperscriptNode::MTsuperscriptNode(JKQTMathText* parent, MTnode* child): - JKQTMathText::MTnode(parent) -{ - this->child=child; -} - -JKQTMathText::MTsuperscriptNode::~MTsuperscriptNode() { - if (child!=nullptr) delete child; -} - -void JKQTMathText::MTsuperscriptNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - JKQTMathText::MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); - QFontMetricsF fm(currentEv.getFont(parent), painter.device()); - child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); - double shift=0;//parent->get_super_shift_factor()*fm.ascent(); - overallHeight=overallHeight+shift; - strikeoutPos=fm.strikeOutPos(); - if (currentEv.italic) width=width+double(fm.width(' '))*parent->get_italic_correction_factor(); -} - -double JKQTMathText::MTsuperscriptNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - doDrawBoxes(painter, x, y, currentEv); - JKQTMathText::MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); - - double cwidth, cbaselineHeight, coverallheight, cStrikeoutPos; - child->getSize(painter, ev, cwidth, cbaselineHeight, coverallheight, cStrikeoutPos); - - QFontMetricsF fm(currentEv.getFont(parent), painter.device()); - - double shift=0;//parent->get_super_shift_factor()*fm.ascent(); - //double shift=ev.; - double xx=x; - if (currentEv.italic) xx=xx+double(fm.width(' '))*parent->get_italic_correction_factor(); - - return child->draw(painter, xx, y-shift, ev);//+0.5*fm.boundingRect("A").width(); -} - -bool JKQTMathText::MTsuperscriptNode::isSubOrSuper() -{ - return true; -} - -QString JKQTMathText::MTsuperscriptNode::getTypeName() const -{ - return "MTsuperscriptNode"; -} - - -bool JKQTMathText::MTsuperscriptNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) -{ - html=html+""; - bool ok=child->toHtml(html, currentEv, defaultEv); - html=html+""; - return ok; -} - -void JKQTMathText::MTsuperscriptNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - child->set_drawBoxes(draw); - -} - - - - - - -JKQTMathText::MTbraceNode::MTbraceNode(JKQTMathText* parent, QString openbrace, QString closebrace, MTnode* child, bool showRightBrace): - JKQTMathText::MTnode(parent) -{ - this->child=child; - this->openbrace=openbrace; - this->closebrace=closebrace; - this->showRightBrace=showRightBrace; -} - -JKQTMathText::MTbraceNode::~MTbraceNode() { - if (child!=nullptr) delete child; -} - -void JKQTMathText::MTbraceNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - - JKQTMathText::MTenvironment ev=currentEv; - child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); - - double bracewidth=0, braceheight=0; - getBraceWidth(painter, ev, baselineHeight, overallHeight, bracewidth, braceheight); - - bracewidth=bracewidth/parent->get_brace_shrink_factor(); - - baselineHeight=/*qMin(baselineHeight, braceheight)*/ baselineHeight*parent->get_brace_factor(); - overallHeight=qMax(overallHeight, braceheight)*parent->get_brace_factor(); //fm.height(); - - width=width+bracewidth*2.0; - - -} - -double JKQTMathText::MTbraceNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - //std::cout<<"drawing brace-node: '"<getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); - - double bracewidth=0, braceheight=0; - getBraceWidth(painter, ev, baselineHeight, overallHeight, bracewidth, braceheight); - - double cwidth=0; - double cbaselineHeight=0; - double coverallHeight=0, cstrikeoutPos=0; - - getSize(painter, currentEv, cwidth, cbaselineHeight, coverallHeight, cstrikeoutPos); - - double lw=qMax(0.25,ceil(currentEv.fontSize/12.0));//fm.lineWidth(); - - double xnew=x+lw; - - QPen pold=painter.pen(); - QPen p=pold; - p.setWidthF(lw); - p.setColor(currentEv.color); - painter.setPen(p); - double brace_fraction=0.85; - if (openbrace=="(") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+brace_fraction*bracewidth, y1); - path.cubicTo(xnew, (y1+y2)/2.0+fabs(y1-y2)/6.0, xnew, (y1+y2)/2.0-fabs(y1-y2)/6.0 , xnew+brace_fraction*bracewidth, y2); - painter.drawPath(path); - } else if (openbrace=="[") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+brace_fraction*bracewidth, y1); - path.lineTo(xnew+lw/2.0, y1); - path.lineTo(xnew+lw/2.0, y2); - path.lineTo(xnew+brace_fraction*bracewidth, y2); - painter.drawPath(path); - } else if (openbrace=="{") { - QPainterPath path=makeHBracePath(0,0,coverallHeight, bracewidth*brace_fraction); - painter.save(); - painter.translate(xnew+bracewidth*(1.0-brace_fraction), y-cbaselineHeight+coverallHeight/2.0); - painter.rotate(90); - painter.drawPath(path); - painter.restore(); - } else if (openbrace=="_") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+brace_fraction*bracewidth, y1); - path.lineTo(xnew, y1); - path.lineTo(xnew, y2); - painter.drawPath(path); - } else if (openbrace=="~") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew, y1); - path.lineTo(xnew, y2); - path.lineTo(xnew+brace_fraction*bracewidth, y2); - painter.drawPath(path); - } else if (openbrace=="|") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - QLineF l(xnew+brace_fraction*bracewidth, y1, xnew+brace_fraction*bracewidth, y2); - if (l.length()>0) painter.drawLine(l); - painter.drawPath(path); - } else if (openbrace=="#" || openbrace=="||") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - QLineF l(xnew+brace_fraction*bracewidth, y1, xnew+brace_fraction*bracewidth, y2); - if (l.length()>0) painter.drawLine(l); - l=QLineF(xnew+brace_fraction*bracewidth-1.5*lw, y1, xnew+brace_fraction*bracewidth-1.5*lw, y2); - if (l.length()>0) painter.drawLine(l); - } else if (openbrace=="<") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+brace_fraction*bracewidth, y1); - path.lineTo(xnew, (y2+y1)/2.0); - path.lineTo(xnew+brace_fraction*bracewidth, y2); - painter.drawPath(path); - } - - painter.setPen(pold); - - xnew= child->draw(painter, xnew+bracewidth/parent->get_brace_shrink_factor()-lw, y, currentEv)+lw; - - if (showRightBrace) { - painter.setPen(p); - if (closebrace==")") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); - path.cubicTo(xnew+bracewidth, (y1+y2)/2.0+fabs(y1-y2)/6.0, xnew+bracewidth, (y1+y2)/2.0-fabs(y1-y2)/6.0 , xnew+(1.0-brace_fraction)*bracewidth, y2); - painter.drawPath(path); - } else if (closebrace=="]") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); - path.lineTo(xnew+bracewidth-lw/2.0, y1); - path.lineTo(xnew+bracewidth-lw/2.0, y2); - path.lineTo(xnew+(1.0-brace_fraction)*bracewidth, y2); - painter.drawPath(path); - } else if (closebrace=="}") { - QPainterPath path=makeHBracePath(0,0,coverallHeight, bracewidth*brace_fraction); - painter.save(); - painter.translate(xnew+bracewidth*brace_fraction, y-cbaselineHeight+coverallHeight/2.0); - painter.rotate(270); - painter.drawPath(path); - painter.restore(); - } else if (closebrace=="_") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); - path.lineTo(xnew+bracewidth, y1); - path.lineTo(xnew+bracewidth, y2); - painter.drawPath(path); - } else if (closebrace=="~") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+bracewidth, y1); - path.lineTo(xnew+bracewidth, y2); - path.lineTo(xnew+(1.0-brace_fraction)*bracewidth, y2); - painter.drawPath(path); - } else if (closebrace=="|") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - QLineF l(xnew+(1.0-brace_fraction)*bracewidth, y1, xnew+(1.0-brace_fraction)*bracewidth, y2); - if (l.length()>0) painter.drawLine(l); - painter.drawPath(path); - } else if (closebrace=="#" || closebrace=="||") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - QLineF l(xnew+(1.0-brace_fraction)*bracewidth, y1, xnew+(1.0-brace_fraction)*bracewidth, y2); - if (l.length()>0) painter.drawLine(l); - l=QLineF(xnew+(1.0-brace_fraction)*bracewidth+1.5*lw, y1, xnew+(1.0-brace_fraction)*bracewidth+1.5*lw, y2); - if (l.length()>0) painter.drawLine(l); - } else if (closebrace==">") { - QPainterPath path; - double y1=y+(coverallHeight-cbaselineHeight); - double y2=y-cbaselineHeight; - path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); - path.lineTo(xnew+bracewidth, (y2+y1)/2.0); - path.lineTo(xnew+(1.0-brace_fraction)*bracewidth, y2); - painter.drawPath(path); - } - painter.setPen(pold); - } - - //qDebug()<<" ==> "<get_brace_shrink_factor()-lw; -} - -bool JKQTMathText::MTbraceNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { - QString ob=openbrace; - QString cb=closebrace; - if (ob=="<") ob="⟨"; - else if (ob=="_") ob="⌊"; - else if (ob=="~") ob="⌈"; - else if (ob=="||" || ob=="#") ob="||"; - if (cb=="<") cb="⟩"; - else if (cb=="_") cb="⌋"; - else if (cb=="~") cb="⌉"; - else if (cb=="||" || cb=="#") cb="||"; - - - html=html+ob; - - bool ok=child->toHtml(html, currentEv, defaultEv); - - html=html+cb; - - return ok; -} - -void JKQTMathText::MTbraceNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - child->set_drawBoxes(draw); - -} - -QString JKQTMathText::MTbraceNode::getTypeName() const -{ - return QLatin1String("MTbraceNode(")+openbrace+" "+closebrace+")"; -} - -void JKQTMathText::MTbraceNode::getBraceWidth(QPainter &/*painter*/, JKQTMathText::MTenvironment ev, double /*baselineHeight*/, double overallHeight, double &bracewidth, double &braceheight) -{ - /*QFont evf=ev.getFont(parent); - if (ev.insideMath) evf.setItalic(false); - ev.italic=false; - while (ev.fontSize<10*parent->getFontSize()) { - const QFontMetricsF fme(evf, painter.device()); - if (fme.ascent()>overallHeight) break; - ev.fontSize+=0.5; - evf.setPointSizeF(ev.fontSize); - } - ev.fontSize=ev.fontSize*parent->get_brace_factor(); - evf.setPointSizeF(ev.fontSize); - QFontMetricsF fm(evf, painter.device()); - QString bc="_X"; - bracewidth=fm.width("I")*parent->get_brace_shrink_factor(); - braceheight=parent->getTBR(evf, bc, painter.device()).height();*/ - double lw=qMax(0.25,ceil(ev.fontSize/12.0)); - braceheight=overallHeight*parent->get_brace_factor(); - bracewidth=0.6*pow(braceheight, 0.6); - if (openbrace=="{" || closebrace=="}") bracewidth=qMax(bracewidth, lw*3.5); - -} - - - - - -JKQTMathText::MTlistNode::MTlistNode(JKQTMathText* parent): - JKQTMathText::MTnode(parent) -{ - nodes.clear(); - // these operations cause sub/sup script to be typeset over/under the operator, not right besides! - subsupOperations<<"sum"<<"prod"<<"coprod" - <<"bigcap"<<"bigcup"<<"bigvee"<<"bighat" - <<"int"<<"iint"<<"iiint"<<"oint"<<"oiint"<<"oiiint" - <<"max"<<"min"<<"argmax"<<"argmin"<<"sup"<<"inf" - <<"liminf"<<"limsup"<<"lim"<<"max"<<"min"; -} - -JKQTMathText::MTlistNode::~MTlistNode() { - for (int i=0; igetTBR(currentEv.getFont(parent), "M", painter.device()); - - - double xnew=0; - bool wasBrace=false; - for (int i=0; igetSize(painter, currentEv, w1, bh, oh, sp); - //qDebug()<<"i="<getTypeName()<<" w1="<getTypeName()<<" w2="<getTypeName()<<" w1="<getTypeName()<<" w2="<get_operatorsubsuper_size_factor(); - double w1=0, w2=0, w3=0; - double oh1=0, oh2=0, oh3=0; - double bh1=0, bh2=0, bh3=0; - double sp1=0, sp2=0, sp3=0; - nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp1); - //qDebug()<<"sub_super: node: "<getTypeName()<<" w1="<getTypeName()<<" w2="<getTypeName()<<" w3="<overallHeight) overallHeight=oh; - if (bh>baselineHeight) { baselineHeight=bh; strikeoutPos=sp1; } - if (oh-bh>overallHeight-baselineHeight) { - overallHeight=baselineHeight+oh-bh; - } - - i++; - i++; - doDraw=false; - xnew+=w; - //qDebug()<<"### subsupop: sub+super2 overallHeight="<overallHeight) overallHeight=oh; - if (bh>baselineHeight) { baselineHeight=bh; strikeoutPos=sp1; } - if (oh-bh>overallHeight-baselineHeight) { - overallHeight=baselineHeight+oh-bh; - } - - i++; - i++; - doDraw=false; - xnew+=w; - //qDebug()<<"### subsupop: sub+super";*/ - } else if (subn) { // is this subscript? - MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_operatorsubsuper_size_factor(); - double w1=0, w2=0; - double oh1=0, oh2=0; - double bh1=0, bh2=0; - double sp1=0, sp2=0;//, sp3=0; - nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp1); - subn->get_child()->getSize(painter, ev, w2, bh2, oh2, sp2); - //double d1=oh1-bh1; - //double d2=oh2-bh2; - - double oh=oh1+oh2; - double sh=oh1-bh1+oh2*1.1; - if (oh>overallHeight) overallHeight=oh; - if (bh1>baselineHeight) baselineHeight=bh1; - if (sh>overallHeight-baselineHeight) { - overallHeight=baselineHeight+sh; - } - double w=qMax(w1, w2)+fm.width(" "); - i++; - doDraw=false; - xnew+=w; - //qDebug()<<"### subsupop: sub overallHeight="<get_super_shift_factor()*tbr.height()+(oh-bh);//((overallHeight-baselineHeight)+(oh-bh)); - if (wasBrace) { - shift=baselineHeight-parent->get_super_shift_factor()*tbr.height()+(oh-bh); - } - //qDebug()<<"+++ super: bh="<baselineHeight) { - double lheight=overallHeight-baselineHeight; - baselineHeight=shift+bh; - overallHeight=baselineHeight+lheight; - } - //qDebug()<<"### super"; - //qDebug()<<"### subsupop: super overallHeight="<overallHeight-baselineHeight) { - overallHeight=baselineHeight+shift+(oh-bh); - } - //qDebug()<<"### sub"; - //qDebug()<<"### subsupop: sub overallHeight="<getTBR(currentEv.getFont(parent), "M", painter.device()); - bool wasBrace=false; - for (int i=0; i(nodes[i]); - // if we find a subscript/superscript node we check whether the next node is super/subscript - // if so, we typeset them at the same x-psotion, so sub/superscripts appear correctly - if (dynamic_cast(nodes[i])) { - double ccwidth=0, ccbaselineHeight=0, ccoverallHeight=0, ccstrieoutPos=0; - nodes[i]->getSize(painter, currentEv, ccwidth, ccbaselineHeight, ccoverallHeight, ccstrieoutPos); - - if (i+1(nodes[i+1])) { // is this subscript? - - double shift=-parent->get_super_shift_factor()*tbr.height(); - if (wasBrace) { - shift=-cbaselineHeight+parent->get_super_shift_factor()*tbr.height(); - } - //painter.setPen(QPen("red")); - //painter.drawEllipse(xnew-4,ynew+shift-(ccoverallHeight-ccbaselineHeight)-4,8,8); - double xnew1=nodes[i]->draw(painter, xnew, ynew+shift-(ccoverallHeight-ccbaselineHeight), currentEv); - i++; - //painter.setPen(QPen("magenta")); - //painter.drawEllipse(xnew-4,ynew-4,8,8); - double xnew2=nodes[i]->draw(painter, xnew, ynew, currentEv); - //i++; - xnew=qMax(xnew1, xnew2); - doDraw=false; - } - } - } else if (dynamic_cast(nodes[i])) { - if (i+1(nodes[i+1])) { // is this subscript? - //painter.setPen(QPen("magenta")); - //painter.drawEllipse(xnew-4,ynew-4,8,8); - double xnew1=nodes[i]->draw(painter, xnew, ynew, currentEv); - i++; - double ccwidth=0, ccbaselineHeight=0, ccoverallHeight=0, ccstrieoutPos=0; - nodes[i]->getSize(painter, currentEv, ccwidth, ccbaselineHeight, ccoverallHeight, ccstrieoutPos); - //QRectF tbr=fm.tightBoundingRect("M"); - double shift=-parent->get_super_shift_factor()*tbr.height(); - if (wasBrace) { - shift=-cbaselineHeight+parent->get_super_shift_factor()*tbr.height(); - } - //painter.setPen(QPen("red")); - //painter.drawEllipse(xnew-4,ynew+shift-(ccoverallHeight-ccbaselineHeight)-4,8,8); - double xnew2=nodes[i]->draw(painter, xnew, ynew+shift-(ccoverallHeight-ccbaselineHeight), currentEv); - //i++; - xnew=qMax(xnew1, xnew2); - doDraw=false; - } - } - } else { - if (smb) { - QString s=smb->get_symbolName(); - if (subsupOperations.contains(s)) { - MTsubscriptNode* subn=nullptr; - if (i+1(nodes[i+1]); - MTsuperscriptNode* supn=nullptr; - if (i+2(nodes[i+2]); - //std::cout<<"symbol ='"<get_operatorsubsuper_size_factor(); - double w1=0, w2=0, w3=0; - double oh1=0, oh2=0, oh3=0; - double bh1=0, bh2=0, bh3=0, sp; - nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp); - subn->get_child()->getSize(painter, ev, w2, bh2, oh2, sp); - supn->get_child()->getSize(painter, ev, w3, bh3, oh3, sp); - double d1=oh1-bh1; - //double d2=oh2-bh2; - double d3=oh3-bh3; - - double w=qMax(qMax(w1, w2), w3); - //double xnew1= - double xn1=nodes[i]->draw(painter, xnew+(w-w1)/2.0, ynew, currentEv); - i++; - //double xnew2= - double xn2=subn->get_child()->draw(painter, xnew+(w-w2)/2.0, ynew+bh2+d1, ev); - i++; - //double xnew3= - double xn3=supn->get_child()->draw(painter, xnew+(w-w3)/2.0, ynew-bh1-d3-fm.xHeight()/4.0, ev); - doDraw=false; - xnew=qMax(qMax(xn1, xn2), xn3)+fm.width(" "); - } else if (subn) { // is this subscript and not superscript? - MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_operatorsubsuper_size_factor(); - double w1=0, w2=0; - double oh1=0, oh2=0; - double bh1=0, bh2=0, sp=0; - nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp); - subn->get_child()->getSize(painter, ev, w2, bh2, oh2, sp); - double d1=oh1-bh1; - //double d2=oh2-bh2; - - double w=qMax(w1, w2); - //double xnew1= - double xn2=nodes[i]->draw(painter, xnew+(w-w1)/2.0, ynew, currentEv); - i++; - //double xnew2= - double xn1=subn->get_child()->draw(painter, xnew+(w-w2)/2.0, ynew+bh2+d1, ev)+fm.width(" "); - doDraw=false; - //xnew+=w; - xnew=qMax(xn1, xn2); - } else if (supn) { // is this subscript and superscript? - MTenvironment ev=currentEv; - ev.fontSize=ev.fontSize*parent->get_operatorsubsuper_size_factor(); - double w1=0, w3=0; - double oh1=0, oh3=0; - double bh1=0, bh3=0, sp; - nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp); - supn->get_child()->getSize(painter, ev, w3, bh3, oh3, sp); - //double d1=oh1-bh1; - //double d2=oh2-bh2; - double d3=oh3-bh3; - - double w=qMax(w1, w3); - //double xnew1= - double xn1=nodes[i]->draw(painter, xnew+(w-w1)/2.0, ynew, currentEv); - i++; - //double xnew3= - double xn3=supn->get_child()->draw(painter, xnew+(w-w3)/2.0, ynew-bh1-d3-fm.xHeight()/4.0, ev); - doDraw=false; - xnew=qMax(xn1, xn3)+fm.width(" "); - } - } - } - - nodes[i]->getSize(painter, currentEv, cwidth, cbaselineHeight, coverallHeight, cstrieoutPos); - } - - if (i(nodes[i])) { // is this superscript? - double ccwidth=0, ccbaselineHeight=0, ccoverallHeight=0, ccstrieoutPos=0; - nodes[i]->getSize(painter, currentEv, ccwidth, ccbaselineHeight, ccoverallHeight, ccstrieoutPos); - //QRectF tbr=fm.tightBoundingRect("M"); - double shift=-parent->get_super_shift_factor()*tbr.height(); - if (wasBrace) { - shift=-cbaselineHeight+parent->get_super_shift_factor()*tbr.height(); - } - //painter.setPen(QPen("red")); - //painter.drawEllipse(xnew-4,ynew+shift-(ccoverallHeight-ccbaselineHeight)-4,8,8); - xnew=nodes[i]->draw(painter, xnew, ynew+shift-(ccoverallHeight-ccbaselineHeight), currentEv); - } else { - xnew=nodes[i]->draw(painter, xnew, ynew, currentEv); - } - } - wasBrace=dynamic_cast(nodes[i]); - } - return xnew; -} - -bool JKQTMathText::MTlistNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { - bool ok=true; - for (int i=0; itoHtml(h, currentEv, defaultEv); - html=html+h; - } - return ok; -} - -void JKQTMathText::MTlistNode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; - for (int i=0; iset_drawBoxes(draw); - } -} - - - - - -JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, QString name, bool addWhitespace): - JKQTMathText::MTnode(parent) -{ - double mathFontFactor=1.8; - symbol = ""; - symbolName=name; - fontFactor=1.0; - bold=0; - italic=-1; - yfactor=0; - QString n=name; - drawBar=false; - font=MTSFdefault; - heightIsAscent=false; - exactAscent=false; - extendWidthInMathmode=false; - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // statische Lookup-Tabellen vorbereiten - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - static QStringList extendWInMM; - if (extendWInMM.isEmpty()) { - extendWInMM <<"ll"<<"gg"<<"leq"<<"geq"<<"leftrightarrow"<<"leftarrow"<<"rightarrow"<<"to"<<"uparrow"<<"downarrow"<<"updownarrow"<<"Leftrightarrow" - <<"iff"<<"Leftarrow"<<"Rightarrow"<<"Uparrow"<<"Downarrow"<<"Updownarrow"<<"pm"<<"mp"<<"nexists"<<"ni"<<"notni"<<"circ"<<"sim"<<"emptyset"<<"odot"<<"ominus" - <<"subsetnot"<<"bot"<<"leftharpoonup"<<"rightharpoonup"<<"upharpoonleft"<<"downharpoonleft"<<"leftrightharpoon"<<"rightleftharpoon"<<"coprod"<<"leftharpoondown" - <<"rightharpoondown"<<"upharpoonright"<<"downharpoonright"<<"nwarrow"<<"nearrow"<<"searrow"<<"swarrow"<<"mapsto"<<"div"<<"multimap"<<"maporiginal"<<"mapimage" - <<"times"<<"propto"<<"bullet"<<"neq"<<"ne"<<"equiv"<<"approx"<<"otimes"<<"oplus"<<"oslash"<<"cap"<<"land"<<"cup"<<"lor"<<"supset"<<"supseteq"<<"supsetnot" - <<"subset"<<"subseteq"<<"in"<<"notin"<<"cdot"<<"wedge"<<"vee"<<"cong"<<"bot"<<"mid"; - } - - if (extendWInMM.contains(n)) { - extendWidthInMathmode=true; - } - - - static QHash simpleTranslations; - if (simpleTranslations.isEmpty()) { - simpleTranslations.insert("", " "); - simpleTranslations.insert("sin", "sin"); - simpleTranslations.insert("cos", "cos"); - simpleTranslations.insert("tan", "tan"); - simpleTranslations.insert("sinh", "sinh"); - simpleTranslations.insert("cosh", "cosh"); - simpleTranslations.insert("tanh", "tanh"); - simpleTranslations.insert("atan", "atan"); - simpleTranslations.insert("acos", "acos"); - simpleTranslations.insert("asin", "asin"); - simpleTranslations.insert("arcsin", "arcsin"); - simpleTranslations.insert("arccos", "arccos"); - simpleTranslations.insert("arctan", "arctan"); - simpleTranslations.insert("degree", QLatin1String("\xB0")); - simpleTranslations.insert("ii", "i"); - simpleTranslations.insert("dd", "d"); - simpleTranslations.insert("exp", "exp"); - simpleTranslations.insert("log", "log"); - simpleTranslations.insert("ln", "ln"); - simpleTranslations.insert("ld", "ld"); - simpleTranslations.insert("lb", "lb"); - simpleTranslations.insert("argmin", "argmin"); - simpleTranslations.insert("argmax", "argmax"); - simpleTranslations.insert("max", "max"); - simpleTranslations.insert("min", "min"); - simpleTranslations.insert("sec", "sec"); - simpleTranslations.insert("gcd", "gcd"); - simpleTranslations.insert("hom", "hom"); - simpleTranslations.insert("ker", "ker"); - simpleTranslations.insert("dim", "dim"); - simpleTranslations.insert("cot", "cot"); - simpleTranslations.insert("arg", "arg"); - simpleTranslations.insert("det", "det"); - simpleTranslations.insert("deg", "deg"); - simpleTranslations.insert("Pr", "Pr"); - simpleTranslations.insert("coth", "coth"); - } - - - static QHash simpleTranslations_heightIsAscent; - if (simpleTranslations_heightIsAscent.isEmpty()) { - simpleTranslations_heightIsAscent.insert("erf", "erf"); - simpleTranslations_heightIsAscent.insert("min", "min"); - simpleTranslations_heightIsAscent.insert("max", "max"); - simpleTranslations_heightIsAscent.insert("inf", "inf"); - simpleTranslations_heightIsAscent.insert("sup", "sup"); - simpleTranslations_heightIsAscent.insert("liminf", "liminf"); - simpleTranslations_heightIsAscent.insert("limsup", "limsup"); - simpleTranslations_heightIsAscent.insert("lim", "lim"); - } - - static QHash winSymbolGreek; - if (winSymbolGreek.isEmpty()) { - winSymbolGreek.insert("alpha", "a"); - winSymbolGreek.insert("beta", "b"); - winSymbolGreek.insert("gamma", "g"); - winSymbolGreek.insert("delta", "d"); - winSymbolGreek.insert("epsilon", "e"); - winSymbolGreek.insert("varepsilon", "e"); - winSymbolGreek.insert("zeta", "z"); - winSymbolGreek.insert("eta", "h"); - winSymbolGreek.insert("theta", "q"); - winSymbolGreek.insert("vartheta", "J"); - winSymbolGreek.insert("iota", "i"); - winSymbolGreek.insert("kappa", "k"); - winSymbolGreek.insert("lambda", "l"); - winSymbolGreek.insert("mu", "m"); - winSymbolGreek.insert("nu", "n"); - winSymbolGreek.insert("xi", "x"); - winSymbolGreek.insert("pi", "p"); - winSymbolGreek.insert("varpi", "v"); - winSymbolGreek.insert("rho", "r"); - winSymbolGreek.insert("sigma", "s"); - winSymbolGreek.insert("varsigma", "V"); - winSymbolGreek.insert("tau", "t"); - winSymbolGreek.insert("upsilon", "u"); - winSymbolGreek.insert("phi", "f"); - winSymbolGreek.insert("varphi", "j"); - winSymbolGreek.insert("chi", "c"); - winSymbolGreek.insert("psi", "y"); - winSymbolGreek.insert("omega", "w"); - winSymbolGreek.insert("Gamma", "G"); - winSymbolGreek.insert("Delta", "D"); - winSymbolGreek.insert("Theta", "Q"); - winSymbolGreek.insert("Lambda", "L"); - winSymbolGreek.insert("Omega", "W"); - winSymbolGreek.insert("Xi", "X"); - winSymbolGreek.insert("Pi", "P"); - winSymbolGreek.insert("Sigma", "S"); - winSymbolGreek.insert("Upsilon", ""); - winSymbolGreek.insert("Phi", "F"); - winSymbolGreek.insert("Psi", "Y"); - } - - static QHash winSymbolSymbol; - if (winSymbolSymbol.isEmpty()) { - winSymbolSymbol.insert("leftrightarrow", QChar(0xAB)); - winSymbolSymbol.insert("leftarrow", QChar(0xAC)); - winSymbolSymbol.insert("rightarrow", QChar(0xAE)); - winSymbolSymbol.insert("to", QChar(0xAE)); - winSymbolSymbol.insert("uparrow", QChar(0xAD)); - winSymbolSymbol.insert("downarrow", QChar(0xAF)); - winSymbolSymbol.insert("Leftrightarrow", QChar(0xDB)); - winSymbolSymbol.insert("iff", QChar(0xDB)); - winSymbolSymbol.insert("Leftarrow", QChar(0xDC)); - winSymbolSymbol.insert("Rightarrow", QChar(0xDE)); - winSymbolSymbol.insert("Uparrow", QChar(0xDD)); - winSymbolSymbol.insert("Downarrow", QChar(0xFF)); - winSymbolSymbol.insert("pm", QChar(0xB1)); - winSymbolSymbol.insert("leq", QChar(0xA3)); - winSymbolSymbol.insert("geq", QChar(0xB3)); - winSymbolSymbol.insert("times", QChar(0xB4)); - winSymbolSymbol.insert("propto", QChar(0xB5)); - winSymbolSymbol.insert("partial", QChar(0xB6)); - winSymbolSymbol.insert("bullet", QChar(0xB7)); - winSymbolSymbol.insert("neq", QChar(0xB9)); - winSymbolSymbol.insert("ne", QChar(0xB9)); - winSymbolSymbol.insert("equiv", QChar(0xBA)); - winSymbolSymbol.insert("approx", QChar(0xBB)); - winSymbolSymbol.insert("ellipsis", QChar(0xBC)); - winSymbolSymbol.insert("Im", QChar(0xC1)); - winSymbolSymbol.insert("Re", QChar(0xC2)); - winSymbolSymbol.insert("otimes", QChar(0xC4)); - winSymbolSymbol.insert("oplus", QChar(0xC5)); - winSymbolSymbol.insert("oslash", QChar(0xC6)); - winSymbolSymbol.insert("cap", QChar(0xC7)); - winSymbolSymbol.insert("land", QChar(0xC7)); - winSymbolSymbol.insert("cup", QChar(0xC8)); - winSymbolSymbol.insert("lor", QChar(0xC8)); - winSymbolSymbol.insert("supset", QChar(0xC9)); - winSymbolSymbol.insert("supseteq", QChar(0xCA)); - winSymbolSymbol.insert("supsetnot", QChar(0xCB)); - winSymbolSymbol.insert("subset", QChar(0xCC)); - winSymbolSymbol.insert("subseteq", QChar(0xCD)); - winSymbolSymbol.insert("in", QChar(0xCE)); - winSymbolSymbol.insert("notin", QChar(0xCF)); - winSymbolSymbol.insert("angle", QChar(0xD0)); - winSymbolSymbol.insert("nabla", QChar(0xD1)); - winSymbolSymbol.insert("copyright", QChar(0xD3)); - winSymbolSymbol.insert("registered", QChar(0xD2)); - winSymbolSymbol.insert("trademark", QChar(0xD4)); - winSymbolSymbol.insert("cdot", QChar(0xD7)); - winSymbolSymbol.insert("neg", QChar(0xD8)); - winSymbolSymbol.insert("wedge", QChar(0xD9)); - winSymbolSymbol.insert("vee", QChar(0xDA)); - winSymbolSymbol.insert("diamond", QChar(0xE0)); - winSymbolSymbol.insert("langle", QChar(0xE1)); - winSymbolSymbol.insert("rangle", QChar(0xF1)); - winSymbolSymbol.insert("forall", QChar(0x22)); - winSymbolSymbol.insert("exists", QChar(0x24)); - winSymbolSymbol.insert("cong", QChar(0x40)); - winSymbolSymbol.insert("bot", QChar(0x5E)); - winSymbolSymbol.insert("ll", "<<"); - winSymbolSymbol.insert("gg", ">>"); - winSymbolSymbol.insert("Alef", QChar(0xC0)); - winSymbolSymbol.insert("alef", QChar(0xC0)); - winSymbolSymbol.insert("tilde", "~"); - winSymbolSymbol.insert("emptyset", QChar(0xC6)); - winSymbolSymbol.insert("varnothing", QChar(0xC6)); - winSymbolSymbol.insert("lceil", QChar(0xE9)); - winSymbolSymbol.insert("rceil", QChar(0xF9)); - winSymbolSymbol.insert("lfloor", QChar(0xEB)); - winSymbolSymbol.insert("rfloor", QChar(0xFB)); - winSymbolSymbol.insert("subsetnot", QChar(0xCB)); - winSymbolSymbol.insert("DC", "="); - winSymbolSymbol.insert("mid", "|"); - winSymbolSymbol.insert("cdots", QString(3, QChar(0xD7))); - winSymbolSymbol.insert("dots", QChar(0xDC)); - winSymbolSymbol.insert("ldots", QChar(0xDC)); - winSymbolSymbol.insert("cent", "c"); - } - - - static QHash unicodeGreek; - if (unicodeGreek.isEmpty()) { - unicodeGreek.insert("alpha", QChar(0x3B1)); - unicodeGreek.insert("beta", QChar(0x3B2)); - unicodeGreek.insert("gamma", QChar(0x3B3)); - unicodeGreek.insert("delta", QChar(0x3B4)); - unicodeGreek.insert("epsilon", QChar(0x3B5)); - unicodeGreek.insert("varepsilon", QChar(0x3B5)); - unicodeGreek.insert("zeta", QChar(0x3B6)); - unicodeGreek.insert("eta", QChar(0x3B7)); - unicodeGreek.insert("theta", QChar(0x3B8)); - unicodeGreek.insert("vartheta", QChar(0x3D1)); - unicodeGreek.insert("iota", QChar(0x3B9)); - unicodeGreek.insert("kappa", QChar(0x3BA)); - unicodeGreek.insert("lambda", QChar(0x3BB)); - unicodeGreek.insert("mu", QChar(0x3BC)); - unicodeGreek.insert("nu", QChar(0x3BD)); - unicodeGreek.insert("xi", QChar(0x3BE)); - unicodeGreek.insert("pi", QChar(0x3C0)); - unicodeGreek.insert("varpi", QChar(0x3D6)); - unicodeGreek.insert("rho", QChar(0x3C1)); - unicodeGreek.insert("varrho", QChar(0x3F1)); - unicodeGreek.insert("sigma", QChar(0x3C3)); - unicodeGreek.insert("varsigma", QChar(0x3C2)); - unicodeGreek.insert("tau", QChar(0x3C4)); - unicodeGreek.insert("upsilon", QChar(0x3C5)); - unicodeGreek.insert("phi", QChar(0x3D5)); - unicodeGreek.insert("varphi", QChar(0x3C6)); - unicodeGreek.insert("chi", QChar(0x3C7)); - unicodeGreek.insert("psi", QChar(0x3C8)); - unicodeGreek.insert("omega", QChar(0x3C9)); - unicodeGreek.insert("Omega", QChar(0x3A9)); - unicodeGreek.insert("Gamma", QChar(0x393)); - unicodeGreek.insert("Delta", QChar(0x394)); - unicodeGreek.insert("Theta", QChar(0x398)); - unicodeGreek.insert("Lambda", QChar(0x39B)); - unicodeGreek.insert("Xi", QChar(0x39E)); - unicodeGreek.insert("Pi", QChar(0x3A0)); - unicodeGreek.insert("Sigma", QChar(0x3A3)); - unicodeGreek.insert("Upsilon", QChar(0x3A5)); - unicodeGreek.insert("Phi", QChar(0x3A6)); - unicodeGreek.insert("Psi", QChar(0x3A8)); - } - - static QHash unicodeSymbol; - if (unicodeSymbol.isEmpty()) { - unicodeSymbol.insert("leftrightarrow", QChar(0x2194)); - unicodeSymbol.insert("leftarrow", QChar(0x2190)); - unicodeSymbol.insert("rightarrow", QChar(0x2192)); - unicodeSymbol.insert("to", QChar(0x2192)); - unicodeSymbol.insert("uparrow", QChar(0x2191)); - unicodeSymbol.insert("downarrow", QChar(0x2193)); - unicodeSymbol.insert("updownarrow", QChar(0x2195)); - unicodeSymbol.insert("Leftrightarrow", QChar(0x21D4)); - unicodeSymbol.insert("iff", QChar(0x21D4)); - unicodeSymbol.insert("Leftarrow", QChar(0x21D0)); - unicodeSymbol.insert("Rightarrow", QChar(0x21D2)); - unicodeSymbol.insert("Uparrow", QChar(0x21D1)); - unicodeSymbol.insert("Downarrow", QChar(0x21D3)); - unicodeSymbol.insert("Updownarrow", QChar(0x21D5)); - unicodeSymbol.insert("pm", QChar(0x00B1)); - unicodeSymbol.insert("mp", QChar(0x2213)); - unicodeSymbol.insert("leq", QChar(0x2264)); - unicodeSymbol.insert("geq", QChar(0x2265)); - unicodeSymbol.insert("ll", QChar(0x226A)); - unicodeSymbol.insert("gg", QChar(0x226B)); - unicodeSymbol.insert("hbar", QChar(0x210F)); - unicodeSymbol.insert("euro", QChar(0x20AC)); - unicodeSymbol.insert("Angstrom", QChar(0x212B)); - unicodeSymbol.insert("Alef", QChar(0x2135)); - unicodeSymbol.insert("Bet", QChar(0x2136)); - unicodeSymbol.insert("Gimel", QChar(0x2137)); - unicodeSymbol.insert("Dalet", QChar(0x2138)); - unicodeSymbol.insert("alef", QChar(0x2135)); - unicodeSymbol.insert("bet", QChar(0x2136)); - unicodeSymbol.insert("gimel", QChar(0x2137)); - unicodeSymbol.insert("dalet", QChar(0x2138)); - unicodeSymbol.insert("nexists", QChar(0x2204)); - unicodeSymbol.insert("ni", QChar(0x220B)); - unicodeSymbol.insert("notni", QChar(0x220C)); - unicodeSymbol.insert("circ", QChar(0x2218)); - unicodeSymbol.insert("tilde", QChar(0x223C)); - unicodeSymbol.insert("emptyset", QChar(0x2300)); - unicodeSymbol.insert("varnothing", QChar(0x2300)); - unicodeSymbol.insert("odot", QChar(0x2299)); - unicodeSymbol.insert("ominus", QChar(0x2296)); - unicodeSymbol.insert("lceil", QChar(0x2308)); - unicodeSymbol.insert("rceil", QChar(0x2309)); - unicodeSymbol.insert("lfloor", QChar(0x230A)); - unicodeSymbol.insert("rfloor", QChar(0x230B)); - unicodeSymbol.insert("subsetnot", QChar(0x2284)); - unicodeSymbol.insert("DC", QChar(0x2393)); - unicodeSymbol.insert("bot", QChar(0x22A4)); - unicodeSymbol.insert("mid", QChar(0xFF5C)); - unicodeSymbol.insert("cdots", QString(QChar(0x00B7)) + QString(QChar(0x00B7)) + QString(QChar(0x00B7))); - unicodeSymbol.insert("vdots", QChar(0x22EE)); - unicodeSymbol.insert("iddots", QChar(0x22F0)); - unicodeSymbol.insert("ddots", QChar(0x22F1)); - unicodeSymbol.insert("dots", "..."); - unicodeSymbol.insert("ldots", "..."); - unicodeSymbol.insert("perthousand", QChar(0x2030)); - unicodeSymbol.insert("leftharpoonup", QChar(0x21BC)); - unicodeSymbol.insert("rightharpoonup", QChar(0x21C0)); - unicodeSymbol.insert("upharpoonleft", QChar(0x21BF)); - unicodeSymbol.insert("downharpoonleft", QChar(0x21C3)); - unicodeSymbol.insert("leftrightharpoon", QChar(0x21CB)); - unicodeSymbol.insert("rightleftharpoon", QChar(0x21CC)); - unicodeSymbol.insert("leftharpoondown", QChar(0x21BD)); - unicodeSymbol.insert("rightharpoondown", QChar(0x21C1)); - unicodeSymbol.insert("upharpoonright", QChar(0x21BE)); - unicodeSymbol.insert("downharpoonright", QChar(0x21C2)); - unicodeSymbol.insert("nwarrow", QChar(0x2196)); - unicodeSymbol.insert("nearrow", QChar(0x2197)); - unicodeSymbol.insert("searrow", QChar(0x2198)); - unicodeSymbol.insert("swarrow", QChar(0x2199)); - unicodeSymbol.insert("mapsto", QChar(0x21A6)); - unicodeSymbol.insert("cent", QChar(0x00A2)); - unicodeSymbol.insert("pound", QChar(0x00A3)); - unicodeSymbol.insert("yen", QChar(0x00A5)); - unicodeSymbol.insert("div", QChar(0x00F7)); - unicodeSymbol.insert("multimap", QChar(0x22B8)); - unicodeSymbol.insert("maporiginal", QChar(0x22B6)); - unicodeSymbol.insert("mapimage", QChar(0x22B7)); - unicodeSymbol.insert("benzene", QChar(0x232C)); - unicodeSymbol.insert("times", QChar(0x2A2F)); - unicodeSymbol.insert("propto", QChar(0x221D)); - unicodeSymbol.insert("partial", QChar(0x2202)); - unicodeSymbol.insert("bullet", QChar(0x2219)); - unicodeSymbol.insert("neq", QChar(0x2260)); - unicodeSymbol.insert("ne", QChar(0x2260)); - unicodeSymbol.insert("equiv", QChar(0x2261)); - unicodeSymbol.insert("approx", QChar(0x2245)); - unicodeSymbol.insert("ellipsis", QChar(0x2026)); - unicodeSymbol.insert("Im", QChar(0x2111)); - unicodeSymbol.insert("Re", QChar(0x211C)); - unicodeSymbol.insert("otimes", QChar(0x2297)); - unicodeSymbol.insert("oplus", QChar(0x2295)); - unicodeSymbol.insert("oslash", QChar(0x2298)); - unicodeSymbol.insert("cap", QChar(0x2229)); - unicodeSymbol.insert("land", QChar(0x2229)); - unicodeSymbol.insert("cup", QChar(0x222A)); - unicodeSymbol.insert("lor", QChar(0x222A)); - unicodeSymbol.insert("supset", QChar(0x2283)); - unicodeSymbol.insert("supseteq", QChar(0x2286)); - unicodeSymbol.insert("supsetnot", QChar(0x2285)); - unicodeSymbol.insert("subset", QChar(0x2282)); - unicodeSymbol.insert("subseteq", QChar(0x2286)); - unicodeSymbol.insert("in", QChar(0x2208)); - unicodeSymbol.insert("notin", QChar(0x2209)); - unicodeSymbol.insert("angle", QChar(0x2221)); - unicodeSymbol.insert("nabla", QChar(0x2207)); - unicodeSymbol.insert("copyright", QChar(0x00A9)); - unicodeSymbol.insert("registered", QChar(0x00AE)); - unicodeSymbol.insert("trademark", QChar(0x2122)); - unicodeSymbol.insert("cdot", QChar(0x00B7)); - unicodeSymbol.insert("neg", QChar(0x00AC)); - unicodeSymbol.insert("wedge", QChar(0x2227)); - unicodeSymbol.insert("vee", QChar(0x2228)); - unicodeSymbol.insert("diamond", QChar(0xE0)); - unicodeSymbol.insert("langle", QChar(0x2329)); - unicodeSymbol.insert("rangle", QChar(0x232A)); - unicodeSymbol.insert("infty", QChar(0x221E)); - unicodeSymbol.insert("forall", QChar(0x2200)); - unicodeSymbol.insert("exists", QChar(0x2203)); - unicodeSymbol.insert("cong", QChar(0x2245)); - unicodeSymbol.insert("bot", QChar(0x22A5)); - - } - - static QHash latexSimpleSymbol; - if (latexSimpleSymbol.isEmpty()) { - latexSimpleSymbol.insert("_", "_"); - latexSimpleSymbol.insert("}", "}"); - latexSimpleSymbol.insert("{", "{"); - latexSimpleSymbol.insert("$", "$"); - latexSimpleSymbol.insert("%", "%"); - latexSimpleSymbol.insert("&", "&"); - latexSimpleSymbol.insert("#", "#"); - latexSimpleSymbol.insert("ast", "*"); - latexSimpleSymbol.insert("glq", QChar(0x27)); - latexSimpleSymbol.insert("grq", QChar(0x60)); - latexSimpleSymbol.insert("glqq", QChar(0x5C)); - latexSimpleSymbol.insert("grqq", "\""); - } - - static QHash latexGreek; - if (latexGreek.isEmpty()) { - latexGreek.insert("alpha", QChar(0xAE)); - latexGreek.insert("beta", QChar(0xAF)); - latexGreek.insert("gamma", QChar(0xB0)); - latexGreek.insert("delta", QChar(0xB1)); - latexGreek.insert("epsilon", QChar(0x22)); - latexGreek.insert("varepsilon", QChar(0xB2)); - latexGreek.insert("zeta", QChar(0xB3)); - latexGreek.insert("eta", QChar(0xB4)); - latexGreek.insert("theta", QChar(0xB5)); - latexGreek.insert("vartheta", QChar(0x23)); - latexGreek.insert("iota", QChar(0xB6)); - latexGreek.insert("kappa", QChar(0xB7)); - latexGreek.insert("lambda", QChar(0xB8)); - latexGreek.insert("mu", QChar(0xB9)); - latexGreek.insert("nu", QChar(0xBA)); - latexGreek.insert("xi", QChar(0xBB)); - latexGreek.insert("pi", QChar(0xBC)); - latexGreek.insert("varpi", QChar(0x24)); - latexGreek.insert("rho", QChar(0xBD)); - latexGreek.insert("varrho", QChar(0x25)); - latexGreek.insert("sigma", QChar(0xBE)); - latexGreek.insert("varsigma", QChar(0x26)); - latexGreek.insert("tau", QChar(0xBF)); - latexGreek.insert("upsilon", QChar(0xC0)); - latexGreek.insert("phi", QChar(0xC1)); - latexGreek.insert("varphi", QChar(0x27)); - latexGreek.insert("chi", QChar(0xC2)); - latexGreek.insert("psi", QChar(0xC3)); - latexGreek.insert("omega", QChar(0x21)); - latexGreek.insert("Gamma", QChar(0xA1)); - latexGreek.insert("Delta", QChar(0xA2)); - latexGreek.insert("Theta", QChar(0xA3)); - latexGreek.insert("Lambda", QChar(0xA4)); - latexGreek.insert("Xi", QChar(0xA5)); - latexGreek.insert("Pi", QChar(0xA6)); - latexGreek.insert("Sigma", QChar(0xA7)); - latexGreek.insert("Upsilon", QChar(0xA8)); - latexGreek.insert("Phi", QChar(0xA9)); - latexGreek.insert("Psi", QChar(0xAA)); - latexGreek.insert("leftharpoonup", QChar(0x28)); - latexGreek.insert("rightharpoonup", QChar(0x2A)); - latexGreek.insert("leftharpoondown", QChar(0x29)); - latexGreek.insert("rightharpoondown", QChar(0x2B)); - latexGreek.insert("neg", QChar(0xAC)); - latexGreek.insert("star", QChar(0x3F)); - } - - static QHash latexSymbol; - if (latexSymbol.isEmpty()) { - latexSymbol.insert("leftrightarrow", QChar(0x24)); - latexSymbol.insert("leftarrow", QChar(0xc3)); - latexSymbol.insert("rightarrow", QChar(0x21)); - latexSymbol.insert("to", QChar(0x21)); - latexSymbol.insert("uparrow", QChar(0x22)); - latexSymbol.insert("downarrow", QChar(0x23)); - latexSymbol.insert("updownarrow", QChar(0x6c)); - latexSymbol.insert("Leftrightarrow", QChar(0x2c)); - latexSymbol.insert("iff", QChar(0x2c)); - latexSymbol.insert("Leftarrow", QChar(0x28)); - latexSymbol.insert("Rightarrow", QChar(0x29)); - latexSymbol.insert("Uparrow", QChar(0x2a)); - latexSymbol.insert("Downarrow", QChar(0x2b)); - latexSymbol.insert("Updownarrow", QChar(0x6d)); - latexSymbol.insert("pm", QChar(0xa7)); - latexSymbol.insert("mp", QChar(0xa8)); - latexSymbol.insert("leq", QChar(0xb7)); - latexSymbol.insert("geq", QChar(0xb8)); - latexSymbol.insert("ll", QChar(0xbf)); - latexSymbol.insert("gg", QChar(0xc0)); - latexSymbol.insert("Alef", QChar(0x40)); - latexSymbol.insert("alef", QChar(0x40)); - latexSymbol.insert("ni", QChar(0x33)); - latexSymbol.insert("circ", QChar(0xb1)); - latexSymbol.insert("tilde", QChar(0xbb)); - latexSymbol.insert("emptyset", QChar(0x3b)); - latexSymbol.insert("odot", QChar(0xaf)); - latexSymbol.insert("ominus", QChar(0xaa)); - latexSymbol.insert("odiv", QChar(0xae)); - latexSymbol.insert("oplus", QChar(0xa9)); - latexSymbol.insert("lceil", QChar(0x64)); - latexSymbol.insert("rceil", QChar(0x65)); - latexSymbol.insert("lfloor", QChar(0x62)); - latexSymbol.insert("rfloor", QChar(0x63)); - latexSymbol.insert("bot", QChar(0x3f)); - latexSymbol.insert("cdots", QString(3, QChar(0xA2))); - latexSymbol.insert("dots", "..."); - latexSymbol.insert("nwarrow", QChar(0x2d)); - latexSymbol.insert("nearrow", QChar(0x25)); - latexSymbol.insert("searrow", QChar(0x26)); - latexSymbol.insert("swarrow", QChar(0x2e)); - latexSymbol.insert("div", QChar(0xa5)); - latexSymbol.insert("times", QChar(0xa3)); - latexSymbol.insert("propto", QChar(0x2f)); - latexSymbol.insert("bullet", QChar(0x2b)); - latexSymbol.insert("equiv", QChar(0xb4)); - latexSymbol.insert("approx", QChar(0xbc)); - latexSymbol.insert("ellipsis", "..."); - latexSymbol.insert("Im", QChar(0x3D)); - latexSymbol.insert("Re", QChar(0x3C)); - latexSymbol.insert("oplus", QChar(0xa9)); - latexSymbol.insert("oslash", QChar(0xae)); - latexSymbol.insert("cap", QChar(0x5c)); - latexSymbol.insert("cup", QChar(0x5b)); - latexSymbol.insert("land", QChar(0x5c)); - latexSymbol.insert("lor", QChar(0x5b)); - latexSymbol.insert("supset", QChar(0xbe)); - latexSymbol.insert("supseteq", QChar(0xb6)); - latexSymbol.insert("subset", QChar(0xbd)); - latexSymbol.insert("subseteq", QChar(0xb5)); - latexSymbol.insert("in", QChar(0x32)); - latexSymbol.insert("nabla", QChar(0x35)); - latexSymbol.insert("cdot", QChar(0xa2)); - latexSymbol.insert("wedge", QChar(0x5e)); - latexSymbol.insert("vee", QChar(0x5f)); - latexSymbol.insert("diamond", QChar(0xE0)); - latexSymbol.insert("langle", QChar(0x68)); - latexSymbol.insert("rangle", QChar(0x69)); - latexSymbol.insert("infty", QChar(0x31)); - latexSymbol.insert("forall", QChar(0x38)); - latexSymbol.insert("exists", QChar(0x39)); - latexSymbol.insert("cong", QChar(0xbb)); - latexSymbol.insert("mid", "|"); - - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - QHash::iterator itsimple = simpleTranslations.find(n); - if (itsimple!= simpleTranslations.end()) { - symbol=itsimple.value(); - } else { - QHash::iterator itsimplehia = simpleTranslations_heightIsAscent.find(n); - if (itsimplehia != simpleTranslations_heightIsAscent.end()) { - symbol = itsimplehia.value(); - heightIsAscent = true; - } else { - if (parent->getFontEncoding() == MTFEwinSymbol) { - // first we start with greek characters - font = MTSFgreek; - italic = -1; - QHash::iterator itgreek = winSymbolGreek.find(n); - if (itgreek!=winSymbolGreek.end()) { - symbol = itgreek.value(); - } else if (n == "sum") { symbol = "S"; fontFactor = mathFontFactor; heightIsAscent = true; exactAscent = true; } - else if (n == "prod") { symbol = "P"; fontFactor = mathFontFactor; heightIsAscent = true; exactAscent = true; } - else { - // now we set the symbols from the Symbol font - font = MTSFsymbol; - QHash::iterator itsymbol = winSymbolSymbol.find(n); - if (itsymbol!=winSymbolSymbol.end()) { - symbol = itsymbol.value(); - } else if (n == "int") { symbol = QChar(0xF2); fontFactor = mathFontFactor; yfactor = +0.1; } - else if (n == "bbC") { symbol = "C"; bold = +1; italic = -1; } - else if (n == "bbH") { symbol = "H"; bold = +1; italic = -1; } - else if (n == "bbN") { symbol = "N"; bold = +1; italic = -1; } - else if (n == "bbP") { symbol = "P"; bold = +1; italic = -1; } - else if (n == "bbQ") { symbol = "Q"; bold = +1; italic = -1; } - else if (n == "bbR") { symbol = "R"; bold = +1; italic = -1; } - else if (n == "bbZ") { symbol = "Z"; bold = +1; italic = -1; } - else if (n == "iint") { symbol = QString(2, QChar(0xF2)); fontFactor = mathFontFactor; yfactor = +0.1; } - else if (n == "iiint") { symbol = QString(3, QChar(0xF2)); fontFactor = mathFontFactor; yfactor = +0.1; } - else if (n == "bigcap") { symbol = QChar(0xC7); fontFactor = 2; } - else if (n == "bigcup") { symbol = QChar(0xC8); fontFactor = 2; } - else if (n == "bigvee") { symbol = QChar(0xDA); fontFactor = 2; } - else if (n == "bighat") { symbol = QChar(0xD9); fontFactor = 2; } - - else { // here are text mode symbols, i.e. bold and italic won't be touched - bold = -1; - italic = -1; - font = MTSFdefault; - if (n == "_") { symbol = "_"; bold = 0; italic = 0; } - else if (n == "}") { symbol = "}"; } - else if (n == "{") { symbol = "{"; } - else if (n == "hbar") { symbol = "h"; bold = 0; italic = 0; drawBar = true; } - else if (n == "euro") { symbol = ""; bold = 0; italic = 0; } - else if (n == "cent") { symbol = QChar(0xA2); bold = 0; italic = 0; } - else if (n == "pound") { symbol = QChar(0xA3); bold = 0; italic = 0; } - else if (n == "yen") { symbol = QChar(0xA5); bold = 0; italic = 0; } - else if (n == "div") { symbol = QChar(0xF7); bold = 0; italic = 0; } - else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } - //else if (n=="|") { symbol="||"; bold=0; italic=0; } - else if (n == "$") { symbol = "$"; bold = 0; italic = 0; } - else if (n == "%") { symbol = "%"; bold = 0; italic = 0; } - else if (n == "&") { symbol = "&"; bold = 0; italic = 0; } - else if (n == "#") { symbol = "#"; bold = 0; italic = 0; } - else if (n == "ast") { symbol = "*"; bold = 0; italic = 0; } - else if (n == "glq") { symbol = "'"; bold = 0; italic = 0; } - else if (n == "grq") { symbol = "'"; bold = 0; italic = 0; } - else if (n == "glqq") { symbol = "\""; bold = 0; italic = 0; } - else if (n == "grqq") { symbol = "\""; bold = 0; italic = 0; } - else if (n == "flq") { symbol = "<"; bold = 0; italic = 0; } - else if (n == "frq") { symbol = ">"; bold = 0; italic = 0; } - else if (n == "flqq") { symbol = ""; bold = 0; italic = 0; } - else if (n == "frqq") { symbol = ""; bold = 0; italic = 0; } - } - //else if (n=="") { symbol=QChar(); font=MTSFdefault; } - //else if (n=="") symbol=QChar(0x); - } - } - else if (parent->getFontEncoding() == MTFEunicode) { // use UNICODE encoding for special characters - // first we start with greek characters - font = MTSFdefault; //MTSFgreek; - //std::cout<<"encoding unicode\n"; - QHash::iterator itgreek = unicodeGreek.find(n); - if (itgreek!=unicodeGreek.end()) { - symbol = itgreek.value(); - } else { - // now we set the symbols from the Symbol font - font = MTSFsymbol; - QHash::iterator itsymbol = unicodeSymbol.find(n); - if (itsymbol!=unicodeSymbol.end()) { - symbol = itsymbol.value(); - } if (n == "sum") { symbol = QChar(0x2211); heightIsAscent = true; exactAscent = true; } - else if (n == "prod") { symbol = QChar(0x220F); heightIsAscent = true; exactAscent = true; } - else if (n == "bbC") { symbol = QChar(0x2102); italic = -1; } - else if (n == "bbH") { symbol = QChar(0x210D); italic = -1; } - else if (n == "bbN") { symbol = QChar(0x2115); italic = -1; } - else if (n == "bbP") { symbol = QChar(0x2119); italic = -1; } - else if (n == "bbQ") { symbol = QChar(0x211A); italic = -1; } - else if (n == "bbR") { symbol = QChar(0x211D); italic = -1; } - else if (n == "bbZ") { symbol = QChar(0x2124); italic = -1; } - else if (n == "iint") { symbol = QChar(0x222C); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "iiint") { symbol = QChar(0x222D); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "oint") { symbol = QChar(0x222E); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "oiint") { symbol = QChar(0x222F); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "oiiint") { symbol = QChar(0x2230); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "coprod") { symbol = QChar(0x2210); heightIsAscent = true; exactAscent = true; } - else if (n == "bigcap") { symbol = QChar(0x22C2); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } - else if (n == "bigcup") { symbol = QChar(0x22C3); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } - else if (n == "bigvee") { symbol = QChar(0x22C1); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } - else if (n == "bighat") { symbol = QChar(0x22C0); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } - else if (n == "int") { symbol = QChar(0x222B); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } - - else { // here are text mode symbols, i.e. bold and italic won't be touched - bold = -1; - italic = -1; - font = MTSFdefault; - if (n == "_") { symbol = "_"; } - else if (n == "}") { symbol = "}"; } - else if (n == "{") { symbol = "{"; } - else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } - //else if (n=="|") { symbol=QChar(0x2016); } - else if (n == "$") { symbol = "$"; } - else if (n == "%") { symbol = "%"; } - else if (n == "&") { symbol = "&"; } - else if (n == "#") { symbol = "#"; } - else if (n == "ast") { symbol = "*"; } - else if (n == "glq") { symbol = QChar(0x2018); bold = 0; italic = 0; } - else if (n == "grq") { symbol = QChar(0x2019); bold = 0; italic = 0; } - else if (n == "glqq") { symbol = QChar(0x201C); bold = 0; italic = 0; } - else if (n == "grqq") { symbol = QChar(0x201D); bold = 0; italic = 0; } - else if (n == "flq") { symbol = QChar(0x2039); bold = 0; italic = 0; } - else if (n == "frq") { symbol = QChar(0x203A); bold = 0; italic = 0; } - else if (n == "flqq") { symbol = ""; bold = 0; italic = 0; } - else if (n == "frqq") { symbol = ""; bold = 0; italic = 0; } - } - //else if (n=="") { symbol=QChar(); font=MTSFdefault; } - //else if (n=="") symbol=QChar(0x); - } - } - else if (parent->getFontEncoding() == MTFElatex) { // use UNICODE encoding for special characters - // first we start with greek characters - font = MTSFdefault; //MTSFgreek; - //std::cout<<"encoding unicode\n"; - QHash::iterator itssymbol = latexSimpleSymbol.find(n); - if (itssymbol!=latexSimpleSymbol.end()) { - symbol = itssymbol.value(); - } else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } - - else { - font = MTSFgreek; - QHash::iterator itgreek = latexGreek.find(n); - if (itgreek!=latexGreek.end()) { - symbol = itgreek.value(); - } else { - // now we set the symbols from the Symbol font - font = MTSFsymbol; - QHash::iterator itsymbol = latexSymbol.find(n); - if (itsymbol!=latexSymbol.end()) { - symbol = itsymbol.value(); - } else if (n == "int") { symbol = QChar(0x73); fontFactor = mathFontFactor; yfactor = +0.1; } - - else { // here are text mode symbols, i.e. bold and italic won't be touched - font = MTSFbraces; - if (n == "bigcap") { symbol = QChar(0x5c); heightIsAscent = true; exactAscent = true; } - else if (n == "bigcup") { symbol = QChar(0x5b); heightIsAscent = true; exactAscent = true; } - else if (n == "bigvee") { symbol = QChar(0x5F); heightIsAscent = true; exactAscent = true; } - else if (n == "bighat") { symbol = QChar(0x5E); heightIsAscent = true; exactAscent = true; } - else if (n == "oint") { symbol = QChar(0x49); yfactor = +0.1; } - else if (n == "coprod") { symbol = QChar(0x61); heightIsAscent = true; exactAscent = true; } - else if (n == "iint") { symbol = QString(2, QChar(0x5A)); yfactor = +0.1; } - else if (n == "iiint") { symbol = QString(3, QChar(0x5A)); yfactor = +0.1; } - else if (n == "sum") { symbol = QChar(0x58); heightIsAscent = true; exactAscent = true; } - else if (n == "prod") { symbol = QChar(0x59); heightIsAscent = true; exactAscent = true; } - - - - } - } - } - } - } - } - if (addWhitespace) symbol=symbol+" "; - - static QSet extraSymbolName = { - "infty", - "|", " ", "quad", ";", ":", ",", "!", - "longleftarrow", "longrightarrow", - "Longleftarrow", "Longrightarrow", - "longleftrightarrow", "Longleftrightarrow" - }; - - if (symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) { - parent->error_list.append(tr("unknown symbol '%1' found!").arg(n)); - } - - //std::cout<<"symbol node '"<getFontGreek()); break; - case MTSFsymbol: fr.setFamily(parent->getFontSymbol()); break; - case MTSFbraces: fr.setFamily(parent->getFontBraces()); break; - case MTSFintegrals: fr.setFamily(parent->getFontIntegrals()); break; - case MTSFcaligraphic: fr.setFamily(parent->getFontCaligraphic()); break; - case MTSFblackboard: fr.setFamily(parent->getFontBlackboard()); break; - default: break; - } - return fr; -} - -void JKQTMathText::MTsymbolNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { - QFont f=currentEv.getFont(parent); - f=getFontName(font, f); - f.setPointSizeF(f.pointSizeF()*fontFactor); - if (italic<0) f.setItalic(false); - if (italic>0) f.setItalic(true); - if (bold<0) f.setBold(false); - if (bold>0) f.setBold(true); - QFontMetricsF fm(f, painter.device()); - QString symb=symbol; - width=0; - if (currentEv.insideMath) width=qMax(parent->getTBR(f, symb, painter.device()).width(),parent->getTBR(f, "i", painter.device()).width());//fm.width(symbol); - else width=fm.boundingRect(symb).width();//fm.width(symbol); - - width=qMax(fm.width("j"), width); - if (symb.isEmpty()) { - width=fm.width("a"); - if (symbolName=="|") width=fm.width("1")*0.8; - else if (symbolName=="infty") width=fm.width("M"); - else if (symbolName=="quad") width=parent->getTBR(f, "M", painter.device()).width(); - else if (symbolName==" ") width=parent->getTBR(f, "x", painter.device()).width(); - else if (symbolName==";") width=parent->getTBR(f, "x", painter.device()).width()*0.75; - else if (symbolName==":") width=parent->getTBR(f, "x", painter.device()).width()*0.5; - else if (symbolName==",") width=parent->getTBR(f, "x", painter.device()).width()*0.25; - else if (symbolName=="!") width=-parent->getTBR(f, "x", painter.device()).width()*0.25; - else if (symbolName=="longleftarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } - else if (symbolName=="longrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } - else if (symbolName=="Longleftarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } - else if (symbolName=="Longrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } - else if (symbolName=="longleftrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } - else if (symbolName=="Longleftrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } - } - QRectF tbr=parent->getTBR(f, symb, painter.device()); - overallHeight=tbr.height();// fm.height(); - baselineHeight=tbr.height()-tbr.bottom(); - if (exactAscent) { - //baselineHeight=fm.ascent()*0.8; - } - if (heightIsAscent) { - overallHeight=baselineHeight*1.1; - } - if (exactAscent && heightIsAscent) { - //qDebug()<get_mathoperator_width_factor(); - -} - -double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { - doDrawBoxes(painter, x, y, currentEv); - double width=0; - double baselineHeight=0; - double overallHeight=0, strikeoutPos=0; - getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); - QPen pold=painter.pen(); - QFont fold=painter.font(); - QFont f=currentEv.getFont(parent); - QFont f1=f; - f=getFontName(font, f); - f.setPointSizeF(f.pointSizeF()*fontFactor); - if (italic<0) f.setItalic(false); - if (italic>0) f.setItalic(true); - if (bold<0) f.setBold(false); - if (bold>0) f.setBold(true); - QFontMetricsF fm(f, painter.device()); - QFontMetricsF fm1(f1, painter.device()); - painter.setFont(f); - - double shift=0; - if (extendWidthInMathmode && currentEv.insideMath) { - double origwidth=width/parent->get_mathoperator_width_factor(); - shift=0.5*(width-origwidth); - //width=width*parent->get_mathoperator_width_factor(); - } - - //std::cout<<"symbol '"<getTBR(f, "M", painter.device()).height()-fm.xHeight())/3.0; - QLineF l(xx, yy, xx+xwi/3.0+((currentEv.italic)?(xwi/3.0):0), yy); - if (drawBar&&l.length()>0) painter.drawLine(l); - - // try to draw some often used special symbols, by synthesizing them from - // standard characters in the current drawing font - } else if (symbolName=="infty") { - //std::cout<<"draw infty\n"; - f1.setItalic(false); - painter.setFont(f1); - painter.save(); - painter.translate(x+shift+fm1.width("8")/3.0, y-fm1.xHeight()); - painter.rotate(90); - painter.drawText(QPointF(0,0), "8"); - painter.restore(); - } else if (symbolName=="|") { - //std::cout<<"draw infty\n"; - f1.setItalic(false); - painter.setFont(f1); - - painter.save(); - painter.translate(x+shift, y); - painter.drawText(QPointF(0,0), "|"); - painter.translate(fm1.width("8")/3.0, 0); - painter.drawText(QPointF(0,0), "|"); - painter.restore(); - - // here are some spaces - } else if (symbolName==" ") { // full space - } else if (symbolName=="quad") { // 75% space - } else if (symbolName==";") { // 75% space - } else if (symbolName==":") { // 50% space - } else if (symbolName==",") { // 25% space - } else if (symbolName=="!") { // -25% space - } else if (symbolName=="longleftarrow") { - double width=parent->getTBR(f, "X", painter.device()).width()*3.0; - double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; - double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); - painter.drawPath(path); - } else if (symbolName=="longrightarrow"){ - double width=parent->getTBR(f, "X", painter.device()).width()*3.0; - double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; - double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); - painter.drawPath(path); - } else if (symbolName=="Longleftarrow") { - double width=parent->getTBR(f, "X", painter.device()).width()*3.0; - double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; - double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); - painter.drawPath(path); - } else if (symbolName=="Longrightarrow") { - double width=parent->getTBR(f, "X", painter.device()).width()*3.0; - double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; - double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); - painter.drawPath(path); - } else if (symbolName=="longleftrightarrow") { - double width=parent->getTBR(f, "X", painter.device()).width()*3.0; - double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; - double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); - painter.drawPath(path); - } else if (symbolName=="Longleftrightarrow") { - double width=parent->getTBR(f, "X", painter.device()).width()*3.0; - double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; - double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); - painter.drawPath(path); - } else { // draw a box to indicate an unavailable symbol - QRectF tbr=parent->getTBR(f, "M", painter.device()); - painter.drawRect(QRectF(x+shift,y-tbr.height(), xwi, tbr.height()*0.8)); - } - painter.setPen(pold); - painter.setFont(fold); - return x+width; -} - -bool JKQTMathText::MTsymbolNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { - bool ok=true; - QString s; - JKQTMathText::MTenvironment ev=currentEv; - - static QMap entitylut; - if (entitylut.isEmpty()) { - entitylut.insert("sin", "sin"); - entitylut.insert("cos", "cos"); - entitylut.insert("tan", "tan"); - entitylut.insert("sinh", "sinh"); - entitylut.insert("cosh", "cosh"); - entitylut.insert("tanh", "tanh"); - entitylut.insert("atan", "atan"); - entitylut.insert("acos", "acos"); - entitylut.insert("asin", "asin"); - entitylut.insert("arcsin", "arcsin"); - entitylut.insert("arccos", "arccos"); - entitylut.insert("arctan", "arctan"); - entitylut.insert("ii", "i"); - entitylut.insert("dd", "d"); - entitylut.insert("exp", "exp"); - entitylut.insert("log", "log"); - entitylut.insert("ln", "ln"); - entitylut.insert("ld", "ld"); - entitylut.insert("lb", "lb"); - entitylut.insert("erf", "erf"); - entitylut.insert("min", "min"); - entitylut.insert("max", "max"); - entitylut.insert("argmin", "argmin"); - entitylut.insert("argmax", "argmax"); - entitylut.insert("inf", "inf"); - entitylut.insert("sup", "sup"); - entitylut.insert("liminf", "liminf"); - entitylut.insert("limsup", "limsup"); - entitylut.insert("lim", "lim"); - entitylut.insert("max", "max"); - entitylut.insert("min", "min"); - entitylut.insert("sec", "sec"); - entitylut.insert("gcd", "gcd"); - entitylut.insert("hom", "hom"); - entitylut.insert("ker", "ker"); - entitylut.insert("dim", "dim"); - entitylut.insert("cot", "cot"); - entitylut.insert("arg", "arg"); - entitylut.insert("det", "det"); - entitylut.insert("deg", "deg"); - entitylut.insert("Pr", "Pr"); - entitylut.insert("coth", "coth"); - entitylut.insert("alpha", "α"); - entitylut.insert("beta", "β"); - entitylut.insert("gamma", "γ"); - entitylut.insert("delta", "δ"); - entitylut.insert("epsilon", "ε"); - entitylut.insert("varepsilon", "ε"); - entitylut.insert("zeta", "ζ"); - entitylut.insert("eta", "η"); - entitylut.insert("theta", "θ"); - entitylut.insert("vartheta", "ϑ"); - entitylut.insert("iota", "ι"); - entitylut.insert("kappa", "κ"); - entitylut.insert("lambda", "λ"); - entitylut.insert("mu", "μ"); - entitylut.insert("nu", "ν"); - entitylut.insert("xi", "ξ"); - entitylut.insert("pi", "π"); - entitylut.insert("varpi", "ϖ"); - entitylut.insert("rho", "ρ"); - entitylut.insert("sigma", "σ"); - entitylut.insert("varsigma", "ς"); - entitylut.insert("tau", "τ"); - entitylut.insert("upsilon", "υ"); - entitylut.insert("phi", "φ"); - entitylut.insert("varphi", "φ"); - entitylut.insert("chi", "χ"); - entitylut.insert("psi", "ψ"); - entitylut.insert("omega", "ω"); - entitylut.insert("Gamma", "Γ"); - entitylut.insert("Delta", "Δ"); - entitylut.insert("Theta", "Θ"); - entitylut.insert("Lambda", "Λ"); - entitylut.insert("Omega", "Ω"); - entitylut.insert("Xi", "Ξ"); - entitylut.insert("Pi", "Π"); - entitylut.insert("Sigma", "Σ"); - entitylut.insert("Upsilon", "Υ"); - entitylut.insert("Phi", "Φ"); - entitylut.insert("Psi", "Ψ"); - entitylut.insert("leftrightarrow", "↔"); - entitylut.insert("leftarrow", "←"); - entitylut.insert("rightarrow", "→"); - entitylut.insert("to", "→"); - entitylut.insert("uparrow", "↑"); - entitylut.insert("downarrow", "↓"); - entitylut.insert("Leftrightarrow", "⇔"); - entitylut.insert("iff", "⇔"); - entitylut.insert("Leftarrow", "⇐"); - entitylut.insert("Rightarrow", "⇒"); - entitylut.insert("Uparrow", "⇑"); - entitylut.insert("Downarrow", "⇓"); - entitylut.insert("pm", "±"); - entitylut.insert("leq", "≤"); - entitylut.insert("geq", "≥"); - entitylut.insert("times", "×"); - entitylut.insert("propto", "∝"); - entitylut.insert("partial", "∂"); - entitylut.insert("bullet", "•"); - entitylut.insert("neq", "≠"); - entitylut.insert("ne", "≠"); - entitylut.insert("equiv", "≡"); - entitylut.insert("approx", "≈"); - entitylut.insert("ellipsis", "..."); - entitylut.insert("Im", "ℑ"); - entitylut.insert("Re", "ℜ"); - entitylut.insert("otimes", "⊗"); - entitylut.insert("oplus", "⊕"); - entitylut.insert("oslash", "/"); - entitylut.insert("cap", "∩"); - entitylut.insert("cup", "∪"); - entitylut.insert("land", "∩"); - entitylut.insert("lor", "∪"); - entitylut.insert("supset", "⊃"); - entitylut.insert("supseteq", "⊇"); - entitylut.insert("supsetnot", "⊅"); - entitylut.insert("subset", "⊂"); - entitylut.insert("subseteq", "⊆"); - entitylut.insert("in", "∈"); - entitylut.insert("notin", "∉"); - entitylut.insert("angle", "∠"); - entitylut.insert("nabla", "∇"); - entitylut.insert("copyright", "©"); - entitylut.insert("registered", "®"); - entitylut.insert("trademark", "™"); - entitylut.insert("cdot", "⋅"); - entitylut.insert("neg", "¬"); - entitylut.insert("wedge", "∧"); - entitylut.insert("vee", "∨"); - entitylut.insert("diamond", "◊"); - entitylut.insert("langle", "⟨"); - entitylut.insert("rangle", "⟩"); - entitylut.insert("int", "∫"); - entitylut.insert("forall", "∀"); - entitylut.insert("exists", "∃"); - entitylut.insert("cong", "∼"); - entitylut.insert("bot", "⊥"); - - - entitylut.insert("ll", "<<"); - entitylut.insert("gg", ">>"); - entitylut.insert("bbC", "C"); - entitylut.insert("bbH", "H"); - entitylut.insert("bbN", "N"); - entitylut.insert("bbP", "P"); - entitylut.insert("bbQ", "Q"); - entitylut.insert("bbR", "R"); - entitylut.insert("bbZ", "Z"); - entitylut.insert("Alef", "ℵ"); - entitylut.insert("alef", "ℵ"); - entitylut.insert("tilde", "~"); - entitylut.insert("iint", "∫∫"); - entitylut.insert("iiint", "∫∫∫"); - entitylut.insert("emptyset", "∅"); - entitylut.insert("varnothing", "∅"); - entitylut.insert("lceil", "⌈"); - entitylut.insert("rceil", "⌉"); - entitylut.insert("lfloor", "⌊"); - entitylut.insert("rfloor", "⌋"); - entitylut.insert("subsetnot", "⊄"); - entitylut.insert("DC", "="); - entitylut.insert("cdots", "⋅⋅⋅"); - entitylut.insert("dots", "..."); - - entitylut.insert("cent", "¢"); - - entitylut.insert("_", "_"); - entitylut.insert("}", "}"); - entitylut.insert("{", "{"); - entitylut.insert("hbar", "ℏ"); - entitylut.insert("euro", "€"); - entitylut.insert("pound", "£"); - entitylut.insert("yen", "¥"); - entitylut.insert("div", "÷"); - entitylut.insert("backslash", "\\"); - entitylut.insert("$", "$"); - entitylut.insert("%", "%"); - entitylut.insert("&", "&"); - entitylut.insert("#", "#"); - entitylut.insert("ast", "*"); - entitylut.insert("glq", "'"); - entitylut.insert("grq", "'"); - entitylut.insert("glqq", "\""); - entitylut.insert("grqq", "\""); - entitylut.insert("flq", "<"); - entitylut.insert("frq", ">"); - entitylut.insert("flqq", ""); - entitylut.insert("frqq", ""); - } - - - QMap::iterator itS = entitylut.find(symbolName); - if (itS!=entitylut.end()) { s=itS.value(); } - else if (symbolName == "sum") { ev.fontSize*=1.7; s="∑"; } - else if (symbolName == "prod") { ev.fontSize*=1.7; s="∏"; } - else if (symbolName == "bigcap") { ev.fontSize*=1.7; s="∩"; } - else if (symbolName == "bigcup") { ev.fontSize*=1.7; s="∪"; } - else if (symbolName == "bigvee") { ev.fontSize*=1.7; s="∨"; } - else if (symbolName == "bighat") { ev.fontSize*=1.7; s="∧"; } - else ok=false; - - if (ok) html=html+ev.toHtmlStart(defaultEv)+s+ev.toHtmlAfter(defaultEv); - return ok; -} - - -// -------------------------------------------------------------------------------------------------- -// -- implementation of the JKQTMathText methods -// -------------------------------------------------------------------------------------------------- -JKQTMathText::JKQTMathText(QObject* parent): - QObject(parent) -{ - Q_INIT_RESOURCE(xits); - QFontDatabase fontdb; - - QString serifFont="Serif"; - QString sansFont="Sans"; - QString symbolFont="Symbol"; - QString scriptFont="Script"; - QString typewriterFont="typewriter"; - QString decorativeFont="decorative"; - - QStringList fonts=fontdb.families(); - //qDebug()<<"fonts:\n"<toHtml(s, ev, defaultev); - } - if (ok) *ok=okk; - return s; -} - -void JKQTMathText::useAnyUnicode(QString timesFont, QString sansFont) { - if (!timesFont.isEmpty()) { fontMathRoman=timesFont; fontRoman=timesFont; } - if (!sansFont.isEmpty()) { fontMathSans=sansFont; fontSans=sansFont; } - useSTIXfonts=false; - useXITSfonts=false; - useASANAfonts=false; - fontGreek=fontMathRoman; - fontSymbol=fontMathRoman; - fontBraces=fontMathRoman; - fontIntegrals=fontMathRoman; - fontEncoding=MTFEunicode; - brace_shrink_factor=0.6; -} - - -JKQTMathText::tokenType JKQTMathText::getToken() { - currentTokenID++; - if (currentTokenID>parseString.size()-1) return currentToken=MTTnone; - QChar c=parseString[currentTokenID]; - currentTokenName=""; - if (c=='\\') { // read an instruction name - currentTokenID++; - if (currentTokenID>=parseString.size()-1) return currentToken=MTTnone; - c=parseString[currentTokenID]; - /*if (c=='_' || c=='\\' || c=='$' || c=='%' || c=='&' || c=='#' || c=='}' || c=='{') { - currentTokenName=c; // parse special one-symbol instructions like \\, \& ... - // that may be directly converted to text - return currentToken=MTTtext; - } else*/ if (c=='|' || c==';' || c==':' || c=='!' || c==',' || c=='_' || c=='\\' || c=='$' || - c=='%' || c=='&' || c=='#' || c=='}' || c=='{' || c==' ') { - currentTokenName=c; // parse one-symbol instructions like \\, \& ... - //std::cout<<"found text node '"<addNode(new MTtextNode(this, text, addWhite, parsingMathEnvironment)); - } else if (currentToken==MTTinstruction) { - QString name=currentTokenName; - if (name=="\\") break; // break on linebrak character - getToken(); // look at next token - if (currentToken==MTTopenbrace) { - //std::cout<<"found '{' after '"<addNode(new MTsqrtNode(this, parseLatexString(true))); - } else if (name=="cbrt") { - nl->addNode(new MTsqrtNode(this, parseLatexString(true), 3)); - } else if (name=="verb") { - QString text=""; - currentTokenID++; - if (currentTokenID<=parseString.size()-1) { - QChar c=parseString[currentTokenID]; - while (c!='}' && (currentTokenIDaddNode(new MTtextNode(this, text, false)); - } - } else if (name=="frac") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMfrac)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="dfrac") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMdfrac)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="tfrac") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMtfrac)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="stackrel") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMstackrel)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="binom") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTbraceNode(this, "(", ")", new MTfracNode(this, n1, n2, MTFMstackrel))); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="underbrace") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMunderbrace)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="underset") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMunderset)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="overbrace") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMoverbrace)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="overset") { - MTnode* n1=parseLatexString(true); - MTnode* n2=nullptr; - if (getToken()==MTTopenbrace) n2=parseLatexString(true); - if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMoverset)); - else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - } else if (name=="begin") { - if (getToken()==MTTtext) { - QString envname=currentTokenName; - while (currentToken!=MTTclosebrace) getToken(); // find closing brace '}' after '\\begin{name' - if (envname=="matrix" || envname=="array" || envname=="aligned" || envname=="align" || envname=="cases" || envname=="pmatrix"|| envname=="bmatrix"|| envname=="Bmatrix"|| envname=="vmatrix"|| envname=="Vmatrix") { - QVector< QVector > items; - //int lines=0; - //int cols=0; - bool first=true; - QVector line; - //std::cout<<"found \\begin{matrix}\n"; - while (first || currentToken==MTTampersand || (currentToken==MTTinstruction && currentTokenName=="\\")) { - MTnode* it=parseLatexString(true, "", envname); - if (currentToken==MTTampersand) { - //std::cout<<" appending item\n"; - line.append(it); - } else { - line.append(it); - //std::cout<<" appending item and line with "<addNode(new MTbraceNode(this, "(", ")", new MTmatrixNode(this, items))); - else if (envname=="cases") nl->addNode(new MTbraceNode(this, "{", "", new MTmatrixNode(this, items))); - else if (envname=="bmatrix") nl->addNode(new MTbraceNode(this, "[", "]", new MTmatrixNode(this, items))); - else if (envname=="Bmatrix") nl->addNode(new MTbraceNode(this, "{", "}", new MTmatrixNode(this, items))); - else if (envname=="vmatrix") nl->addNode(new MTbraceNode(this, "|", "|", new MTmatrixNode(this, items))); - else if (envname=="Vmatrix") nl->addNode(new MTbraceNode(this, "||", "||", new MTmatrixNode(this, items))); - else nl->addNode(new MTmatrixNode(this, items)); - //std::cout<<" creating matrix-node ... done!\n"; - } else { - error_list.append(tr("error @ ch. %1: unknown environment '%2'").arg(currentTokenID).arg(envname)); - } - } else { // find next '}' - error_list.append(tr("error @ ch. %1: text after '\\begin{' expected!").arg(currentTokenID)); - while (currentToken!=MTTclosebrace) getToken(); - getNew=true; - } - } else if (name=="end") { - if (getToken()==MTTtext) { - QString envname=currentTokenName; - while (currentToken!=MTTclosebrace) getToken(); // find closing brace '}' after '\\begin{name' - if (envname==quitOnEnvironmentEnd) { - break; - } else { - error_list.append(tr("error @ ch. %1: '\\end{%2}' widthout preceding '\\begin{%3}'").arg(currentTokenID).arg(envname).arg(envname)); - } - } else { // find next '}' - error_list.append(tr("error @ ch. %1: text after '\\begin{' expected!").arg(currentTokenID)); - while (currentToken!=MTTclosebrace) getToken(); - getNew=true; - } - } else if (name=="vec") { - nl->addNode(new MTdecoratedNode(this, MTDvec, parseLatexString(true))); - } else if (name=="overline"||name=="oline"||name=="ol") { - nl->addNode(new MTdecoratedNode(this, MTDoverline, parseLatexString(true))); - } else if (name=="underline"||name=="uline"||name=="ul") { - nl->addNode(new MTdecoratedNode(this, MTDunderline, parseLatexString(true))); - } else if (name=="uuline"||name=="uul") { - nl->addNode(new MTdecoratedNode(this, MTDdoubleunderline, parseLatexString(true))); - } else if (name=="ooline"||name=="ool") { - nl->addNode(new MTdecoratedNode(this, MTDdoubleoverline, parseLatexString(true))); - } else if (name=="arrow") { - nl->addNode(new MTdecoratedNode(this, MTDarrow, parseLatexString(true))); - } else if (name=="hat") { - nl->addNode(new MTdecoratedNode(this, MTDhat, parseLatexString(true))); - } else if (name=="bar") { - nl->addNode(new MTdecoratedNode(this, MTDbar, parseLatexString(true))); - } else if (name=="dot") { - nl->addNode(new MTdecoratedNode(this, MTDdot, parseLatexString(true))); - } else if (name=="tilde") { - nl->addNode(new MTdecoratedNode(this, MTDtilde, parseLatexString(true))); - } else if (name=="ddot") { - nl->addNode(new MTdecoratedNode(this, MTDddot, parseLatexString(true))); - } else { - if (name=="textcolor" || name=="mathcolor" || name=="color" || name=="colorbox") { - bool foundError=true; - QString col=""; - if (getToken()==MTTtext) { - col=currentTokenName; - if (getToken()==MTTclosebrace) { - if (getToken()==MTTopenbrace) { - foundError=false; - } - } - } - if (foundError) error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); - else nl->addNode(new MTinstruction1Node(this, name, parseLatexString(true), QStringList(col))); - - - } else { - nl->addNode(new MTinstruction1Node(this, name, parseLatexString(true))); - } - } - } else { - //std::cout<<"did not find '{' after '"<0) { - if (QString(currentTokenName[0])==quitOnClosingBrace || quitOnClosingBrace=="any" || QString(currentTokenName[0])==".") { - //std::cout<<"found \\right '"<" && (currentTokenName=="rangle" || QString(currentTokenName[0])==".")) { - showRightBrace=(QString(currentTokenName[0])!="."); - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - break; - } else if (quitOnClosingBrace=="any") { - showRightBrace=(QString(currentTokenName[0])!="."); - //currentTokenName=currentTokenName.right(currentTokenName.size()-1); - break; - } - } else { - getNew=false; - } - } else if (name=="left") { - if (currentToken==MTTtext) { - if (currentTokenName.size()>0) { - if (currentTokenName[0]=='(') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); // we already used the first character from the text token! - nl->addNode(new MTbraceNode(this, "(", ")", parseLatexString(currentTokenName.size()<=0, ")"), showRightBrace)); - } else if (currentTokenName[0]=='[') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "[", "]", parseLatexString(currentTokenName.size()<=0, "]"), showRightBrace)); - } else if (currentTokenName[0]=='{') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "{", "}", parseLatexString(currentTokenName.size()<=0, "}"), showRightBrace)); - } else if (currentTokenName[0]=='<') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "<", ">", parseLatexString(currentTokenName.size()<=0, ">"), showRightBrace)); - } else if (currentTokenName[0]=='|') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "|", "|", parseLatexString(currentTokenName.size()<=0, "|"), showRightBrace)); - } else if (currentTokenName[0]=='~') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "~", "~", parseLatexString(currentTokenName.size()<=0, "~"), showRightBrace)); - } else if (currentTokenName[0]=='_') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "_", "_", parseLatexString(currentTokenName.size()<=0, "_"), showRightBrace)); - } else if (currentTokenName[0]=='#') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "#", "#", parseLatexString(currentTokenName.size()<=0, "#"), showRightBrace)); - } else if (currentTokenName[0]=='.') { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - JKQTMathText::MTnode* cn=parseLatexString(currentTokenName.size()<=0, "any"); - nl->addNode(new MTbraceNode(this, ".", currentTokenName, cn, showRightBrace)); - } else { - getNew=false; - } - } - } else if (currentToken==MTTinstruction && currentTokenName=="langle") { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "<", ">", parseLatexString(true, ">"), showRightBrace)); - } else if (currentToken==MTTinstruction && currentTokenName=="{") { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "{", "}", parseLatexString(currentTokenName.size()<=0, "}"), showRightBrace)); - } else if (currentToken==MTTinstruction && currentTokenName=="lfloor") { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "_", "_", parseLatexString(true, "_"), showRightBrace)); - } else if (currentToken==MTTinstruction && currentTokenName=="lceil") { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "~", "~", parseLatexString(true, "~"), showRightBrace)); - } else if (currentToken==MTTinstruction && currentTokenName=="|") { - currentTokenName=currentTokenName.right(currentTokenName.size()-1); - nl->addNode(new MTbraceNode(this, "#", "#", parseLatexString(currentTokenName.size()<=0, "#"), showRightBrace)); - } else if (currentToken==MTTinstruction && currentTokenName==quitOnClosingBrace) { - break; - } - } else { - //bool addWhite=(currentToken==MTTwhitespace); - //getNew=addWhite; - getNew=false; - bool done=false; - if (name.size()==2) { - QChar n0=name[0]; - QChar n1=name[1]; - if (n0=='v' && n1.isLetter()) { - done=true; - //std::cout<<"found \\v... command\n"; - nl->addNode(new MTdecoratedNode(this, MTDvec, new MTtextNode(this, QString(n1), false, parsingMathEnvironment))); - } else if (n0=='c' && n1.isLetter()) { - done=true; - //std::cout<<"found \\v... command\n"; - nl->addNode(new MTinstruction1Node(this, "mathcal", new MTtextNode(this, QString(n1), false, parsingMathEnvironment))); - } - } else if (name.size()==3) { - QString n0=name.left(2); - QChar n1=name[name.size()-1]; - if (n0=="bb" && n1.isLetter()) { - done=true; - //std::cout<<"found \\v... command\n"; - nl->addNode(new MTinstruction1Node(this, "mathbb", new MTtextNode(this, QString(n1), false, parsingMathEnvironment))); - } - } - if (!done) nl->addNode(new MTsymbolNode(this, name, false));//, addWhite)); - - } - } - } else if (currentToken==MTTwhitespace) { - if (!parsingMathEnvironment) nl->addNode(new MTwhitespaceNode(this)); - } else if (currentToken==MTTunderscore) { - getToken(); - MTnode* child=nullptr; - MTnode* child2=nullptr; - if (currentToken==MTTinstruction) { - QString name=currentTokenName; - getToken(); // look at next token - if (currentToken==MTTopenbrace) { - child=new MTinstruction1Node(this, name, parseLatexString(true)); - } else { - //bool addWhite=(currentToken==MTTwhitespace); - //getNew=addWhite; - //child=new MTsymbolNode(this, name, addWhite); - getNew=false; - child=new MTsymbolNode(this, name, false); - } - } else if (currentToken==MTTopenbrace) { - child=parseLatexString(true); - } else if (currentToken==MTTtext) { - if (currentTokenName.size()<=1) { - child=new MTtextNode(this, currentTokenName, false, parsingMathEnvironment); - } else { - child=new MTtextNode(this, QString(currentTokenName[0]), false, parsingMathEnvironment); - child2=new MTtextNode(this, currentTokenName.right(currentTokenName.size()-1), false, parsingMathEnvironment); - } - } else { - getNew=false; - } - if (child!=nullptr) nl->addNode(new MTsubscriptNode(this, child)); - if (child2!=nullptr) nl->addNode(child2); - } else if (currentToken==MTThat) { - getToken(); - MTnode* child=nullptr; - MTnode* child2=nullptr; - if (currentToken==MTTinstruction) { - QString name=currentTokenName; - getToken(); // look at next token - if (currentToken==MTTopenbrace) { - child=new MTinstruction1Node(this, name, parseLatexString(true)); - } else { - //bool addWhite=(currentToken==MTTwhitespace); - //getNew=addWhite; - //child=new MTsymbolNode(this, name, addWhite); - getNew=false; - child=new MTsymbolNode(this, name, false); - } - } else if (currentToken==MTTopenbrace) { - child=parseLatexString(true); - } else if (currentToken==MTTtext) { - if (currentTokenName.size()<=1) { - child=new MTtextNode(this, currentTokenName, false, parsingMathEnvironment); - } else { - child=new MTtextNode(this, QString(currentTokenName[0]), false, parsingMathEnvironment); - child2=new MTtextNode(this, currentTokenName.right(currentTokenName.size()-1), false, parsingMathEnvironment); - } - } else { - getNew=false; - } - if (child!=nullptr) nl->addNode(new MTsuperscriptNode(this, child)); - if (child2!=nullptr) nl->addNode(child2); - } else if (currentToken==MTTopenbrace) { - nl->addNode(parseLatexString(true)); - } else if (currentToken==MTTclosebrace) { - break; - } else if (currentToken==MTTampersand) { - break; - } else if (currentToken==MTTdollar) { - if (parsingMathEnvironment) { // reached end of math environment - parsingMathEnvironment=false; - break; - } else { // starting math environment - parsingMathEnvironment=true; - nl->addNode(new MTinstruction1Node(this, "equation", parseLatexString(true))); - } - } - if (getNew) getToken(); - } - //std::cout<<" leaving parseLatexString()\n"; - return nl; -} - - -QList JKQTMathText::tbrs=QList(); -QHash JKQTMathText::tbrh=QHash(); - -QRectF JKQTMathText::getTBR(const QFont &fm, const QString &text, QPaintDevice *pd) -{ - JKQTMathText::tbrDataH dh(fm, text, pd); - if (pd) { - if (tbrh.contains(dh)) return tbrh[dh]; - /*for (int i=0; ilogicalDpiX() && tbrs[i].ldpiY==pd->logicalDpiY() && tbrs[i].pdpiX==pd->physicalDpiX() && tbrs[i].pdpiY==pd->physicalDpiY())) { - //qDebug()<<" ### "<getSize(painter, ev, width, ascent, overallHeight, strikeoutPos); - descent=overallHeight-ascent; - ascent=ascent*1.1; - descent=qMax(ascent*0.1, descent*1.1); - strikeoutPos=strikeoutPos*1.1; - } -} - -void JKQTMathText::draw(QPainter& painter, double x, double y, bool drawBoxes){ - if (getTree()!=nullptr) { - MTenvironment ev; - ev.color=fontColor; - ev.fontSize=fontSize; - getTree()->set_drawBoxes(drawBoxes); - getTree()->draw(painter, x, y, ev); - } -} - -void JKQTMathText::draw(QPainter& painter, int flags, QRectF rect, bool drawBoxes) { - if (getTree()!=nullptr) { - MTenvironment ev; - ev.color=fontColor; - ev.fontSize=fontSize; - getTree()->set_drawBoxes(drawBoxes); - - double width=0; - double baselineHeight=0; - double overallHeight=0, strikeoutPos=0; - getTree()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); - - // align left top - double x=rect.left(); - double y=rect.top()+baselineHeight; - - // care for horizontal align - if ((flags & Qt::AlignRight) != 0) x=x+rect.width()-width; - else if ((flags & Qt::AlignHCenter) != 0) x=x+(rect.width()-width)/2.0; - - // care for vertical align - if ((flags & Qt::AlignBottom) != 0) y=y+rect.height()-overallHeight; - else if ((flags & Qt::AlignVCenter) != 0) y=y+(rect.height()-overallHeight)/2.0; - - // finally draw - getTree()->draw(painter, x, y, ev); - } -} - -JKQTMathText::MTwhitespaceNode::MTwhitespaceNode(JKQTMathText *parent): - MTtextNode(parent, " ", false, false) -{ - -} - -JKQTMathText::MTwhitespaceNode::~MTwhitespaceNode() -{ - -} - -QString JKQTMathText::MTwhitespaceNode::getTypeName() const -{ - return QLatin1String("MTwhitespaceNode(")+text+")"; -} - -bool JKQTMathText::MTwhitespaceNode::toHtml(QString &html, JKQTMathText::MTenvironment /*currentEv*/, JKQTMathText::MTenvironment /*defaultEv*/) { - html=html+" "; - return true; -} - -void JKQTMathText::MTnode::set_drawBoxes(bool draw) -{ - this->drawBoxes=draw; -} - -QString JKQTMathText::MTnode::getTypeName() const -{ - return "MTnode"; -} - -QString JKQTMathText::fracModeToString(JKQTMathText::MTfracMode mode) -{ - switch(mode) { - case MTFMfrac: - return "frac"; - case MTFMdfrac: - return "dfrac"; - case MTFMtfrac: - return "tfrac"; - case MTFMunderbrace: - return "underbrace"; - case MTFMoverbrace: - return "overbrace"; - case MTFMunderset: - return "underset"; - case MTFMoverset: - return "overset"; - case MTFMstackrel: - return "stackrel"; - } - return "unknown"; -} - - -QString JKQTMathText::decorationToString(JKQTMathText::MTdecoration mode) -{ - switch(mode) { - case MTDvec: - return "vec"; - case MTDtilde: - return "tilde"; - case MTDhat: - return "hat"; - case MTDdot: - return "dot"; - case MTDddot: - return "ddot"; - case MTDbar: - return "bar"; - case MTDarrow: - return "arrow"; - case MTDoverline: - return "overline"; - case MTDdoubleoverline: - return "double overline"; - case MTDunderline: - return "underline"; - case MTDdoubleunderline: - return "double underline"; - } - return "unknown"; -} - -JKQTMathTextLabel::JKQTMathTextLabel(QWidget *parent): - QLabel(parent) -{ - m_mathText=new JKQTMathText(this); - m_mathText->useXITS(); - m_mathText->setFontSize(font().pointSizeF()*1.3); - lastText=""; - repaintDo=true; - buffer=QPixmap(); -} - -JKQTMathTextLabel::~JKQTMathTextLabel() -{ -} - -JKQTMathText *JKQTMathTextLabel::getMathText() const -{ - return m_mathText; -} - -void JKQTMathTextLabel::setMath(const QString &text, bool doRepaint) -{ - if (text!=lastText || doRepaint){ - lastText=text; - repaintDo=true; - internalPaint(); - update(); - } -} - - -void JKQTMathTextLabel::internalPaint() -{ - //return; - //qDebug()<<"internalPaint "<parse(lastText)<<"\n "<get_error_list().join("\n")<<"\n\n"; - if (!m_mathText->parse(lastText)) { - qDebug()<<"JKQTMathTextLabel::internalPaint(): parse '"<parse(lastText)<<"\n "<get_error_list().join("\n")<<"\n\n"; - } - - if (buffer.width()<=0 || buffer.height()<=0) buffer=QPixmap(1000,100); - //qDebug()<<"internalPaint(): buffer "<getSize(p); - p.end(); - } - buffer=QPixmap(qMax(32.0,size.width()*1.2), qMax(10.0,size.height()*1.1)); - buffer.fill(Qt::transparent); - { - //qDebug()<<"internalPaint(): "<draw(p,alignment(), QRectF(QPointF(0,0), size)); - p.end(); - } - setPixmap(buffer); - //} - //qDebug()<<"internalPaint(): setPixmap"; - QApplication::processEvents(); - //qDebug()<<"internalPaint(): DONE"; -} - -void JKQTMathTextLabel::paintEvent(QPaintEvent *event) -{ - //QLabel::paintEvent(event); - //return; - - //qDebug()<<"paintEvent: "<text=text; - this->tbr=this->fm.tightBoundingRect(text); - this->f=f; - //this->pd=pd; - if (pd) { - ldpiX=pd->logicalDpiX(); - ldpiY=pd->logicalDpiY(); - pdpiX=pd->physicalDpiX(); - pdpiY=pd->physicalDpiY(); - } else { - ldpiX=0; - ldpiY=0; - pdpiX=0; - pdpiY=0; - } -} - -bool JKQTMathText::tbrData::operator==(const JKQTMathText::tbrData &other) const -{ - return ldpiX==other.ldpiX && ldpiY==other.ldpiY && text==other.text && f==other.f; -} - - -JKQTMathText::tbrDataH::tbrDataH(const QFont &f, const QString &text, QPaintDevice *pd) -{ - this->text=text; - this->f=f; - if (pd) { - ldpiX=pd->logicalDpiX(); - ldpiY=pd->logicalDpiY(); - pdpiX=pd->physicalDpiX(); - pdpiY=pd->physicalDpiY(); - } else { - ldpiX=0; - ldpiY=0; - pdpiX=0; - pdpiY=0; - } -} - -bool JKQTMathText::tbrDataH::operator==(const JKQTMathText::tbrDataH &other) const -{ - return ldpiX==other.ldpiX && ldpiY==other.ldpiY && text==other.text && f==other.f; - -} - - -JKQTMathText::MTplainTextNode::MTplainTextNode(JKQTMathText *parent, QString text, bool addWhitespace, bool stripInnerWhitepace): - JKQTMathText::MTtextNode(parent, text, addWhitespace, stripInnerWhitepace) -{ - -} - -QString JKQTMathText::MTplainTextNode::getTypeName() const -{return QLatin1String("MTplainTextNode(")+text+")"; - -} - - -QString JKQTMathText::MTplainTextNode::textTransform(const QString &text, JKQTMathText::MTenvironment /*currentEv*/, bool /*forSize*/) -{ - return text; -} - -void initJKQTMathTextResources() -{ - Q_INIT_RESOURCE(xits); -} +/* + Copyright (c) 2008-2019 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 . +*/ + + + +#include "jkqtmathtext/jkqtmathtext.h" +#include +#include +#include +#include +#include +//#define jkqtp_QColor2String(color) QString(jkqtp_rgbtostring((color).red(), (color).green(), (color).blue(), (color).alpha()).c_str()) + +/** + * \brief saves the given property (for which also a def_property exists) into the given settings object + * \ingroup jkqtmathtext + * \internal + */ +#define JKQTMTPROPERTYsave(settings, group, var, varname) \ + if (var!=def_##var) settings.setValue(group+varname, var); +/** + * \brief loads the given property from the given settings object + * \ingroup jkqtmathtext + * \internal + */ +#define JKQTMTPROPERTYload(settings, group, var, varname, varconvert) \ + var=settings.value(group+varname, var).varconvert; + + +QPainterPath makeHBracePath(double x, double ybrace, double width, double bw, double cubicshrink=0.5, double cubiccontrolfac=0.3) { + double xl1=x-(width)*cubicshrink+bw*cubicshrink; + double xr2=x+(width)*cubicshrink-bw*cubicshrink; + double xl2=x-bw*cubicshrink; + double xr1=x+bw*cubicshrink; + + QPainterPath path; + path.moveTo(xl1-bw*cubicshrink, ybrace-bw*cubicshrink); + path.cubicTo(xl1-bw*cubicshrink, ybrace-bw*cubicshrink+bw*cubiccontrolfac, xl1-bw*cubiccontrolfac, ybrace, xl1, ybrace); + path.lineTo(xl2, ybrace); + path.cubicTo(xl2+bw*cubiccontrolfac, ybrace, (xl2+xr1)/2.0, ybrace+bw*cubicshrink-bw*cubiccontrolfac, (xl2+xr1)/2.0, ybrace+bw*cubicshrink); + path.cubicTo((xl2+xr1)/2.0, ybrace+bw*cubicshrink-bw*cubiccontrolfac, xr1-bw*cubiccontrolfac, ybrace, xr1, ybrace); + path.lineTo(xr2, ybrace); + path.cubicTo(xr2+bw*cubiccontrolfac, ybrace, xr2+bw*cubicshrink, ybrace-bw*cubicshrink+bw*cubiccontrolfac, xr2+bw*cubicshrink, ybrace-bw*cubicshrink); + return path; +} + + +QPainterPath makeArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true) { + double x1=x; + double x2=x+width; + double x3=x2-arrowW/2.0; + double y3u=y-arrowW/2.0; + double y3d=y+arrowW/2.0; + double x3l=x+arrowW/2.0; + + QPainterPath path; + path.moveTo(x1, y); + path.lineTo(x2, y); + if (right) { + path.moveTo(x3, y3u); + path.lineTo(x2, y); + path.lineTo(x3, y3d); + } + if (left) { + path.moveTo(x3l, y3u); + path.lineTo(x1, y); + path.lineTo(x3l, y3d); + } + return path; +} + + +QPainterPath makeDArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true) { + double x1=x; + double x2=x+width; + double dx=arrowW/4.0; + double y1=y-dx; + double y2=y+dx; + double x3=x2-arrowW/2.0; + double y3u=y-arrowW/2.0; + double y3d=y+arrowW/2.0; + double x3l=x+arrowW/2.0; + + QPainterPath path; + path.moveTo(x1+dx, y1); + path.lineTo(x2-dx, y1); + path.moveTo(x1+dx, y2); + path.lineTo(x2-dx, y2); + if (right) { + path.moveTo(x3, y3u); + path.lineTo(x2, y); + path.lineTo(x3, y3d); + } + if (left) { + path.moveTo(x3l, y3u); + path.lineTo(x1, y); + path.lineTo(x3l, y3d); + } + return path; +} + + + +// -------------------------------------------------------------------------------------------------- +// -- implementation of the MTnode's methods +// -------------------------------------------------------------------------------------------------- + +JKQTMathText::MTenvironment::MTenvironment() { + color=QColor("black"); + font=MTEroman; + fontSize=10; + bold=false; + italic=false; + smallCaps=false; + underlined=false; + overline=false; + strike=false; + insideMath=false; +} + +QFont JKQTMathText::MTenvironment::getFont(JKQTMathText* parent) const { + QFont f; + switch (font) { + case MTEsans: + if (insideMath) f.setFamily(parent->getFontMathSans()); + else f.setFamily(parent->getFontSans()); + break; + case MTEtypewriter: f.setFamily(parent->getFontTypewriter()); break; + case MTEscript: f.setFamily(parent->getFontScript()); break; + case MTEroman: + if (insideMath) f.setFamily(parent->getFontMathRoman()); + else f.setFamily(parent->getFontRoman()); + break; + case MTEcaligraphic: f.setFamily(parent->getFontCaligraphic()); break; + case MTEblackboard: f.setFamily(parent->getFontBlackboard()); break; + }; + f.setBold(bold); + f.setItalic(italic); + f.setUnderline(underlined); + f.setOverline(overline); + f.setStrikeOut(strike); + f.setCapitalization(QFont::MixedCase); + if (smallCaps) f.setCapitalization(QFont::SmallCaps); + f.setPointSizeF(fontSize); + f.setStyleStrategy(QFont::NoFontMerging); + return f; +} + +QString JKQTMathText::MTenvironment::toHtmlStart(MTenvironment defaultEv) const { + QString s; + s=s+"font-size: "+QLocale::c().toString(fontSize)+"pt; "; + if (insideMath) { + if (defaultEv.italic) { + if (!italic) s=s+"font-style: italic; "; + if (italic) s=s+"font-style: normal; "; + } else { + if (!italic) s=s+"font-style: italic; "; + } + } else { + if (!defaultEv.italic && italic) s=s+"font-style: italic; "; + } + if (bold && !defaultEv.bold) s=s+"font-weight: bold"; + + QStringList td; + if (underlined && !defaultEv.underlined) td<<"underline"; + if (overline && !defaultEv.overline) td<<"overline"; + if (strike && !defaultEv.strike) td<<"line-through"; + if (td.size()>0) s=s+"text-decoration: "+td.join(", "); + return ""; +} + +QString JKQTMathText::MTenvironment::toHtmlAfter(JKQTMathText::MTenvironment /*defaultEv*/) const { + return ""; +} + +JKQTMathText::MTnode::MTnode(JKQTMathText* parent) { + this->parent=parent; + drawBoxes=false; +} + +JKQTMathText::MTnode::~MTnode() += default; + +void JKQTMathText::MTnode::getSize(QPainter &painter, JKQTMathText::MTenvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos) +{ + double w=width, b=baselineHeight, o=overallHeight, s=strikeoutPos; + getSizeInternal(painter, currentEv, w, b, o, s); + + if (w<1e5) width=w; + if (b<1e5) baselineHeight=b; + if (o<1e5) overallHeight=o; + if (s<1e5) strikeoutPos=s; +} + +bool JKQTMathText::MTnode::toHtml(QString &/*html*/, JKQTMathText::MTenvironment /*currentEv*/, JKQTMathText::MTenvironment /*defaultEv*/) { + return false; +} + + +void JKQTMathText::MTnode::doDrawBoxes(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + if (drawBoxes) { + painter.save(); + double w, oh, bh, sp; + getSize(painter, currentEv, w, bh, oh, sp); + QPen p=painter.pen(); + p.setColor("lightcoral"); + p.setWidthF(0.5); + painter.setPen(p); + QRectF r(x, y-bh, w, oh); + painter.drawRect(r); + p.setColor("lightblue"); + painter.setPen(p); + if (w>0) painter.drawLine(QLineF(x, y, x+w, y)); + p.setColor("green"); + painter.setPen(p); + painter.drawEllipse(x-3.0,y-3.0,6.0,6.0); + p.setColor("lightgreen"); + painter.setPen(p); + painter.drawLine(x-2.0, y, x+2.0, y); + painter.drawLine(x, y-2, x, y+2.0); + painter.restore(); + } +} + + +JKQTMathText::MTtextNode::MTtextNode(JKQTMathText* parent, const QString& textIn, bool addWhitespace, bool stripInnerWhitepace): + JKQTMathText::MTnode(parent) +{ + QString text=textIn; + + if (stripInnerWhitepace) { + text=""; + for (int i=0; itext=text; + // strip all whitespace from left + while (this->text.size()>1 && this->text[0].isSpace()) { + this->text=this->text.right(this->text.size()-1); + } + if (addWhitespace /*&& (this->text.size()>0)*/ && (!this->text[this->text.size()-1].isSpace())) this->text=this->text+" "; + //qDebug()<<"MTtextNode( text="< this->text="<text<<"]"; +} + +JKQTMathText::MTtextNode::~MTtextNode() = default; + +void JKQTMathText::MTtextNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + QFont f=currentEv.getFont(parent); + if (currentEv.insideMath && (text=="(" || text=="[" || text=="|" || text=="]" || text==")" || text=="<" || text==">" || + text==QString(QChar(0x2329)) || text==QString(QChar(0x232A)) || text==QString(QChar(0x2308)) || + text==QString(QChar(0x2309)) || text==QString(QChar(0x230A)) || text==QString(QChar(0x230B)))) { + f.setItalic(false); + f.setFamily(parent->getFontBraces()); + } + QString txt=textTransform(text, currentEv, true); + QFontMetricsF fm(f, painter.device()); + QRectF br=fm.boundingRect(txt); + QRectF tbr=parent->getTBR(f, txt, painter.device()); //fm.tightBoundingRect(txt); + if (txt=="|") { + br=fm.boundingRect("X"); + tbr=QRect(0,0,fm.width("X"), fm.ascent());//fm.boundingRect("X"); + br.setWidth(0.7*br.width()); + } + width=br.width();//width(text); + + if (txt.size()>0) { + if (txt[0].isSpace() /*&& br.width()<=0*/) width=width+fm.boundingRect("I").width(); + if (txt.size()>1 && txt[txt.size()-1].isSpace() /*&& (fm.boundingRect("a ").width()==fm.boundingRect("a").width())*/) width=width+fm.width("I"); + } + + //qDebug()<<"text: "<" || + text==QString(QChar(0x2329)) || text==QString(QChar(0x232A)) || text==QString(QChar(0x2308)) || + text==QString(QChar(0x2309)) || text==QString(QChar(0x230A)) || text==QString(QChar(0x230B)))) { + f.setItalic(false); + f.setFamily(parent->getFontBraces()); + } + + + if (onlyDigits && currentEv.insideMath) { + f.setItalic(false); + } + + painter.setFont(f); + + QPen p=painter.pen(); + p.setColor(currentEv.color); + painter.setPen(p); + double dx=0; + QFontMetricsF fm(f, painter.device()); + /*if (txt.size()>1 && txt[txt.size()-1].isSpace()) { + QFontMetricsF fm(f, painter.device()); + //if ((fm.width("a ")==fm.width("a"))) dx=fm.boundingRect("I").width(); + }*/ + + if (!hasDigits || !f.italic()) { + painter.drawText(QPointF(x+dx, y), txt);//.simplified()); + } else { + int i=0; + double xx=x+dx; + QFont ff=f; + QFontMetricsF fmff(ff, painter.device()); + ff.setItalic(false); + while (igetFontEncoding()==MTFEunicode) { + if (currentEv.insideMath) { + txt=""; + for (int i=0; i': txt+=QString(QString(" > ")); break; + case '=': txt+=QString(QString(" = ")); break; + case ';': txt+=QString(QString("; ")); break; + default: txt+=c; break; + } + } + txt=txt.replace(" ", " "); + } + } + if (currentEv.font==MTEblackboard && parent->getFontEncoding()==MTFEunicode) { + txt=""; + for (int i=0; igetFontEncoding()==MTFEunicode) { + txt=""; + for (int i=0; iname=name; + this->child=child; + this->parameters=parameters; + + JKQTMathText::MTenvironment ev; + if (!setupMTenvironment(ev)) { + parent->error_list.append(tr("unknown instruction '%1' found!").arg(name)); + } +} + +JKQTMathText::MTinstruction1Node::~MTinstruction1Node() { + if (child!=nullptr) delete child; +} + +QString JKQTMathText::MTinstruction1Node::getTypeName() const +{ + return QLatin1String("MTinstruction1Node(")+name+")"; +} + +void JKQTMathText::MTinstruction1Node::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + JKQTMathText::MTenvironment ev=currentEv; + + setupMTenvironment(ev); + + child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); + if (name=="colorbox" || name=="fbox" || name=="boxed") { + QFontMetricsF fm(ev.getFont(parent)); + double xw=fm.width("x"); + width+=xw; + overallHeight+=xw; + baselineHeight+=xw/2.0; + } +} + +double JKQTMathText::MTinstruction1Node::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + doDrawBoxes(painter, x, y, currentEv); + JKQTMathText::MTenvironment ev=currentEv; + + setupMTenvironment(ev); + + QPen oldPen=painter.pen(); + double shiftX=0; + if (name=="colorbox" || name=="fbox" || name=="boxed") { + QColor fcol=currentEv.color; + if (name=="colorbox") fcol=QColor(parameters.value(0, ev.color.name())); + //qDebug()<<"COLOR="<getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); + QPen p=painter.pen(); + QFontMetricsF fm(currentEv.getFont(parent)); + double xw=fm.width("x"); + p.setColor(fcol); + painter.setPen(p); + painter.drawRect(x,y-baselineHeight-xw/2,width+xw,overallHeight+xw); + shiftX=xw/2.0; + } + + double xnew= child->draw(painter, x+shiftX, y, ev); + painter.setPen(oldPen); + return xnew; +} + +bool JKQTMathText::MTinstruction1Node::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { + JKQTMathText::MTenvironment ev=currentEv; + + setupMTenvironment(ev); + + return child->toHtml(html, ev, defaultEv); +} + +void JKQTMathText::MTinstruction1Node::set_drawBoxes(bool draw) +{ + drawBoxes=draw; + child->set_drawBoxes(draw); +} + +bool JKQTMathText::MTinstruction1Node::setupMTenvironment(JKQTMathText::MTenvironment &ev) +{ + if (name=="bf" || name=="textbf" || name=="mathbf") ev.bold=true; + else if (name=="em") ev.italic=!ev.italic; + else if (name=="it" || name=="textit" || name=="mathit") ev.italic=true; + else if (name=="textcolor" || name=="mathcolor" || name=="color") ev.color=QColor(parameters.value(0, ev.color.name())); + else if (name=="equation") { ev.italic=true; ev.insideMath=true; } + else if (name=="sc" || name=="textsc" || name=="mathsc") ev.smallCaps=true; + else if (name=="ul" || name=="underline" || name=="underlined") ev.underlined=true; + else if (name=="ol" || name=="overline" || name=="overlined") ev.overline=true; + else if (name=="strike") ev.strike=true; + else if (name=="rm" || name=="textrm") { ev.font=JKQTMathText::MTEroman; } + else if (name=="mathrm" || name=="text" || name=="mbox" || name=="operatorname") { ev.font=JKQTMathText::MTEroman; ev.italic=false; } + else if (name=="mat") { ev.font=JKQTMathText::MTEroman; ev.italic=false; ev.bold=true; } + else if (name=="cal" || name=="textcal" || name=="mathcal") { ev.font=JKQTMathText::MTEcaligraphic; } + else if (name=="bb" || name=="textbb" || name=="mathbb") { ev.font=JKQTMathText::MTEblackboard; } + else if (name=="tt" || name=="texttt" || name=="mathtt") { ev.font=JKQTMathText::MTEtypewriter; } + else if (name=="sf" || name=="textsf" || name=="mathsf") { ev.font=JKQTMathText::MTEsans; } + else if (name=="script" || name=="textscript" || name=="mathscript") { ev.font=JKQTMathText::MTEscript; } + else if (name=="displaystyle") { ev.fontSize=ev.fontSize/0.8; } + else if (name=="scriptstyle") { ev.fontSize=ev.fontSize*0.8; } + else if (name=="scriptscriptstyle") { ev.fontSize=ev.fontSize*0.8*0.8; } + else { + return false; + } + + return true; +} + + + + +JKQTMathText::MTsubscriptNode::MTsubscriptNode(JKQTMathText* parent, MTnode* child): + JKQTMathText::MTnode(parent) +{ + this->child=child; +} + +JKQTMathText::MTsubscriptNode::~MTsubscriptNode() { + if (child!=nullptr) delete child; +} + +void JKQTMathText::MTsubscriptNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + JKQTMathText::MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); + + QFontMetricsF fm(ev.getFont(parent), painter.device()); + double shift=parent->get_sub_shift_factor()*parent->getTBR(ev.getFont(parent), "M", painter.device()).height(); + + child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); + + QFontMetricsF fmouter(currentEv.getFont(parent), painter.device()); + QRectF tbr=parent->getTBR(currentEv.getFont(parent), "M", painter.device()); + overallHeight=tbr.height()+shift+(overallHeight-baselineHeight); + baselineHeight=tbr.height(); + strikeoutPos=fmouter.strikeOutPos(); + if (currentEv.italic) width=width-double(fm.width(' '))*parent->get_italic_correction_factor(); +} + +double JKQTMathText::MTsubscriptNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + doDrawBoxes(painter, x, y, currentEv); + JKQTMathText::MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); + + QFontMetricsF fm(ev.getFont(parent), painter.device()); + + double shift=parent->get_sub_shift_factor()*parent->getTBR(ev.getFont(parent), "M", painter.device()).height(); + double xx=x; + if (currentEv.italic) xx=xx-double(fm.width(' '))*parent->get_italic_correction_factor(); + return child->draw(painter, xx, y+shift, ev);//+0.5*fm.boundingRect("A").width(); +} + +bool JKQTMathText::MTsubscriptNode::isSubOrSuper() +{ + return true; +} + +QString JKQTMathText::MTsubscriptNode::getTypeName() const +{ + return "MTsubscriptNode"; +} + + +bool JKQTMathText::MTsubscriptNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { + html=html+""; + bool ok=child->toHtml(html, currentEv, defaultEv); + html=html+""; + return ok; +} + +void JKQTMathText::MTsubscriptNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + child->set_drawBoxes(draw); + +} + + + + + +JKQTMathText::MTsqrtNode::MTsqrtNode(JKQTMathText* parent, MTnode* child, int degree): + JKQTMathText::MTnode(parent) +{ + this->child=child; + this->degree=degree; +} + +JKQTMathText::MTsqrtNode::~MTsqrtNode() { + if (child!=nullptr) delete child; +} + +void JKQTMathText::MTsqrtNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + QFontMetricsF fm(currentEv.getFont(parent), painter.device()); + + child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); + + overallHeight=overallHeight*1.2;//+fm.ascent()*0.1; + baselineHeight=baselineHeight*1.2;//+fm.ascent()*0.1; + width=width+fm.boundingRect("A").width()*2; // 1.53 +} + +double JKQTMathText::MTsqrtNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + doDrawBoxes(painter, x, y, currentEv); + double width=0, baselineHeight=0, overallHeight=0, sp=0; + child->getSize(painter, currentEv, width, baselineHeight, overallHeight, sp); + QFont f=currentEv.getFont(parent); + QFont fsmall=f; + QFontMetricsF fm(f, painter.device()); + double w=fm.boundingRect("A").width(); + double a=baselineHeight*1.15; + double d=overallHeight-baselineHeight; + //painter.save(); + QPen p=painter.pen(); + p.setColor(currentEv.color); + p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH,ceil(currentEv.fontSize/16.0))); + //painter.setPen(p); + QPainterPath path; + if (w>0) { + path.moveTo(x+0.1*w, y-0.4*a); + path.lineTo(x+0.33*w, y-0.4*a); + path.lineTo( x+0.66*w, y+0.5*d); + path.lineTo(x+w, y-a); + } + if (degree!=2) { + fsmall.setPointSizeF(fsmall.pointSizeF()/2.0); + fsmall.setItalic(false); + painter.setFont(fsmall); + painter.drawText(QPointF(x+0.33*w, y-0.55*a), QLocale::c().toString(degree)); + } + //painter.restore(); + double xnew=child->draw(painter, x+1.2*w, y, currentEv); + painter.save(); + painter.setPen(p); + if (w>0) { + path.lineTo( xnew+0.2*w, y-a); + path.lineTo(xnew+0.2*w, y-0.8*a); + painter.drawPath(path); + } + painter.restore(); + return xnew+0.33*w; +} + +bool JKQTMathText::MTsqrtNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { + html=html+"√"; + bool ok=child->toHtml(html, currentEv, defaultEv); + html=html+" "; + return ok; +} + +void JKQTMathText::MTsqrtNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + child->set_drawBoxes(draw); + +} + +QString JKQTMathText::MTsqrtNode::getTypeName() const +{ + return "MTsqrtNode"; +} + + + + + + +JKQTMathText::MTfracNode::MTfracNode(JKQTMathText* parent, MTnode* child_top, MTnode* child_bottom, MTfracMode mode): + JKQTMathText::MTnode(parent) +{ + this->child1=child_top; + this->child2=child_bottom; + this->mode=mode; +} + +JKQTMathText::MTfracNode::~MTfracNode() { + if (child1!=nullptr) delete child1; + if (child2!=nullptr) delete child2; +} + +QString JKQTMathText::MTfracNode::getTypeName() const +{ + return "MTfracNode"; +} + +void JKQTMathText::MTfracNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + QFontMetricsF fm(currentEv.getFont(parent), painter.device()); + JKQTMathText::MTenvironment ev1=currentEv; + JKQTMathText::MTenvironment ev2=currentEv; + + double xh=fm.xHeight(); //tightBoundingRect("x").height(); + double sp=xh; + double Ah=parent->getTBR(currentEv.getFont(parent), "M", painter.device()).height();//fm.ascent(); + double xw=fm.boundingRect("x").width(); + + if (mode==MTFMunderbrace || mode==MTFMoverbrace) { + ev2.fontSize=ev2.fontSize*parent->get_underbrace_factor(); + } else if (mode==MTFMunderset || mode==MTFMoverset) { + ev2.fontSize=ev2.fontSize*parent->get_underset_factor(); + } else if (mode==MTFMfrac) { + ev1.fontSize=ev1.fontSize*parent->get_frac_factor(); + ev2.fontSize=ev2.fontSize*parent->get_frac_factor(); + } else if (mode==MTFMtfrac) { + ev1.fontSize=ev1.fontSize*parent->get_frac_factor()*0.7; + ev2.fontSize=ev2.fontSize*parent->get_frac_factor()*0.7; + } + + + double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0; + double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos2=0; + child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1); + child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos2); + + overallHeight=0; + baselineHeight=0; + width=0; + if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) { + //std::cout<<"\nxh="< baselineHeight="<getTBR(f, "M", painter.device()).height();//fm.ascent(); + double bw=Ah/2.0; + + if (mode==MTFMunderbrace || mode==MTFMoverbrace) { + ev2.fontSize=ev2.fontSize*parent->get_underbrace_factor(); + } else if (mode==MTFMunderset || mode==MTFMoverset) { + ev2.fontSize=ev2.fontSize*parent->get_underset_factor(); + } else if (mode==MTFMfrac) { + ev1.fontSize=ev1.fontSize*parent->get_frac_factor(); + ev2.fontSize=ev2.fontSize*parent->get_frac_factor(); + } else if (mode==MTFMtfrac) { + ev1.fontSize=ev1.fontSize*parent->get_frac_factor()*0.7; + ev2.fontSize=ev2.fontSize*parent->get_frac_factor()*0.7; + } + + double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0; + double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0; + child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos); + child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos); + double ascent1=baselineHeight1; + double descent1=overallHeight1-baselineHeight1; + double ascent2=baselineHeight2; + double descent2=overallHeight2-baselineHeight2; + + double yline=y-xh*0.5; + + + //double overallHeight=overallHeight1+overallHeight2+xh; + //double baselineHeight=3.0*xh/2.0+overallHeight1; + double width=qMax(width1, width2); + + QPen p=painter.pen(); + p.setColor(ev1.color); + p.setStyle(Qt::SolidLine); + p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, lw)); + painter.save(); + painter.setPen(p); + if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) { + QLineF l(x+xw/4.0, yline, x+width+xw/2.0, yline); + if (l.length()>0) painter.drawLine(l); + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->get_frac_shift_factor())-descent1, ev1); + child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->get_frac_shift_factor())+ascent2, ev2); + } else if (mode==MTFMstackrel) { + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->get_frac_shift_factor())-descent1, ev1); + child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->get_frac_shift_factor())+ascent2, ev2); + } else if (mode==MTFMunderset) { + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); + child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y+descent1+xh/6.0+ascent2, ev2); + } else if (mode==MTFMunderbrace) { + double ybrace=y+descent1+bw/2.0; + QPainterPath path=makeHBracePath(x+xw/2.0+(width1)/2.0, ybrace, width, bw); + painter.drawPath(path); + + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); + child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y+descent1+bw+ascent2, ev2); + } else if (mode==MTFMoverset) { + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); + child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y-ascent1-xh/6.0-descent2, ev2); + } else if (mode==MTFMoverbrace) { + double ybrace=y-ascent1-bw/2.0; + + painter.save(); + painter.translate(x+xw/2.0+(width1)/2.0, ybrace); + painter.rotate(180); + QPainterPath path=makeHBracePath(0,0, width, bw); + painter.drawPath(path); + painter.restore(); + + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); + child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y-ascent1-bw-descent2, ev2); + } + painter.restore(); + + if (mode==MTFMstackrel) return x+width+ xw; + return x+width+xw; + +} + +bool JKQTMathText::MTfracNode::toHtml(QString &/*html*/, JKQTMathText::MTenvironment /*currentEv*/, JKQTMathText::MTenvironment /*defaultEv*/) { + bool ok=false; + + + + return ok; +} + +void JKQTMathText::MTfracNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + child1->set_drawBoxes(draw); + child2->set_drawBoxes(draw); + +} + + + + + + + + + +JKQTMathText::MTmatrixNode::MTmatrixNode(JKQTMathText* parent, QVector > children): + JKQTMathText::MTnode(parent) +{ + this->lines=children.size(); + this->columns=0; + for (int i=0; ithis->columns) this->columns=children[i].size(); + } + this->children=children; +} + +JKQTMathText::MTmatrixNode::~MTmatrixNode() { + for (int i=0; iget_frac_factor(); + + + QVector colwidth, rowheight; + //QVector > widths, heights, baselines; + + double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0; + //widths.resize(lines); + colwidth.resize(columns); for (int i=0; igetSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1); + /*widths[i].operator[](j)=width1; + baselines[i].operator[](j)=baselineHeight; + heights[i].operator[](j)=overallHeight1;*/ + if (overallHeight1>rowheight[i]) rowheight[i]=overallHeight1; + if (width1>colwidth[j]) colwidth[j]=width1; + } + } + + + overallHeight=(lines-1)*xw/2.0; + width=columns*xw; + for (int i=0; iget_frac_factor(); + + + QVector colwidth, rowheight, rowascent; + //QVector > widths, heights, baselines; + + double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos=0; + //widths.resize(lines); + colwidth.resize(columns); for (int i=0; igetSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos); + /*widths[i].operator[](j)=width1; + baselines[i].operator[](j)=baselineHeight; + heights[i].operator[](j)=overallHeight1;*/ + if (overallHeight1>rowheight[i]) rowheight[i]=overallHeight1; + if (baselineHeight1>rowascent[i]) rowascent[i]=baselineHeight1; + if (width1>colwidth[j]) colwidth[j]=width1; + } + } + + double overallHeight=(lines-1)*xw/2.0; + double width=(columns)*xw; + for (int i=0; i0) yy=yy+rowascent[0]; + for (int i=0; idraw(painter, xx, yy, ev1); + xx=xx+colwidth[j]+xw; + } + + if (idrawBoxes=draw; + for (int i=0; iset_drawBoxes(draw); + } + } + +} + + + + + + + + +JKQTMathText::MTdecoratedNode::MTdecoratedNode(JKQTMathText* parent, MTdecoration decoration, MTnode* child): + JKQTMathText::MTnode(parent) +{ + this->child=child; + this->decoration=decoration; +} + +JKQTMathText::MTdecoratedNode::~MTdecoratedNode() { + if (child!=nullptr) delete child; +} + +void JKQTMathText::MTdecoratedNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + QFontMetricsF fm(currentEv.getFont(parent), painter.device()); + double wc=fm.boundingRect("A").width(); + double dheightfactor=1.0+parent->get_decoration_height_factor()*2.0; + + child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); + + overallHeight=overallHeight*dheightfactor; + baselineHeight=baselineHeight*dheightfactor; + width=width+0.3*wc; +} + +double JKQTMathText::MTdecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + doDrawBoxes(painter, x, y, currentEv); + MTenvironment ev=currentEv; + double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0; + child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); + QFontMetricsF fm(ev.getFont(parent), painter.device()); + double w=width; + double wc=fm.boundingRect("A").width(); + //double ll=wc*0.8; + double a=baselineHeight; + //double d=overallHeight-baselineHeight; + double dheightfactor=parent->get_decoration_height_factor(); + double dpos=y-a*(1.0+dheightfactor); + double dposb=y+qMax((overallHeight-baselineHeight)*(1.0+dheightfactor), fm.xHeight()*dheightfactor); + double deltax=0;//(wc-ll)/2.0; + double dheight=dheightfactor*a; + + + if (ev.italic) deltax+=0.1*fm.boundingRect("A").width(); + QPen pold=painter.pen(); + QPen p=pold; + p.setColor(ev.color); + p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0)); + if (decoration==MTDbar) ev.overline=true; + double xnew=child->draw(painter, x, y, ev); + if (decoration==MTDvec) { + painter.setPen(p); + QPolygonF poly; + poly<0) painter.drawLine(l); + painter.setPen(pold); + } else if (decoration==MTDdoubleoverline) { + painter.setPen(p); + QLineF l(x+deltax, dpos, xnew+deltax-0.2*wc, dpos); + if (l.length()>0) painter.drawLine(l); + l=QLineF(x+deltax, dpos-2.0*p.widthF(), xnew+deltax-0.2*wc, dpos-2.0*p.widthF()); + if (l.length()>0) painter.drawLine(l); + painter.setPen(pold); + } else if (decoration==MTDunderline) { + painter.setPen(p); + QLineF l(x+deltax, dposb, xnew+deltax-0.2*wc, dposb); + if (l.length()>0) painter.drawLine(l); + painter.setPen(pold); + } else if (decoration==MTDdoubleunderline) { + painter.setPen(p); + QLineF l(x+deltax, dposb, xnew+deltax-0.2*wc, dposb); + if (l.length()>0) painter.drawLine(l); + l=QLineF(x+deltax, dposb+2.0*p.widthF(), xnew+deltax-0.2*wc, dposb+2.0*p.widthF()); + if (l.length()>0) painter.drawLine(l); + painter.setPen(pold); + } else if (decoration==MTDarrow) { + painter.setPen(p); + QLineF l(x+deltax, dpos+dheight/2.0, xnew+deltax-0.2*wc, dpos+dheight/2.0); + if (l.length()>0) painter.drawLine(l); + QPolygonF poly; + poly<toHtml(html, ev, defaultEv); + + return false; +} + +void JKQTMathText::MTdecoratedNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + child->set_drawBoxes(draw); + +} + +QString JKQTMathText::MTdecoratedNode::getTypeName() const +{ + return "MTdecoratedNode"; +} + + + + + + +JKQTMathText::MTsuperscriptNode::MTsuperscriptNode(JKQTMathText* parent, MTnode* child): + JKQTMathText::MTnode(parent) +{ + this->child=child; +} + +JKQTMathText::MTsuperscriptNode::~MTsuperscriptNode() { + if (child!=nullptr) delete child; +} + +void JKQTMathText::MTsuperscriptNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + JKQTMathText::MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); + QFontMetricsF fm(currentEv.getFont(parent), painter.device()); + child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); + double shift=0;//parent->get_super_shift_factor()*fm.ascent(); + overallHeight=overallHeight+shift; + strikeoutPos=fm.strikeOutPos(); + if (currentEv.italic) width=width+double(fm.width(' '))*parent->get_italic_correction_factor(); +} + +double JKQTMathText::MTsuperscriptNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + doDrawBoxes(painter, x, y, currentEv); + JKQTMathText::MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_subsuper_size_factor(); + + double cwidth, cbaselineHeight, coverallheight, cStrikeoutPos; + child->getSize(painter, ev, cwidth, cbaselineHeight, coverallheight, cStrikeoutPos); + + QFontMetricsF fm(currentEv.getFont(parent), painter.device()); + + double shift=0;//parent->get_super_shift_factor()*fm.ascent(); + //double shift=ev.; + double xx=x; + if (currentEv.italic) xx=xx+double(fm.width(' '))*parent->get_italic_correction_factor(); + + return child->draw(painter, xx, y-shift, ev);//+0.5*fm.boundingRect("A").width(); +} + +bool JKQTMathText::MTsuperscriptNode::isSubOrSuper() +{ + return true; +} + +QString JKQTMathText::MTsuperscriptNode::getTypeName() const +{ + return "MTsuperscriptNode"; +} + + +bool JKQTMathText::MTsuperscriptNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) +{ + html=html+""; + bool ok=child->toHtml(html, currentEv, defaultEv); + html=html+""; + return ok; +} + +void JKQTMathText::MTsuperscriptNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + child->set_drawBoxes(draw); + +} + + + + + + +JKQTMathText::MTbraceNode::MTbraceNode(JKQTMathText* parent, const QString& openbrace, const QString& closebrace, MTnode* child, bool showRightBrace): + JKQTMathText::MTnode(parent) +{ + this->child=child; + this->openbrace=openbrace; + this->closebrace=closebrace; + this->showRightBrace=showRightBrace; +} + +JKQTMathText::MTbraceNode::~MTbraceNode() { + if (child!=nullptr) delete child; +} + +void JKQTMathText::MTbraceNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + + JKQTMathText::MTenvironment ev=currentEv; + child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); + + double bracewidth=0, braceheight=0; + getBraceWidth(painter, ev, baselineHeight, overallHeight, bracewidth, braceheight); + + bracewidth=bracewidth/parent->get_brace_shrink_factor(); + + baselineHeight=/*qMin(baselineHeight, braceheight)*/ baselineHeight*parent->get_brace_factor(); + overallHeight=qMax(overallHeight, braceheight)*parent->get_brace_factor(); //fm.height(); + + width=width+bracewidth*2.0; + + +} + +double JKQTMathText::MTbraceNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + //std::cout<<"drawing brace-node: '"<getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); + + double bracewidth=0, braceheight=0; + getBraceWidth(painter, ev, baselineHeight, overallHeight, bracewidth, braceheight); + + double cwidth=0; + double cbaselineHeight=0; + double coverallHeight=0, cstrikeoutPos=0; + + getSize(painter, currentEv, cwidth, cbaselineHeight, coverallHeight, cstrikeoutPos); + + double lw=qMax(0.25,ceil(currentEv.fontSize/12.0));//fm.lineWidth(); + + double xnew=x+lw; + + QPen pold=painter.pen(); + QPen p=pold; + p.setWidthF(lw); + p.setColor(currentEv.color); + painter.setPen(p); + double brace_fraction=0.85; + if (openbrace=="(") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+brace_fraction*bracewidth, y1); + path.cubicTo(xnew, (y1+y2)/2.0+fabs(y1-y2)/6.0, xnew, (y1+y2)/2.0-fabs(y1-y2)/6.0 , xnew+brace_fraction*bracewidth, y2); + painter.drawPath(path); + } else if (openbrace=="[") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+brace_fraction*bracewidth, y1); + path.lineTo(xnew+lw/2.0, y1); + path.lineTo(xnew+lw/2.0, y2); + path.lineTo(xnew+brace_fraction*bracewidth, y2); + painter.drawPath(path); + } else if (openbrace=="{") { + QPainterPath path=makeHBracePath(0,0,coverallHeight, bracewidth*brace_fraction); + painter.save(); + painter.translate(xnew+bracewidth*(1.0-brace_fraction), y-cbaselineHeight+coverallHeight/2.0); + painter.rotate(90); + painter.drawPath(path); + painter.restore(); + } else if (openbrace=="_") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+brace_fraction*bracewidth, y1); + path.lineTo(xnew, y1); + path.lineTo(xnew, y2); + painter.drawPath(path); + } else if (openbrace=="~") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew, y1); + path.lineTo(xnew, y2); + path.lineTo(xnew+brace_fraction*bracewidth, y2); + painter.drawPath(path); + } else if (openbrace=="|") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + QLineF l(xnew+brace_fraction*bracewidth, y1, xnew+brace_fraction*bracewidth, y2); + if (l.length()>0) painter.drawLine(l); + painter.drawPath(path); + } else if (openbrace=="#" || openbrace=="||") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + QLineF l(xnew+brace_fraction*bracewidth, y1, xnew+brace_fraction*bracewidth, y2); + if (l.length()>0) painter.drawLine(l); + l=QLineF(xnew+brace_fraction*bracewidth-1.5*lw, y1, xnew+brace_fraction*bracewidth-1.5*lw, y2); + if (l.length()>0) painter.drawLine(l); + } else if (openbrace=="<") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+brace_fraction*bracewidth, y1); + path.lineTo(xnew, (y2+y1)/2.0); + path.lineTo(xnew+brace_fraction*bracewidth, y2); + painter.drawPath(path); + } + + painter.setPen(pold); + + xnew= child->draw(painter, xnew+bracewidth/parent->get_brace_shrink_factor()-lw, y, currentEv)+lw; + + if (showRightBrace) { + painter.setPen(p); + if (closebrace==")") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); + path.cubicTo(xnew+bracewidth, (y1+y2)/2.0+fabs(y1-y2)/6.0, xnew+bracewidth, (y1+y2)/2.0-fabs(y1-y2)/6.0 , xnew+(1.0-brace_fraction)*bracewidth, y2); + painter.drawPath(path); + } else if (closebrace=="]") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); + path.lineTo(xnew+bracewidth-lw/2.0, y1); + path.lineTo(xnew+bracewidth-lw/2.0, y2); + path.lineTo(xnew+(1.0-brace_fraction)*bracewidth, y2); + painter.drawPath(path); + } else if (closebrace=="}") { + QPainterPath path=makeHBracePath(0,0,coverallHeight, bracewidth*brace_fraction); + painter.save(); + painter.translate(xnew+bracewidth*brace_fraction, y-cbaselineHeight+coverallHeight/2.0); + painter.rotate(270); + painter.drawPath(path); + painter.restore(); + } else if (closebrace=="_") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); + path.lineTo(xnew+bracewidth, y1); + path.lineTo(xnew+bracewidth, y2); + painter.drawPath(path); + } else if (closebrace=="~") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+bracewidth, y1); + path.lineTo(xnew+bracewidth, y2); + path.lineTo(xnew+(1.0-brace_fraction)*bracewidth, y2); + painter.drawPath(path); + } else if (closebrace=="|") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + QLineF l(xnew+(1.0-brace_fraction)*bracewidth, y1, xnew+(1.0-brace_fraction)*bracewidth, y2); + if (l.length()>0) painter.drawLine(l); + painter.drawPath(path); + } else if (closebrace=="#" || closebrace=="||") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + QLineF l(xnew+(1.0-brace_fraction)*bracewidth, y1, xnew+(1.0-brace_fraction)*bracewidth, y2); + if (l.length()>0) painter.drawLine(l); + l=QLineF(xnew+(1.0-brace_fraction)*bracewidth+1.5*lw, y1, xnew+(1.0-brace_fraction)*bracewidth+1.5*lw, y2); + if (l.length()>0) painter.drawLine(l); + } else if (closebrace==">") { + QPainterPath path; + double y1=y+(coverallHeight-cbaselineHeight); + double y2=y-cbaselineHeight; + path.moveTo(xnew+(1.0-brace_fraction)*bracewidth, y1); + path.lineTo(xnew+bracewidth, (y2+y1)/2.0); + path.lineTo(xnew+(1.0-brace_fraction)*bracewidth, y2); + painter.drawPath(path); + } + painter.setPen(pold); + } + + //qDebug()<<" ==> "<get_brace_shrink_factor()-lw; +} + +bool JKQTMathText::MTbraceNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { + QString ob=openbrace; + QString cb=closebrace; + if (ob=="<") ob="⟨"; + else if (ob=="_") ob="⌊"; + else if (ob=="~") ob="⌈"; + else if (ob=="||" || ob=="#") ob="||"; + if (cb=="<") cb="⟩"; + else if (cb=="_") cb="⌋"; + else if (cb=="~") cb="⌉"; + else if (cb=="||" || cb=="#") cb="||"; + + + html=html+ob; + + bool ok=child->toHtml(html, currentEv, defaultEv); + + html=html+cb; + + return ok; +} + +void JKQTMathText::MTbraceNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + child->set_drawBoxes(draw); + +} + +QString JKQTMathText::MTbraceNode::getTypeName() const +{ + return QLatin1String("MTbraceNode(")+openbrace+" "+closebrace+")"; +} + +void JKQTMathText::MTbraceNode::getBraceWidth(QPainter &/*painter*/, JKQTMathText::MTenvironment ev, double /*baselineHeight*/, double overallHeight, double &bracewidth, double &braceheight) +{ + /*QFont evf=ev.getFont(parent); + if (ev.insideMath) evf.setItalic(false); + ev.italic=false; + while (ev.fontSize<10*parent->getFontSize()) { + const QFontMetricsF fme(evf, painter.device()); + if (fme.ascent()>overallHeight) break; + ev.fontSize+=0.5; + evf.setPointSizeF(ev.fontSize); + } + ev.fontSize=ev.fontSize*parent->get_brace_factor(); + evf.setPointSizeF(ev.fontSize); + QFontMetricsF fm(evf, painter.device()); + QString bc="_X"; + bracewidth=fm.width("I")*parent->get_brace_shrink_factor(); + braceheight=parent->getTBR(evf, bc, painter.device()).height();*/ + double lw=qMax(0.25,ceil(ev.fontSize/12.0)); + braceheight=overallHeight*parent->get_brace_factor(); + bracewidth=0.6*pow(braceheight, 0.6); + if (openbrace=="{" || closebrace=="}") bracewidth=qMax(bracewidth, lw*3.5); + +} + + + + + +JKQTMathText::MTlistNode::MTlistNode(JKQTMathText* parent): + JKQTMathText::MTnode(parent) +{ + nodes.clear(); + // these operations cause sub/sup script to be typeset over/under the operator, not right besides! + subsupOperations<<"sum"<<"prod"<<"coprod" + <<"bigcap"<<"bigcup"<<"bigvee"<<"bighat" + <<"int"<<"iint"<<"iiint"<<"oint"<<"oiint"<<"oiiint" + <<"max"<<"min"<<"argmax"<<"argmin"<<"sup"<<"inf" + <<"liminf"<<"limsup"<<"lim"<<"max"<<"min"; +} + +JKQTMathText::MTlistNode::~MTlistNode() { + for (int i=0; igetTBR(currentEv.getFont(parent), "M", painter.device()); + + + double xnew=0; + bool wasBrace=false; + for (int i=0; igetSize(painter, currentEv, w1, bh, oh, sp); + //qDebug()<<"i="<getTypeName()<<" w1="<getTypeName()<<" w2="<getTypeName()<<" w1="<getTypeName()<<" w2="<get_operatorsubsuper_size_factor(); + double w1=0, w2=0, w3=0; + double oh1=0, oh2=0, oh3=0; + double bh1=0, bh2=0, bh3=0; + double sp1=0, sp2=0, sp3=0; + nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp1); + //qDebug()<<"sub_super: node: "<getTypeName()<<" w1="<getTypeName()<<" w2="<getTypeName()<<" w3="<overallHeight) overallHeight=oh; + if (bh>baselineHeight) { baselineHeight=bh; strikeoutPos=sp1; } + if (oh-bh>overallHeight-baselineHeight) { + overallHeight=baselineHeight+oh-bh; + } + + i++; + i++; + doDraw=false; + xnew+=w; + //qDebug()<<"### subsupop: sub+super2 overallHeight="<overallHeight) overallHeight=oh; + if (bh>baselineHeight) { baselineHeight=bh; strikeoutPos=sp1; } + if (oh-bh>overallHeight-baselineHeight) { + overallHeight=baselineHeight+oh-bh; + } + + i++; + i++; + doDraw=false; + xnew+=w; + //qDebug()<<"### subsupop: sub+super";*/ + } else if (subn) { // is this subscript? + MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_operatorsubsuper_size_factor(); + double w1=0, w2=0; + double oh1=0, oh2=0; + double bh1=0, bh2=0; + double sp1=0, sp2=0;//, sp3=0; + nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp1); + subn->get_child()->getSize(painter, ev, w2, bh2, oh2, sp2); + //double d1=oh1-bh1; + //double d2=oh2-bh2; + + double oh=oh1+oh2; + double sh=oh1-bh1+oh2*1.1; + if (oh>overallHeight) overallHeight=oh; + if (bh1>baselineHeight) baselineHeight=bh1; + if (sh>overallHeight-baselineHeight) { + overallHeight=baselineHeight+sh; + } + double w=qMax(w1, w2)+fm.width(" "); + i++; + doDraw=false; + xnew+=w; + //qDebug()<<"### subsupop: sub overallHeight="<get_super_shift_factor()*tbr.height()+(oh-bh);//((overallHeight-baselineHeight)+(oh-bh)); + if (wasBrace) { + shift=baselineHeight-parent->get_super_shift_factor()*tbr.height()+(oh-bh); + } + //qDebug()<<"+++ super: bh="<baselineHeight) { + double lheight=overallHeight-baselineHeight; + baselineHeight=shift+bh; + overallHeight=baselineHeight+lheight; + } + //qDebug()<<"### super"; + //qDebug()<<"### subsupop: super overallHeight="<overallHeight-baselineHeight) { + overallHeight=baselineHeight+shift+(oh-bh); + } + //qDebug()<<"### sub"; + //qDebug()<<"### subsupop: sub overallHeight="<getTBR(currentEv.getFont(parent), "M", painter.device()); + bool wasBrace=false; + for (int i=0; i(nodes[i]); + // if we find a subscript/superscript node we check whether the next node is super/subscript + // if so, we typeset them at the same x-psotion, so sub/superscripts appear correctly + if (dynamic_cast(nodes[i])) { + double ccwidth=0, ccbaselineHeight=0, ccoverallHeight=0, ccstrieoutPos=0; + nodes[i]->getSize(painter, currentEv, ccwidth, ccbaselineHeight, ccoverallHeight, ccstrieoutPos); + + if (i+1(nodes[i+1])) { // is this subscript? + + double shift=-parent->get_super_shift_factor()*tbr.height(); + if (wasBrace) { + shift=-cbaselineHeight+parent->get_super_shift_factor()*tbr.height(); + } + //painter.setPen(QPen("red")); + //painter.drawEllipse(xnew-4,ynew+shift-(ccoverallHeight-ccbaselineHeight)-4,8,8); + double xnew1=nodes[i]->draw(painter, xnew, ynew+shift-(ccoverallHeight-ccbaselineHeight), currentEv); + i++; + //painter.setPen(QPen("magenta")); + //painter.drawEllipse(xnew-4,ynew-4,8,8); + double xnew2=nodes[i]->draw(painter, xnew, ynew, currentEv); + //i++; + xnew=qMax(xnew1, xnew2); + doDraw=false; + } + } + } else if (dynamic_cast(nodes[i])) { + if (i+1(nodes[i+1])) { // is this subscript? + //painter.setPen(QPen("magenta")); + //painter.drawEllipse(xnew-4,ynew-4,8,8); + double xnew1=nodes[i]->draw(painter, xnew, ynew, currentEv); + i++; + double ccwidth=0, ccbaselineHeight=0, ccoverallHeight=0, ccstrieoutPos=0; + nodes[i]->getSize(painter, currentEv, ccwidth, ccbaselineHeight, ccoverallHeight, ccstrieoutPos); + //QRectF tbr=fm.tightBoundingRect("M"); + double shift=-parent->get_super_shift_factor()*tbr.height(); + if (wasBrace) { + shift=-cbaselineHeight+parent->get_super_shift_factor()*tbr.height(); + } + //painter.setPen(QPen("red")); + //painter.drawEllipse(xnew-4,ynew+shift-(ccoverallHeight-ccbaselineHeight)-4,8,8); + double xnew2=nodes[i]->draw(painter, xnew, ynew+shift-(ccoverallHeight-ccbaselineHeight), currentEv); + //i++; + xnew=qMax(xnew1, xnew2); + doDraw=false; + } + } + } else { + if (smb) { + QString s=smb->get_symbolName(); + if (subsupOperations.contains(s)) { + MTsubscriptNode* subn=nullptr; + if (i+1(nodes[i+1]); + MTsuperscriptNode* supn=nullptr; + if (i+2(nodes[i+2]); + //std::cout<<"symbol ='"<get_operatorsubsuper_size_factor(); + double w1=0, w2=0, w3=0; + double oh1=0, oh2=0, oh3=0; + double bh1=0, bh2=0, bh3=0, sp; + nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp); + subn->get_child()->getSize(painter, ev, w2, bh2, oh2, sp); + supn->get_child()->getSize(painter, ev, w3, bh3, oh3, sp); + double d1=oh1-bh1; + //double d2=oh2-bh2; + double d3=oh3-bh3; + + double w=qMax(qMax(w1, w2), w3); + //double xnew1= + double xn1=nodes[i]->draw(painter, xnew+(w-w1)/2.0, ynew, currentEv); + i++; + //double xnew2= + double xn2=subn->get_child()->draw(painter, xnew+(w-w2)/2.0, ynew+bh2+d1, ev); + i++; + //double xnew3= + double xn3=supn->get_child()->draw(painter, xnew+(w-w3)/2.0, ynew-bh1-d3-fm.xHeight()/4.0, ev); + doDraw=false; + xnew=qMax(qMax(xn1, xn2), xn3)+fm.width(" "); + } else if (subn) { // is this subscript and not superscript? + MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_operatorsubsuper_size_factor(); + double w1=0, w2=0; + double oh1=0, oh2=0; + double bh1=0, bh2=0, sp=0; + nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp); + subn->get_child()->getSize(painter, ev, w2, bh2, oh2, sp); + double d1=oh1-bh1; + //double d2=oh2-bh2; + + double w=qMax(w1, w2); + //double xnew1= + double xn2=nodes[i]->draw(painter, xnew+(w-w1)/2.0, ynew, currentEv); + i++; + //double xnew2= + double xn1=subn->get_child()->draw(painter, xnew+(w-w2)/2.0, ynew+bh2+d1, ev)+fm.width(" "); + doDraw=false; + //xnew+=w; + xnew=qMax(xn1, xn2); + } else if (supn) { // is this subscript and superscript? + MTenvironment ev=currentEv; + ev.fontSize=ev.fontSize*parent->get_operatorsubsuper_size_factor(); + double w1=0, w3=0; + double oh1=0, oh3=0; + double bh1=0, bh3=0, sp; + nodes[i]->getSize(painter, currentEv, w1, bh1, oh1, sp); + supn->get_child()->getSize(painter, ev, w3, bh3, oh3, sp); + //double d1=oh1-bh1; + //double d2=oh2-bh2; + double d3=oh3-bh3; + + double w=qMax(w1, w3); + //double xnew1= + double xn1=nodes[i]->draw(painter, xnew+(w-w1)/2.0, ynew, currentEv); + i++; + //double xnew3= + double xn3=supn->get_child()->draw(painter, xnew+(w-w3)/2.0, ynew-bh1-d3-fm.xHeight()/4.0, ev); + doDraw=false; + xnew=qMax(xn1, xn3)+fm.width(" "); + } + } + } + + nodes[i]->getSize(painter, currentEv, cwidth, cbaselineHeight, coverallHeight, cstrieoutPos); + } + + if (i(nodes[i])) { // is this superscript? + double ccwidth=0, ccbaselineHeight=0, ccoverallHeight=0, ccstrieoutPos=0; + nodes[i]->getSize(painter, currentEv, ccwidth, ccbaselineHeight, ccoverallHeight, ccstrieoutPos); + //QRectF tbr=fm.tightBoundingRect("M"); + double shift=-parent->get_super_shift_factor()*tbr.height(); + if (wasBrace) { + shift=-cbaselineHeight+parent->get_super_shift_factor()*tbr.height(); + } + //painter.setPen(QPen("red")); + //painter.drawEllipse(xnew-4,ynew+shift-(ccoverallHeight-ccbaselineHeight)-4,8,8); + xnew=nodes[i]->draw(painter, xnew, ynew+shift-(ccoverallHeight-ccbaselineHeight), currentEv); + } else { + xnew=nodes[i]->draw(painter, xnew, ynew, currentEv); + } + } + wasBrace=dynamic_cast(nodes[i]); + } + return xnew; +} + +bool JKQTMathText::MTlistNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { + bool ok=true; + for (int i=0; itoHtml(h, currentEv, defaultEv); + html=html+h; + } + return ok; +} + +void JKQTMathText::MTlistNode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; + for (int i=0; iset_drawBoxes(draw); + } +} + + + + + +JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& name, bool addWhitespace): + JKQTMathText::MTnode(parent) +{ + double mathFontFactor=1.8; + symbol = ""; + symbolName=name; + fontFactor=1.0; + bold=0; + italic=-1; + yfactor=0; + QString n=name; + drawBar=false; + font=MTSFdefault; + heightIsAscent=false; + exactAscent=false; + extendWidthInMathmode=false; + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // statische Lookup-Tabellen vorbereiten + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + static QStringList extendWInMM; + if (extendWInMM.isEmpty()) { + extendWInMM <<"ll"<<"gg"<<"leq"<<"geq"<<"leftrightarrow"<<"leftarrow"<<"rightarrow"<<"to"<<"uparrow"<<"downarrow"<<"updownarrow"<<"Leftrightarrow" + <<"iff"<<"Leftarrow"<<"Rightarrow"<<"Uparrow"<<"Downarrow"<<"Updownarrow"<<"pm"<<"mp"<<"nexists"<<"ni"<<"notni"<<"circ"<<"sim"<<"emptyset"<<"odot"<<"ominus" + <<"subsetnot"<<"bot"<<"leftharpoonup"<<"rightharpoonup"<<"upharpoonleft"<<"downharpoonleft"<<"leftrightharpoon"<<"rightleftharpoon"<<"coprod"<<"leftharpoondown" + <<"rightharpoondown"<<"upharpoonright"<<"downharpoonright"<<"nwarrow"<<"nearrow"<<"searrow"<<"swarrow"<<"mapsto"<<"div"<<"multimap"<<"maporiginal"<<"mapimage" + <<"times"<<"propto"<<"bullet"<<"neq"<<"ne"<<"equiv"<<"approx"<<"otimes"<<"oplus"<<"oslash"<<"cap"<<"land"<<"cup"<<"lor"<<"supset"<<"supseteq"<<"supsetnot" + <<"subset"<<"subseteq"<<"in"<<"notin"<<"cdot"<<"wedge"<<"vee"<<"cong"<<"bot"<<"mid"; + } + + if (extendWInMM.contains(n)) { + extendWidthInMathmode=true; + } + + + static QHash simpleTranslations; + if (simpleTranslations.isEmpty()) { + simpleTranslations.insert("", " "); + simpleTranslations.insert("sin", "sin"); + simpleTranslations.insert("cos", "cos"); + simpleTranslations.insert("tan", "tan"); + simpleTranslations.insert("sinh", "sinh"); + simpleTranslations.insert("cosh", "cosh"); + simpleTranslations.insert("tanh", "tanh"); + simpleTranslations.insert("atan", "atan"); + simpleTranslations.insert("acos", "acos"); + simpleTranslations.insert("asin", "asin"); + simpleTranslations.insert("arcsin", "arcsin"); + simpleTranslations.insert("arccos", "arccos"); + simpleTranslations.insert("arctan", "arctan"); + simpleTranslations.insert("degree", QLatin1String("\xB0")); + simpleTranslations.insert("ii", "i"); + simpleTranslations.insert("dd", "d"); + simpleTranslations.insert("exp", "exp"); + simpleTranslations.insert("log", "log"); + simpleTranslations.insert("ln", "ln"); + simpleTranslations.insert("ld", "ld"); + simpleTranslations.insert("lb", "lb"); + simpleTranslations.insert("argmin", "argmin"); + simpleTranslations.insert("argmax", "argmax"); + simpleTranslations.insert("max", "max"); + simpleTranslations.insert("min", "min"); + simpleTranslations.insert("sec", "sec"); + simpleTranslations.insert("gcd", "gcd"); + simpleTranslations.insert("hom", "hom"); + simpleTranslations.insert("ker", "ker"); + simpleTranslations.insert("dim", "dim"); + simpleTranslations.insert("cot", "cot"); + simpleTranslations.insert("arg", "arg"); + simpleTranslations.insert("det", "det"); + simpleTranslations.insert("deg", "deg"); + simpleTranslations.insert("Pr", "Pr"); + simpleTranslations.insert("coth", "coth"); + } + + + static QHash simpleTranslations_heightIsAscent; + if (simpleTranslations_heightIsAscent.isEmpty()) { + simpleTranslations_heightIsAscent.insert("erf", "erf"); + simpleTranslations_heightIsAscent.insert("min", "min"); + simpleTranslations_heightIsAscent.insert("max", "max"); + simpleTranslations_heightIsAscent.insert("inf", "inf"); + simpleTranslations_heightIsAscent.insert("sup", "sup"); + simpleTranslations_heightIsAscent.insert("liminf", "liminf"); + simpleTranslations_heightIsAscent.insert("limsup", "limsup"); + simpleTranslations_heightIsAscent.insert("lim", "lim"); + } + + static QHash winSymbolGreek; + if (winSymbolGreek.isEmpty()) { + winSymbolGreek.insert("alpha", "a"); + winSymbolGreek.insert("beta", "b"); + winSymbolGreek.insert("gamma", "g"); + winSymbolGreek.insert("delta", "d"); + winSymbolGreek.insert("epsilon", "e"); + winSymbolGreek.insert("varepsilon", "e"); + winSymbolGreek.insert("zeta", "z"); + winSymbolGreek.insert("eta", "h"); + winSymbolGreek.insert("theta", "q"); + winSymbolGreek.insert("vartheta", "J"); + winSymbolGreek.insert("iota", "i"); + winSymbolGreek.insert("kappa", "k"); + winSymbolGreek.insert("lambda", "l"); + winSymbolGreek.insert("mu", "m"); + winSymbolGreek.insert("nu", "n"); + winSymbolGreek.insert("xi", "x"); + winSymbolGreek.insert("pi", "p"); + winSymbolGreek.insert("varpi", "v"); + winSymbolGreek.insert("rho", "r"); + winSymbolGreek.insert("sigma", "s"); + winSymbolGreek.insert("varsigma", "V"); + winSymbolGreek.insert("tau", "t"); + winSymbolGreek.insert("upsilon", "u"); + winSymbolGreek.insert("phi", "f"); + winSymbolGreek.insert("varphi", "j"); + winSymbolGreek.insert("chi", "c"); + winSymbolGreek.insert("psi", "y"); + winSymbolGreek.insert("omega", "w"); + winSymbolGreek.insert("Gamma", "G"); + winSymbolGreek.insert("Delta", "D"); + winSymbolGreek.insert("Theta", "Q"); + winSymbolGreek.insert("Lambda", "L"); + winSymbolGreek.insert("Omega", "W"); + winSymbolGreek.insert("Xi", "X"); + winSymbolGreek.insert("Pi", "P"); + winSymbolGreek.insert("Sigma", "S"); + winSymbolGreek.insert("Upsilon", ""); + winSymbolGreek.insert("Phi", "F"); + winSymbolGreek.insert("Psi", "Y"); + } + + static QHash winSymbolSymbol; + if (winSymbolSymbol.isEmpty()) { + winSymbolSymbol.insert("leftrightarrow", QChar(0xAB)); + winSymbolSymbol.insert("leftarrow", QChar(0xAC)); + winSymbolSymbol.insert("rightarrow", QChar(0xAE)); + winSymbolSymbol.insert("to", QChar(0xAE)); + winSymbolSymbol.insert("uparrow", QChar(0xAD)); + winSymbolSymbol.insert("downarrow", QChar(0xAF)); + winSymbolSymbol.insert("Leftrightarrow", QChar(0xDB)); + winSymbolSymbol.insert("iff", QChar(0xDB)); + winSymbolSymbol.insert("Leftarrow", QChar(0xDC)); + winSymbolSymbol.insert("Rightarrow", QChar(0xDE)); + winSymbolSymbol.insert("Uparrow", QChar(0xDD)); + winSymbolSymbol.insert("Downarrow", QChar(0xFF)); + winSymbolSymbol.insert("pm", QChar(0xB1)); + winSymbolSymbol.insert("leq", QChar(0xA3)); + winSymbolSymbol.insert("geq", QChar(0xB3)); + winSymbolSymbol.insert("times", QChar(0xB4)); + winSymbolSymbol.insert("propto", QChar(0xB5)); + winSymbolSymbol.insert("partial", QChar(0xB6)); + winSymbolSymbol.insert("bullet", QChar(0xB7)); + winSymbolSymbol.insert("neq", QChar(0xB9)); + winSymbolSymbol.insert("ne", QChar(0xB9)); + winSymbolSymbol.insert("equiv", QChar(0xBA)); + winSymbolSymbol.insert("approx", QChar(0xBB)); + winSymbolSymbol.insert("ellipsis", QChar(0xBC)); + winSymbolSymbol.insert("Im", QChar(0xC1)); + winSymbolSymbol.insert("Re", QChar(0xC2)); + winSymbolSymbol.insert("otimes", QChar(0xC4)); + winSymbolSymbol.insert("oplus", QChar(0xC5)); + winSymbolSymbol.insert("oslash", QChar(0xC6)); + winSymbolSymbol.insert("cap", QChar(0xC7)); + winSymbolSymbol.insert("land", QChar(0xC7)); + winSymbolSymbol.insert("cup", QChar(0xC8)); + winSymbolSymbol.insert("lor", QChar(0xC8)); + winSymbolSymbol.insert("supset", QChar(0xC9)); + winSymbolSymbol.insert("supseteq", QChar(0xCA)); + winSymbolSymbol.insert("supsetnot", QChar(0xCB)); + winSymbolSymbol.insert("subset", QChar(0xCC)); + winSymbolSymbol.insert("subseteq", QChar(0xCD)); + winSymbolSymbol.insert("in", QChar(0xCE)); + winSymbolSymbol.insert("notin", QChar(0xCF)); + winSymbolSymbol.insert("angle", QChar(0xD0)); + winSymbolSymbol.insert("nabla", QChar(0xD1)); + winSymbolSymbol.insert("copyright", QChar(0xD3)); + winSymbolSymbol.insert("registered", QChar(0xD2)); + winSymbolSymbol.insert("trademark", QChar(0xD4)); + winSymbolSymbol.insert("cdot", QChar(0xD7)); + winSymbolSymbol.insert("neg", QChar(0xD8)); + winSymbolSymbol.insert("wedge", QChar(0xD9)); + winSymbolSymbol.insert("vee", QChar(0xDA)); + winSymbolSymbol.insert("diamond", QChar(0xE0)); + winSymbolSymbol.insert("langle", QChar(0xE1)); + winSymbolSymbol.insert("rangle", QChar(0xF1)); + winSymbolSymbol.insert("forall", QChar(0x22)); + winSymbolSymbol.insert("exists", QChar(0x24)); + winSymbolSymbol.insert("cong", QChar(0x40)); + winSymbolSymbol.insert("bot", QChar(0x5E)); + winSymbolSymbol.insert("ll", "<<"); + winSymbolSymbol.insert("gg", ">>"); + winSymbolSymbol.insert("Alef", QChar(0xC0)); + winSymbolSymbol.insert("alef", QChar(0xC0)); + winSymbolSymbol.insert("tilde", "~"); + winSymbolSymbol.insert("emptyset", QChar(0xC6)); + winSymbolSymbol.insert("varnothing", QChar(0xC6)); + winSymbolSymbol.insert("lceil", QChar(0xE9)); + winSymbolSymbol.insert("rceil", QChar(0xF9)); + winSymbolSymbol.insert("lfloor", QChar(0xEB)); + winSymbolSymbol.insert("rfloor", QChar(0xFB)); + winSymbolSymbol.insert("subsetnot", QChar(0xCB)); + winSymbolSymbol.insert("DC", "="); + winSymbolSymbol.insert("mid", "|"); + winSymbolSymbol.insert("cdots", QString(3, QChar(0xD7))); + winSymbolSymbol.insert("dots", QChar(0xDC)); + winSymbolSymbol.insert("ldots", QChar(0xDC)); + winSymbolSymbol.insert("cent", "c"); + } + + + static QHash unicodeGreek; + if (unicodeGreek.isEmpty()) { + unicodeGreek.insert("alpha", QChar(0x3B1)); + unicodeGreek.insert("beta", QChar(0x3B2)); + unicodeGreek.insert("gamma", QChar(0x3B3)); + unicodeGreek.insert("delta", QChar(0x3B4)); + unicodeGreek.insert("epsilon", QChar(0x3B5)); + unicodeGreek.insert("varepsilon", QChar(0x3B5)); + unicodeGreek.insert("zeta", QChar(0x3B6)); + unicodeGreek.insert("eta", QChar(0x3B7)); + unicodeGreek.insert("theta", QChar(0x3B8)); + unicodeGreek.insert("vartheta", QChar(0x3D1)); + unicodeGreek.insert("iota", QChar(0x3B9)); + unicodeGreek.insert("kappa", QChar(0x3BA)); + unicodeGreek.insert("lambda", QChar(0x3BB)); + unicodeGreek.insert("mu", QChar(0x3BC)); + unicodeGreek.insert("nu", QChar(0x3BD)); + unicodeGreek.insert("xi", QChar(0x3BE)); + unicodeGreek.insert("pi", QChar(0x3C0)); + unicodeGreek.insert("varpi", QChar(0x3D6)); + unicodeGreek.insert("rho", QChar(0x3C1)); + unicodeGreek.insert("varrho", QChar(0x3F1)); + unicodeGreek.insert("sigma", QChar(0x3C3)); + unicodeGreek.insert("varsigma", QChar(0x3C2)); + unicodeGreek.insert("tau", QChar(0x3C4)); + unicodeGreek.insert("upsilon", QChar(0x3C5)); + unicodeGreek.insert("phi", QChar(0x3D5)); + unicodeGreek.insert("varphi", QChar(0x3C6)); + unicodeGreek.insert("chi", QChar(0x3C7)); + unicodeGreek.insert("psi", QChar(0x3C8)); + unicodeGreek.insert("omega", QChar(0x3C9)); + unicodeGreek.insert("Omega", QChar(0x3A9)); + unicodeGreek.insert("Gamma", QChar(0x393)); + unicodeGreek.insert("Delta", QChar(0x394)); + unicodeGreek.insert("Theta", QChar(0x398)); + unicodeGreek.insert("Lambda", QChar(0x39B)); + unicodeGreek.insert("Xi", QChar(0x39E)); + unicodeGreek.insert("Pi", QChar(0x3A0)); + unicodeGreek.insert("Sigma", QChar(0x3A3)); + unicodeGreek.insert("Upsilon", QChar(0x3A5)); + unicodeGreek.insert("Phi", QChar(0x3A6)); + unicodeGreek.insert("Psi", QChar(0x3A8)); + } + + static QHash unicodeSymbol; + if (unicodeSymbol.isEmpty()) { + unicodeSymbol.insert("leftrightarrow", QChar(0x2194)); + unicodeSymbol.insert("leftarrow", QChar(0x2190)); + unicodeSymbol.insert("rightarrow", QChar(0x2192)); + unicodeSymbol.insert("to", QChar(0x2192)); + unicodeSymbol.insert("uparrow", QChar(0x2191)); + unicodeSymbol.insert("downarrow", QChar(0x2193)); + unicodeSymbol.insert("updownarrow", QChar(0x2195)); + unicodeSymbol.insert("Leftrightarrow", QChar(0x21D4)); + unicodeSymbol.insert("iff", QChar(0x21D4)); + unicodeSymbol.insert("Leftarrow", QChar(0x21D0)); + unicodeSymbol.insert("Rightarrow", QChar(0x21D2)); + unicodeSymbol.insert("Uparrow", QChar(0x21D1)); + unicodeSymbol.insert("Downarrow", QChar(0x21D3)); + unicodeSymbol.insert("Updownarrow", QChar(0x21D5)); + unicodeSymbol.insert("pm", QChar(0x00B1)); + unicodeSymbol.insert("mp", QChar(0x2213)); + unicodeSymbol.insert("leq", QChar(0x2264)); + unicodeSymbol.insert("geq", QChar(0x2265)); + unicodeSymbol.insert("ll", QChar(0x226A)); + unicodeSymbol.insert("gg", QChar(0x226B)); + unicodeSymbol.insert("hbar", QChar(0x210F)); + unicodeSymbol.insert("euro", QChar(0x20AC)); + unicodeSymbol.insert("Angstrom", QChar(0x212B)); + unicodeSymbol.insert("Alef", QChar(0x2135)); + unicodeSymbol.insert("Bet", QChar(0x2136)); + unicodeSymbol.insert("Gimel", QChar(0x2137)); + unicodeSymbol.insert("Dalet", QChar(0x2138)); + unicodeSymbol.insert("alef", QChar(0x2135)); + unicodeSymbol.insert("bet", QChar(0x2136)); + unicodeSymbol.insert("gimel", QChar(0x2137)); + unicodeSymbol.insert("dalet", QChar(0x2138)); + unicodeSymbol.insert("nexists", QChar(0x2204)); + unicodeSymbol.insert("ni", QChar(0x220B)); + unicodeSymbol.insert("notni", QChar(0x220C)); + unicodeSymbol.insert("circ", QChar(0x2218)); + unicodeSymbol.insert("tilde", QChar(0x223C)); + unicodeSymbol.insert("emptyset", QChar(0x2300)); + unicodeSymbol.insert("varnothing", QChar(0x2300)); + unicodeSymbol.insert("odot", QChar(0x2299)); + unicodeSymbol.insert("ominus", QChar(0x2296)); + unicodeSymbol.insert("lceil", QChar(0x2308)); + unicodeSymbol.insert("rceil", QChar(0x2309)); + unicodeSymbol.insert("lfloor", QChar(0x230A)); + unicodeSymbol.insert("rfloor", QChar(0x230B)); + unicodeSymbol.insert("subsetnot", QChar(0x2284)); + unicodeSymbol.insert("DC", QChar(0x2393)); + unicodeSymbol.insert("bot", QChar(0x22A4)); + unicodeSymbol.insert("mid", QChar(0xFF5C)); + unicodeSymbol.insert("cdots", QString(QChar(0x00B7)) + QString(QChar(0x00B7)) + QString(QChar(0x00B7))); + unicodeSymbol.insert("vdots", QChar(0x22EE)); + unicodeSymbol.insert("iddots", QChar(0x22F0)); + unicodeSymbol.insert("ddots", QChar(0x22F1)); + unicodeSymbol.insert("dots", "..."); + unicodeSymbol.insert("ldots", "..."); + unicodeSymbol.insert("perthousand", QChar(0x2030)); + unicodeSymbol.insert("leftharpoonup", QChar(0x21BC)); + unicodeSymbol.insert("rightharpoonup", QChar(0x21C0)); + unicodeSymbol.insert("upharpoonleft", QChar(0x21BF)); + unicodeSymbol.insert("downharpoonleft", QChar(0x21C3)); + unicodeSymbol.insert("leftrightharpoon", QChar(0x21CB)); + unicodeSymbol.insert("rightleftharpoon", QChar(0x21CC)); + unicodeSymbol.insert("leftharpoondown", QChar(0x21BD)); + unicodeSymbol.insert("rightharpoondown", QChar(0x21C1)); + unicodeSymbol.insert("upharpoonright", QChar(0x21BE)); + unicodeSymbol.insert("downharpoonright", QChar(0x21C2)); + unicodeSymbol.insert("nwarrow", QChar(0x2196)); + unicodeSymbol.insert("nearrow", QChar(0x2197)); + unicodeSymbol.insert("searrow", QChar(0x2198)); + unicodeSymbol.insert("swarrow", QChar(0x2199)); + unicodeSymbol.insert("mapsto", QChar(0x21A6)); + unicodeSymbol.insert("cent", QChar(0x00A2)); + unicodeSymbol.insert("pound", QChar(0x00A3)); + unicodeSymbol.insert("yen", QChar(0x00A5)); + unicodeSymbol.insert("div", QChar(0x00F7)); + unicodeSymbol.insert("multimap", QChar(0x22B8)); + unicodeSymbol.insert("maporiginal", QChar(0x22B6)); + unicodeSymbol.insert("mapimage", QChar(0x22B7)); + unicodeSymbol.insert("benzene", QChar(0x232C)); + unicodeSymbol.insert("times", QChar(0x2A2F)); + unicodeSymbol.insert("propto", QChar(0x221D)); + unicodeSymbol.insert("partial", QChar(0x2202)); + unicodeSymbol.insert("bullet", QChar(0x2219)); + unicodeSymbol.insert("neq", QChar(0x2260)); + unicodeSymbol.insert("ne", QChar(0x2260)); + unicodeSymbol.insert("equiv", QChar(0x2261)); + unicodeSymbol.insert("approx", QChar(0x2245)); + unicodeSymbol.insert("ellipsis", QChar(0x2026)); + unicodeSymbol.insert("Im", QChar(0x2111)); + unicodeSymbol.insert("Re", QChar(0x211C)); + unicodeSymbol.insert("otimes", QChar(0x2297)); + unicodeSymbol.insert("oplus", QChar(0x2295)); + unicodeSymbol.insert("oslash", QChar(0x2298)); + unicodeSymbol.insert("cap", QChar(0x2229)); + unicodeSymbol.insert("land", QChar(0x2229)); + unicodeSymbol.insert("cup", QChar(0x222A)); + unicodeSymbol.insert("lor", QChar(0x222A)); + unicodeSymbol.insert("supset", QChar(0x2283)); + unicodeSymbol.insert("supseteq", QChar(0x2286)); + unicodeSymbol.insert("supsetnot", QChar(0x2285)); + unicodeSymbol.insert("subset", QChar(0x2282)); + unicodeSymbol.insert("subseteq", QChar(0x2286)); + unicodeSymbol.insert("in", QChar(0x2208)); + unicodeSymbol.insert("notin", QChar(0x2209)); + unicodeSymbol.insert("angle", QChar(0x2221)); + unicodeSymbol.insert("nabla", QChar(0x2207)); + unicodeSymbol.insert("copyright", QChar(0x00A9)); + unicodeSymbol.insert("registered", QChar(0x00AE)); + unicodeSymbol.insert("trademark", QChar(0x2122)); + unicodeSymbol.insert("cdot", QChar(0x00B7)); + unicodeSymbol.insert("neg", QChar(0x00AC)); + unicodeSymbol.insert("wedge", QChar(0x2227)); + unicodeSymbol.insert("vee", QChar(0x2228)); + unicodeSymbol.insert("diamond", QChar(0xE0)); + unicodeSymbol.insert("langle", QChar(0x2329)); + unicodeSymbol.insert("rangle", QChar(0x232A)); + unicodeSymbol.insert("infty", QChar(0x221E)); + unicodeSymbol.insert("forall", QChar(0x2200)); + unicodeSymbol.insert("exists", QChar(0x2203)); + unicodeSymbol.insert("cong", QChar(0x2245)); + unicodeSymbol.insert("bot", QChar(0x22A5)); + + } + + static QHash latexSimpleSymbol; + if (latexSimpleSymbol.isEmpty()) { + latexSimpleSymbol.insert("_", "_"); + latexSimpleSymbol.insert("}", "}"); + latexSimpleSymbol.insert("{", "{"); + latexSimpleSymbol.insert("$", "$"); + latexSimpleSymbol.insert("%", "%"); + latexSimpleSymbol.insert("&", "&"); + latexSimpleSymbol.insert("#", "#"); + latexSimpleSymbol.insert("ast", "*"); + latexSimpleSymbol.insert("glq", QChar(0x27)); + latexSimpleSymbol.insert("grq", QChar(0x60)); + latexSimpleSymbol.insert("glqq", QChar(0x5C)); + latexSimpleSymbol.insert("grqq", "\""); + } + + static QHash latexGreek; + if (latexGreek.isEmpty()) { + latexGreek.insert("alpha", QChar(0xAE)); + latexGreek.insert("beta", QChar(0xAF)); + latexGreek.insert("gamma", QChar(0xB0)); + latexGreek.insert("delta", QChar(0xB1)); + latexGreek.insert("epsilon", QChar(0x22)); + latexGreek.insert("varepsilon", QChar(0xB2)); + latexGreek.insert("zeta", QChar(0xB3)); + latexGreek.insert("eta", QChar(0xB4)); + latexGreek.insert("theta", QChar(0xB5)); + latexGreek.insert("vartheta", QChar(0x23)); + latexGreek.insert("iota", QChar(0xB6)); + latexGreek.insert("kappa", QChar(0xB7)); + latexGreek.insert("lambda", QChar(0xB8)); + latexGreek.insert("mu", QChar(0xB9)); + latexGreek.insert("nu", QChar(0xBA)); + latexGreek.insert("xi", QChar(0xBB)); + latexGreek.insert("pi", QChar(0xBC)); + latexGreek.insert("varpi", QChar(0x24)); + latexGreek.insert("rho", QChar(0xBD)); + latexGreek.insert("varrho", QChar(0x25)); + latexGreek.insert("sigma", QChar(0xBE)); + latexGreek.insert("varsigma", QChar(0x26)); + latexGreek.insert("tau", QChar(0xBF)); + latexGreek.insert("upsilon", QChar(0xC0)); + latexGreek.insert("phi", QChar(0xC1)); + latexGreek.insert("varphi", QChar(0x27)); + latexGreek.insert("chi", QChar(0xC2)); + latexGreek.insert("psi", QChar(0xC3)); + latexGreek.insert("omega", QChar(0x21)); + latexGreek.insert("Gamma", QChar(0xA1)); + latexGreek.insert("Delta", QChar(0xA2)); + latexGreek.insert("Theta", QChar(0xA3)); + latexGreek.insert("Lambda", QChar(0xA4)); + latexGreek.insert("Xi", QChar(0xA5)); + latexGreek.insert("Pi", QChar(0xA6)); + latexGreek.insert("Sigma", QChar(0xA7)); + latexGreek.insert("Upsilon", QChar(0xA8)); + latexGreek.insert("Phi", QChar(0xA9)); + latexGreek.insert("Psi", QChar(0xAA)); + latexGreek.insert("leftharpoonup", QChar(0x28)); + latexGreek.insert("rightharpoonup", QChar(0x2A)); + latexGreek.insert("leftharpoondown", QChar(0x29)); + latexGreek.insert("rightharpoondown", QChar(0x2B)); + latexGreek.insert("neg", QChar(0xAC)); + latexGreek.insert("star", QChar(0x3F)); + } + + static QHash latexSymbol; + if (latexSymbol.isEmpty()) { + latexSymbol.insert("leftrightarrow", QChar(0x24)); + latexSymbol.insert("leftarrow", QChar(0xc3)); + latexSymbol.insert("rightarrow", QChar(0x21)); + latexSymbol.insert("to", QChar(0x21)); + latexSymbol.insert("uparrow", QChar(0x22)); + latexSymbol.insert("downarrow", QChar(0x23)); + latexSymbol.insert("updownarrow", QChar(0x6c)); + latexSymbol.insert("Leftrightarrow", QChar(0x2c)); + latexSymbol.insert("iff", QChar(0x2c)); + latexSymbol.insert("Leftarrow", QChar(0x28)); + latexSymbol.insert("Rightarrow", QChar(0x29)); + latexSymbol.insert("Uparrow", QChar(0x2a)); + latexSymbol.insert("Downarrow", QChar(0x2b)); + latexSymbol.insert("Updownarrow", QChar(0x6d)); + latexSymbol.insert("pm", QChar(0xa7)); + latexSymbol.insert("mp", QChar(0xa8)); + latexSymbol.insert("leq", QChar(0xb7)); + latexSymbol.insert("geq", QChar(0xb8)); + latexSymbol.insert("ll", QChar(0xbf)); + latexSymbol.insert("gg", QChar(0xc0)); + latexSymbol.insert("Alef", QChar(0x40)); + latexSymbol.insert("alef", QChar(0x40)); + latexSymbol.insert("ni", QChar(0x33)); + latexSymbol.insert("circ", QChar(0xb1)); + latexSymbol.insert("tilde", QChar(0xbb)); + latexSymbol.insert("emptyset", QChar(0x3b)); + latexSymbol.insert("odot", QChar(0xaf)); + latexSymbol.insert("ominus", QChar(0xaa)); + latexSymbol.insert("odiv", QChar(0xae)); + latexSymbol.insert("oplus", QChar(0xa9)); + latexSymbol.insert("lceil", QChar(0x64)); + latexSymbol.insert("rceil", QChar(0x65)); + latexSymbol.insert("lfloor", QChar(0x62)); + latexSymbol.insert("rfloor", QChar(0x63)); + latexSymbol.insert("bot", QChar(0x3f)); + latexSymbol.insert("cdots", QString(3, QChar(0xA2))); + latexSymbol.insert("dots", "..."); + latexSymbol.insert("nwarrow", QChar(0x2d)); + latexSymbol.insert("nearrow", QChar(0x25)); + latexSymbol.insert("searrow", QChar(0x26)); + latexSymbol.insert("swarrow", QChar(0x2e)); + latexSymbol.insert("div", QChar(0xa5)); + latexSymbol.insert("times", QChar(0xa3)); + latexSymbol.insert("propto", QChar(0x2f)); + latexSymbol.insert("bullet", QChar(0x2b)); + latexSymbol.insert("equiv", QChar(0xb4)); + latexSymbol.insert("approx", QChar(0xbc)); + latexSymbol.insert("ellipsis", "..."); + latexSymbol.insert("Im", QChar(0x3D)); + latexSymbol.insert("Re", QChar(0x3C)); + latexSymbol.insert("oplus", QChar(0xa9)); + latexSymbol.insert("oslash", QChar(0xae)); + latexSymbol.insert("cap", QChar(0x5c)); + latexSymbol.insert("cup", QChar(0x5b)); + latexSymbol.insert("land", QChar(0x5c)); + latexSymbol.insert("lor", QChar(0x5b)); + latexSymbol.insert("supset", QChar(0xbe)); + latexSymbol.insert("supseteq", QChar(0xb6)); + latexSymbol.insert("subset", QChar(0xbd)); + latexSymbol.insert("subseteq", QChar(0xb5)); + latexSymbol.insert("in", QChar(0x32)); + latexSymbol.insert("nabla", QChar(0x35)); + latexSymbol.insert("cdot", QChar(0xa2)); + latexSymbol.insert("wedge", QChar(0x5e)); + latexSymbol.insert("vee", QChar(0x5f)); + latexSymbol.insert("diamond", QChar(0xE0)); + latexSymbol.insert("langle", QChar(0x68)); + latexSymbol.insert("rangle", QChar(0x69)); + latexSymbol.insert("infty", QChar(0x31)); + latexSymbol.insert("forall", QChar(0x38)); + latexSymbol.insert("exists", QChar(0x39)); + latexSymbol.insert("cong", QChar(0xbb)); + latexSymbol.insert("mid", "|"); + + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + QHash::iterator itsimple = simpleTranslations.find(n); + if (itsimple!= simpleTranslations.end()) { + symbol=itsimple.value(); + } else { + QHash::iterator itsimplehia = simpleTranslations_heightIsAscent.find(n); + if (itsimplehia != simpleTranslations_heightIsAscent.end()) { + symbol = itsimplehia.value(); + heightIsAscent = true; + } else { + if (parent->getFontEncoding() == MTFEwinSymbol) { + // first we start with greek characters + font = MTSFgreek; + italic = -1; + QHash::iterator itgreek = winSymbolGreek.find(n); + if (itgreek!=winSymbolGreek.end()) { + symbol = itgreek.value(); + } else if (n == "sum") { symbol = "S"; fontFactor = mathFontFactor; heightIsAscent = true; exactAscent = true; } + else if (n == "prod") { symbol = "P"; fontFactor = mathFontFactor; heightIsAscent = true; exactAscent = true; } + else { + // now we set the symbols from the Symbol font + font = MTSFsymbol; + QHash::iterator itsymbol = winSymbolSymbol.find(n); + if (itsymbol!=winSymbolSymbol.end()) { + symbol = itsymbol.value(); + } else if (n == "int") { symbol = QChar(0xF2); fontFactor = mathFontFactor; yfactor = +0.1; } + else if (n == "bbC") { symbol = "C"; bold = +1; italic = -1; } + else if (n == "bbH") { symbol = "H"; bold = +1; italic = -1; } + else if (n == "bbN") { symbol = "N"; bold = +1; italic = -1; } + else if (n == "bbP") { symbol = "P"; bold = +1; italic = -1; } + else if (n == "bbQ") { symbol = "Q"; bold = +1; italic = -1; } + else if (n == "bbR") { symbol = "R"; bold = +1; italic = -1; } + else if (n == "bbZ") { symbol = "Z"; bold = +1; italic = -1; } + else if (n == "iint") { symbol = QString(2, QChar(0xF2)); fontFactor = mathFontFactor; yfactor = +0.1; } + else if (n == "iiint") { symbol = QString(3, QChar(0xF2)); fontFactor = mathFontFactor; yfactor = +0.1; } + else if (n == "bigcap") { symbol = QChar(0xC7); fontFactor = 2; } + else if (n == "bigcup") { symbol = QChar(0xC8); fontFactor = 2; } + else if (n == "bigvee") { symbol = QChar(0xDA); fontFactor = 2; } + else if (n == "bighat") { symbol = QChar(0xD9); fontFactor = 2; } + + else { // here are text mode symbols, i.e. bold and italic won't be touched + bold = -1; + italic = -1; + font = MTSFdefault; + if (n == "_") { symbol = "_"; bold = 0; italic = 0; } + else if (n == "}") { symbol = "}"; } + else if (n == "{") { symbol = "{"; } + else if (n == "hbar") { symbol = "h"; bold = 0; italic = 0; drawBar = true; } + else if (n == "euro") { symbol = ""; bold = 0; italic = 0; } + else if (n == "cent") { symbol = QChar(0xA2); bold = 0; italic = 0; } + else if (n == "pound") { symbol = QChar(0xA3); bold = 0; italic = 0; } + else if (n == "yen") { symbol = QChar(0xA5); bold = 0; italic = 0; } + else if (n == "div") { symbol = QChar(0xF7); bold = 0; italic = 0; } + else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } + //else if (n=="|") { symbol="||"; bold=0; italic=0; } + else if (n == "$") { symbol = "$"; bold = 0; italic = 0; } + else if (n == "%") { symbol = "%"; bold = 0; italic = 0; } + else if (n == "&") { symbol = "&"; bold = 0; italic = 0; } + else if (n == "#") { symbol = "#"; bold = 0; italic = 0; } + else if (n == "ast") { symbol = "*"; bold = 0; italic = 0; } + else if (n == "glq") { symbol = "'"; bold = 0; italic = 0; } + else if (n == "grq") { symbol = "'"; bold = 0; italic = 0; } + else if (n == "glqq") { symbol = "\""; bold = 0; italic = 0; } + else if (n == "grqq") { symbol = "\""; bold = 0; italic = 0; } + else if (n == "flq") { symbol = "<"; bold = 0; italic = 0; } + else if (n == "frq") { symbol = ">"; bold = 0; italic = 0; } + else if (n == "flqq") { symbol = ""; bold = 0; italic = 0; } + else if (n == "frqq") { symbol = ""; bold = 0; italic = 0; } + } + //else if (n=="") { symbol=QChar(); font=MTSFdefault; } + //else if (n=="") symbol=QChar(0x); + } + } + else if (parent->getFontEncoding() == MTFEunicode) { // use UNICODE encoding for special characters + // first we start with greek characters + font = MTSFdefault; //MTSFgreek; + //std::cout<<"encoding unicode\n"; + QHash::iterator itgreek = unicodeGreek.find(n); + if (itgreek!=unicodeGreek.end()) { + symbol = itgreek.value(); + } else { + // now we set the symbols from the Symbol font + font = MTSFsymbol; + QHash::iterator itsymbol = unicodeSymbol.find(n); + if (itsymbol!=unicodeSymbol.end()) { + symbol = itsymbol.value(); + } if (n == "sum") { symbol = QChar(0x2211); heightIsAscent = true; exactAscent = true; } + else if (n == "prod") { symbol = QChar(0x220F); heightIsAscent = true; exactAscent = true; } + else if (n == "bbC") { symbol = QChar(0x2102); italic = -1; } + else if (n == "bbH") { symbol = QChar(0x210D); italic = -1; } + else if (n == "bbN") { symbol = QChar(0x2115); italic = -1; } + else if (n == "bbP") { symbol = QChar(0x2119); italic = -1; } + else if (n == "bbQ") { symbol = QChar(0x211A); italic = -1; } + else if (n == "bbR") { symbol = QChar(0x211D); italic = -1; } + else if (n == "bbZ") { symbol = QChar(0x2124); italic = -1; } + else if (n == "iint") { symbol = QChar(0x222C); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } + else if (n == "iiint") { symbol = QChar(0x222D); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } + else if (n == "oint") { symbol = QChar(0x222E); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } + else if (n == "oiint") { symbol = QChar(0x222F); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } + else if (n == "oiiint") { symbol = QChar(0x2230); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } + else if (n == "coprod") { symbol = QChar(0x2210); heightIsAscent = true; exactAscent = true; } + else if (n == "bigcap") { symbol = QChar(0x22C2); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } + else if (n == "bigcup") { symbol = QChar(0x22C3); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } + else if (n == "bigvee") { symbol = QChar(0x22C1); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } + else if (n == "bighat") { symbol = QChar(0x22C0); heightIsAscent = true; exactAscent = true;; heightIsAscent = true; exactAscent = true; } + else if (n == "int") { symbol = QChar(0x222B); fontFactor = mathFontFactor; /*yfactor=+0.1;;*/ heightIsAscent = true; exactAscent = true; } + + else { // here are text mode symbols, i.e. bold and italic won't be touched + bold = -1; + italic = -1; + font = MTSFdefault; + if (n == "_") { symbol = "_"; } + else if (n == "}") { symbol = "}"; } + else if (n == "{") { symbol = "{"; } + else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } + //else if (n=="|") { symbol=QChar(0x2016); } + else if (n == "$") { symbol = "$"; } + else if (n == "%") { symbol = "%"; } + else if (n == "&") { symbol = "&"; } + else if (n == "#") { symbol = "#"; } + else if (n == "ast") { symbol = "*"; } + else if (n == "glq") { symbol = QChar(0x2018); bold = 0; italic = 0; } + else if (n == "grq") { symbol = QChar(0x2019); bold = 0; italic = 0; } + else if (n == "glqq") { symbol = QChar(0x201C); bold = 0; italic = 0; } + else if (n == "grqq") { symbol = QChar(0x201D); bold = 0; italic = 0; } + else if (n == "flq") { symbol = QChar(0x2039); bold = 0; italic = 0; } + else if (n == "frq") { symbol = QChar(0x203A); bold = 0; italic = 0; } + else if (n == "flqq") { symbol = ""; bold = 0; italic = 0; } + else if (n == "frqq") { symbol = ""; bold = 0; italic = 0; } + } + //else if (n=="") { symbol=QChar(); font=MTSFdefault; } + //else if (n=="") symbol=QChar(0x); + } + } + else if (parent->getFontEncoding() == MTFElatex) { // use UNICODE encoding for special characters + // first we start with greek characters + font = MTSFdefault; //MTSFgreek; + //std::cout<<"encoding unicode\n"; + QHash::iterator itssymbol = latexSimpleSymbol.find(n); + if (itssymbol!=latexSimpleSymbol.end()) { + symbol = itssymbol.value(); + } else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } + + else { + font = MTSFgreek; + QHash::iterator itgreek = latexGreek.find(n); + if (itgreek!=latexGreek.end()) { + symbol = itgreek.value(); + } else { + // now we set the symbols from the Symbol font + font = MTSFsymbol; + QHash::iterator itsymbol = latexSymbol.find(n); + if (itsymbol!=latexSymbol.end()) { + symbol = itsymbol.value(); + } else if (n == "int") { symbol = QChar(0x73); fontFactor = mathFontFactor; yfactor = +0.1; } + + else { // here are text mode symbols, i.e. bold and italic won't be touched + font = MTSFbraces; + if (n == "bigcap") { symbol = QChar(0x5c); heightIsAscent = true; exactAscent = true; } + else if (n == "bigcup") { symbol = QChar(0x5b); heightIsAscent = true; exactAscent = true; } + else if (n == "bigvee") { symbol = QChar(0x5F); heightIsAscent = true; exactAscent = true; } + else if (n == "bighat") { symbol = QChar(0x5E); heightIsAscent = true; exactAscent = true; } + else if (n == "oint") { symbol = QChar(0x49); yfactor = +0.1; } + else if (n == "coprod") { symbol = QChar(0x61); heightIsAscent = true; exactAscent = true; } + else if (n == "iint") { symbol = QString(2, QChar(0x5A)); yfactor = +0.1; } + else if (n == "iiint") { symbol = QString(3, QChar(0x5A)); yfactor = +0.1; } + else if (n == "sum") { symbol = QChar(0x58); heightIsAscent = true; exactAscent = true; } + else if (n == "prod") { symbol = QChar(0x59); heightIsAscent = true; exactAscent = true; } + + + + } + } + } + } + } + } + if (addWhitespace) symbol=symbol+" "; + + static QSet extraSymbolName = { + "infty", + "|", " ", "quad", ";", ":", ",", "!", + "longleftarrow", "longrightarrow", + "Longleftarrow", "Longrightarrow", + "longleftrightarrow", "Longleftrightarrow" + }; + + if (symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) { + parent->error_list.append(tr("unknown symbol '%1' found!").arg(n)); + } + + //std::cout<<"symbol node '"<getFontGreek()); break; + case MTSFsymbol: fr.setFamily(parent->getFontSymbol()); break; + case MTSFbraces: fr.setFamily(parent->getFontBraces()); break; + case MTSFintegrals: fr.setFamily(parent->getFontIntegrals()); break; + case MTSFcaligraphic: fr.setFamily(parent->getFontCaligraphic()); break; + case MTSFblackboard: fr.setFamily(parent->getFontBlackboard()); break; + default: break; + } + return fr; +} + +void JKQTMathText::MTsymbolNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos) { + QFont f=currentEv.getFont(parent); + f=getFontName(font, f); + f.setPointSizeF(f.pointSizeF()*fontFactor); + if (italic<0) f.setItalic(false); + if (italic>0) f.setItalic(true); + if (bold<0) f.setBold(false); + if (bold>0) f.setBold(true); + QFontMetricsF fm(f, painter.device()); + QString symb=symbol; + width=0; + if (currentEv.insideMath) width=qMax(parent->getTBR(f, symb, painter.device()).width(),parent->getTBR(f, "i", painter.device()).width());//fm.width(symbol); + else width=fm.boundingRect(symb).width();//fm.width(symbol); + + width=qMax(fm.width("j"), width); + if (symb.isEmpty()) { + width=fm.width("a"); + if (symbolName=="|") width=fm.width("1")*0.8; + else if (symbolName=="infty") width=fm.width("M"); + else if (symbolName=="quad") width=parent->getTBR(f, "M", painter.device()).width(); + else if (symbolName==" ") width=parent->getTBR(f, "x", painter.device()).width(); + else if (symbolName==";") width=parent->getTBR(f, "x", painter.device()).width()*0.75; + else if (symbolName==":") width=parent->getTBR(f, "x", painter.device()).width()*0.5; + else if (symbolName==",") width=parent->getTBR(f, "x", painter.device()).width()*0.25; + else if (symbolName=="!") width=-parent->getTBR(f, "x", painter.device()).width()*0.25; + else if (symbolName=="longleftarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } + else if (symbolName=="longrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } + else if (symbolName=="Longleftarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } + else if (symbolName=="Longrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } + else if (symbolName=="longleftrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } + else if (symbolName=="Longleftrightarrow") { width=parent->getTBR(f, "X", painter.device()).width()*3.5; symb="x"; } + } + QRectF tbr=parent->getTBR(f, symb, painter.device()); + overallHeight=tbr.height();// fm.height(); + baselineHeight=tbr.height()-tbr.bottom(); + if (exactAscent) { + //baselineHeight=fm.ascent()*0.8; + } + if (heightIsAscent) { + overallHeight=baselineHeight*1.1; + } + if (exactAscent && heightIsAscent) { + //qDebug()<get_mathoperator_width_factor(); + +} + +double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { + doDrawBoxes(painter, x, y, currentEv); + double width=0; + double baselineHeight=0; + double overallHeight=0, strikeoutPos=0; + getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos); + QPen pold=painter.pen(); + QFont fold=painter.font(); + QFont f=currentEv.getFont(parent); + QFont f1=f; + f=getFontName(font, f); + f.setPointSizeF(f.pointSizeF()*fontFactor); + if (italic<0) f.setItalic(false); + if (italic>0) f.setItalic(true); + if (bold<0) f.setBold(false); + if (bold>0) f.setBold(true); + QFontMetricsF fm(f, painter.device()); + QFontMetricsF fm1(f1, painter.device()); + painter.setFont(f); + + double shift=0; + if (extendWidthInMathmode && currentEv.insideMath) { + double origwidth=width/parent->get_mathoperator_width_factor(); + shift=0.5*(width-origwidth); + //width=width*parent->get_mathoperator_width_factor(); + } + + //std::cout<<"symbol '"<getTBR(f, "M", painter.device()).height()-fm.xHeight())/3.0; + QLineF l(xx, yy, xx+xwi/3.0+((currentEv.italic)?(xwi/3.0):0), yy); + if (drawBar&&l.length()>0) painter.drawLine(l); + + // try to draw some often used special symbols, by synthesizing them from + // standard characters in the current drawing font + } else if (symbolName=="infty") { + //std::cout<<"draw infty\n"; + f1.setItalic(false); + painter.setFont(f1); + painter.save(); + painter.translate(x+shift+fm1.width("8")/3.0, y-fm1.xHeight()); + painter.rotate(90); + painter.drawText(QPointF(0,0), "8"); + painter.restore(); + } else if (symbolName=="|") { + //std::cout<<"draw infty\n"; + f1.setItalic(false); + painter.setFont(f1); + + painter.save(); + painter.translate(x+shift, y); + painter.drawText(QPointF(0,0), "|"); + painter.translate(fm1.width("8")/3.0, 0); + painter.drawText(QPointF(0,0), "|"); + painter.restore(); + + // here are some spaces + } else if (symbolName==" ") { // full space + } else if (symbolName=="quad") { // 75% space + } else if (symbolName==";") { // 75% space + } else if (symbolName==":") { // 50% space + } else if (symbolName==",") { // 25% space + } else if (symbolName=="!") { // -25% space + } else if (symbolName=="longleftarrow") { + double width=parent->getTBR(f, "X", painter.device()).width()*3.0; + double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; + double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; + QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); + painter.drawPath(path); + } else if (symbolName=="longrightarrow"){ + double width=parent->getTBR(f, "X", painter.device()).width()*3.0; + double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; + double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; + QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); + painter.drawPath(path); + } else if (symbolName=="Longleftarrow") { + double width=parent->getTBR(f, "X", painter.device()).width()*3.0; + double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; + double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; + QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); + painter.drawPath(path); + } else if (symbolName=="Longrightarrow") { + double width=parent->getTBR(f, "X", painter.device()).width()*3.0; + double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; + double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; + QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); + painter.drawPath(path); + } else if (symbolName=="longleftrightarrow") { + double width=parent->getTBR(f, "X", painter.device()).width()*3.0; + double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; + double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; + QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); + painter.drawPath(path); + } else if (symbolName=="Longleftrightarrow") { + double width=parent->getTBR(f, "X", painter.device()).width()*3.0; + double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; + double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; + QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); + painter.drawPath(path); + } else { // draw a box to indicate an unavailable symbol + QRectF tbr=parent->getTBR(f, "M", painter.device()); + painter.drawRect(QRectF(x+shift,y-tbr.height(), xwi, tbr.height()*0.8)); + } + painter.setPen(pold); + painter.setFont(fold); + return x+width; +} + +bool JKQTMathText::MTsymbolNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { + bool ok=true; + QString s; + JKQTMathText::MTenvironment ev=currentEv; + + static QMap entitylut; + if (entitylut.isEmpty()) { + entitylut.insert("sin", "sin"); + entitylut.insert("cos", "cos"); + entitylut.insert("tan", "tan"); + entitylut.insert("sinh", "sinh"); + entitylut.insert("cosh", "cosh"); + entitylut.insert("tanh", "tanh"); + entitylut.insert("atan", "atan"); + entitylut.insert("acos", "acos"); + entitylut.insert("asin", "asin"); + entitylut.insert("arcsin", "arcsin"); + entitylut.insert("arccos", "arccos"); + entitylut.insert("arctan", "arctan"); + entitylut.insert("ii", "i"); + entitylut.insert("dd", "d"); + entitylut.insert("exp", "exp"); + entitylut.insert("log", "log"); + entitylut.insert("ln", "ln"); + entitylut.insert("ld", "ld"); + entitylut.insert("lb", "lb"); + entitylut.insert("erf", "erf"); + entitylut.insert("min", "min"); + entitylut.insert("max", "max"); + entitylut.insert("argmin", "argmin"); + entitylut.insert("argmax", "argmax"); + entitylut.insert("inf", "inf"); + entitylut.insert("sup", "sup"); + entitylut.insert("liminf", "liminf"); + entitylut.insert("limsup", "limsup"); + entitylut.insert("lim", "lim"); + entitylut.insert("max", "max"); + entitylut.insert("min", "min"); + entitylut.insert("sec", "sec"); + entitylut.insert("gcd", "gcd"); + entitylut.insert("hom", "hom"); + entitylut.insert("ker", "ker"); + entitylut.insert("dim", "dim"); + entitylut.insert("cot", "cot"); + entitylut.insert("arg", "arg"); + entitylut.insert("det", "det"); + entitylut.insert("deg", "deg"); + entitylut.insert("Pr", "Pr"); + entitylut.insert("coth", "coth"); + entitylut.insert("alpha", "α"); + entitylut.insert("beta", "β"); + entitylut.insert("gamma", "γ"); + entitylut.insert("delta", "δ"); + entitylut.insert("epsilon", "ε"); + entitylut.insert("varepsilon", "ε"); + entitylut.insert("zeta", "ζ"); + entitylut.insert("eta", "η"); + entitylut.insert("theta", "θ"); + entitylut.insert("vartheta", "ϑ"); + entitylut.insert("iota", "ι"); + entitylut.insert("kappa", "κ"); + entitylut.insert("lambda", "λ"); + entitylut.insert("mu", "μ"); + entitylut.insert("nu", "ν"); + entitylut.insert("xi", "ξ"); + entitylut.insert("pi", "π"); + entitylut.insert("varpi", "ϖ"); + entitylut.insert("rho", "ρ"); + entitylut.insert("sigma", "σ"); + entitylut.insert("varsigma", "ς"); + entitylut.insert("tau", "τ"); + entitylut.insert("upsilon", "υ"); + entitylut.insert("phi", "φ"); + entitylut.insert("varphi", "φ"); + entitylut.insert("chi", "χ"); + entitylut.insert("psi", "ψ"); + entitylut.insert("omega", "ω"); + entitylut.insert("Gamma", "Γ"); + entitylut.insert("Delta", "Δ"); + entitylut.insert("Theta", "Θ"); + entitylut.insert("Lambda", "Λ"); + entitylut.insert("Omega", "Ω"); + entitylut.insert("Xi", "Ξ"); + entitylut.insert("Pi", "Π"); + entitylut.insert("Sigma", "Σ"); + entitylut.insert("Upsilon", "Υ"); + entitylut.insert("Phi", "Φ"); + entitylut.insert("Psi", "Ψ"); + entitylut.insert("leftrightarrow", "↔"); + entitylut.insert("leftarrow", "←"); + entitylut.insert("rightarrow", "→"); + entitylut.insert("to", "→"); + entitylut.insert("uparrow", "↑"); + entitylut.insert("downarrow", "↓"); + entitylut.insert("Leftrightarrow", "⇔"); + entitylut.insert("iff", "⇔"); + entitylut.insert("Leftarrow", "⇐"); + entitylut.insert("Rightarrow", "⇒"); + entitylut.insert("Uparrow", "⇑"); + entitylut.insert("Downarrow", "⇓"); + entitylut.insert("pm", "±"); + entitylut.insert("leq", "≤"); + entitylut.insert("geq", "≥"); + entitylut.insert("times", "×"); + entitylut.insert("propto", "∝"); + entitylut.insert("partial", "∂"); + entitylut.insert("bullet", "•"); + entitylut.insert("neq", "≠"); + entitylut.insert("ne", "≠"); + entitylut.insert("equiv", "≡"); + entitylut.insert("approx", "≈"); + entitylut.insert("ellipsis", "..."); + entitylut.insert("Im", "ℑ"); + entitylut.insert("Re", "ℜ"); + entitylut.insert("otimes", "⊗"); + entitylut.insert("oplus", "⊕"); + entitylut.insert("oslash", "/"); + entitylut.insert("cap", "∩"); + entitylut.insert("cup", "∪"); + entitylut.insert("land", "∩"); + entitylut.insert("lor", "∪"); + entitylut.insert("supset", "⊃"); + entitylut.insert("supseteq", "⊇"); + entitylut.insert("supsetnot", "⊅"); + entitylut.insert("subset", "⊂"); + entitylut.insert("subseteq", "⊆"); + entitylut.insert("in", "∈"); + entitylut.insert("notin", "∉"); + entitylut.insert("angle", "∠"); + entitylut.insert("nabla", "∇"); + entitylut.insert("copyright", "©"); + entitylut.insert("registered", "®"); + entitylut.insert("trademark", "™"); + entitylut.insert("cdot", "⋅"); + entitylut.insert("neg", "¬"); + entitylut.insert("wedge", "∧"); + entitylut.insert("vee", "∨"); + entitylut.insert("diamond", "◊"); + entitylut.insert("langle", "⟨"); + entitylut.insert("rangle", "⟩"); + entitylut.insert("int", "∫"); + entitylut.insert("forall", "∀"); + entitylut.insert("exists", "∃"); + entitylut.insert("cong", "∼"); + entitylut.insert("bot", "⊥"); + + + entitylut.insert("ll", "<<"); + entitylut.insert("gg", ">>"); + entitylut.insert("bbC", "C"); + entitylut.insert("bbH", "H"); + entitylut.insert("bbN", "N"); + entitylut.insert("bbP", "P"); + entitylut.insert("bbQ", "Q"); + entitylut.insert("bbR", "R"); + entitylut.insert("bbZ", "Z"); + entitylut.insert("Alef", "ℵ"); + entitylut.insert("alef", "ℵ"); + entitylut.insert("tilde", "~"); + entitylut.insert("iint", "∫∫"); + entitylut.insert("iiint", "∫∫∫"); + entitylut.insert("emptyset", "∅"); + entitylut.insert("varnothing", "∅"); + entitylut.insert("lceil", "⌈"); + entitylut.insert("rceil", "⌉"); + entitylut.insert("lfloor", "⌊"); + entitylut.insert("rfloor", "⌋"); + entitylut.insert("subsetnot", "⊄"); + entitylut.insert("DC", "="); + entitylut.insert("cdots", "⋅⋅⋅"); + entitylut.insert("dots", "..."); + + entitylut.insert("cent", "¢"); + + entitylut.insert("_", "_"); + entitylut.insert("}", "}"); + entitylut.insert("{", "{"); + entitylut.insert("hbar", "ℏ"); + entitylut.insert("euro", "€"); + entitylut.insert("pound", "£"); + entitylut.insert("yen", "¥"); + entitylut.insert("div", "÷"); + entitylut.insert("backslash", "\\"); + entitylut.insert("$", "$"); + entitylut.insert("%", "%"); + entitylut.insert("&", "&"); + entitylut.insert("#", "#"); + entitylut.insert("ast", "*"); + entitylut.insert("glq", "'"); + entitylut.insert("grq", "'"); + entitylut.insert("glqq", "\""); + entitylut.insert("grqq", "\""); + entitylut.insert("flq", "<"); + entitylut.insert("frq", ">"); + entitylut.insert("flqq", ""); + entitylut.insert("frqq", ""); + } + + + QMap::iterator itS = entitylut.find(symbolName); + if (itS!=entitylut.end()) { s=itS.value(); } + else if (symbolName == "sum") { ev.fontSize*=1.7; s="∑"; } + else if (symbolName == "prod") { ev.fontSize*=1.7; s="∏"; } + else if (symbolName == "bigcap") { ev.fontSize*=1.7; s="∩"; } + else if (symbolName == "bigcup") { ev.fontSize*=1.7; s="∪"; } + else if (symbolName == "bigvee") { ev.fontSize*=1.7; s="∨"; } + else if (symbolName == "bighat") { ev.fontSize*=1.7; s="∧"; } + else ok=false; + + if (ok) html=html+ev.toHtmlStart(defaultEv)+s+ev.toHtmlAfter(defaultEv); + return ok; +} + + +// -------------------------------------------------------------------------------------------------- +// -- implementation of the JKQTMathText methods +// -------------------------------------------------------------------------------------------------- +JKQTMathText::JKQTMathText(QObject* parent): + QObject(parent) +{ + Q_INIT_RESOURCE(xits); + QFontDatabase fontdb; + + QString serifFont="Serif"; + QString sansFont="Sans"; + QString symbolFont="Symbol"; + QString scriptFont="Script"; + QString typewriterFont="typewriter"; + QString decorativeFont="decorative"; + + QStringList fonts=fontdb.families(); + //qDebug()<<"fonts:\n"<toHtml(s, ev, defaultev); + } + if (ok) *ok=okk; + return s; +} + +void JKQTMathText::useAnyUnicode(QString timesFont, const QString& sansFont) { + if (!timesFont.isEmpty()) { fontMathRoman=timesFont; fontRoman=timesFont; } + if (!sansFont.isEmpty()) { fontMathSans=sansFont; fontSans=sansFont; } + useSTIXfonts=false; + useXITSfonts=false; + useASANAfonts=false; + fontGreek=fontMathRoman; + fontSymbol=fontMathRoman; + fontBraces=fontMathRoman; + fontIntegrals=fontMathRoman; + fontEncoding=MTFEunicode; + brace_shrink_factor=0.6; +} + + +JKQTMathText::tokenType JKQTMathText::getToken() { + currentTokenID++; + if (currentTokenID>parseString.size()-1) return currentToken=MTTnone; + QChar c=parseString[currentTokenID]; + currentTokenName=""; + if (c=='\\') { // read an instruction name + currentTokenID++; + if (currentTokenID>=parseString.size()-1) return currentToken=MTTnone; + c=parseString[currentTokenID]; + /*if (c=='_' || c=='\\' || c=='$' || c=='%' || c=='&' || c=='#' || c=='}' || c=='{') { + currentTokenName=c; // parse special one-symbol instructions like \\, \& ... + // that may be directly converted to text + return currentToken=MTTtext; + } else*/ if (c=='|' || c==';' || c==':' || c=='!' || c==',' || c=='_' || c=='\\' || c=='$' || + c=='%' || c=='&' || c=='#' || c=='}' || c=='{' || c==' ') { + currentTokenName=c; // parse one-symbol instructions like \\, \& ... + //std::cout<<"found text node '"<addNode(new MTtextNode(this, text, addWhite, parsingMathEnvironment)); + } else if (currentToken==MTTinstruction) { + QString name=currentTokenName; + if (name=="\\") break; // break on linebrak character + getToken(); // look at next token + if (currentToken==MTTopenbrace) { + //std::cout<<"found '{' after '"<addNode(new MTsqrtNode(this, parseLatexString(true))); + } else if (name=="cbrt") { + nl->addNode(new MTsqrtNode(this, parseLatexString(true), 3)); + } else if (name=="verb") { + QString text=""; + currentTokenID++; + if (currentTokenID<=parseString.size()-1) { + QChar c=parseString[currentTokenID]; + while (c!='}' && (currentTokenIDaddNode(new MTtextNode(this, text, false)); + } + } else if (name=="frac") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMfrac)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="dfrac") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMdfrac)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="tfrac") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMtfrac)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="stackrel") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMstackrel)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="binom") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTbraceNode(this, "(", ")", new MTfracNode(this, n1, n2, MTFMstackrel))); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="underbrace") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMunderbrace)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="underset") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMunderset)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="overbrace") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMoverbrace)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="overset") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMoverset)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="begin") { + if (getToken()==MTTtext) { + QString envname=currentTokenName; + while (currentToken!=MTTclosebrace) getToken(); // find closing brace '}' after '\\begin{name' + if (envname=="matrix" || envname=="array" || envname=="aligned" || envname=="align" || envname=="cases" || envname=="pmatrix"|| envname=="bmatrix"|| envname=="Bmatrix"|| envname=="vmatrix"|| envname=="Vmatrix") { + QVector< QVector > items; + //int lines=0; + //int cols=0; + bool first=true; + QVector line; + //std::cout<<"found \\begin{matrix}\n"; + while (first || currentToken==MTTampersand || (currentToken==MTTinstruction && currentTokenName=="\\")) { + MTnode* it=parseLatexString(true, "", envname); + if (currentToken==MTTampersand) { + //std::cout<<" appending item\n"; + line.append(it); + } else { + line.append(it); + //std::cout<<" appending item and line with "<addNode(new MTbraceNode(this, "(", ")", new MTmatrixNode(this, items))); + else if (envname=="cases") nl->addNode(new MTbraceNode(this, "{", "", new MTmatrixNode(this, items))); + else if (envname=="bmatrix") nl->addNode(new MTbraceNode(this, "[", "]", new MTmatrixNode(this, items))); + else if (envname=="Bmatrix") nl->addNode(new MTbraceNode(this, "{", "}", new MTmatrixNode(this, items))); + else if (envname=="vmatrix") nl->addNode(new MTbraceNode(this, "|", "|", new MTmatrixNode(this, items))); + else if (envname=="Vmatrix") nl->addNode(new MTbraceNode(this, "||", "||", new MTmatrixNode(this, items))); + else nl->addNode(new MTmatrixNode(this, items)); + //std::cout<<" creating matrix-node ... done!\n"; + } else { + error_list.append(tr("error @ ch. %1: unknown environment '%2'").arg(currentTokenID).arg(envname)); + } + } else { // find next '}' + error_list.append(tr("error @ ch. %1: text after '\\begin{' expected!").arg(currentTokenID)); + while (currentToken!=MTTclosebrace) getToken(); + getNew=true; + } + } else if (name=="end") { + if (getToken()==MTTtext) { + QString envname=currentTokenName; + while (currentToken!=MTTclosebrace) getToken(); // find closing brace '}' after '\\begin{name' + if (envname==quitOnEnvironmentEnd) { + break; + } else { + error_list.append(tr("error @ ch. %1: '\\end{%2}' widthout preceding '\\begin{%3}'").arg(currentTokenID).arg(envname).arg(envname)); + } + } else { // find next '}' + error_list.append(tr("error @ ch. %1: text after '\\begin{' expected!").arg(currentTokenID)); + while (currentToken!=MTTclosebrace) getToken(); + getNew=true; + } + } else if (name=="vec") { + nl->addNode(new MTdecoratedNode(this, MTDvec, parseLatexString(true))); + } else if (name=="overline"||name=="oline"||name=="ol") { + nl->addNode(new MTdecoratedNode(this, MTDoverline, parseLatexString(true))); + } else if (name=="underline"||name=="uline"||name=="ul") { + nl->addNode(new MTdecoratedNode(this, MTDunderline, parseLatexString(true))); + } else if (name=="uuline"||name=="uul") { + nl->addNode(new MTdecoratedNode(this, MTDdoubleunderline, parseLatexString(true))); + } else if (name=="ooline"||name=="ool") { + nl->addNode(new MTdecoratedNode(this, MTDdoubleoverline, parseLatexString(true))); + } else if (name=="arrow") { + nl->addNode(new MTdecoratedNode(this, MTDarrow, parseLatexString(true))); + } else if (name=="hat") { + nl->addNode(new MTdecoratedNode(this, MTDhat, parseLatexString(true))); + } else if (name=="bar") { + nl->addNode(new MTdecoratedNode(this, MTDbar, parseLatexString(true))); + } else if (name=="dot") { + nl->addNode(new MTdecoratedNode(this, MTDdot, parseLatexString(true))); + } else if (name=="tilde") { + nl->addNode(new MTdecoratedNode(this, MTDtilde, parseLatexString(true))); + } else if (name=="ddot") { + nl->addNode(new MTdecoratedNode(this, MTDddot, parseLatexString(true))); + } else { + if (name=="textcolor" || name=="mathcolor" || name=="color" || name=="colorbox") { + bool foundError=true; + QString col=""; + if (getToken()==MTTtext) { + col=currentTokenName; + if (getToken()==MTTclosebrace) { + if (getToken()==MTTopenbrace) { + foundError=false; + } + } + } + if (foundError) error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + else nl->addNode(new MTinstruction1Node(this, name, parseLatexString(true), QStringList(col))); + + + } else { + nl->addNode(new MTinstruction1Node(this, name, parseLatexString(true))); + } + } + } else { + //std::cout<<"did not find '{' after '"<0) { + if (QString(currentTokenName[0])==quitOnClosingBrace || quitOnClosingBrace=="any" || QString(currentTokenName[0])==".") { + //std::cout<<"found \\right '"<" && (currentTokenName=="rangle" || QString(currentTokenName[0])==".")) { + showRightBrace=(QString(currentTokenName[0])!="."); + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + break; + } else if (quitOnClosingBrace=="any") { + showRightBrace=(QString(currentTokenName[0])!="."); + //currentTokenName=currentTokenName.right(currentTokenName.size()-1); + break; + } + } else { + getNew=false; + } + } else if (name=="left") { + if (currentToken==MTTtext) { + if (currentTokenName.size()>0) { + if (currentTokenName[0]=='(') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); // we already used the first character from the text token! + nl->addNode(new MTbraceNode(this, "(", ")", parseLatexString(currentTokenName.size()<=0, ")"), showRightBrace)); + } else if (currentTokenName[0]=='[') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "[", "]", parseLatexString(currentTokenName.size()<=0, "]"), showRightBrace)); + } else if (currentTokenName[0]=='{') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "{", "}", parseLatexString(currentTokenName.size()<=0, "}"), showRightBrace)); + } else if (currentTokenName[0]=='<') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "<", ">", parseLatexString(currentTokenName.size()<=0, ">"), showRightBrace)); + } else if (currentTokenName[0]=='|') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "|", "|", parseLatexString(currentTokenName.size()<=0, "|"), showRightBrace)); + } else if (currentTokenName[0]=='~') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "~", "~", parseLatexString(currentTokenName.size()<=0, "~"), showRightBrace)); + } else if (currentTokenName[0]=='_') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "_", "_", parseLatexString(currentTokenName.size()<=0, "_"), showRightBrace)); + } else if (currentTokenName[0]=='#') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "#", "#", parseLatexString(currentTokenName.size()<=0, "#"), showRightBrace)); + } else if (currentTokenName[0]=='.') { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + JKQTMathText::MTnode* cn=parseLatexString(currentTokenName.size()<=0, "any"); + nl->addNode(new MTbraceNode(this, ".", currentTokenName, cn, showRightBrace)); + } else { + getNew=false; + } + } + } else if (currentToken==MTTinstruction && currentTokenName=="langle") { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "<", ">", parseLatexString(true, ">"), showRightBrace)); + } else if (currentToken==MTTinstruction && currentTokenName=="{") { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "{", "}", parseLatexString(currentTokenName.size()<=0, "}"), showRightBrace)); + } else if (currentToken==MTTinstruction && currentTokenName=="lfloor") { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "_", "_", parseLatexString(true, "_"), showRightBrace)); + } else if (currentToken==MTTinstruction && currentTokenName=="lceil") { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "~", "~", parseLatexString(true, "~"), showRightBrace)); + } else if (currentToken==MTTinstruction && currentTokenName=="|") { + currentTokenName=currentTokenName.right(currentTokenName.size()-1); + nl->addNode(new MTbraceNode(this, "#", "#", parseLatexString(currentTokenName.size()<=0, "#"), showRightBrace)); + } else if (currentToken==MTTinstruction && currentTokenName==quitOnClosingBrace) { + break; + } + } else { + //bool addWhite=(currentToken==MTTwhitespace); + //getNew=addWhite; + getNew=false; + bool done=false; + if (name.size()==2) { + QChar n0=name[0]; + QChar n1=name[1]; + if (n0=='v' && n1.isLetter()) { + done=true; + //std::cout<<"found \\v... command\n"; + nl->addNode(new MTdecoratedNode(this, MTDvec, new MTtextNode(this, QString(n1), false, parsingMathEnvironment))); + } else if (n0=='c' && n1.isLetter()) { + done=true; + //std::cout<<"found \\v... command\n"; + nl->addNode(new MTinstruction1Node(this, "mathcal", new MTtextNode(this, QString(n1), false, parsingMathEnvironment))); + } + } else if (name.size()==3) { + QString n0=name.left(2); + QChar n1=name[name.size()-1]; + if (n0=="bb" && n1.isLetter()) { + done=true; + //std::cout<<"found \\v... command\n"; + nl->addNode(new MTinstruction1Node(this, "mathbb", new MTtextNode(this, QString(n1), false, parsingMathEnvironment))); + } + } + if (!done) nl->addNode(new MTsymbolNode(this, name, false));//, addWhite)); + + } + } + } else if (currentToken==MTTwhitespace) { + if (!parsingMathEnvironment) nl->addNode(new MTwhitespaceNode(this)); + } else if (currentToken==MTTunderscore) { + getToken(); + MTnode* child=nullptr; + MTnode* child2=nullptr; + if (currentToken==MTTinstruction) { + QString name=currentTokenName; + getToken(); // look at next token + if (currentToken==MTTopenbrace) { + child=new MTinstruction1Node(this, name, parseLatexString(true)); + } else { + //bool addWhite=(currentToken==MTTwhitespace); + //getNew=addWhite; + //child=new MTsymbolNode(this, name, addWhite); + getNew=false; + child=new MTsymbolNode(this, name, false); + } + } else if (currentToken==MTTopenbrace) { + child=parseLatexString(true); + } else if (currentToken==MTTtext) { + if (currentTokenName.size()<=1) { + child=new MTtextNode(this, currentTokenName, false, parsingMathEnvironment); + } else { + child=new MTtextNode(this, QString(currentTokenName[0]), false, parsingMathEnvironment); + child2=new MTtextNode(this, currentTokenName.right(currentTokenName.size()-1), false, parsingMathEnvironment); + } + } else { + getNew=false; + } + if (child!=nullptr) nl->addNode(new MTsubscriptNode(this, child)); + if (child2!=nullptr) nl->addNode(child2); + } else if (currentToken==MTThat) { + getToken(); + MTnode* child=nullptr; + MTnode* child2=nullptr; + if (currentToken==MTTinstruction) { + QString name=currentTokenName; + getToken(); // look at next token + if (currentToken==MTTopenbrace) { + child=new MTinstruction1Node(this, name, parseLatexString(true)); + } else { + //bool addWhite=(currentToken==MTTwhitespace); + //getNew=addWhite; + //child=new MTsymbolNode(this, name, addWhite); + getNew=false; + child=new MTsymbolNode(this, name, false); + } + } else if (currentToken==MTTopenbrace) { + child=parseLatexString(true); + } else if (currentToken==MTTtext) { + if (currentTokenName.size()<=1) { + child=new MTtextNode(this, currentTokenName, false, parsingMathEnvironment); + } else { + child=new MTtextNode(this, QString(currentTokenName[0]), false, parsingMathEnvironment); + child2=new MTtextNode(this, currentTokenName.right(currentTokenName.size()-1), false, parsingMathEnvironment); + } + } else { + getNew=false; + } + if (child!=nullptr) nl->addNode(new MTsuperscriptNode(this, child)); + if (child2!=nullptr) nl->addNode(child2); + } else if (currentToken==MTTopenbrace) { + nl->addNode(parseLatexString(true)); + } else if (currentToken==MTTclosebrace) { + break; + } else if (currentToken==MTTampersand) { + break; + } else if (currentToken==MTTdollar) { + if (parsingMathEnvironment) { // reached end of math environment + parsingMathEnvironment=false; + break; + } else { // starting math environment + parsingMathEnvironment=true; + nl->addNode(new MTinstruction1Node(this, "equation", parseLatexString(true))); + } + } + if (getNew) getToken(); + } + //std::cout<<" leaving parseLatexString()\n"; + return nl; +} + + +QList JKQTMathText::tbrs=QList(); +QHash JKQTMathText::tbrh=QHash(); + +QRectF JKQTMathText::getTBR(const QFont &fm, const QString &text, QPaintDevice *pd) +{ + JKQTMathText::tbrDataH dh(fm, text, pd); + if (pd) { + if (tbrh.contains(dh)) return tbrh[dh]; + /*for (int i=0; ilogicalDpiX() && tbrs[i].ldpiY==pd->logicalDpiY() && tbrs[i].pdpiX==pd->physicalDpiX() && tbrs[i].pdpiY==pd->physicalDpiY())) { + //qDebug()<<" ### "<getSize(painter, ev, width, ascent, overallHeight, strikeoutPos); + descent=overallHeight-ascent; + ascent=ascent*1.1; + descent=qMax(ascent*0.1, descent*1.1); + strikeoutPos=strikeoutPos*1.1; + } +} + +void JKQTMathText::draw(QPainter& painter, double x, double y, bool drawBoxes){ + if (getTree()!=nullptr) { + MTenvironment ev; + ev.color=fontColor; + ev.fontSize=fontSize; + getTree()->set_drawBoxes(drawBoxes); + getTree()->draw(painter, x, y, ev); + } +} + +void JKQTMathText::draw(QPainter& painter, int flags, QRectF rect, bool drawBoxes) { + if (getTree()!=nullptr) { + MTenvironment ev; + ev.color=fontColor; + ev.fontSize=fontSize; + getTree()->set_drawBoxes(drawBoxes); + + double width=0; + double baselineHeight=0; + double overallHeight=0, strikeoutPos=0; + getTree()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos); + + // align left top + double x=rect.left(); + double y=rect.top()+baselineHeight; + + // care for horizontal align + if ((flags & Qt::AlignRight) != 0) x=x+rect.width()-width; + else if ((flags & Qt::AlignHCenter) != 0) x=x+(rect.width()-width)/2.0; + + // care for vertical align + if ((flags & Qt::AlignBottom) != 0) y=y+rect.height()-overallHeight; + else if ((flags & Qt::AlignVCenter) != 0) y=y+(rect.height()-overallHeight)/2.0; + + // finally draw + getTree()->draw(painter, x, y, ev); + } +} + +JKQTMathText::MTwhitespaceNode::MTwhitespaceNode(JKQTMathText *parent): + MTtextNode(parent, " ", false, false) +{ + +} + +JKQTMathText::MTwhitespaceNode::~MTwhitespaceNode() += default; + +QString JKQTMathText::MTwhitespaceNode::getTypeName() const +{ + return QLatin1String("MTwhitespaceNode(")+text+")"; +} + +bool JKQTMathText::MTwhitespaceNode::toHtml(QString &html, JKQTMathText::MTenvironment /*currentEv*/, JKQTMathText::MTenvironment /*defaultEv*/) { + html=html+" "; + return true; +} + +void JKQTMathText::MTnode::set_drawBoxes(bool draw) +{ + this->drawBoxes=draw; +} + +QString JKQTMathText::MTnode::getTypeName() const +{ + return "MTnode"; +} + +QString JKQTMathText::fracModeToString(JKQTMathText::MTfracMode mode) +{ + switch(mode) { + case MTFMfrac: + return "frac"; + case MTFMdfrac: + return "dfrac"; + case MTFMtfrac: + return "tfrac"; + case MTFMunderbrace: + return "underbrace"; + case MTFMoverbrace: + return "overbrace"; + case MTFMunderset: + return "underset"; + case MTFMoverset: + return "overset"; + case MTFMstackrel: + return "stackrel"; + } + return "unknown"; +} + + +QString JKQTMathText::decorationToString(JKQTMathText::MTdecoration mode) +{ + switch(mode) { + case MTDvec: + return "vec"; + case MTDtilde: + return "tilde"; + case MTDhat: + return "hat"; + case MTDdot: + return "dot"; + case MTDddot: + return "ddot"; + case MTDbar: + return "bar"; + case MTDarrow: + return "arrow"; + case MTDoverline: + return "overline"; + case MTDdoubleoverline: + return "double overline"; + case MTDunderline: + return "underline"; + case MTDdoubleunderline: + return "double underline"; + } + return "unknown"; +} + +JKQTMathTextLabel::JKQTMathTextLabel(QWidget *parent): + QLabel(parent) +{ + m_mathText=new JKQTMathText(this); + m_mathText->useXITS(); + m_mathText->setFontSize(font().pointSizeF()*1.3); + lastText=""; + repaintDo=true; + buffer=QPixmap(); +} + +JKQTMathTextLabel::~JKQTMathTextLabel() += default; + +JKQTMathText *JKQTMathTextLabel::getMathText() const +{ + return m_mathText; +} + +void JKQTMathTextLabel::setMath(const QString &text, bool doRepaint) +{ + if (text!=lastText || doRepaint){ + lastText=text; + repaintDo=true; + internalPaint(); + update(); + } +} + + +void JKQTMathTextLabel::internalPaint() +{ + //return; + //qDebug()<<"internalPaint "<parse(lastText)<<"\n "<get_error_list().join("\n")<<"\n\n"; + if (!m_mathText->parse(lastText)) { + qDebug()<<"JKQTMathTextLabel::internalPaint(): parse '"<parse(lastText)<<"\n "<get_error_list().join("\n")<<"\n\n"; + } + + if (buffer.width()<=0 || buffer.height()<=0) buffer=QPixmap(1000,100); + //qDebug()<<"internalPaint(): buffer "<getSize(p); + p.end(); + } + buffer=QPixmap(qMax(32.0,size.width()*1.2), qMax(10.0,size.height()*1.1)); + buffer.fill(Qt::transparent); + { + //qDebug()<<"internalPaint(): "<draw(p,alignment(), QRectF(QPointF(0,0), size)); + p.end(); + } + setPixmap(buffer); + //} + //qDebug()<<"internalPaint(): setPixmap"; + QApplication::processEvents(); + //qDebug()<<"internalPaint(): DONE"; +} + +void JKQTMathTextLabel::paintEvent(QPaintEvent *event) +{ + //QLabel::paintEvent(event); + //return; + + //qDebug()<<"paintEvent: "<text=text; + this->tbr=this->fm.tightBoundingRect(text); + this->f=f; + //this->pd=pd; + if (pd) { + ldpiX=pd->logicalDpiX(); + ldpiY=pd->logicalDpiY(); + pdpiX=pd->physicalDpiX(); + pdpiY=pd->physicalDpiY(); + } else { + ldpiX=0; + ldpiY=0; + pdpiX=0; + pdpiY=0; + } +} + +bool JKQTMathText::tbrData::operator==(const JKQTMathText::tbrData &other) const +{ + return ldpiX==other.ldpiX && ldpiY==other.ldpiY && text==other.text && f==other.f; +} + + +JKQTMathText::tbrDataH::tbrDataH(const QFont &f, const QString &text, QPaintDevice *pd) +{ + this->text=text; + this->f=f; + if (pd) { + ldpiX=pd->logicalDpiX(); + ldpiY=pd->logicalDpiY(); + pdpiX=pd->physicalDpiX(); + pdpiY=pd->physicalDpiY(); + } else { + ldpiX=0; + ldpiY=0; + pdpiX=0; + pdpiY=0; + } +} + +bool JKQTMathText::tbrDataH::operator==(const JKQTMathText::tbrDataH &other) const +{ + return ldpiX==other.ldpiX && ldpiY==other.ldpiY && text==other.text && f==other.f; + +} + + +JKQTMathText::MTplainTextNode::MTplainTextNode(JKQTMathText *parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace): + JKQTMathText::MTtextNode(parent, text, addWhitespace, stripInnerWhitepace) +{ + +} + +QString JKQTMathText::MTplainTextNode::getTypeName() const +{return QLatin1String("MTplainTextNode(")+text+")"; + +} + + +QString JKQTMathText::MTplainTextNode::textTransform(const QString &text, JKQTMathText::MTenvironment /*currentEv*/, bool /*forSize*/) +{ + return text; +} + +void initJKQTMathTextResources() +{ + Q_INIT_RESOURCE(xits); +} diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index f3b756b1f3..bc0108d3a4 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -230,9 +230,9 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief class destructor */ ~JKQTMathText(); /** \brief load the object settings from the given QSettings object with the given name prefix */ - void loadSettings(QSettings& settings, QString group=QString("mathtext")); + void loadSettings(const QSettings& settings, const QString& group=QString("mathtext")); /** \brief store the object settings to the given QSettings object with the given name prefix */ - void saveSettings(QSettings& settings, QString group=QString("mathtext")); + void saveSettings(QSettings& settings, const QString& group=QString("mathtext")) const; /** \brief parse the given enhanced string. Returns \c true on success. */ bool parse(QString text); /** \brief get the size of the drawn representation. returns an invalid size if no text has been parsed. */ @@ -286,9 +286,9 @@ class LIB_EXPORT JKQTMathText : public QObject { * setAnyUnicode("Courier New", "Courier New"):
\image html jkqtmathparser_couriernew.png * setAnyUnicode("Comic Sans MS", "Comic Sans MS"):
\image html jkqtmathparser_comicsans.png */ - void useAnyUnicode(QString timesFont=QString(""), QString sansFont=QString("")); + void useAnyUnicode(QString timesFont=QString(""), const QString& sansFont=QString("")); - void useLatexFonts(QString prefix=QString(""), QString postfix=QString("")); + void useLatexFonts(QString prefix=QString(""), const QString& postfix=QString("")); /** \brief convert LaTeX to HTML. returns \c ok=true on success and \c ok=false else. */ QString toHtml(bool* ok=nullptr, double fontPointSize=10); @@ -846,7 +846,7 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief subclass representing one text node in the syntax tree */ class MTtextNode: public MTnode { public: - MTtextNode(JKQTMathText* parent, QString text, bool addWhitespace, bool stripInnerWhitepace=false); + MTtextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false); virtual ~MTtextNode(); virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos); virtual double draw(QPainter& painter, double x, double y, MTenvironment currentEv); @@ -866,7 +866,7 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief subclass representing one text node in the syntax tree */ class MTplainTextNode: public MTtextNode { public: - MTplainTextNode(JKQTMathText* parent, QString text, bool addWhitespace, bool stripInnerWhitepace=false); + MTplainTextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false); virtual QString getTypeName() const; protected: virtual QString textTransform(const QString& text, JKQTMathText::MTenvironment currentEv, bool forSize=false); @@ -884,7 +884,7 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief subclass representing one symbol (e.g. \c \\alpha , \c \\cdot ...) node in the syntax tree */ class MTsymbolNode: public MTnode { public: - MTsymbolNode(JKQTMathText* parent, QString name, bool addWhitespace); + MTsymbolNode(JKQTMathText* parent, const QString& name, bool addWhitespace); virtual ~MTsymbolNode(); virtual QString getTypeName() const; virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos); @@ -947,7 +947,7 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief subclass representing an instruction node with exactly one argument in the syntax tree */ class MTinstruction1Node: public MTnode { public: - MTinstruction1Node(JKQTMathText* parent, QString name, MTnode* child, const QStringList& parameters=QStringList()); + MTinstruction1Node(JKQTMathText* parent, const QString& name, MTnode* child, const QStringList& parameters=QStringList()); virtual ~MTinstruction1Node(); virtual QString getTypeName() const; virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos); @@ -1030,7 +1030,7 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief subclass representing a brace node */ class MTbraceNode: public MTnode { public: - MTbraceNode(JKQTMathText* parent, QString openbrace, QString closebrace, MTnode* child, bool showRightBrace=true); + MTbraceNode(JKQTMathText* parent, const QString& openbrace, const QString& closebrace, MTnode* child, bool showRightBrace=true); virtual ~MTbraceNode(); virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos); virtual double draw(QPainter& painter, double x, double y, MTenvironment currentEv); @@ -1436,7 +1436,7 @@ class LIB_EXPORT JKQTMathText : public QObject { /** \brief tokenizer for the LaTeX parser */ tokenType getToken(); /** \brief parse a LaTeX string */ - MTnode* parseLatexString(bool get, QString quitOnClosingBrace=QString(""), QString quitOnEnvironmentEnd=QString("")); + MTnode* parseLatexString(bool get, const QString& quitOnClosingBrace=QString(""), const QString& quitOnEnvironmentEnd=QString("")); /** \brief parse a LaTeX math environment */ MTnode* parseMath(bool get); diff --git a/lib/jkqtplotter/jkqtpbaseelements.cpp b/lib/jkqtplotter/jkqtpbaseelements.cpp index ef48fc3459..d9134785fa 100644 --- a/lib/jkqtplotter/jkqtpbaseelements.cpp +++ b/lib/jkqtplotter/jkqtpbaseelements.cpp @@ -1,7 +1,7 @@ /* Copyright (c) 2008-2019 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 @@ -113,18 +113,17 @@ JKQTPCoordinateAxis::JKQTPCoordinateAxis(JKQTBasePlotter* parent): QObject(paren paramsChanged=true; } -JKQTPCoordinateAxis::~JKQTPCoordinateAxis() { -} +JKQTPCoordinateAxis::~JKQTPCoordinateAxis() = default; void JKQTPCoordinateAxis::set_parent(JKQTBasePlotter* parent) { this->parent=parent; QObject::setParent(parent); } -void JKQTPCoordinateAxis::replotPlot() { +void JKQTPCoordinateAxis::redrawPlot() { //if (paramsChanged) { calcPlotScaling(); - parent->replotPlot(); + parent->redrawPlot(); //} } @@ -196,43 +195,43 @@ void JKQTPCoordinateAxis::loadSettings(JKQTPCoordinateAxis* settings) { void JKQTPCoordinateAxis::clearAxisTickLabels() { tickLabels.clear(); - replotPlot(); + redrawPlot(); } -void JKQTPCoordinateAxis::addAxisTickLabel(double x, QString label) { +void JKQTPCoordinateAxis::addAxisTickLabel(double x, const QString& label) { tickLabels.append(qMakePair(x, label)); - replotPlot(); + redrawPlot(); } void JKQTPCoordinateAxis::addAxisTickLabels(const QVector &x, const QStringList &label) { for (int i=0; i &x, const QString *label) { for (int i=0; i(i)*tickSpacing), unitdigits)== floattolabel((minval+(double)(i+1)*tickSpacing), unitdigits)); }*/ while ((unitdigits<20) && equals) { unitdigits++; equals=false; for (int i=-10; i<10; i++) { - QString l1=floattolabel((minval+(double)i*tickSpacing), unitdigits+2); + QString l1=floattolabel((minval+static_cast(i)*tickSpacing), unitdigits+2); QString l2=floattolabel((minval+(double)(i+1.0)*tickSpacing), unitdigits+2); //qDebug()<<"unitdigits="<\copydoc axisLabel * \see axisLabel for more information */ - virtual void setAxisLabel (QString __value); + virtual void setAxisLabel (const QString& __value); /** \brief sets the property labelPosition to the specified \a __value. * \details Description of the parameter labelPosition is:
\copydoc labelPosition
*/ @@ -436,7 +436,7 @@ class LIB_EXPORT JKQTPCoordinateAxis: public QObject { /** \brief sets the property labelFont to the specified \a __value. * \details Description of the parameter labelFont is:
\copydoc labelFont
*/ - virtual void set_labelFont (QString __value); + virtual void set_labelFont (const QString& __value); /** \brief sets the property labelFontSize to the specified \a __value. * \details Description of the parameter labelFontSize is:
\copydoc labelFontSize
*/ @@ -444,22 +444,22 @@ class LIB_EXPORT JKQTPCoordinateAxis: public QObject { /** \brief sets the property tickLabelFont to the specified \a __value. * \details Description of the parameter tickLabelFont is:
\copydoc tickLabelFont
*/ - virtual void set_tickLabelFont (QString __value); + virtual void set_tickLabelFont (const QString& __value); /** \brief sets the property tickTimeFormat to the specified \a __value. * \details Description of the parameter tickTimeFormat is:
\copydoc tickTimeFormat
*/ - virtual void set_tickTimeFormat (QString __value); + virtual void set_tickTimeFormat (const QString& __value); /** \brief sets the property tickDateFormat to the specified \a __value. * \details Description of the parameter tickDateFormat is:
\copydoc tickDateFormat
*/ - virtual void set_tickDateFormat (QString __value); + virtual void set_tickDateFormat (const QString& __value); /** \brief sets the property tickDateTimeFormat to the specified \a __value. * \details Description of the parameter tickDateTimeFormat is:
\copydoc tickDateTimeFormat
*/ - virtual void set_tickDateTimeFormat (QString __value); + virtual void set_tickDateTimeFormat (const QString& __value); /** \brief sets the property tickLabelFontSize to the specified \a __value. @@ -504,7 +504,7 @@ class LIB_EXPORT JKQTPCoordinateAxis: public QObject { /** \brief sets the property axisColor to the specified \a __value. * \details Description of the parameter axisColor is:
\copydoc axisColor
*/ - virtual void setAxisColor (QColor __value); + virtual void setAxisColor (const QColor& __value); /** \brief sets the property showZeroAxis to the specified \a __value. * \details Description of the parameter showZeroAxis is:
\copydoc showZeroAxis
*/ @@ -516,11 +516,11 @@ class LIB_EXPORT JKQTPCoordinateAxis: public QObject { /** \brief sets the property gridColor to the specified \a __value. * \details Description of the parameter gridColor is:
\copydoc gridColor
*/ - virtual void setGridColor(QColor __value); + virtual void setGridColor(const QColor& __value); /** \brief sets the property minorGridColor to the specified \a __value. * \details Description of the parameter minorGridColor is:
\copydoc minorGridColor
*/ - virtual void set_minorGridColor(QColor __value); + virtual void set_minorGridColor(const QColor& __value); /** \brief sets the property gridWidth to the specified \a __value. * \details Description of the parameter gridWidth is:
\copydoc gridWidth
*/ @@ -592,8 +592,8 @@ class LIB_EXPORT JKQTPCoordinateAxis: public QObject { bool paramsChanged; bool doUpdateScaling; - /** \brief simply calls the replotPlot method of the parent plotter class */ - void replotPlot(); + /** \brief simply calls the redrawPlot method of the parent plotter class */ + void redrawPlot(); /** \brief a list of tick labels. * * If this list contains items, this class will NOT plot a standard x-axis, diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index 842ae63acb..143935bee3 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -75,7 +75,7 @@ JKQTBasePlotter::JKQTBasePlotter() initJKQTBasePlotterResources(); } -void JKQTBasePlotter::setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, QString userSettigsPrefix) +void JKQTBasePlotter::setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString& userSettigsPrefix) { globalUserSettigsFilename=userSettigsFilename; globalUserSettigsPrefix=userSettigsPrefix; @@ -335,6 +335,10 @@ void JKQTBasePlotter::forceInternalDatastore(){ if (emitPlotSignals) emit plotUpdated(); } +bool JKQTBasePlotter::isEmittingSignalsEnabled() const { + return this->emitSignals; +} + void JKQTBasePlotter::initSettings() { useClipping=true; //doDrawing=true; @@ -463,6 +467,7 @@ void JKQTBasePlotter::zoom(double nxmin, double nxmax, double nymin, double nyma if (emitPlotSignals) emit plotUpdated(); if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this); } + void JKQTBasePlotter::resize(int wid, int heigh) { widgetWidth=wid; widgetHeight=heigh; @@ -481,7 +486,7 @@ void JKQTBasePlotter::setHeight(int heigh) { if (emitPlotSignals) emit plotUpdated(); } -void JKQTBasePlotter::saveSettings(QSettings& settings, QString group){ +void JKQTBasePlotter::saveSettings(QSettings& settings, const QString& group) const{ QString g=group+"/"; if (group.isEmpty()) g=""; @@ -553,7 +558,7 @@ void JKQTBasePlotter::saveSettings(QSettings& settings, QString group){ } -void JKQTBasePlotter::loadUserSettings(QSettings &settings, QString group) { +void JKQTBasePlotter::loadUserSettings(const QSettings &settings, const QString& group) { currentSaveDirectory=settings.value(group+"currentSaveDirectory", currentSaveDirectory).toString(); currentFileFormat=settings.value(group+"currentFileFormat", currentFileFormat).toString(); currentDataFileFormat=settings.value(group+"currentDataFileFormat", currentFileFormat).toString(); @@ -568,22 +573,19 @@ void JKQTBasePlotter::loadUserSettings(QSettings &settings, QString group) { printKeepAspect=settings.value(group+"printKeepAspect", printKeepAspect).toBool(); exportUnitInMM=settings.value(group+"exportUnitInMM", exportUnitInMM).toBool(); currentPrinter=settings.value(group+"printer", currentPrinter).toString(); - settings.beginGroup(group+"selections"); - int count=settings.value("count", 0).toInt(); + int count=settings.value(group+"selections.count", 0).toInt(); getDataColumnsByUserSaved.clear(); for (int i=0; ipaintPlot(painter, drawOverlays); @@ -1335,7 +1337,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, gridPrintingList[i].plotter->setLineWidthMultiplier(lwm[i]); gridPrintingList[i].plotter->set_paintMagnification(pm[i]); gridPrintingList[i].plotter->setBackgroundColor(backg[i]); - gridPrintingList[i].plotter->replotPlot(); + gridPrintingList[i].plotter->redrawPlot(); } } @@ -1386,8 +1388,8 @@ void JKQTBasePlotter::gridPaintOverlays(JKQTPEnhancedPainter &painter, QSizeF pa int t_y=0; //std::cout<<"printing "<paintOverlays(painter); @@ -2271,7 +2273,7 @@ void JKQTBasePlotter::printpreviewUpdate() } } -void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, QRect rect, bool drawOverlays) { +void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QRect& rect, bool drawOverlays) { #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::draw(rect, %1)").arg(drawOverlays)); #endif @@ -2299,7 +2301,7 @@ void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, QRect rect, bool drawO emitPlotSignals=oldEmitPlotSignals; } -void JKQTBasePlotter::drawOverlays(JKQTPEnhancedPainter &painter, QRect rect) +void JKQTBasePlotter::drawOverlays(JKQTPEnhancedPainter &painter, const QRect& rect) { //resize(rect.width(), rect.height()); @@ -2311,7 +2313,7 @@ void JKQTBasePlotter::drawOverlays(JKQTPEnhancedPainter &painter, QRect rect) painter.restore(); } -void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, QPoint pos, bool drawOverlays) { +void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QPoint& pos, bool drawOverlays) { #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::draw(pos, %1)").arg(drawOverlays)); #endif @@ -2339,7 +2341,7 @@ void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, QPoint pos, bool drawO emitPlotSignals=oldEmitPlotSignals; } -void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, QRect rect, bool drawOverlays) { +void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect, bool drawOverlays) { #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGrid(rect, %1)").arg(drawOverlays)); #endif @@ -2385,7 +2387,7 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, QRect rect, boo } -void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, QPoint pos, bool drawOverlays) { +void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos, bool drawOverlays) { #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGrid(pos, %1)").arg(drawOverlays)); #endif @@ -2431,7 +2433,7 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, QPoint pos, boo emitPlotSignals=oldEmitPlotSignals; } -void JKQTBasePlotter::drawNonGridOverlays(JKQTPEnhancedPainter& painter, QPoint pos) { +void JKQTBasePlotter::drawNonGridOverlays(JKQTPEnhancedPainter& painter, const QPoint& pos) { #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGridOverlays(point)")); #endif @@ -2450,6 +2452,16 @@ void JKQTBasePlotter::drawNonGridOverlays(JKQTPEnhancedPainter& painter, QPoint painter.restore(); } +void JKQTBasePlotter::setEmittingPlotSignalsEnabled(bool __value) +{ + this->emitPlotSignals = __value; +} + +bool JKQTBasePlotter::isEmittingPlotSignalsEnabled() const +{ + return this->emitPlotSignals; +} + void JKQTBasePlotter::registerAdditionalAction(const QString &key, QAction *act) { if (!lstAdditionalPlotterActions.contains(key)) { @@ -2524,7 +2536,7 @@ void JKQTBasePlotter::copyDataMatlab() { saveUserSettings(); } -void JKQTBasePlotter::saveData(QString filename, QString format) { +void JKQTBasePlotter::saveData(const QString& filename, const QString &format) { loadUserSettings(); QStringList fileformats; QStringList fileformatIDs; @@ -2618,7 +2630,7 @@ void JKQTBasePlotter::saveData(QString filename, QString format) { } } -void JKQTBasePlotter::saveAsCSV(QString filename) { +void JKQTBasePlotter::saveAsCSV(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2634,7 +2646,7 @@ void JKQTBasePlotter::saveAsCSV(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsSYLK(QString filename) { +void JKQTBasePlotter::saveAsSYLK(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2650,7 +2662,7 @@ void JKQTBasePlotter::saveAsSYLK(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsMatlab(QString filename) { +void JKQTBasePlotter::saveAsMatlab(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2666,7 +2678,7 @@ void JKQTBasePlotter::saveAsMatlab(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsDIF(QString filename) { +void JKQTBasePlotter::saveAsDIF(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2682,7 +2694,7 @@ void JKQTBasePlotter::saveAsDIF(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsSemicolonSV(QString filename) { +void JKQTBasePlotter::saveAsSemicolonSV(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2698,7 +2710,7 @@ void JKQTBasePlotter::saveAsSemicolonSV(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsTabSV(QString filename) { +void JKQTBasePlotter::saveAsTabSV(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2714,7 +2726,7 @@ void JKQTBasePlotter::saveAsTabSV(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsGerExcelCSV(QString filename) { +void JKQTBasePlotter::saveAsGerExcelCSV(const QString& filename) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2730,7 +2742,7 @@ void JKQTBasePlotter::saveAsGerExcelCSV(QString filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsPDF(QString filename, bool displayPreview) { +void JKQTBasePlotter::saveAsPDF(const QString& filename, bool displayPreview) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2763,7 +2775,7 @@ void JKQTBasePlotter::saveAsPDF(QString filename, bool displayPreview) { saveUserSettings(); } -void JKQTBasePlotter::saveAsPS(QString filename, bool displayPreview) { +void JKQTBasePlotter::saveAsPS(const QString& filename, bool displayPreview) { #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) loadUserSettings(); QString fn=filename; @@ -2800,7 +2812,7 @@ void JKQTBasePlotter::saveAsPS(QString filename, bool displayPreview) { } -void JKQTBasePlotter::saveImage(QString filename, bool displayPreview) { +void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) { loadUserSettings(); QString fn=filename; QStringList filt; @@ -2905,7 +2917,7 @@ void JKQTBasePlotter::saveImage(QString filename, bool displayPreview) { } -void JKQTBasePlotter::saveAsPixelImage(QString filename, bool displayPreview, const QByteArray& outputFormat) { +void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPreview, const QByteArray& outputFormat) { loadUserSettings(); QString fn=filename; QStringList filt; @@ -3091,7 +3103,7 @@ void JKQTBasePlotter::copyPixelImage() { } -void JKQTBasePlotter::saveAsSVG(QString filename, bool displayPreview) { +void JKQTBasePlotter::saveAsSVG(const QString& filename, bool displayPreview) { loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -3218,7 +3230,7 @@ void JKQTBasePlotter::synchronizeXYAxis(double newxmin, double newxmax, double n setXY(newxmin, newxmax, newymin, newymax); } -size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPGraphPlotstyle graphStyle) { +size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, const QString& title, JKQTPGraphPlotstyle graphStyle) { if (graphStyle==JKQTPImpulsesHorizontal) { JKQTPImpulsesHorizontalGraph* gr=new JKQTPImpulsesHorizontalGraph(this); gr->set_title(title); @@ -3267,7 +3279,7 @@ size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, QString title, return -1; } -size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPGraphPlotstyle graphStyle, QColor color, JKQTPGraphSymbols symbol, Qt::PenStyle penstyle, double width) { +size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, const QString& title, JKQTPGraphPlotstyle graphStyle, QColor color, JKQTPGraphSymbols symbol, Qt::PenStyle penstyle, double width) { if (graphStyle==JKQTPImpulsesHorizontal) { JKQTPImpulsesHorizontalGraph* gr=new JKQTPImpulsesHorizontalGraph(this); gr->set_title(title); @@ -3400,7 +3412,7 @@ void JKQTBasePlotter::addVerticalBargraph(QVector xColumns, size_t yColu } } -size_t JKQTBasePlotter::addGraphWithXError(size_t xColumn, size_t yColumn, size_t xErrorColumn, QString title, JKQTPGraphPlotstyle graphStyle, JKQTPErrorPlotstyle errorStyle){ +size_t JKQTBasePlotter::addGraphWithXError(size_t xColumn, size_t yColumn, size_t xErrorColumn, const QString& title, JKQTPGraphPlotstyle graphStyle, JKQTPErrorPlotstyle errorStyle){ if (graphStyle==JKQTPImpulsesHorizontal) { JKQTPImpulsesHorizontalErrorGraph* gr=new JKQTPImpulsesHorizontalErrorGraph(this); gr->set_title(title); @@ -3444,7 +3456,7 @@ size_t JKQTBasePlotter::addGraphWithXError(size_t xColumn, size_t yColumn, size_ } -size_t JKQTBasePlotter::addGraphWithYError(size_t xColumn, size_t yColumn, size_t yErrorColumn, QString title, JKQTPGraphPlotstyle graphStyle, JKQTPErrorPlotstyle errorStyle){ +size_t JKQTBasePlotter::addGraphWithYError(size_t xColumn, size_t yColumn, size_t yErrorColumn, const QString& title, JKQTPGraphPlotstyle graphStyle, JKQTPErrorPlotstyle errorStyle){ if (graphStyle==JKQTPImpulsesVertical) { JKQTPImpulsesVerticalErrorGraph* gr=new JKQTPImpulsesVerticalErrorGraph(this); gr->set_title(title); @@ -3488,7 +3500,7 @@ size_t JKQTBasePlotter::addGraphWithYError(size_t xColumn, size_t yColumn, size_ } } -size_t JKQTBasePlotter::addGraphWithXYError(size_t xColumn, size_t yColumn, size_t xErrorColumn, size_t yErrorColumn, QString title, JKQTPGraphPlotstyle graphStyle){ +size_t JKQTBasePlotter::addGraphWithXYError(size_t xColumn, size_t yColumn, size_t xErrorColumn, size_t yErrorColumn, const QString& title, JKQTPGraphPlotstyle graphStyle){ JKQTPXYLineErrorGraph* gr=new JKQTPXYLineErrorGraph(this); gr->set_title(title); gr->set_xColumn(xColumn); @@ -3839,7 +3851,7 @@ void JKQTBasePlotter::loadUserSettings() } } -void JKQTBasePlotter::saveUserSettings() +void JKQTBasePlotter::saveUserSettings() const { if (!userSettigsFilename.isEmpty()) { QSettings set(userSettigsFilename, QSettings::IniFormat); @@ -4529,5 +4541,4 @@ QPaintDevice *JKQTPPaintDeviceAdapter::createPaintdeviceMM(const QString &filena return createPaintdevice(filename, widthMM/25.4*QApplication::desktop()->logicalDpiX(), heightMM/25.4*QApplication::desktop()->logicalDpiY()); } -JKQTPSaveDataAdapter::~JKQTPSaveDataAdapter() { -} +JKQTPSaveDataAdapter::~JKQTPSaveDataAdapter() = default; diff --git a/lib/jkqtplotter/jkqtpbaseplotter.h b/lib/jkqtplotter/jkqtpbaseplotter.h index 77ae7d2cb5..e543309c9f 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.h +++ b/lib/jkqtplotter/jkqtpbaseplotter.h @@ -291,45 +291,45 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief default value for property property varname. \see plotBorderTop for more information */ int def_plotBorderTop; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - int iplotBorderTop; - int iplotKeyBorderTop; + double iplotBorderTop; + double iplotKeyBorderTop; /** \brief height of the plot title (or 0 if no title) */ - int iTitleHeight; + double iTitleHeight; /** \brief free space between widget left border and plot left border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderLeft */ int plotBorderLeft; /*! \brief default value for property property varname. \see plotBorderLeft for more information */ int def_plotBorderLeft; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - int iplotBorderLeft; - int iplotKeyBorderLeft; + double iplotBorderLeft; + double iplotKeyBorderLeft; /** \brief free space between widget bottom border and plot bottom border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderBottom */ int plotBorderBottom; /*! \brief default value for property property varname. \see plotBorderBottom for more information */ int def_plotBorderBottom; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - int iplotBorderBottom; - int iplotKeyBorderBottom; + double iplotBorderBottom; + double iplotKeyBorderBottom; /** \brief free space between widget right border and plot right border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderRight */ int plotBorderRight; /*! \brief default value for property property varname. \see plotBorderRight for more information */ int def_plotBorderRight; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - int iplotBorderRight; - int iplotKeyBorderRight; + double iplotBorderRight; + double iplotKeyBorderRight; /** \brief free space between widget top border and plot top border (including coordinate axes) */ - int iplotBorderTop_nographs; + double iplotBorderTop_nographs; /** \brief free space between widget left border and plot left border (including coordinate axes) */ - int iplotBorderLeft_nographs; + double iplotBorderLeft_nographs; /** \brief free space between widget right border and plot right border (including coordinate axes) */ - int iplotBorderBottom_nographs; + double iplotBorderBottom_nographs; /** \brief free space between widget bottom border and plot bottom border (including coordinate axes) */ - int iplotBorderRight_nographs; + double iplotBorderRight_nographs; /** \brief indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight */ bool maintainAspectRatio; @@ -499,7 +499,8 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /** \brief set the standard settings (colors, line widths ...) */ void initSettings(); - /** \brief specifies whether this class emits signals, like zoomChangedLocally() */ + + /** \brief specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */ bool emitSignals; /** \brief specifies whether to use antialiasing for plotting the coordinate system */ @@ -575,17 +576,17 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { void gridPrintingCalc(); /** \brief plot the grid */ - virtual void plotSystemGrid(JKQTPEnhancedPainter& painter); + void plotSystemGrid(JKQTPEnhancedPainter& painter); /** \brief plot the x coordinate axis (incl. labels) */ - virtual void plotSystemXAxis(JKQTPEnhancedPainter& painter); + void plotSystemXAxis(JKQTPEnhancedPainter& painter); /** \brief plot the x coordinate axis (incl. labels) */ - virtual void plotSystemYAxis(JKQTPEnhancedPainter& painter); + void plotSystemYAxis(JKQTPEnhancedPainter& painter); /** \brief plot the graphs */ - virtual void plotGraphs(JKQTPEnhancedPainter& painter); + void plotGraphs(JKQTPEnhancedPainter& painter); /** \brief plot a key */ - virtual void plotKey(JKQTPEnhancedPainter& painter); + void plotKey(JKQTPEnhancedPainter& painter); /** \brief plot all overlay elements */ - virtual void plotOverlays(JKQTPEnhancedPainter& painter); + void plotOverlays(JKQTPEnhancedPainter& painter); /** \brief plot the key contents * @@ -600,7 +601,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * * So any implementation should only draw inside the rectangle [x..x+width, y..y+hieght] */ - virtual void plotKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double width, double height); + void plotKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double width, double height); /** \brief returns the size of the key (as call-by-reference parameters * @@ -610,7 +611,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * * The implementation in here returns zero size! */ - virtual void getKeyExtent(JKQTPEnhancedPainter& painter, double *width, double *height, double *text_width=nullptr, double *text_height=nullptr, int *columns_count=nullptr, int* lines_count=nullptr); + void getKeyExtent(JKQTPEnhancedPainter& painter, double *width, double *height, double *text_width=nullptr, double *text_height=nullptr, int *columns_count=nullptr, int* lines_count=nullptr); /** \brief QAction which triggers saving of the plot as an image */ QAction* actSavePlot; /** \brief QAction which triggers saving of the data used for the plot */ @@ -659,7 +660,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { bool masterSynchronizeHeight; - + /** \brief controls, whether the signals plotUpdated() and overlaysUpdated() are emitted */ bool emitPlotSignals; @@ -670,42 +671,42 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property fontSizeMultiplier to the specified \a __value. \details Description of the parameter fontSizeMultiplier is:
\copydoc fontSizeMultiplier
\see fontSizeMultiplier for more information */ - inline virtual void setFontSizeMultiplier(double __value) + inline void setFontSizeMultiplier(double __value) { this->fontSizeMultiplier = __value; } /*! \brief sets the property lineWidthMultiplier to the specified \a __value. \details Description of the parameter lineWidthMultiplier is:
\copydoc lineWidthMultiplier
\see lineWidthMultiplier for more information */ - inline virtual void setLineWidthMultiplier(double __value) + inline void setLineWidthMultiplier(double __value) { this->lineWidthMultiplier = __value; } /*! \brief sets the property printMagnification to the specified \a __value. \details Description of the parameter printMagnification is:
\copydoc printMagnification
\see printMagnification for more information */ - inline virtual void set_printMagnification(double __value) + inline void set_printMagnification(double __value) { this->printMagnification = __value; } /*! \brief returns the property printMagnification. \details Description of the parameter printMagnification is:
\copydoc printMagnification
\see printMagnification for more information */ - inline virtual double get_printMagnification() const + inline double get_printMagnification() const { return this->printMagnification; } /*! \brief sets the property paintMagnification to the specified \a __value. \details Description of the parameter paintMagnification is:
\copydoc paintMagnification
\see paintMagnification for more information */ - inline virtual void set_paintMagnification(double __value) + inline void set_paintMagnification(double __value) { this->paintMagnification = __value; } /*! \brief returns the property paintMagnification. \details Description of the parameter paintMagnification is:
\copydoc paintMagnification
\see paintMagnification for more information */ - inline virtual double get_paintMagnification() const + inline double get_paintMagnification() const { return this->paintMagnification; } @@ -785,23 +786,23 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { void setGrid(bool val); /** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed */ - void saveAsPixelImage(QString filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray()); + void saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray()); /** \brief copy the current plot as a pixel image to the clipboard */ void copyPixelImage(); /** \brief save the current plot as a SVG file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */ - void saveAsSVG(QString filename=QString(""), bool displayPreview=true); + void saveAsSVG(const QString& filename=QString(""), bool displayPreview=true); /** \brief save the current plot as a PDF file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */ - void saveAsPDF(QString filename=QString(""), bool displayPreview=true); + void saveAsPDF(const QString& filename=QString(""), bool displayPreview=true); /** \brief save the current plot as a PS file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */ - void saveAsPS(QString filename=QString(""), bool displayPreview=true); + void saveAsPS(const QString& filename=QString(""), bool displayPreview=true); /** \brief save the current plot as an image file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed. * The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...) */ - void saveImage(QString filename=QString(""), bool displayPreview=true); + void saveImage(const QString& filename=QString(""), bool displayPreview=true); /** \brief save the data used for the current plot. The file format is extracted from the file extension (csv, ...) * @@ -811,7 +812,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * If \a format is \c "slk" the output will be in SYLK format, if \a format is \c "csv" or \a "dat" the output will be comma separated values * and if \a format is \c "txt" the output will be tab separated values. */ - void saveData(QString filename=QString(""), QString jkqtp_format=QString("")); + void saveData(const QString& filename=QString(""), const QString& jkqtp_format=QString("")); /** \brief copy the data used for the current plot to the clipboard * * copies data as tab separated data with the system-decimal point. @@ -821,25 +822,25 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { */ void copyDataMatlab(); /** \brief save the current plot data as a Comma Separated Values (CSV) file*/ - virtual void saveAsCSV(QString filename=QString("")); + void saveAsCSV(const QString& filename=QString("")); /** \brief save the current plot data as a DIF file*/ - virtual void saveAsDIF(QString filename=QString("")); + void saveAsDIF(const QString& filename=QString("")); /** \brief save the current plot data as a SYLK spreadsheet file*/ - virtual void saveAsSYLK(QString filename=QString("")); + void saveAsSYLK(const QString& filename=QString("")); /** \brief save the current plot data as a Matlab Script*/ - virtual void saveAsMatlab(QString filename=QString("")); + void saveAsMatlab(const QString& filename=QString("")); /** \brief save the current plot data as a Semicolon Separated Values (SSV) file*/ - virtual void saveAsSemicolonSV(QString filename=QString("")); + void saveAsSemicolonSV(const QString& filename=QString("")); /** \brief save the current plot data as a Tabulator Separated Values (CSV) file*/ - virtual void saveAsTabSV(QString filename=QString("")); + void saveAsTabSV(const QString& filename=QString("")); /** \brief save the current plot data as a Semicolon Separated Values (CSV) file for german Excel, i.e. with comma as decimal separator*/ - virtual void saveAsGerExcelCSV(QString filename=QString("")); + void saveAsGerExcelCSV(const QString& filename=QString("")); /** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */ void print(QPrinter* printer=nullptr, bool displayPreview=true); @@ -856,7 +857,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * For log< plots we actually use this on the logarithmized data! (default: 1.05) * */ - virtual void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05); + void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05); /** \brief zooms into the graph (the same as turning the mouse wheel) by the given factor */ void zoomIn(double factor=2.0); @@ -871,13 +872,13 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /** \brief en-/disables the maintaining of the data aspect ratio */ void setMaintainAspectRatio(bool value) { maintainAspectRatio=value; - replotPlot(); + redrawPlot(); } /** \brief en-/disables the maintaining of the axis aspect ratio */ void setMaintainAxisAspectRatio(bool value) { maintainAxisAspectRatio=value; - replotPlot(); + redrawPlot(); } void setUserSettigsFilename(const QString& filename, const QString& prefix); @@ -895,7 +896,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { void loadUserSettings(); /** \brief saves the plot user properties if userSettingsFilename is set, does nothing otherwise */ - void saveUserSettings(); + void saveUserSettings() const; public: /** \brief class constructor * @@ -944,28 +945,28 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * the lather case */ void forceInternalDatastore(); - /*! \brief returns the property emitSignals. \details Description of the parameter emitSignals is:
\copydoc emitSignals
. \see emitSignals for more information */ - inline bool isEmittingSignalsEnabled()const { return this->emitSignals; } - + /** \brief returns whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */ + bool isEmittingSignalsEnabled()const; + /** \brief specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */ void setEmittingSignalsEnabled(bool enabled); /** \brief loads the plot properties from a QSettings object */ - virtual void loadSettings(QSettings& settings, QString group=QString("plots")); + void loadSettings(const QSettings& settings, const QString& group=QString("plots")); /** \brief saves the plot properties into a QSettings object. * * This method only saves those properties that differ from their default value. */ - virtual void saveSettings(QSettings& settings, QString group=QString("plots")); + void saveSettings(QSettings& settings, const QString& group=QString("plots")) const; /** \brief loads the plot user properties from a QSettings object */ - virtual void loadUserSettings(QSettings& settings, QString group=QString("plots_user")); + void loadUserSettings(const QSettings& settings, const QString& group=QString("plots_user")); /** \brief saves the plot user properties into a QSettings object. */ - virtual void saveUserSettings(QSettings& settings, QString group=QString("plots_user")); + void saveUserSettings(QSettings& settings, const QString& group=QString("plots_user")) const; /** \brief sets the width of the plot widget */ void setWidth(int wid); @@ -1136,50 +1137,40 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ - void draw(JKQTPEnhancedPainter& painter, QRect rect, bool drawOverlays=true); + void draw(JKQTPEnhancedPainter& painter, const QRect& rect, bool drawOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ - void drawOverlays(JKQTPEnhancedPainter& painter, QRect rect); + void drawOverlays(JKQTPEnhancedPainter& painter, const QRect& rect); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param pos where to plot the painter (left-top corner) */ - void draw(JKQTPEnhancedPainter& painter, QPoint pos=QPoint(0,0), bool drawOverlays=true); + void draw(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool drawOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ - void drawNonGrid(JKQTPEnhancedPainter& painter, QRect rect, bool drawOverlays=true); + void drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect, bool drawOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param pos where to plot the painter (left-top corner) */ - void drawNonGrid(JKQTPEnhancedPainter& painter, QPoint pos=QPoint(0,0), bool drawOverlays=true); - void drawNonGridOverlays(JKQTPEnhancedPainter &painter, QPoint pos=QPoint(0,0)); + void drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool drawOverlays=true); + void drawNonGridOverlays(JKQTPEnhancedPainter &painter, const QPoint& pos=QPoint(0,0)); /** \brief emit plotUpdated() */ - void replotPlot() { if (emitPlotSignals) emit plotUpdated(); } + void redrawPlot() { if (emitPlotSignals) emit plotUpdated(); } - /*! \brief sets the property emitPlotSignals to the specified \a __value. - \details Description of the parameter emitPlotSignals is:
\copydoc emitPlotSignals
- \see emitPlotSignals for more information */ - inline virtual void setEmittingPlotSignalsEnabled(bool __value) - { - this->emitPlotSignals = __value; - } - /*! \brief returns the property emitPlotSignals. - \details Description of the parameter emitPlotSignals is:
\copydoc emitPlotSignals
- \see emitPlotSignals for more information */ - inline virtual bool isEmittingPlotSignalsEnabled() const - { - return this->emitPlotSignals; - } + /** \brief controls, whether the signals plotUpdated() and overlaysUpdated() are emitted */ + void setEmittingPlotSignalsEnabled(bool __value); + /** \brief returns, whether the signals plotUpdated() and overlaysUpdated() are emitted */ + bool isEmittingPlotSignalsEnabled() const; /*! \brief returns the property plotBorderTop. \details Description of the parameter plotBorderTop is:
\copydoc plotBorderTop
. \see plotBorderTop for more information */ inline int getPlotBorderTop() const { return this->plotBorderTop; } @@ -1195,17 +1186,17 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property aspectRatio to the specified \a __value. \details Description of the parameter aspectRatio is:
\copydoc aspectRatio
\see aspectRatio for more information */ - inline virtual void setAspectRatio(double __value) + inline void setAspectRatio(double __value) { if (this->aspectRatio != __value) { this->aspectRatio = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property aspectRatio. \details Description of the parameter aspectRatio is:
\copydoc aspectRatio
\see aspectRatio for more information */ - inline virtual double getAspectRatio() const + inline double getAspectRatio() const { return this->aspectRatio; } @@ -1215,17 +1206,17 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property axisAspectRatio to the specified \a __value. \details Description of the parameter axisAspectRatio is:
\copydoc axisAspectRatio
\see axisAspectRatio for more information */ - inline virtual void setAxisAspectRatio(double __value) + inline void setAxisAspectRatio(double __value) { if (this->axisAspectRatio != __value) { this->axisAspectRatio = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property axisAspectRatio. \details Description of the parameter axisAspectRatio is:
\copydoc axisAspectRatio
\see axisAspectRatio for more information */ - inline virtual double getAxisAspectRatio() const + inline double getAxisAspectRatio() const { return this->axisAspectRatio; } @@ -1233,51 +1224,51 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property useAntiAliasingForSystem to the specified \a __value. \details Description of the parameter useAntiAliasingForSystem is:
\copydoc useAntiAliasingForSystem
\see useAntiAliasingForSystem for more information */ - inline virtual void setUseAntiAliasingForSystem(bool __value) + inline void setUseAntiAliasingForSystem(bool __value) { if (this->useAntiAliasingForSystem != __value) { this->useAntiAliasingForSystem = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property useAntiAliasingForSystem. \details Description of the parameter useAntiAliasingForSystem is:
\copydoc useAntiAliasingForSystem
\see useAntiAliasingForSystem for more information */ - inline virtual bool isUsingAntiAliasingForSystem() const + inline bool isUsingAntiAliasingForSystem() const { return this->useAntiAliasingForSystem; } /*! \brief sets the property useAntiAliasingForGraphs to the specified \a __value. \details Description of the parameter useAntiAliasingForGraphs is:
\copydoc useAntiAliasingForGraphs
\see useAntiAliasingForGraphs for more information */ - inline virtual void setUseAntiAliasingForGraphs(bool __value) + inline void setUseAntiAliasingForGraphs(bool __value) { if (this->useAntiAliasingForGraphs != __value) { this->useAntiAliasingForGraphs = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property useAntiAliasingForGraphs. \details Description of the parameter useAntiAliasingForGraphs is:
\copydoc useAntiAliasingForGraphs
\see useAntiAliasingForGraphs for more information */ - inline virtual bool isUsingAntiAliasingForGraphs() const + inline bool isUsingAntiAliasingForGraphs() const { return this->useAntiAliasingForGraphs; } /*! \brief sets the property useAntiAliasingForText to the specified \a __value. \details Description of the parameter useAntiAliasingForText is:
\copydoc useAntiAliasingForText
\see useAntiAliasingForText for more information */ - inline virtual void setUseAntiAliasingForText(bool __value) + inline void setUseAntiAliasingForText(bool __value) { if (this->useAntiAliasingForText != __value) { this->useAntiAliasingForText = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property useAntiAliasingForText. \details Description of the parameter useAntiAliasingForText is:
\copydoc useAntiAliasingForText
\see useAntiAliasingForText for more information */ - inline virtual bool isUsingAntiAliasingForText() const + inline bool isUsingAntiAliasingForText() const { return this->useAntiAliasingForText; } @@ -1285,34 +1276,34 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property graphColor to the specified \a __value. \details Description of the parameter graphColor is:
\copydoc graphColor
\see graphColor for more information */ - inline virtual void setGraphColor(const QColor & __value) + inline void setGraphColor(const QColor & __value) { if (this->graphColor != __value) { this->graphColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property graphColor. \details Description of the parameter graphColor is:
\copydoc graphColor
\see graphColor for more information */ - inline virtual QColor getGraphColor() const + inline QColor getGraphColor() const { return this->graphColor; } /*! \brief sets the property graphWidth to the specified \a __value. \details Description of the parameter graphWidth is:
\copydoc graphWidth
\see graphWidth for more information */ - inline virtual void setGraphWidth(double __value) + inline void setGraphWidth(double __value) { if (this->graphWidth != __value) { this->graphWidth = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property graphWidth. \details Description of the parameter graphWidth is:
\copydoc graphWidth
\see graphWidth for more information */ - inline virtual double getGraphWidth() const + inline double getGraphWidth() const { return this->graphWidth; } @@ -1320,51 +1311,51 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property backgroundColor to the specified \a __value. \details Description of the parameter backgroundColor is:
\copydoc backgroundColor
\see backgroundColor for more information */ - inline virtual void setBackgroundColor(const QColor & __value) + inline void setBackgroundColor(const QColor & __value) { if (this->backgroundColor != __value) { this->backgroundColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property backgroundColor. \details Description of the parameter backgroundColor is:
\copydoc backgroundColor
\see backgroundColor for more information */ - inline virtual QColor getBackgroundColor() const + inline QColor getBackgroundColor() const { return this->backgroundColor; } /*! \brief sets the property exportBackgroundColor to the specified \a __value. \details Description of the parameter exportBackgroundColor is:
\copydoc exportBackgroundColor
\see exportBackgroundColor for more information */ - inline virtual void setExportBackgroundColor(const QColor & __value) + inline void setExportBackgroundColor(const QColor & __value) { if (this->exportBackgroundColor != __value) { this->exportBackgroundColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property exportBackgroundColor. \details Description of the parameter exportBackgroundColor is:
\copydoc exportBackgroundColor
\see exportBackgroundColor for more information */ - inline virtual QColor getExportBackgroundColor() const + inline QColor getExportBackgroundColor() const { return this->exportBackgroundColor; } /*! \brief sets the property plotBackgroundColor to the specified \a __value. \details Description of the parameter plotBackgroundColor is:
\copydoc plotBackgroundColor
\see plotBackgroundColor for more information */ - inline virtual void setPlotBackgroundColor(const QColor & __value) + inline void setPlotBackgroundColor(const QColor & __value) { if (this->plotBackgroundColor != __value) { this->plotBackgroundColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotBackgroundColor. \details Description of the parameter plotBackgroundColor is:
\copydoc plotBackgroundColor
\see plotBackgroundColor for more information */ - inline virtual QColor getPlotBackgroundColor() const + inline QColor getPlotBackgroundColor() const { return this->plotBackgroundColor; } @@ -1372,153 +1363,153 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property keyFont to the specified \a __value. \details Description of the parameter keyFont is:
\copydoc keyFont
\see keyFont for more information */ - inline virtual void setKeyFont(const QString & __value) + inline void setKeyFont(const QString & __value) { if (this->keyFont != __value) { this->keyFont = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyFont. \details Description of the parameter keyFont is:
\copydoc keyFont
\see keyFont for more information */ - inline virtual QString getKeyFont() const + inline QString getKeyFont() const { return this->keyFont; } /*! \brief sets the property keyFontSize to the specified \a __value. \details Description of the parameter keyFontSize is:
\copydoc keyFontSize
\see keyFontSize for more information */ - inline virtual void setKeyFontSize(double __value) + inline void setKeyFontSize(double __value) { if (this->keyFontSize != __value) { this->keyFontSize = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyFontSize. \details Description of the parameter keyFontSize is:
\copydoc keyFontSize
\see keyFontSize for more information */ - inline virtual double getKeyFontSize() const + inline double getKeyFontSize() const { return this->keyFontSize; } /*! \brief sets the property key_item_width to the specified \a __value. \details Description of the parameter key_item_width is:
\copydoc key_item_width
\see key_item_width for more information */ - inline virtual void setKeyItemWidth(double __value) + inline void setKeyItemWidth(double __value) { if (this->key_item_width != __value) { this->key_item_width = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property key_item_width. \details Description of the parameter key_item_width is:
\copydoc key_item_width
\see key_item_width for more information */ - inline virtual double getKeyItemWidth() const + inline double getKeyItemWidth() const { return this->key_item_width; } /*! \brief sets the property key_item_height to the specified \a __value. \details Description of the parameter key_item_height is:
\copydoc key_item_height
\see key_item_height for more information */ - inline virtual void setKeyItemHeight(double __value) + inline void setKeyItemHeight(double __value) { if (this->key_item_height != __value) { this->key_item_height = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property key_item_height. \details Description of the parameter key_item_height is:
\copydoc key_item_height
\see key_item_height for more information */ - inline virtual double getKeyItemHeight() const + inline double getKeyItemHeight() const { return this->key_item_height; } /*! \brief sets the property keyYSeparation to the specified \a __value. \details Description of the parameter keyYSeparation is:
\copydoc keyYSeparation
\see keyYSeparation for more information */ - inline virtual void setKeyYSeparation(double __value) + inline void setKeyYSeparation(double __value) { if (this->keyYSeparation != __value) { this->keyYSeparation = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyYSeparation. \details Description of the parameter keyYSeparation is:
\copydoc keyYSeparation
\see keyYSeparation for more information */ - inline virtual double getKeyYSeparation() const + inline double getKeyYSeparation() const { return this->keyYSeparation; } /*! \brief sets the property key_line_length to the specified \a __value. \details Description of the parameter key_line_length is:
\copydoc key_line_length
\see key_line_length for more information */ - inline virtual void setKeyLineLength(double __value) + inline void setKeyLineLength(double __value) { if (this->key_line_length != __value) { this->key_line_length = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property key_line_length. \details Description of the parameter key_line_length is:
\copydoc key_line_length
\see key_line_length for more information */ - inline virtual double getKeyLineLength() const + inline double getKeyLineLength() const { return this->key_line_length; } /*! \brief sets the property keyXMargin to the specified \a __value. \details Description of the parameter keyXMargin is:
\copydoc keyXMargin
\see keyXMargin for more information */ - inline virtual void setKeyXMargin(double __value) + inline void setKeyXMargin(double __value) { if (this->keyXMargin != __value) { this->keyXMargin = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyXMargin. \details Description of the parameter keyXMargin is:
\copydoc keyXMargin
\see keyXMargin for more information */ - inline virtual double getKeyXMargin() const + inline double getKeyXMargin() const { return this->keyXMargin; } /*! \brief sets the property keyYMargin to the specified \a __value. \details Description of the parameter keyYMargin is:
\copydoc keyYMargin
\see keyYMargin for more information */ - inline virtual void setKeyYMargin(double __value) + inline void setKeyYMargin(double __value) { if (this->keyYMargin != __value) { this->keyYMargin = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyYMargin. \details Description of the parameter keyYMargin is:
\copydoc keyYMargin
\see keyYMargin for more information */ - inline virtual double getKeyYMargin() const + inline double getKeyYMargin() const { return this->keyYMargin; } /*! \brief sets the property keyXSeparation to the specified \a __value. \details Description of the parameter keyXSeparation is:
\copydoc keyXSeparation
\see keyXSeparation for more information */ - inline virtual void setKeyXSeparation(double __value) + inline void setKeyXSeparation(double __value) { if (this->keyXSeparation != __value) { this->keyXSeparation = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyXSeparation. \details Description of the parameter keyXSeparation is:
\copydoc keyXSeparation
\see keyXSeparation for more information */ - inline virtual double getKeyXSeparation() const + inline double getKeyXSeparation() const { return this->keyXSeparation; } @@ -1526,170 +1517,170 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property keyXOffset to the specified \a __value. \details Description of the parameter keyXOffset is:
\copydoc keyXOffset
\see keyXOffset for more information */ - inline virtual void setKeyXOffset(double __value) + inline void setKeyXOffset(double __value) { if (this->keyXOffset != __value) { this->keyXOffset = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyXOffset. \details Description of the parameter keyXOffset is:
\copydoc keyXOffset
\see keyXOffset for more information */ - inline virtual double getKeyXOffset() const + inline double getKeyXOffset() const { return this->keyXOffset; } /*! \brief sets the property keyYOffset to the specified \a __value. \details Description of the parameter keyYOffset is:
\copydoc keyYOffset
\see keyYOffset for more information */ - inline virtual void setKeyYOffset(double __value) + inline void setKeyYOffset(double __value) { if (this->keyYOffset != __value) { this->keyYOffset = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyYOffset. \details Description of the parameter keyYOffset is:
\copydoc keyYOffset
\see keyYOffset for more information */ - inline virtual double getKeyYOffset() const + inline double getKeyYOffset() const { return this->keyYOffset; } /*! \brief sets the property showKey to the specified \a __value. \details Description of the parameter showKey is:
\copydoc showKey
\see showKey for more information */ - inline virtual void setShowKey(bool __value) + inline void setShowKey(bool __value) { if (this->showKey != __value) { this->showKey = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property showKey. \details Description of the parameter showKey is:
\copydoc showKey
\see showKey for more information */ - inline virtual bool getShowKey() const + inline bool getShowKey() const { return this->showKey; } /*! \brief sets the property showKeyFrame to the specified \a __value. \details Description of the parameter showKeyFrame is:
\copydoc showKeyFrame
\see showKeyFrame for more information */ - inline virtual void setShowKeyFrame(bool __value) + inline void setShowKeyFrame(bool __value) { if (this->showKeyFrame != __value) { this->showKeyFrame = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property showKeyFrame. \details Description of the parameter showKeyFrame is:
\copydoc showKeyFrame
\see showKeyFrame for more information */ - inline virtual bool getShowKeyFrame() const + inline bool getShowKeyFrame() const { return this->showKeyFrame; } /*! \brief sets the property keyFrameColor to the specified \a __value. \details Description of the parameter keyFrameColor is:
\copydoc keyFrameColor
\see keyFrameColor for more information */ - inline virtual void setKeyFrameColor(const QColor & __value) + inline void setKeyFrameColor(const QColor & __value) { if (this->keyFrameColor != __value) { this->keyFrameColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyFrameColor. \details Description of the parameter keyFrameColor is:
\copydoc keyFrameColor
\see keyFrameColor for more information */ - inline virtual QColor getKeyFrameColor() const + inline QColor getKeyFrameColor() const { return this->keyFrameColor; } /*! \brief sets the property keyBackgroundColor to the specified \a __value. \details Description of the parameter keyBackgroundColor is:
\copydoc keyBackgroundColor
\see keyBackgroundColor for more information */ - inline virtual void setKeyBackgroundColor(const QColor & __value) + inline void setKeyBackgroundColor(const QColor & __value) { if (this->keyBackgroundColor != __value) { this->keyBackgroundColor = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyBackgroundColor. \details Description of the parameter keyBackgroundColor is:
\copydoc keyBackgroundColor
\see keyBackgroundColor for more information */ - inline virtual QColor getKeyBackgroundColor() const + inline QColor getKeyBackgroundColor() const { return this->keyBackgroundColor; } /*! \brief sets the property keyFrameWidth to the specified \a __value. \details Description of the parameter keyFrameWidth is:
\copydoc keyFrameWidth
\see keyFrameWidth for more information */ - inline virtual void setKeyFrameWidth(double __value) + inline void setKeyFrameWidth(double __value) { if (this->keyFrameWidth != __value) { this->keyFrameWidth = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyFrameWidth. \details Description of the parameter keyFrameWidth is:
\copydoc keyFrameWidth
\see keyFrameWidth for more information */ - inline virtual double getKeyFrameWidth() const + inline double getKeyFrameWidth() const { return this->keyFrameWidth; } /*! \brief sets the property keyAutosize to the specified \a __value. \details Description of the parameter keyAutosize is:
\copydoc keyAutosize
\see keyAutosize for more information */ - inline virtual void setKeyAutosize(bool __value) + inline void setKeyAutosize(bool __value) { if (this->keyAutosize != __value) { this->keyAutosize = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyAutosize. \details Description of the parameter keyAutosize is:
\copydoc keyAutosize
\see keyAutosize for more information */ - inline virtual bool getKeyAutosize() const + inline bool getKeyAutosize() const { return this->keyAutosize; } /*! \brief sets the property keyPosition to the specified \a __value. \details Description of the parameter keyPosition is:
\copydoc keyPosition
\see keyPosition for more information */ - inline virtual void setKeyPosition(const JKQTPKeyPosition & __value) + inline void setKeyPosition(const JKQTPKeyPosition & __value) { if (this->keyPosition != __value) { this->keyPosition = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyPosition. \details Description of the parameter keyPosition is:
\copydoc keyPosition
\see keyPosition for more information */ - inline virtual JKQTPKeyPosition getKeyPosition() const + inline JKQTPKeyPosition getKeyPosition() const { return this->keyPosition; } /*! \brief sets the property keyLayout to the specified \a __value. \details Description of the parameter keyLayout is:
\copydoc keyLayout
\see keyLayout for more information */ - inline virtual void setKeyLayout(const JKQTPKeyLayout & __value) + inline void setKeyLayout(const JKQTPKeyLayout & __value) { if (this->keyLayout != __value) { this->keyLayout = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property keyLayout. \details Description of the parameter keyLayout is:
\copydoc keyLayout
\see keyLayout for more information */ - inline virtual JKQTPKeyLayout getKeyLayout() const + inline JKQTPKeyLayout getKeyLayout() const { return this->keyLayout; } @@ -1697,51 +1688,51 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property plotLabelFontSize to the specified \a __value. \details Description of the parameter plotLabelFontSize is:
\copydoc plotLabelFontSize
\see plotLabelFontSize for more information */ - inline virtual void setPlotLabelFontSize(double __value) + inline void setPlotLabelFontSize(double __value) { if (this->plotLabelFontSize != __value) { this->plotLabelFontSize = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotLabelFontSize. \details Description of the parameter plotLabelFontSize is:
\copydoc plotLabelFontSize
\see plotLabelFontSize for more information */ - inline virtual double getPlotLabelFontSize() const + inline double getPlotLabelFontSize() const { return this->plotLabelFontSize; } /*! \brief sets the property plotLabelFontname to the specified \a __value. \details Description of the parameter plotLabelFontname is:
\copydoc plotLabelFontname
\see plotLabelFontname for more information */ - inline virtual void setPlotLabelFontname(const QString & __value) + inline void setPlotLabelFontname(const QString & __value) { if (this->plotLabelFontname != __value) { this->plotLabelFontname = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotLabelFontname. \details Description of the parameter plotLabelFontname is:
\copydoc plotLabelFontname
\see plotLabelFontname for more information */ - inline virtual QString getPlotLabelFontname() const + inline QString getPlotLabelFontname() const { return this->plotLabelFontname; } /*! \brief sets the property plotLabel to the specified \a __value. \details Description of the parameter plotLabel is:
\copydoc plotLabel
\see plotLabel for more information */ - inline virtual void setPlotLabel(const QString & __value) + inline void setPlotLabel(const QString & __value) { if (this->plotLabel != __value) { this->plotLabel = __value; - replotPlot(); + redrawPlot(); } } /*! \brief returns the property plotLabel. \details Description of the parameter plotLabel is:
\copydoc plotLabel
\see plotLabel for more information */ - inline virtual QString getPlotLabel() const + inline QString getPlotLabel() const { return this->plotLabel; } @@ -1749,110 +1740,110 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property gridPrinting to the specified \a __value. \details Description of the parameter gridPrinting is:
\copydoc gridPrinting
\see gridPrinting for more information */ - inline virtual void setGridPrinting(bool __value) + inline void setGridPrinting(bool __value) { this->gridPrinting = __value; } /*! \brief returns the property gridPrinting. \details Description of the parameter gridPrinting is:
\copydoc gridPrinting
\see gridPrinting for more information */ - inline virtual bool getGridPrinting() const + inline bool getGridPrinting() const { return this->gridPrinting; } /*! \brief sets the property gridPrintingCurrentX to the specified \a __value. \details Description of the parameter gridPrintingCurrentX is:
\copydoc gridPrintingCurrentX
\see gridPrintingCurrentX for more information */ - inline virtual void setGridPrintingCurrentX(size_t __value) + inline void setGridPrintingCurrentX(size_t __value) { this->gridPrintingCurrentX = __value; } /*! \brief returns the property gridPrintingCurrentX. \details Description of the parameter gridPrintingCurrentX is:
\copydoc gridPrintingCurrentX
\see gridPrintingCurrentX for more information */ - inline virtual size_t getGridPrintingCurrentX() const + inline size_t getGridPrintingCurrentX() const { return this->gridPrintingCurrentX; } /*! \brief sets the property gridPrintingCurrentY to the specified \a __value. \details Description of the parameter gridPrintingCurrentY is:
\copydoc gridPrintingCurrentY
\see gridPrintingCurrentY for more information */ - inline virtual void setGridPrintingCurrentY(size_t __value) + inline void setGridPrintingCurrentY(size_t __value) { this->gridPrintingCurrentY = __value; } /*! \brief returns the property gridPrintingCurrentY. \details Description of the parameter gridPrintingCurrentY is:
\copydoc gridPrintingCurrentY
\see gridPrintingCurrentY for more information */ - inline virtual size_t getGridPrintingCurrentY() const + inline size_t getGridPrintingCurrentY() const { return this->gridPrintingCurrentY; } /*! \brief sets the property currentSaveDirectory to the specified \a __value. \details Description of the parameter currentSaveDirectory is:
\copydoc currentSaveDirectory
\see currentSaveDirectory for more information */ - inline virtual void setCurrentSaveDirectory(const QString & __value) + inline void setCurrentSaveDirectory(const QString & __value) { this->currentSaveDirectory = __value; } /*! \brief returns the property currentSaveDirectory. \details Description of the parameter currentSaveDirectory is:
\copydoc currentSaveDirectory
\see currentSaveDirectory for more information */ - inline virtual QString getCurrentSaveDirectory() const + inline QString getCurrentSaveDirectory() const { return this->currentSaveDirectory; } /*! \brief sets the property currentFileFormat to the specified \a __value. \details Description of the parameter currentFileFormat is:
\copydoc currentFileFormat
\see currentFileFormat for more information */ - inline virtual void setCurrentFileFormat(const QString & __value) + inline void setCurrentFileFormat(const QString & __value) { this->currentFileFormat = __value; } /*! \brief returns the property currentFileFormat. \details Description of the parameter currentFileFormat is:
\copydoc currentFileFormat
\see currentFileFormat for more information */ - inline virtual QString getCurrentFileFormat() const + inline QString getCurrentFileFormat() const { return this->currentFileFormat; } /*! \brief sets the property CSVdecimalSeparator to the specified \a __value. \details Description of the parameter CSVdecimalSeparator is:
\copydoc CSVdecimalSeparator
\see CSVdecimalSeparator for more information */ - inline virtual void setCSVdecimalSeparator(const QString & __value) + inline void setCSVdecimalSeparator(const QString & __value) { this->CSVdecimalSeparator = __value; } /*! \brief returns the property CSVdecimalSeparator. \details Description of the parameter CSVdecimalSeparator is:
\copydoc CSVdecimalSeparator
\see CSVdecimalSeparator for more information */ - inline virtual QString getCSVdecimalSeparator() const + inline QString getCSVdecimalSeparator() const { return this->CSVdecimalSeparator; } /*! \brief sets the property CSVcommentInitializer to the specified \a __value. \details Description of the parameter CSVcommentInitializer is:
\copydoc CSVcommentInitializer
\see CSVcommentInitializer for more information */ - inline virtual void setCSVcommentInitializer(const QString & __value) + inline void setCSVcommentInitializer(const QString & __value) { this->CSVcommentInitializer = __value; } /*! \brief returns the property CSVcommentInitializer. \details Description of the parameter CSVcommentInitializer is:
\copydoc CSVcommentInitializer
\see CSVcommentInitializer for more information */ - inline virtual QString getCSVcommentInitializer() const + inline QString getCSVcommentInitializer() const { return this->CSVcommentInitializer; } /*! \brief returns the property iplotBorderTop. \details Description of the parameter iplotBorderTop is:
\copydoc iplotBorderTop
. \see iplotBorderTop for more information */ - inline int getInternalPlotBorderTop() const { return this->iplotBorderTop; } + inline double getInternalPlotBorderTop() const { return this->iplotBorderTop; } /*! \brief returns the property iplotBorderLeft. \details Description of the parameter iplotBorderLeft is:
\copydoc iplotBorderLeft
. \see iplotBorderLeft for more information */ - inline int getInternalPlotBorderLeft() const { return this->iplotBorderLeft; } + inline double getInternalPlotBorderLeft() const { return this->iplotBorderLeft; } /*! \brief returns the property iplotBorderBottom. \details Description of the parameter iplotBorderBottom is:
\copydoc iplotBorderBottom
. \see iplotBorderBottom for more information */ - inline int getInternalPlotBorderBottom() const { return this->iplotBorderBottom; } + inline double getInternalPlotBorderBottom() const { return this->iplotBorderBottom; } /*! \brief returns the property iplotBorderRight. \details Description of the parameter iplotBorderRight is:
\copydoc iplotBorderRight
. \see iplotBorderRight for more information */ - inline int getInternalPlotBorderRight() const { return this->iplotBorderRight; } + inline double getInternalPlotBorderRight() const { return this->iplotBorderRight; } /*! \brief returns the property plotWidth. \details Description of the parameter plotWidth is:
\copydoc plotWidth
. \see plotWidth for more information */ inline int getPlotWidth() const { return this->plotWidth; } /*! \brief returns the property plotHeight. \details Description of the parameter plotHeight is:
\copydoc plotHeight
. \see plotHeight for more information */ @@ -1917,14 +1908,14 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property def_backgroundColor to the specified \a __value. \details Description of the parameter def_backgroundColor is:
\copydoc def_backgroundColor
\see def_backgroundColor for more information */ - inline virtual void setDefaultBackgroundColor(const QColor & __value) + inline void setDefaultBackgroundColor(const QColor & __value) { this->def_backgroundColor = __value; } /*! \brief sets the property def_plotBackgroundColor to the specified \a __value. \details Description of the parameter def_plotBackgroundColor is:
\copydoc def_plotBackgroundColor
\see def_plotBackgroundColor for more information */ - inline virtual void setDefaultPlotBackgroundColor(const QColor & __value) + inline void setDefaultPlotBackgroundColor(const QColor & __value) { this->def_plotBackgroundColor = __value; } @@ -1932,28 +1923,28 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { /*! \brief sets the property fontSizePrintMultiplier to the specified \a __value. \details Description of the parameter fontSizePrintMultiplier is:
\copydoc fontSizePrintMultiplier
\see fontSizePrintMultiplier for more information */ - inline virtual void setFontSizePrintMultiplier(double __value) + inline void setFontSizePrintMultiplier(double __value) { this->fontSizePrintMultiplier = __value; } /*! \brief returns the property fontSizePrintMultiplier. \details Description of the parameter fontSizePrintMultiplier is:
\copydoc fontSizePrintMultiplier
\see fontSizePrintMultiplier for more information */ - inline virtual double getFontSizePrintMultiplier() const + inline double getFontSizePrintMultiplier() const { return this->fontSizePrintMultiplier; } /*! \brief sets the property lineWidthPrintMultiplier to the specified \a __value. \details Description of the parameter lineWidthPrintMultiplier is:
\copydoc lineWidthPrintMultiplier
\see lineWidthPrintMultiplier for more information */ - inline virtual void setLineWidthPrintMultiplier(double __value) + inline void setLineWidthPrintMultiplier(double __value) { this->lineWidthPrintMultiplier = __value; } /*! \brief returns the property lineWidthPrintMultiplier. \details Description of the parameter lineWidthPrintMultiplier is:
\copydoc lineWidthPrintMultiplier
\see lineWidthPrintMultiplier for more information */ - inline virtual double getLineWidthPrintMultiplier() const + inline double getLineWidthPrintMultiplier() const { return this->lineWidthPrintMultiplier; } @@ -2021,7 +2012,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * setGraph(i, gr); * \endcode */ - size_t addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPGraphPlotstyle graphStyle=JKQTPLines); + size_t addGraph(size_t xColumn, size_t yColumn, const QString& title, JKQTPGraphPlotstyle graphStyle=JKQTPLines); /** \brief add a new graph, returns it's position in the graphs list. * @@ -2037,7 +2028,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * Both point to columns in the datastore explained in the JKQTBasePlotter class. * The symbolSize is set to 10 and no error information is expected. */ - size_t addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPGraphPlotstyle graphStyle, QColor color, JKQTPGraphSymbols symbol=JKQTPCross, Qt::PenStyle penstyle=Qt::SolidLine, double width=2); + size_t addGraph(size_t xColumn, size_t yColumn, const QString& title, JKQTPGraphPlotstyle graphStyle, QColor color, JKQTPGraphSymbols symbol=JKQTPCross, Qt::PenStyle penstyle=Qt::SolidLine, double width=2); /** \brief add a new graph with x-error information, returns it's position in the graphs list. * @@ -2052,7 +2043,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * Both point to columns in the datastore explained in the JKQTBasePlotter class. * The symbolSize is set to 10 and no error information is expected. */ - size_t addGraphWithXError(size_t xColumn, size_t yColumn, size_t xErrorColumn, QString title, JKQTPGraphPlotstyle graphStyle=JKQTPPoints, JKQTPErrorPlotstyle errorStyle=JKQTPErrorBars); + size_t addGraphWithXError(size_t xColumn, size_t yColumn, size_t xErrorColumn, const QString& title, JKQTPGraphPlotstyle graphStyle=JKQTPPoints, JKQTPErrorPlotstyle errorStyle=JKQTPErrorBars); /** \brief add a new graph with x-error information, returns it's position in the graphs list. * @@ -2067,7 +2058,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * Both point to columns in the datastore explained in the JKQTBasePlotter class. * The symbolSize is set to 10 and no error information is expected. */ - size_t addGraphWithYError(size_t xColumn, size_t yColumn, size_t yErrorColumn, QString title, JKQTPGraphPlotstyle graphStyle=JKQTPPoints, JKQTPErrorPlotstyle errorStyle=JKQTPErrorBars); + size_t addGraphWithYError(size_t xColumn, size_t yColumn, size_t yErrorColumn, const QString& title, JKQTPGraphPlotstyle graphStyle=JKQTPPoints, JKQTPErrorPlotstyle errorStyle=JKQTPErrorBars); /** \brief add a new graph with x-error information, returns it's position in the graphs list. * @@ -2083,7 +2074,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * The symbolSize is set to 10 and no error information is expected. The errorStyle is set to JKQTPErrorBars * for both directions. */ - size_t addGraphWithXYError(size_t xColumn, size_t yColumn, size_t xErrorColumn, size_t yErrorColumn, QString title, JKQTPGraphPlotstyle graphStyle=JKQTPPoints); + size_t addGraphWithXYError(size_t xColumn, size_t yColumn, size_t xErrorColumn, size_t yErrorColumn, const QString& title, JKQTPGraphPlotstyle graphStyle=JKQTPPoints); /** \brief add a boxplot graph to the plot * @@ -2235,7 +2226,7 @@ class LIB_EXPORT JKQTBasePlotter: public QObject { * on a local-basis for each JKQTBasePrinter separately. The changed values from this function call will only take effect for * newly created plotters AFTER the function call! */ - static void setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, QString userSettigsPrefix); + static void setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString& userSettigsPrefix); /** \brief register a user-defined QPaintDevice (with factory JKQTPPaintDeviceAdapter) as a plugin to JKQTBasePlotter/JKQTPlotter, diff --git a/lib/jkqtplotter/jkqtpdatastorage.cpp b/lib/jkqtplotter/jkqtpdatastorage.cpp index ebb00c0cc5..c02f0f9a79 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.cpp +++ b/lib/jkqtplotter/jkqtpdatastorage.cpp @@ -55,9 +55,7 @@ JKQTPColumn::JKQTPColumn(JKQTPDatastore *datastore, const QString &name, size_t //////////////////////////////////////////////////////////////////////////////////////////////// JKQTPColumn::~JKQTPColumn() -{ - -} += default; //////////////////////////////////////////////////////////////////////////////////////////////// size_t JKQTPColumn::getRows() const { @@ -521,7 +519,7 @@ size_t JKQTPDatastore::addLinearColumn(size_t rows, double start, double end, co double delta=(end-start)/(double)(rows-1); JKQTPDatastoreItem* it=new JKQTPDatastoreItem(1, rows); for (size_t i=0; iset(0, i, start+(double)i * delta); + it->set(0, i, start+static_cast(i) * delta); //std::cout<<"copy@"< userColumns, QString separator, QString decimal_separator, QString comment, QString aroundStrings, char floatformat) { +void JKQTPDatastore::saveCSV(const QString& filename, const QSet& userColumns, const QString& separator, const QString& decimal_separator, const QString& comment, const QString& aroundStrings, char floatformat) { //std::cout< userColumns, QString se } //////////////////////////////////////////////////////////////////////////////////////////////// -void JKQTPDatastore::saveMatlab(QString filename, QSet userColumns) { +void JKQTPDatastore::saveMatlab(const QString& filename, const QSet& userColumns) { //std::cout< userColumns) { +void JKQTPDatastore::saveMatlab(QTextStream &txt, const QSet& userColumns) { //std::cout< userColumns) { } //////////////////////////////////////////////////////////////////////////////////////////////// -void JKQTPDatastore::saveCSV(QTextStream& txt, QSet userColumns, QString separator, QString decimal_separator, QString comment, QString aroundStrings, char floatformat) { +void JKQTPDatastore::saveCSV(QTextStream& txt, const QSet& userColumns, const QString& separator, const QString& decimal_separator, const QString& comment, const QString& aroundStrings, char floatformat) { //std::cout< userColumns, QString se } //////////////////////////////////////////////////////////////////////////////////////////////// -void JKQTPDatastore::saveSYLK(QString filename, QSet userColumns, QString floatformat) { +void JKQTPDatastore::saveSYLK(const QString& filename, const QSet& userColumns, const QString& floatformat) { Q_UNUSED(floatformat) // find out the decimal and the thousand separator QLocale loc=QLocale::c(); @@ -836,7 +834,7 @@ void JKQTPDatastore::saveSYLK(QString filename, QSet userColumns, QString f } //////////////////////////////////////////////////////////////////////////////////////////////// -QList > JKQTPDatastore::getData(QStringList *columnNames, QSet userColumns) +QList > JKQTPDatastore::getData(QStringList *columnNames, const QSet& userColumns) { QStringList cl; QList > res; @@ -867,7 +865,7 @@ QList > JKQTPDatastore::getData(QStringList *columnNames, QSet userColumns, QString floatformat) { +void JKQTPDatastore::saveDIF(const QString& filename, const QSet& userColumns, const QString& floatformat) { Q_UNUSED(floatformat) // find out the decimal and the thousand separator QLocale loc=QLocale::c(); @@ -935,8 +933,7 @@ JKQTPDatastoreModel::JKQTPDatastoreModel(JKQTPDatastore *datastore, QObject *par //////////////////////////////////////////////////////////////////////////////////////////////// JKQTPDatastoreModel::~JKQTPDatastoreModel() -{ -} += default; //////////////////////////////////////////////////////////////////////////////////////////////// QVariant JKQTPDatastoreModel::data(const QModelIndex &index, int role) const { diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 66f9893b3c..905ac09d21 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -525,7 +525,7 @@ class LIB_EXPORT JKQTPDatastore{ * - ... * . */ - void saveCSV(QString filename, QSet userColumns=QSet(), QString separator=QString(", "), QString decimal_separator=QString("."), QString comment=QString("#"), QString aroundStrings=QString(""), char floatformat='g'); + void saveCSV(const QString& filename, const QSet& userColumns=QSet(), const QString& separator=QString(", "), const QString& decimal_separator=QString("."), const QString& comment=QString("#"), const QString& aroundStrings=QString(""), char floatformat='g'); /** \brief save contents of datastore as Comma Separated Values (CSV) file * * \param txt QTextStream to write to @@ -543,7 +543,7 @@ class LIB_EXPORT JKQTPDatastore{ * - ... * . */ - void saveCSV(QTextStream& txt, QSet userColumns=QSet(), QString separator=QString(", "), QString decimal_separator=QString("."), QString comment=QString("#"), QString aroundStrings=QString(""), char floatformat='g'); + void saveCSV(QTextStream& txt, const QSet& userColumns=QSet(), const QString& separator=QString(", "), const QString& decimal_separator=QString("."), const QString& comment=QString("#"), const QString& aroundStrings=QString(""), char floatformat='g'); /** \brief save contents of datastore as SYLK file (SYmbolic LinK) * @@ -551,14 +551,14 @@ class LIB_EXPORT JKQTPDatastore{ * \param userColumns a list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames() * \param floatformat a \c printf format string that is used to print floating point numbers to the file */ - void saveSYLK(QString filename, QSet userColumns=QSet(), QString floatformat=QString("%10.10lf")); + void saveSYLK(const QString& filename, const QSet& userColumns=QSet(), const QString& floatformat=QString("%10.10lf")); /** \brief return contents of datastore as QList >, i.e. a list of column-vectors * * \param columnNames if \c !=nullptr this will afterwards conatin the column titles * \param userColumns a list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames() */ - QList > getData(QStringList* columnNames=nullptr, QSet userColumns=QSet()); + QList > getData(QStringList* columnNames=nullptr, const QSet& userColumns=QSet()); /** \brief save contents of datastore as DIF file (data interchange format) * @@ -566,20 +566,20 @@ class LIB_EXPORT JKQTPDatastore{ * \param userColumns a list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames() * \param floatformat a \c printf format string that is used to print floating point numbers to the file */ - void saveDIF(QString filename, QSet userColumns=QSet(), QString floatformat=QString("%10.10lf")); + void saveDIF(const QString& filename, const QSet& userColumns=QSet(), const QString& floatformat=QString("%10.10lf")); /** \brief save contents of datastore as a Matlab script * * \param filename the file to create * \param userColumns a list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames() */ - void saveMatlab(QString filename, QSet userColumns=QSet()); + void saveMatlab(const QString& filename, const QSet& userColumns=QSet()); /** \brief save contents of datastore as a Matlab script * * \param txt the QTextStream to write to * \param userColumns a list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames() */ - void saveMatlab(QTextStream& txt, QSet userColumns=QSet()); + void saveMatlab(QTextStream& txt, const QSet& userColumns=QSet()); /** \brief return a list with all columns available in the datastore */ QStringList getColumnNames() const; diff --git a/lib/jkqtplotter/jkqtpelementsoverlay.cpp b/lib/jkqtplotter/jkqtpelementsoverlay.cpp index e928468579..1a3d390375 100644 --- a/lib/jkqtplotter/jkqtpelementsoverlay.cpp +++ b/lib/jkqtplotter/jkqtpelementsoverlay.cpp @@ -122,7 +122,7 @@ JKQTPOverlayVerticalLine::JKQTPOverlayVerticalLine(double pos, JKQTBasePlotter * } -JKQTPOverlayVerticalLine::JKQTPOverlayVerticalLine(double pos, QString text, JKQTBasePlotter *parent): +JKQTPOverlayVerticalLine::JKQTPOverlayVerticalLine(double pos, const QString& text, JKQTBasePlotter *parent): JKQTPOverlayOneCoordOverlay(pos, parent) { set_text(text); @@ -169,7 +169,7 @@ JKQTPOverlayVerticalRange::JKQTPOverlayVerticalRange(double pos, double pos2, JK inverted=false; } -JKQTPOverlayVerticalRange::JKQTPOverlayVerticalRange(double pos, double pos2, QString text, JKQTBasePlotter *parent): +JKQTPOverlayVerticalRange::JKQTPOverlayVerticalRange(double pos, double pos2, const QString& text, JKQTBasePlotter *parent): JKQTPOverlayTwoCoordOverlay(pos, pos2, parent) { set_text(text); diff --git a/lib/jkqtplotter/jkqtpelementsoverlay.h b/lib/jkqtplotter/jkqtpelementsoverlay.h index 99a05e9f40..d2413e2e3a 100644 --- a/lib/jkqtplotter/jkqtpelementsoverlay.h +++ b/lib/jkqtplotter/jkqtpelementsoverlay.h @@ -374,7 +374,7 @@ class LIB_EXPORT JKQTPOverlayVerticalLine : public JKQTPOverlayOneCoordOverlay { Q_OBJECT public: explicit JKQTPOverlayVerticalLine(double pos, JKQTBasePlotter *parent = 0); - explicit JKQTPOverlayVerticalLine(double pos, QString text, JKQTBasePlotter *parent = 0); + explicit JKQTPOverlayVerticalLine(double pos, const QString& text, JKQTBasePlotter *parent = 0); /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter); @@ -391,7 +391,7 @@ class LIB_EXPORT JKQTPOverlayVerticalRange : public JKQTPOverlayTwoCoordOverlay Q_OBJECT public: explicit JKQTPOverlayVerticalRange(double pos, double pos2, JKQTBasePlotter *parent = 0); - explicit JKQTPOverlayVerticalRange(double pos, double pos2, QString text, JKQTBasePlotter *parent = 0); + explicit JKQTPOverlayVerticalRange(double pos, double pos2, const QString& text, JKQTBasePlotter *parent = 0); /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter); diff --git a/lib/jkqtplotter/jkqtpgraphsbase.cpp b/lib/jkqtplotter/jkqtpgraphsbase.cpp index 8128b54cbe..0bca576132 100644 --- a/lib/jkqtplotter/jkqtpgraphsbase.cpp +++ b/lib/jkqtplotter/jkqtpgraphsbase.cpp @@ -48,9 +48,7 @@ JKQTPPlotElement::JKQTPPlotElement(JKQTPlotter *parent): } JKQTPPlotElement::~JKQTPPlotElement() -{ - -} += default; JKQTPGraph::JKQTPGraph(JKQTBasePlotter* parent): JKQTPPlotElement(parent) @@ -65,9 +63,7 @@ JKQTPGraph::JKQTPGraph(JKQTPlotter *parent): } JKQTPGraph::~JKQTPGraph() -{ - -} += default; QImage JKQTPPlotElement::generateKeyMarker(QSize size) { @@ -517,9 +513,7 @@ JKQTPGraphErrors::JKQTPGraphErrors(QColor graphColor) { } JKQTPGraphErrors::~JKQTPGraphErrors() -{ - -} += default; @@ -1210,6 +1204,4 @@ JKQTPPlotObject::JKQTPPlotObject(JKQTPlotter *parent): } JKQTPPlotObject::~JKQTPPlotObject() -{ - -} += default; diff --git a/lib/jkqtplotter/jkqtpgraphsgeometric.cpp b/lib/jkqtplotter/jkqtpgraphsgeometric.cpp index 413580f0f2..6972a4252d 100644 --- a/lib/jkqtplotter/jkqtpgraphsgeometric.cpp +++ b/lib/jkqtplotter/jkqtpgraphsgeometric.cpp @@ -134,7 +134,7 @@ void JKQTPGeoBaseFilled::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& re -JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, QString text, double fontSize, QColor color): +JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize, QColor color): JKQTPPlotObject(parent) { this->x=x; @@ -144,7 +144,7 @@ JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, QString this->color=color; } -JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, QString text, double fontSize, QColor color): +JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize, QColor color): JKQTPPlotObject(parent) { this->x=x; diff --git a/lib/jkqtplotter/jkqtpgraphsgeometric.h b/lib/jkqtplotter/jkqtpgraphsgeometric.h index 092d68068f..d41f4f2fec 100644 --- a/lib/jkqtplotter/jkqtpgraphsgeometric.h +++ b/lib/jkqtplotter/jkqtpgraphsgeometric.h @@ -396,7 +396,7 @@ class LIB_EXPORT JKQTPGeoText: public JKQTPPlotObject { \param color color of drawing \param fontSize base font size of text */ - JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, QString text, double fontSize=10, QColor color=QColor("black")); + JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize=10, QColor color=QColor("black")); /*! \brief class contructor \param parent parent plotter widget @@ -406,7 +406,7 @@ class LIB_EXPORT JKQTPGeoText: public JKQTPPlotObject { \param color color of drawing \param fontSize base font size of text */ - JKQTPGeoText(JKQTPlotter* parent, double x, double y, QString text, double fontSize=10, QColor color=QColor("black")); + JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize=10, QColor color=QColor("black")); /*! \brief sets the property color to the specified \a __value. \details Description of the parameter color is:
\copydoc color
diff --git a/lib/jkqtplotter/jkqtpgraphsimage.cpp b/lib/jkqtplotter/jkqtpgraphsimage.cpp index d9cf8cf370..3b5ae1136e 100644 --- a/lib/jkqtplotter/jkqtpgraphsimage.cpp +++ b/lib/jkqtplotter/jkqtpgraphsimage.cpp @@ -119,8 +119,8 @@ void JKQTPImageBase::plotImage(JKQTPEnhancedPainter& painter, QImage& image, dou painter.drawImage(QPoint(p1.x(), p1.y()), image.scaled(QSize(fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y())), Qt::IgnoreAspectRatio, Qt::FastTransformation)); //qDebug()<<"\nimage.size = "<(image.width()); + double pixheight=fabs(p2.y()-p1.y())/static_cast(image.height()); //qDebug()<<"\nimage.size = "<((double*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage((float*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage((uint8_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage((uint16_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage((uint32_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage((uint64_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage((int8_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage((int16_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage((int32_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage((int64_t*)dataModifier, Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; } } } @@ -716,7 +716,7 @@ void JKQTPMathImage::initJKQTPMathImage() { this->autoModifierRange=true; } -JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter* parent): +JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter* parent): JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) { initJKQTPMathImage(); @@ -731,7 +731,7 @@ JKQTPMathImage::JKQTPMathImage(JKQTBasePlotter *parent): -JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent): +JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent): JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) { initJKQTPMathImage(); @@ -1102,16 +1102,16 @@ double JKQTPMathImage::getValueAt(double x, double y) int yy=trunc((y-this->y)/height*double(Ny)); if (xx>=0 && xx<(int64_t)Nx && yy>=0 && yy<(int64_t)Ny) { switch(datatype) { - case JKQTPMathImageBase::DoubleArray: return ((double*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::FloatArray: return ((float*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::UInt8Array: return ((uint8_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::UInt16Array: return ((uint16_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::UInt32Array: return ((uint32_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::UInt64Array: return ((uint64_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::Int8Array: return ((int8_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::Int16Array: return ((int16_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::Int32Array: return ((int32_t*)data)[yy*Nx+xx]; break; - case JKQTPMathImageBase::Int64Array: return ((int64_t*)data)[yy*Nx+xx]; break; + case JKQTPMathImageBase::DoubleArray: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::FloatArray: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::UInt8Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::UInt16Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::UInt32Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::UInt64Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::Int8Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::Int16Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::Int32Array: return (static_cast(data))[yy*Nx+xx]; break; + case JKQTPMathImageBase::Int64Array: return (static_cast(data))[yy*Nx+xx]; break; } } return 0.0; } @@ -1220,16 +1220,16 @@ QImage JKQTPMathImage::drawImage() { QImage img(Nx, Ny, QImage::Format_ARGB32); getDataMinMax(internalDataMin, internalDataMax); switch(datatype) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2image((double*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2image((float*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2image((uint8_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2image((uint16_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2image((uint32_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2image((uint64_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2image((int8_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2image((int16_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2image((int32_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2image((int64_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2image(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; } modifyImage(img); return img; @@ -1261,7 +1261,7 @@ void JKQTPMathImage::set_palette(int pal) { -JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTBasePlotter* parent): +JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): JKQTPImageBase(x, y, width, height, parent) { actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); @@ -1288,7 +1288,7 @@ JKQTPOverlayImage::JKQTPOverlayImage(JKQTBasePlotter *parent): this->trueColor=QColor("red"); } -JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTPlotter* parent): +JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): JKQTPImageBase(x, y, width, height, parent) { actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); @@ -1330,9 +1330,9 @@ QImage JKQTPOverlayImage::drawImage() { QRgb tc=qRgba(round(trueColor.red()*trueColor.alphaF()), round(trueColor.green()*trueColor.alphaF()), round(trueColor.blue()*trueColor.alphaF()), trueColor.alpha()); QRgb fc=qRgba(round(falseColor.red()*falseColor.alphaF()), round(falseColor.green()*falseColor.alphaF()), round(falseColor.blue()*falseColor.alphaF()), falseColor.alpha()); - for (uint32_t y=0; ydata=data; this->Nx=Nx; this->Ny=Ny; } -JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTBasePlotter* parent): +JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): JKQTPOverlayImage(x, y, width, height, data, Nx, Ny, colTrue, parent) { symbol=JKQTPTarget; @@ -1392,7 +1392,7 @@ JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTBasePlotter *parent): rectanglesAsImageOverlay=false; } -JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTPlotter* parent): +JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): JKQTPOverlayImage(x, y, width, height, data, Nx, Ny, colTrue, parent) { symbol=JKQTPTarget; @@ -1429,7 +1429,7 @@ void JKQTPOverlayImageEnhanced::draw(JKQTPEnhancedPainter& painter) { double dy=height/(double)Ny; for (int ix=0; ix<(int64_t)Nx; ix++) { for (int iy=0; iy<(int64_t)Ny; iy++) { - QPointF p1=transform(x+(double)ix*dx, y+(double)iy*dy); + QPointF p1=transform(x+static_cast(ix)*dx, y+static_cast(iy)*dy); QPointF p2=transform(x+(double)(ix+1)*dx, y+(double)(iy+1)*dx); if (drawAsRectangles) { if (data[ix+iy*Nx]) { @@ -1569,14 +1569,14 @@ void JKQTPRGBMathImage::initObject() -JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTBasePlotter *parent): +JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) { initObject(); } -JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent): JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) { initObject(); @@ -1978,44 +1978,44 @@ void JKQTPRGBMathImage::getDataMinMaxG(double& imin, double& imax) { if (!dataG) return; switch(datatype) { case JKQTPMathImageBase::DoubleArray: - imin= JKQTPImagePlot_getImageMin((double*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((double*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::FloatArray: - imin= JKQTPImagePlot_getImageMin((float*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((float*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::UInt8Array: - imin= JKQTPImagePlot_getImageMin((uint8_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint8_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::UInt16Array: - imin= JKQTPImagePlot_getImageMin((uint16_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint16_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::UInt32Array: - imin= JKQTPImagePlot_getImageMin((uint32_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint32_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::UInt64Array: - imin= JKQTPImagePlot_getImageMin((uint64_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint64_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::Int8Array: - imin= JKQTPImagePlot_getImageMin((int8_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int8_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::Int16Array: - imin= JKQTPImagePlot_getImageMin((int16_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int16_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::Int32Array: - imin= JKQTPImagePlot_getImageMin((int32_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int32_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageBase::Int64Array: - imin= JKQTPImagePlot_getImageMin((int64_t*)dataG, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int64_t*)dataG, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; } } else { @@ -2031,44 +2031,44 @@ void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) { if (!dataG) return; switch(datatype) { case JKQTPMathImageBase::DoubleArray: - imin= JKQTPImagePlot_getImageMin((double*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((double*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::FloatArray: - imin= JKQTPImagePlot_getImageMin((float*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((float*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::UInt8Array: - imin= JKQTPImagePlot_getImageMin((uint8_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint8_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::UInt16Array: - imin= JKQTPImagePlot_getImageMin((uint16_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint16_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::UInt32Array: - imin= JKQTPImagePlot_getImageMin((uint32_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint32_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::UInt64Array: - imin= JKQTPImagePlot_getImageMin((uint64_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((uint64_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::Int8Array: - imin= JKQTPImagePlot_getImageMin((int8_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int8_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::Int16Array: - imin= JKQTPImagePlot_getImageMin((int16_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int16_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::Int32Array: - imin= JKQTPImagePlot_getImageMin((int32_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int32_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageBase::Int64Array: - imin= JKQTPImagePlot_getImageMin((int64_t*)dataB, Nx, Ny); - imax= JKQTPImagePlot_getImageMax((int64_t*)dataB, Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; } } else { @@ -2084,20 +2084,20 @@ double JKQTPRGBMathImage::getValueAt(double x, double y, int channel) if (channel==0) dd=data; if (channel==1) dd=dataG; if (channel==2) dd=dataB; - int xx=trunc((x-this->x)/width*double(Nx)); - int yy=trunc((y-this->y)/height*double(Ny)); - if (xx>=0 && xx<(int64_t)Nx && yy>=0 && yy<(int64_t)Ny) { + int xx=static_cast(trunc((x-this->x)/width*Nx)); + int yy=static_cast(trunc((y-this->y)/height*Ny)); + if (xx>=0 && xx=0 && yy((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::FloatArray: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; } } return 0.0; } @@ -2190,46 +2190,46 @@ QImage JKQTPRGBMathImage::drawImage() { int palette = 0; if (data) { switch(datatype) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage((double*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage((float*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage((uint8_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage((uint16_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage((uint32_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage((uint64_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage((int8_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage((int16_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage((int32_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage((int64_t*)data, Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; } } palette = 1; if (dataG) { switch(datatypeG) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage((double*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage((float*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage((uint8_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage((uint16_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage((uint32_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage((uint64_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage((int8_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage((int16_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage((int32_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage((int64_t*)dataG, Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; } } palette = 2; if (dataB) { switch(datatypeB) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage((double*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage((float*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage((uint8_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage((uint16_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage((uint32_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage((uint64_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage((int8_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage((int16_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage((int32_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage((int64_t*)dataB, Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; } } @@ -2238,7 +2238,7 @@ QImage JKQTPRGBMathImage::drawImage() { return img; } -void JKQTPRGBMathImage::set_data(void* data, uint32_t Nx, uint32_t Ny, DataType datatype) { +void JKQTPRGBMathImage::set_data(void* data, int Nx, int Ny, DataType datatype) { this->data=data; this->datatype=datatype; this->dataG=nullptr; @@ -2247,7 +2247,7 @@ void JKQTPRGBMathImage::set_data(void* data, uint32_t Nx, uint32_t Ny, DataType this->Ny=Ny; } -void JKQTPRGBMathImage::set_data(void* data, uint32_t Nx, uint32_t Ny) { +void JKQTPRGBMathImage::set_data(void* data, int Nx, int Ny) { this->data=data; this->Nx=Nx; this->Ny=Ny; @@ -2256,7 +2256,7 @@ void JKQTPRGBMathImage::set_data(void* data, uint32_t Nx, uint32_t Ny) { } -void JKQTPRGBMathImage::set_data(void *data, void *dataG, void *dataB, uint32_t Nx, uint32_t Ny, JKQTPMathImageBase::DataType datatype) { +void JKQTPRGBMathImage::set_data(void *data, void *dataG, void *dataB, int Nx, int Ny, JKQTPMathImageBase::DataType datatype) { this->data=data; this->datatype=datatype; this->datatypeG=datatype; @@ -2267,7 +2267,7 @@ void JKQTPRGBMathImage::set_data(void *data, void *dataG, void *dataB, uint32_t this->Ny=Ny; } -void JKQTPRGBMathImage::set_data(void *data, void *dataG, void *dataB, uint32_t Nx, uint32_t Ny) { +void JKQTPRGBMathImage::set_data(void *data, void *dataG, void *dataB, int Nx, int Ny) { this->data=data; this->dataG=dataG; this->dataB=dataB; @@ -2285,7 +2285,7 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(JKQTBasePlotter *parent): this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTBasePlotter *parent): +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,JKQTPMathImageGRAY,parent) { this->modifierColumn=-1; @@ -2293,7 +2293,7 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, dou this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter *parent): +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter *parent): JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,palette,parent) { this->modifierColumn=-1; @@ -2309,7 +2309,7 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(JKQTPlotter *parent): this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,JKQTPMathImageGRAY,parent) { this->modifierColumn=-1; @@ -2317,14 +2317,14 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, dou this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, JKQTPlotter *parent): +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter *parent): JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,palette,parent) { this->modifierColumn=-1; this->imageColumn=imageColumn; this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPlotter *parent): JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,JKQTPMathImageGRAY,parent) { this->modifierColumn=-1; @@ -2396,7 +2396,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTBasePlotter *parent): this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTBasePlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2406,7 +2406,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, uint32_t Nx, uint32_t Ny, JKQTBasePlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2416,7 +2416,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, uint32_t Nx, uint32_t Ny, JKQTBasePlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2426,7 +2426,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, uint32_t Nx, uint32_t Ny, JKQTBasePlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2446,7 +2446,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTPlotter *parent): this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2456,7 +2456,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2466,7 +2466,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2476,7 +2476,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -2509,34 +2509,34 @@ QVector JKQTPRGBMathImage::getDataGAsDoubleVector() const { switch(datatype) { case JKQTPMathImageBase::DoubleArray: - return JKQTPImagePlot_arrayToDVector((double*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::FloatArray: - return JKQTPImagePlot_arrayToDVector((float*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::UInt8Array: - return JKQTPImagePlot_arrayToDVector((uint8_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::UInt16Array: - return JKQTPImagePlot_arrayToDVector((uint16_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::UInt32Array: - return JKQTPImagePlot_arrayToDVector((uint32_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::UInt64Array: - return JKQTPImagePlot_arrayToDVector((uint64_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::Int8Array: - return JKQTPImagePlot_arrayToDVector((int8_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::Int16Array: - return JKQTPImagePlot_arrayToDVector((int16_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::Int32Array: - return JKQTPImagePlot_arrayToDVector((int32_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; case JKQTPMathImageBase::Int64Array: - return JKQTPImagePlot_arrayToDVector((int64_t*)dataG, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); break; } QVector res; @@ -2547,34 +2547,34 @@ QVector JKQTPRGBMathImage::getDataBAsDoubleVector() const { switch(datatype) { case JKQTPMathImageBase::DoubleArray: - return JKQTPImagePlot_arrayToDVector((double*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::FloatArray: - return JKQTPImagePlot_arrayToDVector((float*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::UInt8Array: - return JKQTPImagePlot_arrayToDVector((uint8_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::UInt16Array: - return JKQTPImagePlot_arrayToDVector((uint16_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::UInt32Array: - return JKQTPImagePlot_arrayToDVector((uint32_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::UInt64Array: - return JKQTPImagePlot_arrayToDVector((uint64_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::Int8Array: - return JKQTPImagePlot_arrayToDVector((int8_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::Int16Array: - return JKQTPImagePlot_arrayToDVector((int16_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::Int32Array: - return JKQTPImagePlot_arrayToDVector((int32_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; case JKQTPMathImageBase::Int64Array: - return JKQTPImagePlot_arrayToDVector((int64_t*)dataB, Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); break; } QVector res; @@ -2783,25 +2783,25 @@ double JKQTPContour::value(int xIdx, int yIdx) if (!data) return 0; switch(datatype) { case JKQTPMathImageBase::DoubleArray: - return ((double*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::FloatArray: - return ((float*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::UInt8Array: - return ((uint8_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::UInt16Array: - return ((uint16_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::UInt32Array: - return ((uint32_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::UInt64Array: - return ((uint64_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::Int8Array: - return ((int8_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::Int16Array: - return ((int16_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::Int32Array: - return ((int32_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; case JKQTPMathImageBase::Int64Array: - return ((int64_t*)data)[yIdx*get_Nx()+xIdx]; + return (static_cast(data))[yIdx*get_Nx()+xIdx]; default: return 0; } @@ -2925,7 +2925,7 @@ JKQTPContour::JKQTPContour(JKQTBasePlotter *parent) : } } -JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTBasePlotter* parent) : +JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTBasePlotter* parent) : JKQTPMathImage( x, y, width, height, datatype, data, Nx, Ny, palette, parent) { lineColor=QColor("red"); @@ -2957,7 +2957,7 @@ JKQTPContour::JKQTPContour(JKQTPlotter *parent) : } } -JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTPlotter* parent) : +JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTPlotter* parent) : JKQTPMathImage( x, y, width, height, datatype, data, Nx, Ny, palette, parent) { lineColor=QColor("red"); diff --git a/lib/jkqtplotter/jkqtpgraphsimage.h b/lib/jkqtplotter/jkqtpgraphsimage.h index a6392edf66..b624a0f1de 100644 --- a/lib/jkqtplotter/jkqtpgraphsimage.h +++ b/lib/jkqtplotter/jkqtpgraphsimage.h @@ -199,13 +199,13 @@ class LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { /** \brief class constructor */ JKQTPMathImageBase(JKQTBasePlotter* parent=nullptr); JKQTPMathImageBase(double x, double y, double width, double height, JKQTBasePlotter* parent=nullptr); - JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); + JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ JKQTPMathImageBase(JKQTPlotter* parent); JKQTPMathImageBase(double x, double y, double width, double height, JKQTPlotter* parent=nullptr); - JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); + JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); /** \brief plots a key marker inside the specified rectangle \a rect */ virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; @@ -213,28 +213,28 @@ class LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { /*! \brief sets the property Nx to the specified \a __value. \details Description of the parameter Nx is:
\copydoc Nx
\see Nx for more information */ - inline virtual void set_Nx(uint32_t __value) + inline virtual void set_Nx(int __value) { this->Nx = __value; } /*! \brief returns the property Nx. \details Description of the parameter Nx is:
\copydoc Nx
\see Nx for more information */ - inline virtual uint32_t get_Nx() const + inline virtual int get_Nx() const { return this->Nx; } /*! \brief sets the property Ny to the specified \a __value. \details Description of the parameter Ny is:
\copydoc Ny
\see Ny for more information */ - inline virtual void set_Ny(uint32_t __value) + inline virtual void set_Ny(int __value) { this->Ny = __value; } /*! \brief returns the property Ny. \details Description of the parameter Ny is:
\copydoc Ny
\see Ny for more information */ - inline virtual uint32_t get_Ny() const + inline virtual int get_Ny() const { return this->Ny; } @@ -310,8 +310,8 @@ class LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { } virtual void set_dataModifier(void* data, DataType datatype); - virtual void set_data(void* data, uint32_t Nx, uint32_t Ny, DataType datatype); - virtual void set_data(void* data, uint32_t Nx, uint32_t Ny); + virtual void set_data(void* data, int Nx, int Ny, DataType datatype); + virtual void set_data(void* data, int Nx, int Ny); /** \brief determine min/max data value of the image */ virtual void getDataMinMax(double& imin, double& imax); /** \brief determine min/max data value of the image */ @@ -325,9 +325,9 @@ class LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { /** \brief datatype of the data array data */ DataType datatype; /** \brief width of the data array data in pt */ - uint32_t Nx; + int Nx; /** \brief height of the data array data in pt */ - uint32_t Ny; + int Ny; /** \brief points to the data array, holding the modifier image */ void* dataModifier; @@ -344,7 +344,7 @@ class LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { virtual void ensureImageData(); void modifyImage(QImage& img); - void modifyImage(QImage& img, void* dataModifier, DataType datatypeModifier, uint32_t Nx, uint32_t Ny, double internalModifierMin, double internalModifierMax); + void modifyImage(QImage& img, void* dataModifier, DataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax); }; @@ -427,9 +427,9 @@ class LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase { public: /** \brief class constructor */ - JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr); + JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr); JKQTPMathImage(JKQTBasePlotter* parent=nullptr); - JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); + JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); JKQTPMathImage(JKQTPlotter* parent); /** \brief plots the graph to the plotter object specified as parent */ @@ -913,14 +913,14 @@ class LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase { class LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { Q_OBJECT public: - + using JKQTPMathImageBase::set_data; /** \brief class constructor */ - JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); + JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ - JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); + JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); /** \brief class constructor */ JKQTPRGBMathImage(JKQTBasePlotter* parent=nullptr); @@ -935,11 +935,11 @@ class LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { - virtual void set_data(void* data, void* dataG, void* dataB, uint32_t Nx, uint32_t Ny, DataType datatype); - virtual void set_data(void* data, void* dataG, void* dataB, uint32_t Nx, uint32_t Ny); + virtual void set_data(void* data, void* dataG, void* dataB, int Nx, int Ny, DataType datatype); + virtual void set_data(void* data, void* dataG, void* dataB, int Nx, int Ny); - virtual void set_data(void* data, uint32_t Nx, uint32_t Ny, DataType datatype); - virtual void set_data(void* data, uint32_t Nx, uint32_t Ny); + virtual void set_data(void* data, int Nx, int Ny, DataType datatype) override; + virtual void set_data(void* data, int Nx, int Ny) override ; /** \brief determine min/max data value of the image */ @@ -1434,13 +1434,13 @@ class LIB_EXPORT JKQTPColumnMathImage: public JKQTPMathImage { /** \brief class constructor */ JKQTPColumnMathImage(JKQTBasePlotter* parent=nullptr); - JKQTPColumnMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr); + JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ JKQTPColumnMathImage(JKQTPlotter* parent); - JKQTPColumnMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); - JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); - JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); + JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); + JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPlotter* parent); /*! \brief sets the property imageColumn to the specified \a __value. \details Description of the parameter imageColumn is:
\copydoc imageColumn
@@ -1498,16 +1498,16 @@ class LIB_EXPORT JKQTPColumnRGBMathImage: public JKQTPRGBMathImage { /** \brief class constructor */ JKQTPColumnRGBMathImage(JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, uint32_t Nx, uint32_t Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ JKQTPColumnRGBMathImage(JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, uint32_t Nx, uint32_t Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter* parent); /*! \brief sets the property imageRColumn to the specified \a __value. \details Description of the parameter imageRColumn is:
\copydoc imageRColumn
@@ -1591,11 +1591,11 @@ class LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase { public: /** \brief class constructor */ - JKQTPOverlayImage(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); + JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); JKQTPOverlayImage(JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ - JKQTPOverlayImage(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTPlotter* parent); + JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); JKQTPOverlayImage(JKQTPlotter* parent); /** \brief plots the graph to the plotter object specified as parent */ @@ -1640,28 +1640,28 @@ class LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase { /*! \brief sets the property Nx to the specified \a __value. \details Description of the parameter Nx is:
\copydoc Nx
\see Nx for more information */ - inline virtual void set_Nx(uint32_t __value) + inline virtual void set_Nx(int __value) { this->Nx = __value; } /*! \brief returns the property Nx. \details Description of the parameter Nx is:
\copydoc Nx
\see Nx for more information */ - inline virtual uint32_t get_Nx() const + inline virtual int get_Nx() const { return this->Nx; } /*! \brief sets the property Ny to the specified \a __value. \details Description of the parameter Ny is:
\copydoc Ny
\see Ny for more information */ - inline virtual void set_Ny(uint32_t __value) + inline virtual void set_Ny(int __value) { this->Ny = __value; } /*! \brief returns the property Ny. \details Description of the parameter Ny is:
\copydoc Ny
\see Ny for more information */ - inline virtual uint32_t get_Ny() const + inline virtual int get_Ny() const { return this->Ny; } @@ -1680,7 +1680,7 @@ class LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase { return this->data; } - void set_data(bool* data, uint32_t Nx, uint32_t Ny); + void set_data(bool* data, int Nx, int Ny); QVector getDataAsDoubleVector() const; @@ -1688,9 +1688,9 @@ class LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase { /** \brief points to the data array, holding the image */ bool* data; /** \brief width of the data array data in pt */ - uint32_t Nx; + int Nx; /** \brief height of the data array data in pt */ - uint32_t Ny; + int Ny; /** \brief color for \c true pixels */ QColor trueColor; @@ -1722,10 +1722,10 @@ class LIB_EXPORT JKQTPOverlayImageEnhanced: public JKQTPOverlayImage { Q_OBJECT public: /** \brief class constructor */ - JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); + JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); JKQTPOverlayImageEnhanced(JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ - JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, uint32_t Nx, uint32_t Ny, QColor colTrue, JKQTPlotter* parent); + JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); JKQTPOverlayImageEnhanced(JKQTPlotter* parent); /** \brief plots the graph to the plotter object specified as parent */ @@ -1889,11 +1889,11 @@ class LIB_EXPORT JKQTPContour: public JKQTPMathImage { /** \brief class constructor */ JKQTPContour(JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ - JKQTPContour(double x, double y, double width, double height, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, DataType datatype = JKQTPMathImageBase::DoubleArray, JKQTBasePlotter* parent=nullptr); + JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, DataType datatype = JKQTPMathImageBase::DoubleArray, JKQTBasePlotter* parent=nullptr); /** \brief class constructor */ JKQTPContour(JKQTPlotter* parent); /** \brief class constructor */ - JKQTPContour(double x, double y, double width, double height, void* data, uint32_t Nx, uint32_t Ny, JKQTPMathImageColorPalette palette, DataType datatype , JKQTPlotter* parent); + JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype , JKQTPlotter* parent); /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; diff --git a/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp b/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp index c47498c6f3..967e75b562 100644 --- a/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp +++ b/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp @@ -149,7 +149,7 @@ void JKQTPXParsedFunctionLineGraph::createPlotData(bool /*collectParams*/) double JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraphFunction(double x, void* data) { - JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraphFunctionData* d=(JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraphFunctionData*)data; + JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraphFunctionData* d=static_cast(data); if (d && d->parser && d->node) { try { d->parser->addVariableDouble("x", x); @@ -312,7 +312,7 @@ void JKQTPYParsedFunctionLineGraph::createPlotData(bool /*collectParams*/) } double JKQTPYParsedFunctionLineGraph::JKQTPYParsedFunctionLineGraphFunction(double x, void* data) { - JKQTPYParsedFunctionLineGraph::JKQTPYParsedFunctionLineGraphFunctionData* d=(JKQTPYParsedFunctionLineGraph::JKQTPYParsedFunctionLineGraphFunctionData*)data; + JKQTPYParsedFunctionLineGraph::JKQTPYParsedFunctionLineGraphFunctionData* d=static_cast(data); if (d && d->parser && d->node) { try { d->parser->addVariableDouble("x", x); diff --git a/lib/jkqtplotter/jkqtplotter.cpp b/lib/jkqtplotter/jkqtplotter.cpp index 66d7807a2b..796d33f779 100644 --- a/lib/jkqtplotter/jkqtplotter.cpp +++ b/lib/jkqtplotter/jkqtplotter.cpp @@ -88,8 +88,8 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* mousePosY=0; rightMouseButtonAction=JKQTPlotter::RightMouseButtonContextMenu; - connect(plotter, SIGNAL(plotUpdated()), this, SLOT(replotPlot())); - connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(replotOverlays())); + connect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); + connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); connect(plotter, SIGNAL(beforePlotScalingRecalculate()), this, SLOT(intBeforePlotScalingRecalculate())); connect(plotter, SIGNAL(zoomChangedLocally(double, double, double, double, JKQTBasePlotter*)), this, SLOT(pzoomChangedLocally(double, double, double, double, JKQTBasePlotter*))); @@ -136,13 +136,13 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* resize(400,300); doDrawing=true; plotter->setEmittingSignalsEnabled(true); - replotPlot(); + redrawPlot(); } JKQTPlotter::~JKQTPlotter() { - disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(replotPlot())); - disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(replotOverlays())); + disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); + disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); disconnect(plotter, SIGNAL(beforePlotScalingRecalculate()), this, SLOT(intBeforePlotScalingRecalculate())); disconnect(plotter, SIGNAL(zoomChangedLocally(double, double, double, double, JKQTBasePlotter*)), this, SLOT(pzoomChangedLocally(double, double, double, double, JKQTBasePlotter*))); delete plotter; @@ -244,7 +244,7 @@ JKQTPlotter::MouseActionModes JKQTPlotter::getMouseActionMode() const return this->mouseActionMode; } -void JKQTPlotter::loadSettings(QSettings& settings, QString group) { +void JKQTPlotter::loadSettings(const QSettings& settings, const QString& group) { plotter->loadSettings(settings, group); @@ -252,10 +252,10 @@ void JKQTPlotter::loadSettings(QSettings& settings, QString group) { mousePositionTemplate=settings.value(group+"mouse_position_template", mousePositionTemplate).toString(); userActionColor=QColor(settings.value(group+"zoomrect_color", jkqtp_QColor2String(userActionColor)).toString()); - replotPlot(); + redrawPlot(); } -void JKQTPlotter::saveSettings(QSettings& settings, QString group) { +void JKQTPlotter::saveSettings(QSettings& settings, const QString& group) const { plotter->saveSettings(settings, group); if (userActionColor!=def_userActionColor) settings.setValue(group+"zoomrect_color", jkqtp_QColor2String(userActionColor)); @@ -384,10 +384,10 @@ void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){ mouseLastClickX=event->x(); mouseLastClickY=event->y(); if (rightMouseButtonAction==JKQTPlotter::RightMouseButtonZoom) { - double xmin=plotter->p2x((long)round((double)plotter->getInternalPlotBorderLeft()-(double)plotter->getPlotWidth()/2.0)); - double xmax=plotter->p2x((long)round((double)plotter->getInternalPlotBorderLeft()+1.5*(double)plotter->getPlotWidth())); - double ymin=plotter->p2y((long)round((double)plotter->getInternalPlotBorderTop()+1.5*(double)plotter->getPlotHeight())); - double ymax=plotter->p2y((long)round((double)plotter->getInternalPlotBorderTop()-(double)plotter->getPlotHeight()/2.0)); + double xmin=plotter->p2x((long)round(static_cast(plotter->getInternalPlotBorderLeft())-static_cast(plotter->getPlotWidth())/2.0)); + double xmax=plotter->p2x((long)round(static_cast(plotter->getInternalPlotBorderLeft())+1.5*static_cast(plotter->getPlotWidth()))); + double ymin=plotter->p2y((long)round(static_cast(plotter->getInternalPlotBorderTop())+1.5*static_cast(plotter->getPlotHeight()))); + double ymax=plotter->p2y((long)round(static_cast(plotter->getInternalPlotBorderTop())-static_cast(plotter->getPlotHeight())/2.0)); if (plotter->getXAxis()->isLogAxis()) { if (xmin<=0) xmin=1; if (xmax<=0) xmax=10; @@ -398,7 +398,7 @@ void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){ } /*plotter->getXAxis->setRange(xmin, xmax); plotter->getYAxis->setRange(ymin, ymax);*/ - //replotPlot(); + //redrawPlot(); /*if (plotter->isEmittingSignalsEnabled())*/ emit zoomChangedLocally(xmin, xmax, ymin, ymax, this); plotter->setXY(xmin, xmax, ymin, ymax); //update(); @@ -483,15 +483,15 @@ void JKQTPlotter::mouseDoubleClickEvent ( QMouseEvent * event ){ if (rightMouseButtonAction==JKQTPlotter::RightMouseButtonZoom && event->button()==Qt::RightButton) { double factor=4.0; if (event->button()==Qt::RightButton) factor=1; - double xmin=plotter->p2x((long)round((double)event->x()/magnification-(double)plotter->getPlotWidth()/factor)); - double xmax=plotter->p2x((long)round((double)event->x()/magnification+(double)plotter->getPlotWidth()/factor)); - double ymin=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()+(double)plotter->getPlotHeight()/factor)); - double ymax=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()-(double)plotter->getPlotHeight()/factor)); + double xmin=plotter->p2x((long)round((double)event->x()/magnification-static_cast(plotter->getPlotWidth())/factor)); + double xmax=plotter->p2x((long)round((double)event->x()/magnification+static_cast(plotter->getPlotWidth())/factor)); + double ymin=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()+static_cast(plotter->getPlotHeight())/factor)); + double ymax=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()-static_cast(plotter->getPlotHeight())/factor)); event->accept(); //xAxis->setRange(xmin, xmax); //yAxis->setRange(ymin, ymax); - //replotPlot(); + //redrawPlot(); /*if (plotter->isEmittingSignalsEnabled())*/ emit zoomChangedLocally(xmin, xmax, ymin, ymax, this); plotter->setXY(xmin, xmax, ymin, ymax); update(); @@ -518,22 +518,16 @@ void JKQTPlotter::wheelEvent ( QWheelEvent * event ) { if ( (event->x()/magnification>=plotter->getInternalPlotBorderLeft()) && (event->x()/magnification<=plotter->getPlotWidth()+plotter->getInternalPlotBorderLeft()) && ((event->y()-getPlotYOffset())/magnification>=plotter->getInternalPlotBorderTop()) && ((event->y()-getPlotYOffset())/magnification<=plotter->getPlotHeight()+plotter->getInternalPlotBorderTop()) ) { double factor=pow(2.0, 1.0*(double)event->delta()/120.0)*2.0; - //std::cout<<(double)event->delta()/120.0<<": "<p2x((long)round((double)event->x()/magnification-(double)plotter->getPlotWidth()/factor)); - double xmax=plotter->p2x((long)round((double)event->x()/magnification+(double)plotter->getPlotWidth()/factor)); - double ymin=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()+(double)plotter->getPlotHeight()/factor)); - double ymax=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()-(double)plotter->getPlotHeight()/factor)); + double xmin=plotter->p2x((long)round((double)event->x()/magnification-static_cast(plotter->getPlotWidth())/factor)); + double xmax=plotter->p2x((long)round((double)event->x()/magnification+static_cast(plotter->getPlotWidth())/factor)); + double ymin=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()+static_cast(plotter->getPlotHeight())/factor)); + double ymax=plotter->p2y((long)round((double)event->y()/magnification-(double)getPlotYOffset()-static_cast(plotter->getPlotHeight())/factor)); - //std::cout<<"t="< "<accept(); - /*if (plotter->isEmittingSignalsEnabled())*/ emit zoomChangedLocally(xmin, xmax, ymin, ymax, this); plotter->setXY(xmin, xmax, ymin, ymax); - //update(); - /*xAxis->setRange(xmin, xmax); - yAxis->setRange(ymin, ymax); - //replotPlot(); - if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this);*/ - } else { event->ignore(); } + } else { + event->ignore(); + } } int JKQTPlotter::getPlotYOffset() { @@ -662,13 +656,13 @@ void JKQTPlotter::synchronizeXYAxis(double newxmin, double newxmax, double newym setXY(newxmin, newxmax, newymin, newymax); } -void JKQTPlotter::replotOverlays() { +void JKQTPlotter::redrawOverlays() { #ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot(QString("JKQTPlotter::replotOverlays()")); + JKQTPAutoOutputTimer jkaaot(QString("JKQTPlotter::redrawOverlays()")); #endif if (!doDrawing) return; - disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(replotPlot())); - disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(replotOverlays())); + disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); + disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); image=imageNoOverlays; JKQTPEnhancedPainter painter(&image); if (painter.isActive()) { @@ -676,18 +670,18 @@ void JKQTPlotter::replotOverlays() { plotter->drawNonGridOverlays(painter); } oldImage=image; - connect(plotter, SIGNAL(plotUpdated()), this, SLOT(replotPlot())); - connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(replotOverlays())); + connect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); + connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); repaint(); } -void JKQTPlotter::replotPlot() { +void JKQTPlotter::redrawPlot() { #ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot(QString("JKQTPlotter::replotPlot()")); + JKQTPAutoOutputTimer jkaaot(QString("JKQTPlotter::redrawPlot()")); #endif if (!doDrawing) return; - disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(replotPlot())); - disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(replotOverlays())); + disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); + disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); plotter->resize(width()/magnification, height()/magnification-getPlotYOffset()); JKQTPEnhancedPainter painter(&image); if (painter.isActive()) { @@ -700,8 +694,8 @@ void JKQTPlotter::replotPlot() { plotter->drawNonGridOverlays(painter); } oldImage=image; - connect(plotter, SIGNAL(plotUpdated()), this, SLOT(replotPlot())); - connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(replotOverlays())); + connect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); + connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); update(); } @@ -780,7 +774,7 @@ void JKQTPlotter::delayedResizeEvent() sizeChanged=true; } - if (sizeChanged) replotPlot(); + if (sizeChanged) redrawPlot(); } void JKQTPlotter::leaveEvent(QEvent * /*event*/) { @@ -821,7 +815,7 @@ QSize JKQTPlotter::sizeHint() const { void JKQTPlotter::masterPlotScalingRecalculated() { if (masterPlotter) { if (plotter->getMasterSynchronizeHeight()||plotter->getMasterSynchronizeWidth()) { - replotPlot(); + redrawPlot(); } } } @@ -833,13 +827,13 @@ void JKQTPlotter::synchronizeToMaster(JKQTPlotter* master, bool synchronizeWidth plotter->synchronizeToMaster(master->getPlotter(), synchronizeWidth, synchronizeHeight); masterPlotter=master; if (masterPlotter) connect(masterPlotter->getPlotter(), SIGNAL(plotScalingRecalculated()), this, SLOT(masterPlotScalingRecalculated())); - replotPlot(); + redrawPlot(); } void JKQTPlotter::resetMasterSynchronization() { if (masterPlotter) disconnect(masterPlotter->getPlotter(), SIGNAL(plotScalingRecalculated()), this, SLOT(masterPlotScalingRecalculated())); plotter->resetMasterSynchronization(); - replotPlot(); + redrawPlot(); } bool JKQTPlotter::isPlotUpdateEnabled() const { @@ -930,7 +924,7 @@ int JKQTPlotter::getMouseLastClickY() const { void JKQTPlotter::setMagnification(double m) { magnification=m; - replotPlot(); + redrawPlot(); } bool JKQTPlotter::getZoomByMouseRectangle() const { diff --git a/lib/jkqtplotter/jkqtplotter.h b/lib/jkqtplotter/jkqtplotter.h index dd8d186a62..b30e5599d9 100644 --- a/lib/jkqtplotter/jkqtplotter.h +++ b/lib/jkqtplotter/jkqtplotter.h @@ -235,7 +235,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget { virtual ~JKQTPlotter(); /** reinitializes the toolbar, i.e. fills in QActions added to the QWidget since its creation/the last call to this function */ - virtual void updateToolbarActions(); + void updateToolbarActions(); /** \brief set the width/height of the icons in the toolbar in pt */ @@ -252,39 +252,39 @@ class LIB_EXPORT JKQTPlotter: public QWidget { /*! \brief returns the property displayToolbar. \details Description of the parameter displayToolbar is:
\copydoc displayToolbar
\see displayToolbar for more information */ - virtual bool isToolbarVisible() const; + bool isToolbarVisible() const; /*! \brief returns the property toolbarAlwaysOn. \details Description of the parameter toolbarAlwaysOn is:
\copydoc toolbarAlwaysOn
\see toolbarAlwaysOn for more information */ - virtual bool isToolbarAlwaysOn() const; + bool isToolbarAlwaysOn() const; /*! \brief returns the property displayMousePosition. \details Description of the parameter displayMousePosition is:
\copydoc displayMousePosition
\see displayMousePosition for more information */ - virtual bool isMousePositionShown() const; + bool isMousePositionShown() const; /*! \brief returns the property userActionColor. \details Description of the parameter userActionColor is:
\copydoc userActionColor
\see userActionColor for more information */ - virtual QColor getUserActionColor() const; + QColor getUserActionColor() const; /*! \brief returns the property userActionCompositionMode. \details Description of the parameter userActionCompositionMode is:
\copydoc userActionCompositionMode
\see userActionCompositionMode for more information */ - virtual QPainter::CompositionMode getUserActionCompositionMode() const; + QPainter::CompositionMode getUserActionCompositionMode() const; /*! \brief returns the current mouseActionMode. \details Description of the parameter mouseActionMode is:
specifies the user-action mode this JKQtPlotter use when mouse events occur. * This allows you to e.g. draw rectangles or lines over the plot and receive a signal, when the drawing finishes
\see mouseActionMode for more information */ - virtual MouseActionModes getMouseActionMode() const; + MouseActionModes getMouseActionMode() const; /** \brief loads the plot properties from a QSettings object */ - virtual void loadSettings(QSettings& settings, QString group=QString("plots")); + void loadSettings(const QSettings &settings, const QString& group=QString("plots")); /** \brief saves the plot properties into a QSettings object. * * This method only saves those properties that differ from their default value. */ - virtual void saveSettings(QSettings& settings, QString group=QString("plots")); + void saveSettings(QSettings& settings, const QString& group=QString("plots")) const; /** \brief returns the minimum size of the widget */ QSize minimumSizeHint() const; @@ -323,25 +323,19 @@ class LIB_EXPORT JKQTPlotter: public QWidget { */ inline void useExternalDatastore(JKQTPDatastore* newStore) { plotter->useExternalDatastore(newStore); } - /** \brief tells the plotter object to use the given external datastore and treat it as an internal one (i.e. free it - * when the plotter object ist destroyed. - */ + /** \copydoc JKQTBasePlotter::useAsInternalDatastore() */ inline void useAsInternalDatastore(JKQTPDatastore* newStore) { plotter->useAsInternalDatastore(newStore); } - /** \brief tells the plotter object to use an internal datastore. A new internal datastore object is generated only if - * the current datastore is not internal. - */ + /** \copydoc JKQTBasePlotter::useInternalDatastore() */ inline void useInternalDatastore() { plotter->useInternalDatastore(); } - /** \brief tells the plotter object to use an internal datastore (just like useInternalDatastore() ), but forces the - * generation of a new datastore, even if the current one is already internal (the current one will be freed in - * the lather case */ + /** \copydoc JKQTBasePlotter::forceInternalDatastore() */ inline void forceInternalDatastore() { plotter->forceInternalDatastore(); } - /** \brief switch emitting of signals, such as zoomChangedLocally() ..., on (sig=true) or off (sig=false) */ + /** \copydoc JKQTBasePlotter::setEmittingSignalsEnabled() */ inline void setEmittingSignalsEnabled(bool sig) { plotter->setEmittingSignalsEnabled(sig); } - /** \brief determine, whether emitting of signals, such as zoomChangedLocally() ..., is switched on or off */ - inline bool isEmittingSignalsEnabled() { return plotter; } + /** \copydoc JKQTBasePlotter::isEmittingSignalsEnabled() */ + inline bool isEmittingSignalsEnabled() { return plotter->isEmittingSignalsEnabled(); } /** \brief returns, whether updating the plot is currently activated (e.g. you can deactivate this with setPlotUpdateEnabled() while performing major updates on the plot) * @@ -361,11 +355,11 @@ class LIB_EXPORT JKQTPlotter: public QWidget { /*! \brief returns the property rightMouseButtonAction. \details Description of the parameter rightMouseButtonAction is:
\copydoc rightMouseButtonAction
\see rightMouseButtonAction for more information */ - virtual RightMouseButtonAction getActionRightMouseButton() const; + RightMouseButtonAction getActionRightMouseButton() const; /*! \brief returns the property leftDoubleClickAction. \details Description of the parameter leftDoubleClickAction is:
\copydoc leftDoubleClickAction
\see leftDoubleClickAction for more information */ - virtual LeftDoubleClickAction getActionLeftDoubleClick() const; + LeftDoubleClickAction getActionLeftDoubleClick() const; /*! \brief returns the property menuSpecialContextMenu. \details Description of the parameter menuSpecialContextMenu is:
\copydoc menuSpecialContextMenu
. \see menuSpecialContextMenu for more information */ QMenu *getMenuSpecialContextMenu() const; @@ -379,7 +373,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget { /*! \brief returns the property zoomByMouseWheel. \details Description of the parameter zoomByMouseWheel is:
\copydoc zoomByMouseWheel
\see zoomByMouseWheel for more information */ - virtual bool getZoomByMouseWheel() const; + bool getZoomByMouseWheel() const; /** \brief returns the property mouseContextX. \details Description of the parameter mouseContextX is:
\copydoc mouseContextX
. @@ -508,7 +502,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget { /** \brief save the current plot as an image file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed. * The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...) */ - inline void saveImage(QString filename=QString(""), bool displayPreview=true) { + inline void saveImage(const QString& filename=QString(""), bool displayPreview=true) { plotter->saveImage(filename, displayPreview); } @@ -520,7 +514,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget { * If \a format is \c "slk" the output will be in SYLK format, if \a format is \c "csv" or \a "dat" the output will be comma separated values * and if \a format is \c "txt" the output will be tab separated values. */ - inline void saveData(QString filename=QString(""), QString format=QString("")) { + inline void saveData(const QString& filename=QString(""), const QString& format=QString("")) { plotter->saveData(filename, format); } @@ -560,10 +554,15 @@ class LIB_EXPORT JKQTPlotter: public QWidget { inline void zoomOut(double factor=2.0) { plotter->zoomOut(factor); } /** \brief update the plot and the overlays */ - void replotPlot(); + void redrawPlot(); - /** \brief replot overlays only (use replotPlot() to replot the plot and the overlays) */ - void replotOverlays(); + /** \brief replot overlays only (use redrawPlot() to replot the plot and the overlays) + * + * You can use this function, if you only changed the overlays but not the graphs in this plotter. + * Then only the overlas are redrawn and the old (saved) image of the graphs and the coordinate syste, + * is used as a base. This is significantly faster than redrawing the whole plot. + */ + void redrawOverlays(); /*! \brief sets the property displayToolbar to the specified \a __value. \details Description of the parameter displayToolbar is:
\copydoc displayToolbar
@@ -614,7 +613,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget { /** \brief popuplate the given toolbar with all actions shown in a toolbar from this class ... */ - virtual void populateToolbar(QToolBar* toolbar) const; + void populateToolbar(QToolBar* toolbar) const; /** \brief open the context menu at the mouse position of the last click */ void openContextMenu(); @@ -684,7 +683,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget { * * The plotter will fill the menu with the default items and then call this method. The default implementation does NOTHING. */ - virtual void modifyContextMenu(QMenu* menu); + void modifyContextMenu(QMenu* menu); void init(bool datastore_internal, QWidget* parent, JKQTPDatastore* datast); diff --git a/lib/jkqtplottergui/jkqtpenhancedtableview.h b/lib/jkqtplottergui/jkqtpenhancedtableview.h index 37dbae8170..fd859933e9 100644 --- a/lib/jkqtplottergui/jkqtpenhancedtableview.h +++ b/lib/jkqtplottergui/jkqtpenhancedtableview.h @@ -52,7 +52,7 @@ class LIB_EXPORT JKQTPEnhancedTableView : public QTableView { QAction* getActionPrint() const { return printAction; } signals: - void keyPressed(int key, Qt::KeyboardModifiers modifiers, QString text); + void keyPressed(int key, Qt::KeyboardModifiers modifiers, const QString& text); public slots: void copySelectionToExcel(int copyrole=Qt::EditRole, bool storeHead=true); void copySelectionToExcelNoHead(int copyrole=Qt::EditRole); diff --git a/lib/jkqtplottertools/jkqtpdrawingtools.cpp b/lib/jkqtplottertools/jkqtpdrawingtools.cpp index c16421a0c5..ec7acedf70 100644 --- a/lib/jkqtplottertools/jkqtpdrawingtools.cpp +++ b/lib/jkqtplottertools/jkqtpdrawingtools.cpp @@ -59,7 +59,7 @@ void JKQTPPlotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPGra star_items=5; double angle=360.0/double(star_items)/180.0*M_PI; for (int i=0; i(i)+0.5)*angle; starcordsx[i*2]=sin(a); starcordsx[i*2+1]=0.5*sin(a+angle/2.0); starcordsy[i*2]=cos(a); diff --git a/lib/jkqtplottertools/jkqttools.cpp b/lib/jkqtplottertools/jkqttools.cpp index 2740189a2e..c8af5faea0 100644 --- a/lib/jkqtplottertools/jkqttools.cpp +++ b/lib/jkqtplottertools/jkqttools.cpp @@ -27,12 +27,12 @@ #include #include -void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, QString prefix) { +void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix) { settings.setValue(prefix+"pos", widget->pos()); settings.setValue(prefix+"size", widget->size()); } -void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoint defaultPosition, QSize defaultSize, QString prefix) { +void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoint defaultPosition, QSize defaultSize, const QString& prefix) { QPoint pos = settings.value(prefix+"pos", defaultPosition).toPoint(); QSize size = settings.value(prefix+"size", defaultSize).toSize(); @@ -42,11 +42,11 @@ void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoint defaultPo widget->move(pos); } -void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QString prefix) { +void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix) { jkloadWidgetGeometry(settings, widget, QPoint(10, 10), QSize(100, 100), prefix); } -void jksaveSplitter(QSettings& settings, QSplitter* splitter, QString prefix) { +void jksaveSplitter(QSettings& settings, QSplitter* splitter, const QString& prefix) { /*QList sizes=splitter->sizes(); QString data=""; for (int i=0; isaveState()); } -void jkloadSplitter(QSettings& settings, QSplitter* splitter, QString prefix) { +void jkloadSplitter(QSettings& settings, QSplitter* splitter, const QString& prefix) { /*QString data=settings.value(prefix+"splitter_sizes", "").toString(); QList sizes, s1; QStringList sl=data.split(","); @@ -71,7 +71,7 @@ void jkloadSplitter(QSettings& settings, QSplitter* splitter, QString prefix) { splitter->restoreState(settings.value(prefix+"splitter_sizes").toByteArray()); } -QString jkVariantListToString(const QList& data, QString separator) { +QString jkVariantListToString(const QList& data, const QString& separator) { QString r=""; QLocale loc=QLocale::c(); loc.setNumberOptions(QLocale::OmitGroupSeparator); diff --git a/lib/jkqtplottertools/jkqttools.h b/lib/jkqtplottertools/jkqttools.h index 089ef0af0e..8503092710 100644 --- a/lib/jkqtplottertools/jkqttools.h +++ b/lib/jkqtplottertools/jkqttools.h @@ -42,7 +42,7 @@ \param widget the widget to store \param prefix this prefix is prepended to the QSettings keys */ -LIB_EXPORT void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, QString prefix=QString("")); +LIB_EXPORT void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix=QString("")); /*! \brief load the geometry of a given widget to a QSettings \ingroup jkqtpjkqtptools_qt @@ -53,7 +53,7 @@ LIB_EXPORT void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, QStri \param[out] widget the widget to change \param prefix this prefix is prepended to the QSettings keys */ -LIB_EXPORT void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QString prefix=QString("")); +LIB_EXPORT void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix=QString("")); /*! \brief load the geometry of a given widget to a QSettings @@ -67,7 +67,7 @@ LIB_EXPORT void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QStri \param defaultSize default size of the widget \param prefix this prefix is prepended to the QSettings keys */ -LIB_EXPORT void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoint defaultPosition, QSize defaultSize, QString prefix=QString("")); +LIB_EXPORT void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoint defaultPosition, QSize defaultSize, const QString& prefix=QString("")); /*! \brief store the geometry of a given widget to a QSettings \ingroup jkqtpjkqtptools_qt @@ -78,7 +78,7 @@ LIB_EXPORT void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoin \param widget the widget to store \param prefix this prefix is prepended to the QSettings keys */ -LIB_EXPORT void jksaveSplitter(QSettings& settings, QSplitter* splitter, QString prefix=QString("")); +LIB_EXPORT void jksaveSplitter(QSettings& settings, QSplitter* splitter, const QString& prefix=QString("")); /*! \brief load the geometry of a given widget to a QSettings \ingroup jkqtpjkqtptools_qt @@ -89,14 +89,14 @@ LIB_EXPORT void jksaveSplitter(QSettings& settings, QSplitter* splitter, QString \param[out] plitter the plitter to change \param prefix this prefix is prepended to the QSettings keys */ -LIB_EXPORT void jkloadSplitter(QSettings& settings, QSplitter* splitter, QString prefix=QString("")); +LIB_EXPORT void jkloadSplitter(QSettings& settings, QSplitter* splitter, const QString& prefix=QString("")); /*! \brief convert a QList to a string \ingroup jkqtpjkqtptools_qt */ -LIB_EXPORT QString jkVariantListToString(const QList& data, QString separator=QString(", ")); +LIB_EXPORT QString jkVariantListToString(const QList& data, const QString& separator=QString(", ")); /*! \brief filename-ize a string, i.e. replace every non-number and non-character (and also not _ -) character to \c _