diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index efdb639121..e4cb39941a 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -48,10 +48,12 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
IMPROVED: rendering of sqrt
IMPROVED: rendering and size calculation of decorations
IMPROVED: tokenizing and parsing of text in text-mode: now a lot of accents with commands like \c \\\"a, \c \\'e and variants (e.g. \c {\\\"a}, \c \\\"{a}, ...) are supported now
- IMPROVED/breaking: refactored symbol node JKQTMathTextSymbolNode and changed font-lookup!
- IMPROVED/NEW/breaking: refactored whitespace-processing node JKQTMathTextWhitespaceNode, now all major LaTeX whitespace commands are supported properly
- IMPROVED/NEW/breaking: refactored LaTeX parser in JKQTMathText
- REMOVED/breaking: \c \\v[a-zA-Z] and shorthand for \c \\vec{a-zA-Z} was removed, implementation of \c \\bbR,\c \\bbC,... changed
+ IMPROVED/BREAKING: refactored symbol node JKQTMathTextSymbolNode and changed font-lookup!
+ IMPROVED/NEW/BREAKING: refactored whitespace-processing node JKQTMathTextWhitespaceNode, now all major LaTeX whitespace commands are supported properly
+ IMPROVED/NEW/BREAKING: refactored LaTeX parser in JKQTMathText
+ REMOVED/BREAKING: \c \\v[a-zA-Z] and shorthand for \c \\vec{a-zA-Z} was removed, implementation of \c \\bbR,\c \\bbC,... changed
+ MODIFIED/BREAKING: new options interface for JKQTMathText::parse()
+ EMOVED/BREAKING: removed JKQTMathtext::unparsedNode
IMPROVED/REWORKED rendering of text in text- and math-mode. Now it is more consistent with the output of LaTeX itself
IMPROVED/REWORKED rendering of blackboard font: now several different rendering modes can be selected using JKQTMathText::setFontBlackboradMode()
BREAKING/REWORKED: The \\verb!...!-command now works the same as in LaTeX
@@ -123,25 +125,25 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
fixed issue #52: 'runtime_error': is not a member of 'std', thanks to user:gomgomi
fixed issue #56: Logscale zoom multiple zeros? , thanks to user:sufuk
merged PR #51: Bug: JKMathParser exception return local variable , thanks to user:StephanOostveen
- renamed/breaking change: renamed JKQTPPlotObject->JKQTPGeometricPlotElement and added new base class JKQTPPlotAnnotationElement
- renamed/breaking change: renamed JKQTPColorPaletteStyleAndToolsMixin::setPalette() -> JKQTPColorPaletteStyleAndToolsMixin::setColorPalette()
- removed/breaking change: removed the usage of some deprecated functions and objects (e.g. QMatrix)
- removed/breaking change: removed the overlay elements (derived from JKQTPOverlayElement), which were not very well set up and are more confusing than useful.
- improved/breaking change: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved/breaking change: geometric elements constructor: removed all styling properties, added setStyle()-functions to replace them. This is necessary to better work with the extended Styling system
+ renamed/BREAKING change: renamed JKQTPPlotObject->JKQTPGeometricPlotElement and added new base class JKQTPPlotAnnotationElement
+ renamed/BREAKING change: renamed JKQTPColorPaletteStyleAndToolsMixin::setPalette() -> JKQTPColorPaletteStyleAndToolsMixin::setColorPalette()
+ removed/BREAKING change: removed the usage of some deprecated functions and objects (e.g. QMatrix)
+ removed/BREAKING change: removed the overlay elements (derived from JKQTPOverlayElement), which were not very well set up and are more confusing than useful.
+ improved/BREAKING change: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
+ improved/BREAKING change: geometric elements constructor: removed all styling properties, added setStyle()-functions to replace them. This is necessary to better work with the extended Styling system
improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- improved/breaking change: reworked class hierarchy of parsed function plots and declared several setters as slots.
- improved/breaking change: reworked class hierarchy of bar & impulse charts.
- improved/breaking change: reworked class hierarchy of range charts.
- improved/breaking change: reworked class hierarchy of special line (step) graphs.
- improved/breaking change: reworked class hierarchy of filled line graphs.
- improved/breaking change: reworked class hierarchy of range plot elements (JKQTPVerticalRange and JKQTPHorizontalRange).
- improved/breaking change: reworked class hierarchy of boxplots.
- improved/breaking change: reworked class hierarchy of violin plots.
- improved/breaking change: extended styling system for graphs.
- improved/breaking change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)
- improved/breaking change: made more functions and function parameters const
- improved/breaking change: image plots now manage CONST-data, not plain pointer arrays... This is OK, since the raw data is never owned nor modified by the plot, only referenced!.
+ improved/BREAKING change: reworked class hierarchy of parsed function plots and declared several setters as slots.
+ improved/BREAKING change: reworked class hierarchy of bar & impulse charts.
+ improved/BREAKING change: reworked class hierarchy of range charts.
+ improved/BREAKING change: reworked class hierarchy of special line (step) graphs.
+ improved/BREAKING change: reworked class hierarchy of filled line graphs.
+ improved/BREAKING change: reworked class hierarchy of range plot elements (JKQTPVerticalRange and JKQTPHorizontalRange).
+ improved/BREAKING change: reworked class hierarchy of boxplots.
+ improved/BREAKING change: reworked class hierarchy of violin plots.
+ improved/BREAKING change: extended styling system for graphs.
+ improved/BREAKING change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)
+ improved/BREAKING change: made more functions and function parameters const
+ improved/BREAKING change: image plots now manage CONST-data, not plain pointer arrays... This is OK, since the raw data is never owned nor modified by the plot, only referenced!.
bugfixed/improved: aspect ratio handling in JKQTPlotter.
new: switching to semantic versioning ... starting with v4.0.0
new: Compatibility with Qt 5.15 and Qt6
diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp
index 9f918e9d47..4a371c66c6 100644
--- a/lib/jkqtmathtext/jkqtmathtext.cpp
+++ b/lib/jkqtmathtext/jkqtmathtext.cpp
@@ -185,10 +185,8 @@ JKQTMathText::JKQTMathText(QObject* parent):
//qDebug()<<"set fonts: "<(std::chrono::high_resolution_clock::now()-t0).count()/1000.0<<"ms"; t0=std::chrono::high_resolution_clock::now();
useXITS();
//qDebug()<<"useXITS: "<(std::chrono::high_resolution_clock::now()-t0).count()/1000.0<<"ms"; t0=std::chrono::high_resolution_clock::now();
- useUnparsed=false;
parsedNode=nullptr;
- unparsedNode=nullptr;
currentToken=MTTnone;
currentTokenName="";
@@ -200,8 +198,6 @@ JKQTMathText::JKQTMathText(QObject* parent):
JKQTMathText::~JKQTMathText() {
if (parsedNode!=nullptr) delete parsedNode;
parsedNode=nullptr;
- if (unparsedNode!=nullptr) delete unparsedNode;
- unparsedNode=nullptr;
}
void JKQTMathText::loadSettings(const QSettings& settings, const QString& group){
@@ -1058,16 +1054,6 @@ void JKQTMathText::setMatrixYPaddingFactor(double factor)
matrix_yPadding_factor=factor;
}
-void JKQTMathText::setUseUnparsed(bool __value)
-{
- this->useUnparsed = __value;
-}
-
-bool JKQTMathText::isUsingUnparsed() const
-{
- return this->useUnparsed;
-}
-
QStringList JKQTMathText::getErrorList() const {
return this->error_list;
}
@@ -2288,15 +2274,15 @@ JKQTMathTextNode *JKQTMathText::getParsedNode() const {
-bool JKQTMathText::parse(const QString& text, bool addSpaceBeforeAndAfter, bool allowLinebreaks){
+bool JKQTMathText::parse(const QString& text, ParseOptions options){
QString ntext;
- if (addSpaceBeforeAndAfter) ntext=QString("\\;")+text+QString("\\;");
+ if (options.testFlag(StartWithMathMode)) ntext=QString("$")+text+QString("$");
+ if (options.testFlag(AddSpaceBeforeAndAfter)) ntext=QString("\\;")+text+QString("\\;");
else ntext=text;
if (parsedNode && parseString==ntext) return true;
if (parsedNode!=nullptr) delete parsedNode;
- if (unparsedNode!=nullptr) delete unparsedNode;
parseString=ntext;
currentTokenID=-1;
@@ -2306,12 +2292,11 @@ bool JKQTMathText::parse(const QString& text, bool addSpaceBeforeAndAfter, bool
lastLineCount.clear();
error_list.clear();
- if (allowLinebreaks) {
+ if (options.testFlag(AllowLinebreaks)) {
parsedNode=parseMultilineLatexString(true, QString(""), MTHALeft, 1.0, MTSMDefaultSpacing, MTVOFirstLine);
} else {
parsedNode=parseLatexString(true);
}
- unparsedNode=new JKQTMathTextVerbatimNode(this, text);
return (parsedNode!=nullptr);
}
@@ -2516,7 +2501,6 @@ QPicture JKQTMathText::drawIntoPicture(bool drawBoxes)
JKQTMathTextNode *JKQTMathText::getNodeTree() const {
- if (useUnparsed) return unparsedNode;
return parsedNode;
}
diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h
index 8e737b2a13..354e8bf73e 100644
--- a/lib/jkqtmathtext/jkqtmathtext.h
+++ b/lib/jkqtmathtext/jkqtmathtext.h
@@ -25,6 +25,7 @@
#ifndef JKQTMATHTEXT_H
#define JKQTMATHTEXT_H
+#include
#include
#include
#include
@@ -214,14 +215,24 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
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, const QString& group=QString("mathtext/")) const;
+ /** \brief options for parse() */
+ enum ParseOption {
+ AddSpaceBeforeAndAfter = 0x01, /*!< \brief If set, a little bit of space is added before and after the text. */
+ StartWithMathMode = 0x02, /*!< \brief if set, the parser assumes the LaTeX string is in math-mode (as if surrounded by \c $ ) */
+ AllowLinebreaks = 0x04, /*!< \brief If set, linebreak (i.e. \c \\ or \c \\newline ) are allowed, otherwise a single line wihtout such linebreak commands is expected */
+ DefaultParseOptions=AllowLinebreaks,
+ };
+ Q_DECLARE_FLAGS(ParseOptions, ParseOption)
+ Q_FLAG(ParseOptions)
/** \brief parse the given LaTeX string.
*
- * \param addSpaceBeforeAndAfter If \ctrue a little bit of space is added before and after the text.
- * \param allowLinebreaks If \c true , linebreak (i.e. \c \\ or \c \\newline ) are allowed, otherwise a single line wihtout such linebreak commands is expected
+ * \param options Options for parsing, \see ParseOptions
+ * \param allowLinebreaks
*
* \returns \c true on success.
*/
- bool parse(const QString &text, bool addSpaceBeforeAndAfter=false, bool allowLinebreaks=true);
+ bool parse(const QString &text, ParseOptions options=DefaultParseOptions);
+
/** \brief get the size of the drawn representation. returns an invalid size if no text has been parsed. */
QSizeF getSize(QPainter& painter);
/** \brief return the descent, i.e. the distance from the baseline to the lowest part of the representation */
@@ -643,11 +654,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
void setMatrixYPaddingFactor(double factor);
-
- /** \copydoc useUnparsed */
- void setUseUnparsed(bool __value);
- /** \copydoc useUnparsed */
- bool isUsingUnparsed() const;
/** \copydoc error_list */
QStringList getErrorList() const;
/** \brief returns \c true when errors were registered in the system \see error_list */
@@ -883,10 +889,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
/** \brief the result of parsing the last string supplied to the object via parse() */
JKQTMathTextNode* parsedNode;
- /** \brief a tree containing the unparsed text as a single node */
- JKQTMathTextNode* unparsedNode;
- /** \brief if true, the unparsedNode is drawn \see unparsedNode */
- bool useUnparsed;
/** \brief returns the syntax tree of JKQTMathTextNode's that was created by the last parse call */
JKQTMathTextNode* getNodeTree() const;
diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp
index 7c4860ae16..299130bd75 100644
--- a/lib/jkqtplotter/jkqtpbaseplotter.cpp
+++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp
@@ -1738,7 +1738,6 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
plotterStyle.widgetBackgroundBrush=bc;
paintMagnification=oldP;
- mathText.setUseUnparsed(false);
return res;
@@ -3744,7 +3743,6 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
QFile::copy(fn, tempFM);
}
- mathText.setUseUnparsed(!jkqtpPaintDeviceAdapters[adapterID]->useLatexParser());
gridPrintingCalc();
QPaintDevice* paintDevice=jkqtpPaintDeviceAdapters[adapterID]->createPaintdevice(fn, jkqtp_roundTo(gridPrintingSize.width()), jkqtp_roundTo(gridPrintingSize.height()));
@@ -5104,11 +5102,6 @@ JKQTBasePlotter::textSizeData::textSizeData():
-bool JKQTPPaintDeviceAdapter::useLatexParser() const
-{
- return true;
-}
-
QPaintDevice *JKQTPPaintDeviceAdapter::createPaintdeviceMM(const QString &filename, double widthMM, double heightMM) const
{
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
diff --git a/lib/jkqtplotter/jkqtpbaseplotter.h b/lib/jkqtplotter/jkqtpbaseplotter.h
index e81a6d9e7f..205ccd8b1d 100644
--- a/lib/jkqtplotter/jkqtpbaseplotter.h
+++ b/lib/jkqtplotter/jkqtpbaseplotter.h
@@ -87,7 +87,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPaintDeviceAdapter {
virtual double getPrintSizeXInMM() const =0;
virtual double getPrintSizeYInMM() const =0;
virtual bool isPrinter() const=0;
- virtual bool useLatexParser() const;
/** \brief create a paint device with a given size in pt */
virtual QPaintDevice* createPaintdevice(const QString& filename, int widthPix, int heightPix) const=0;
/** \brief create a paint device with a given size in millimeters ... the default implementation call createPaintdevice(), assuming the standard logical resolution of the desktop!!!) */