mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 09:31:40 +08:00
- NEW: reworked node class tree: inserted base-class nodes for single-child, dual-child!
- NEW: improved frac-rendering: font-scaling takes nesting-level into account, overall-rendering, sizes, if a brace surrounds a frac, the heights are equal above and below to center the brace ...
This commit is contained in:
parent
993ed1fb3d
commit
1a8de1bb2f
@ -41,7 +41,7 @@ This page lists several todos and wishes for future version of JKQTPlotter
|
||||
<li>add instruction for unicode-characters \char"XXXX, \unicode{XXXX}, \utf8{XXXX}, \utf16{XXXX}, \utf32{XXXX} ...</li>
|
||||
<li>check sub/superscript with italic text in math mode, possibly a correction is necessary</li>
|
||||
<li>explore where QFontMetricsF::horizontalAdvance() can be used (for Qt >=5.15)</li>
|
||||
<li></li>
|
||||
<li>correction of frac-height (2*maxHeight or height1+height2) should be done by brace-node, not frac-node</li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
</ul></li>
|
||||
|
@ -14,21 +14,29 @@ This page lists release notes for the different version of JKQTPlotter
|
||||
\subsection page_whatsnew_TRUNK_OVERVIEW trunk: Overview
|
||||
Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
||||
<ul>
|
||||
<li>fixed issue described in <a href="https://github.com/jkriege2/JKQtPlotter/pull/62">#62: Fix custom labels draw, because giving exactly two label-strings did not display all of them</a>, thanks to <a href="https://github.com/FalsinSoft">user:FalsinSoft</a></li>
|
||||
<li>fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/70">#70: Typo in jkqtplotter/CMakeLists.txt</a>, thanks to <a href="https://github.com/tedlinlab">user:tedlinlab</a></li>
|
||||
<li>fixed: styling was not properly applied to coordinate axes of colorbars outside the plot</li>
|
||||
<li>fixed: JKQTMathText added a little whitespace before and after the LaTeX-string. This was removed as it disturbed the layout of text in plots</li>
|
||||
<li>fixes/improvements: JKQTMathText renders several LaTeX strings better (simple braces in math mode, +-*... as symbols with proper sizes in math mode, added some missing instruction aliases, improved size of \vec and \hat, corrrected fonts usage for mathrm</li>
|
||||
<li>improved: high-dpr-support in JKQTMathText</li>
|
||||
<li>improved: QT6-compatibility by removing deprecated warnings</li>
|
||||
<li>NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request <a href="https://github.com/jkriege2/JKQtPlotter/issues/68">#68 Wiggle Plots</a> from <a href="https://github.com/xichaoqiang">user:xichaoqiang</a> </li>
|
||||
<li>NEW/BREAKING CHANGE: data tooltip can now also be shown when "just" moving the mouse (so far this was only possible when dragging the mouse with a button pressed). This also removes JKQtPlotter::getActMouseLeftAsToolTip() and adds JKQtPlotter::getActMouseMoveToolTip() instead! Also the default toolbars and context menus changed!</li>
|
||||
<li>NEW: new "seaborn" style for plots</li>
|
||||
<li>NEW/BREAKING CHANGE: changed JKQTPColorDerivationMode into a struct, which extends its capabilities above the previously available few enum-items</li>
|
||||
<li>NEW: added debug-feature to show boxes around text in the plot</li>
|
||||
<li>NEW: JKQTMathText: now supports new decoration instructions: \cancel, \xcancel, \bcancel, \sout, \ocirc, \widetilde, \widehat, \breve</li>
|
||||
<li>NEW: JKQTMathText: reworked drawing of decorations: improved appearance and positioning!</li>
|
||||
<li>NEW: JKQTMathText: reworked code structure: broke up large, single CPP-files into several smaller files!</li>
|
||||
<li>JKQtPlotter:<ul>
|
||||
<li>fixed issue described in <a href="https://github.com/jkriege2/JKQtPlotter/pull/62">#62: Fix custom labels draw, because giving exactly two label-strings did not display all of them</a>, thanks to <a href="https://github.com/FalsinSoft">user:FalsinSoft</a></li>
|
||||
<li>fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/70">#70: Typo in jkqtplotter/CMakeLists.txt</a>, thanks to <a href="https://github.com/tedlinlab">user:tedlinlab</a></li>
|
||||
<li>fixed: styling was not properly applied to coordinate axes of colorbars outside the plot</li>
|
||||
<li>improved: QT6-compatibility by removing deprecated warnings</li>
|
||||
<li>NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request <a href="https://github.com/jkriege2/JKQtPlotter/issues/68">#68 Wiggle Plots</a> from <a href="https://github.com/xichaoqiang">user:xichaoqiang</a> </li>
|
||||
<li>NEW/BREAKING CHANGE: data tooltip can now also be shown when "just" moving the mouse (so far this was only possible when dragging the mouse with a button pressed). This also removes JKQtPlotter::getActMouseLeftAsToolTip() and adds JKQtPlotter::getActMouseMoveToolTip() instead! Also the default toolbars and context menus changed!</li>
|
||||
<li>NEW: new "seaborn" style for plots</li>
|
||||
<li>NEW/BREAKING CHANGE: changed JKQTPColorDerivationMode into a struct, which extends its capabilities above the previously available few enum-items</li>
|
||||
<li>NEW: added debug-feature to show boxes around text in the plot</li>
|
||||
</ul>
|
||||
|
||||
<li>JKQTMathText:<ul>
|
||||
<li>fixed: JKQTMathText added a little whitespace before and after the LaTeX-string. This was removed as it disturbed the layout of text in plots</li>
|
||||
<li>fixed: height-calculation of frac-like instructions: before the ascent and descent were equal, even if the numerator and denominator have different hieghts</li>
|
||||
<li>fixes/improvements: JKQTMathText renders several LaTeX strings better (simple braces in math mode, +-*... as symbols with proper sizes in math mode, added some missing instruction aliases, improved size of \vec and \hat, corrrected fonts usage for mathrm</li>
|
||||
<li>improved: high-dpr-support in JKQTMathText</li>
|
||||
<li>NEW: now supports new decoration instructions: \cancel, \xcancel, \bcancel, \sout, \ocirc, \widetilde, \widehat, \breve</li>
|
||||
<li>NEW: reworked drawing of decorations: improved appearance and positioning!</li>
|
||||
<li>NEW: reworked code structure: broke up large, single CPP-files into several smaller files!</li>
|
||||
<li>NEW: reworked node class tree: inserted base-class nodes for single-child, dual-child!</li>
|
||||
<li>NEW: improved frac-rendering: font-scaling takes nesting-level into account, overall-rendering, sizes, if a brace surrounds a frac, the heights are equal above and below to center the brace , ...</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
\subsection page_whatsnew_TRUNK_DOWNLOAD trunk: Download
|
||||
|
BIN
doc/images/jkqtmathtext_fracnode_geo.cdr
Normal file
BIN
doc/images/jkqtmathtext_fracnode_geo.cdr
Normal file
Binary file not shown.
BIN
doc/images/jkqtmathtext_fracnode_geo.png
Normal file
BIN
doc/images/jkqtmathtext_fracnode_geo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 29 KiB |
BIN
doc/images/jkqtmathtext_sfracnode_geo.cdr
Normal file
BIN
doc/images/jkqtmathtext_sfracnode_geo.cdr
Normal file
Binary file not shown.
BIN
doc/images/jkqtmathtext_sfracnode_geo.png
Normal file
BIN
doc/images/jkqtmathtext_sfracnode_geo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
Binary file not shown.
@ -130,5 +130,7 @@
|
||||
\item\textbf{math: frac test:} \[\frac{a}{b}+\frac{g}{a}-\frac{a^2}{b^2}\cdot\frac{a^2}{b^{\frac{1}{2}}}\]
|
||||
|
||||
\end{itemize}
|
||||
|
||||
|
||||
|
||||
\end{document}
|
@ -67,7 +67,8 @@ JKQTMathText::JKQTMathText(QObject* parent):
|
||||
brace_shrink_factor=0.6;
|
||||
fontColor=QColor("black");
|
||||
|
||||
frac_factor=0.9;
|
||||
frac_factor=1.0;
|
||||
frac_nested_factor=0.7;
|
||||
frac_shift_factor=0.4;
|
||||
underbrace_factor=0.75;
|
||||
undersetFactor=0.7;
|
||||
@ -733,6 +734,16 @@ double JKQTMathText::getFracFactor() const
|
||||
return this->frac_factor;
|
||||
}
|
||||
|
||||
void JKQTMathText::setFracNestedFactor(double __value)
|
||||
{
|
||||
frac_nested_factor=__value;
|
||||
}
|
||||
|
||||
double JKQTMathText::getFracNestedFactor() const
|
||||
{
|
||||
return frac_nested_factor;
|
||||
}
|
||||
|
||||
void JKQTMathText::setFracShiftFactor(double __value)
|
||||
{
|
||||
this->frac_shift_factor = __value;
|
||||
@ -962,7 +973,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, const QString& quitOn
|
||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(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") {
|
||||
} else if (name=="dfrac" || name=="cfrac") {
|
||||
JKQTMathTextNode* n1=parseLatexString(true);
|
||||
JKQTMathTextNode* n2=nullptr;
|
||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||
|
@ -466,11 +466,17 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
||||
void setUndersetFactor(double __value);
|
||||
/** \copydoc undersetFactor */
|
||||
double getUndersetFactor() const;
|
||||
/** \copydoc frac_factor */
|
||||
/** \copydoc frac_factor */
|
||||
void setFracFactor(double __value);
|
||||
/** \copydoc frac_factor */
|
||||
/** \copydoc frac_factor */
|
||||
double getFracFactor() const;
|
||||
/** \copydoc frac_shift_factor */
|
||||
/** \copydoc frac_nested_factor */
|
||||
void setFracNestedFactor(double __value);
|
||||
/** \copydoc frac_nested_factor */
|
||||
double getFracNestedFactor() const;
|
||||
|
||||
|
||||
/** \copydoc frac_shift_factor */
|
||||
void setFracShiftFactor(double __value);
|
||||
/** \copydoc frac_shift_factor */
|
||||
double getFracShiftFactor() const;
|
||||
@ -541,8 +547,10 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
||||
double sub_shift_factor;
|
||||
|
||||
|
||||
/** \brief scaling factor for font of nominator and denominator of a fraction */
|
||||
/** \brief scaling factor for font size of nominator and denominator of a fraction */
|
||||
double frac_factor;
|
||||
/** \brief scaling factor for font size of nominator and denominator of a nested fraction */
|
||||
double frac_nested_factor;
|
||||
/** \brief shift of denominator/nummerator away from central line of a frac */
|
||||
double frac_shift_factor;
|
||||
/** \brief scaling factor for font of underbrace/overbrace text */
|
||||
|
@ -37,30 +37,29 @@
|
||||
|
||||
|
||||
JKQTMathTextBraceNode::JKQTMathTextBraceNode(JKQTMathText* _parent, const QString& openbrace, const QString& closebrace, JKQTMathTextNode* child, bool showRightBrace):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextSingleChildNode(child, _parent)
|
||||
{
|
||||
this->child=child;
|
||||
this->openbrace=openbrace;
|
||||
this->closebrace=closebrace;
|
||||
this->showRightBrace=showRightBrace;
|
||||
}
|
||||
|
||||
|
||||
JKQTMathTextBraceNode::~JKQTMathTextBraceNode() {
|
||||
if (child!=nullptr) delete child;
|
||||
}
|
||||
|
||||
void JKQTMathTextBraceNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
const JKQTMathTextEnvironment 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->getBraceShrinkFactor();
|
||||
bracewidth=bracewidth/parentMathText->getBraceShrinkFactor();
|
||||
|
||||
baselineHeight=/*qMin(baselineHeight, braceheight)*/ baselineHeight*parent->getBraceFactor();
|
||||
overallHeight=qMax(overallHeight, braceheight)*parent->getBraceFactor(); //fm.height();
|
||||
baselineHeight=/*qMin(baselineHeight, braceheight)*/ baselineHeight*parentMathText->getBraceFactor();
|
||||
overallHeight=qMax(overallHeight, braceheight)*parentMathText->getBraceFactor(); //fm.height();
|
||||
|
||||
width=width+bracewidth*2.0;
|
||||
|
||||
@ -87,11 +86,11 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
||||
|
||||
getSize(painter, currentEv, cWidth, cBaselineHeight, cOverallHeight, cstrikeoutPos);
|
||||
|
||||
double lw=qMax(0.25,ceil(currentEv.fontSize/16.0));//fm.lineWidth();
|
||||
const double lw=qMax(0.25,ceil(currentEv.fontSize/16.0));//fm.lineWidth();
|
||||
|
||||
double xnew=x+lw;
|
||||
|
||||
QPen pold=painter.pen();
|
||||
const QPen pold=painter.pen();
|
||||
QPen p=pold;
|
||||
p.setWidthF(lw);
|
||||
p.setColor(currentEv.color);
|
||||
@ -99,15 +98,15 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
||||
double brace_fraction=0.85;
|
||||
if (openbrace=="(") {
|
||||
QPainterPath path;
|
||||
double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
double y2=y-cBaselineHeight;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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);
|
||||
@ -122,39 +121,36 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
||||
|
||||
} else if (openbrace=="_") {
|
||||
QPainterPath path;
|
||||
double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
double y2=y-cBaselineHeight;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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);
|
||||
@ -163,21 +159,21 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
||||
|
||||
painter.setPen(pold);
|
||||
|
||||
xnew= child->draw(painter, xnew+bracewidth/parent->getBraceShrinkFactor()-lw, y, currentEv)+lw;
|
||||
xnew= child->draw(painter, xnew+bracewidth/parentMathText->getBraceShrinkFactor()-lw, y, currentEv)+lw;
|
||||
|
||||
if (showRightBrace) {
|
||||
painter.setPen(p);
|
||||
if (closebrace==")") {
|
||||
QPainterPath path;
|
||||
double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
double y2=y-cBaselineHeight;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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);
|
||||
@ -192,39 +188,36 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
||||
|
||||
} else if (closebrace=="_") {
|
||||
QPainterPath path;
|
||||
double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
double y2=y-cBaselineHeight;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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;
|
||||
const double y1=y+(cOverallHeight-cBaselineHeight);
|
||||
const 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);
|
||||
@ -234,7 +227,7 @@ double JKQTMathTextBraceNode::draw(QPainter& painter, double x, double y, JKQTMa
|
||||
}
|
||||
|
||||
//qDebug()<<" ==> "<<bc<<fm.boundingRect(bc).width();
|
||||
return xnew+bracewidth/parent->getBraceShrinkFactor()-lw;
|
||||
return xnew+bracewidth/parentMathText->getBraceShrinkFactor()-lw;
|
||||
}
|
||||
|
||||
bool JKQTMathTextBraceNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
||||
@ -259,19 +252,24 @@ bool JKQTMathTextBraceNode::toHtml(QString &html, JKQTMathTextEnvironment curren
|
||||
return ok;
|
||||
}
|
||||
|
||||
void JKQTMathTextBraceNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
this->drawBoxes=draw;
|
||||
child->setDrawBoxes(draw);
|
||||
|
||||
}
|
||||
|
||||
QString JKQTMathTextBraceNode::getTypeName() const
|
||||
{
|
||||
return QLatin1String("MTbraceNode(")+openbrace+" "+closebrace+")";
|
||||
}
|
||||
|
||||
void JKQTMathTextBraceNode::getBraceWidth(QPainter &/*painter*/, JKQTMathTextEnvironment ev, double /*baselineHeight*/, double overallHeight, double &bracewidth, double &braceheight)
|
||||
QString JKQTMathTextBraceNode::getOpenbrace() const {
|
||||
return this->openbrace;
|
||||
}
|
||||
|
||||
QString JKQTMathTextBraceNode::getClosebrace() const {
|
||||
return this->closebrace;
|
||||
}
|
||||
|
||||
bool JKQTMathTextBraceNode::getShowRightBrace() const {
|
||||
return this->showRightBrace;
|
||||
}
|
||||
|
||||
void JKQTMathTextBraceNode::getBraceWidth(QPainter &/*painter*/, JKQTMathTextEnvironment ev, double /*baselineHeight*/, double overallHeight, double &bracewidth, double &braceheight) const
|
||||
{
|
||||
/*QFont evf=ev.getFont(parent);
|
||||
if (ev.insideMath) evf.setItalic(false);
|
||||
@ -289,7 +287,7 @@ void JKQTMathTextBraceNode::getBraceWidth(QPainter &/*painter*/, JKQTMathTextEnv
|
||||
bracewidth=fm.width("I")*parent->getBraceShrinkFactor();
|
||||
braceheight=parent->getTBR(evf, bc, painter.device()).height();*/
|
||||
double lw=qMax(0.25,ceil(ev.fontSize/12.0));
|
||||
braceheight=overallHeight*parent->getBraceFactor();
|
||||
braceheight=overallHeight*parentMathText->getBraceFactor();
|
||||
bracewidth=0.6*pow(braceheight, 0.6);
|
||||
if (openbrace=="{" || closebrace=="}") bracewidth=qMax(bracewidth, lw*3.5);
|
||||
|
||||
|
@ -35,7 +35,7 @@ class JKQTMathText; // forward
|
||||
/** \brief subclass representing a brace node
|
||||
* \ingroup jkqtmathtext_items
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceNode: public JKQTMathTextNode {
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceNode: public JKQTMathTextSingleChildNode {
|
||||
public:
|
||||
JKQTMathTextBraceNode(JKQTMathText* parent, const QString& openbrace, const QString& closebrace, JKQTMathTextNode* child, bool showRightBrace=true);
|
||||
virtual ~JKQTMathTextBraceNode() override;
|
||||
@ -43,35 +43,25 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceNode: public JKQTMathTextNode {
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||
virtual QString getTypeName() const override;
|
||||
/** \brief returns the child node */
|
||||
inline JKQTMathTextNode* getChild() const {
|
||||
return this->child;
|
||||
}
|
||||
/** \copydoc openbrace */
|
||||
inline QString getOpenbrace() const {
|
||||
return this->openbrace;
|
||||
}
|
||||
/** \copydoc openbrace */
|
||||
QString getOpenbrace() const;
|
||||
/** \copydoc closebrace */
|
||||
inline QString getClosebrace() const {
|
||||
return this->closebrace;
|
||||
}
|
||||
QString getClosebrace() const;
|
||||
/** \copydoc showRightBrace */
|
||||
inline bool getShowRightBrace() const {
|
||||
return this->showRightBrace;
|
||||
}
|
||||
bool getShowRightBrace() const;
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
JKQTMathTextNode* child;
|
||||
/**\brief opening brace */
|
||||
QString openbrace;
|
||||
/**\brief closing brace */
|
||||
QString closebrace;
|
||||
/**\brief if \c true, the right-hand-side brace is drawn */
|
||||
bool showRightBrace;
|
||||
|
||||
void getBraceWidth(QPainter& painter, JKQTMathTextEnvironment currentEv, double baselineHeight, double overallHeight, double& bracewidth, double& braceheight);
|
||||
/** \brief calculate the width of the brace */
|
||||
void getBraceWidth(QPainter& painter, JKQTMathTextEnvironment currentEv, double baselineHeight, double overallHeight, double& bracewidth, double& braceheight) const;
|
||||
};
|
||||
|
||||
#endif // JKQTMATHTEXTBRACENODE_H
|
||||
|
@ -39,23 +39,21 @@
|
||||
|
||||
|
||||
JKQTMathTextDecoratedNode::JKQTMathTextDecoratedNode(JKQTMathText* _parent, JKQTMathTextDecoration decoration, JKQTMathTextNode* child):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextSingleChildNode(child, _parent)
|
||||
{
|
||||
this->child=child;
|
||||
this->decoration=decoration;
|
||||
}
|
||||
|
||||
JKQTMathTextDecoratedNode::~JKQTMathTextDecoratedNode() {
|
||||
if (child!=nullptr) delete child;
|
||||
}
|
||||
|
||||
void JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
const QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
|
||||
child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
|
||||
const double italic_xcorrection=getNonItalicXCorretion(painter, width, currentEv, child);
|
||||
const double decoheightfactor=parent->getDecorationHeightFactor();
|
||||
const double decoheightfactor=parentMathText->getDecorationHeightFactor();
|
||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("~").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||
|
||||
const double decoAboveAscent_yposdelta=fm.ascent()*(1.0+2.0*decoheightfactor);
|
||||
@ -76,19 +74,19 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0;
|
||||
child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
const QFont font=ev.getFont(parent);
|
||||
const QFont font=ev.getFont(parentMathText);
|
||||
const QFontMetricsF fm(font, painter.device());
|
||||
const double width_X=fm.boundingRect("X").width();
|
||||
const double width_x=fm.boundingRect("x").width();
|
||||
const double width_dot=fm.boundingRect(".").width()/2.0;
|
||||
const double decoheightfactor=parent->getDecorationHeightFactor();
|
||||
const double decoheightfactor=parentMathText->getDecorationHeightFactor();
|
||||
const double deco_ypos=y-baselineHeight*(1.0+decoheightfactor);
|
||||
const double decoAboveAscent_ypos=y-fm.ascent()*(1.0+decoheightfactor);
|
||||
const double strike_ypos=y-baselineHeight/2.0;
|
||||
const double decobelow_ypos=y+qMax((overallHeight-baselineHeight)*(1.0+decoheightfactor), fm.xHeight()*decoheightfactor);
|
||||
const double deco_height=decoheightfactor*baselineHeight;
|
||||
const double italic_xcorrection=getNonItalicXCorretion(painter, width, ev, child);
|
||||
const double deco_xoffset=parent->getDecorationWidthReductionXFactor()*width_X/2.0;
|
||||
const double deco_xoffset=parentMathText->getDecorationWidthReductionXFactor()*width_X/2.0;
|
||||
const double deco_width=std::max<double>(width_x*0.5,width-2.0*deco_xoffset-italic_xcorrection);
|
||||
const double deco_vecwidth=width_x*0.33;
|
||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("~").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||
@ -104,7 +102,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
QPen pold=painter.pen();
|
||||
QPen p=pold;
|
||||
p.setColor(ev.color);
|
||||
p.setWidthF(qMax(parent->ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0));
|
||||
p.setWidthF(qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0));
|
||||
|
||||
double xnew=child->draw(painter, x, y, ev);
|
||||
|
||||
@ -279,22 +277,11 @@ bool JKQTMathTextDecoratedNode::toHtml(QString &/*html*/, JKQTMathTextEnvironmen
|
||||
return false;
|
||||
}
|
||||
|
||||
void JKQTMathTextDecoratedNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
this->drawBoxes=draw;
|
||||
child->setDrawBoxes(draw);
|
||||
|
||||
}
|
||||
|
||||
QString JKQTMathTextDecoratedNode::getTypeName() const
|
||||
{
|
||||
return "MTdecoratedNode";
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextDecoratedNode::getChild() const {
|
||||
return this->child;
|
||||
}
|
||||
|
||||
JKQTMathTextDecoration JKQTMathTextDecoratedNode::getDecoration() const {
|
||||
return this->decoration;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class JKQTMathText; // forward
|
||||
* \image html mathparser/decoration_sizing.png
|
||||
*
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextNode {
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSingleChildNode {
|
||||
public:
|
||||
JKQTMathTextDecoratedNode(JKQTMathText* parent, JKQTMathTextDecoration decoration, JKQTMathTextNode* child);
|
||||
virtual ~JKQTMathTextDecoratedNode() override;
|
||||
@ -46,19 +46,13 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextNode
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||
virtual QString getTypeName() const override ;
|
||||
/** \brief returns the child node */
|
||||
JKQTMathTextNode* getChild() const;
|
||||
/** \copydoc decoration */
|
||||
JKQTMathTextDecoration getDecoration() const;
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \brief child node that is decorated by this node */
|
||||
JKQTMathTextNode* child;
|
||||
/** \brief type of decoration that is added to the child node */
|
||||
JKQTMathTextDecoration decoration;
|
||||
};
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
|
||||
#include "jkqtmathtext/nodes/jkqtmathtextfracnode.h"
|
||||
#include "jkqtmathtext/nodes/jkqtmathtextbracenode.h"
|
||||
#include "jkqtmathtext/jkqtmathtexttools.h"
|
||||
#include "jkqtmathtext/jkqtmathtext.h"
|
||||
#include "jkqtcommon/jkqtpcodestructuring.h"
|
||||
@ -39,16 +40,12 @@
|
||||
|
||||
|
||||
JKQTMathTextFracNode::JKQTMathTextFracNode(JKQTMathText* _parent, JKQTMathTextNode* child_top, JKQTMathTextNode* child_bottom, JKQTMathTextFracMode mode):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextDualChildNode(child_top, child_bottom, _parent)
|
||||
{
|
||||
this->child1=child_top;
|
||||
this->child2=child_bottom;
|
||||
this->mode=mode;
|
||||
}
|
||||
|
||||
JKQTMathTextFracNode::~JKQTMathTextFracNode() {
|
||||
if (child1!=nullptr) delete child1;
|
||||
if (child2!=nullptr) delete child2;
|
||||
}
|
||||
|
||||
QString JKQTMathTextFracNode::getTypeName() const
|
||||
@ -57,25 +54,25 @@ QString JKQTMathTextFracNode::getTypeName() const
|
||||
}
|
||||
|
||||
void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
JKQTMathTextEnvironment ev1=currentEv;
|
||||
JKQTMathTextEnvironment ev2=currentEv;
|
||||
|
||||
double xh=fm.xHeight(); //tightBoundingRect("x").height();
|
||||
double sp=xh;
|
||||
double Ah=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parent), "M", painter.device()).height();//fm.ascent();
|
||||
double xw=fm.boundingRect("x").width();
|
||||
const double xheight=fm.xHeight(); //tightBoundingRect("x").height();
|
||||
const double line_ascent=xheight/2.0;
|
||||
const double Mheight=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device()).height();//fm.ascent();
|
||||
const double xwidth=fm.boundingRect("x").width();
|
||||
|
||||
if (mode==MTFMunderbrace || mode==MTFMoverbrace) {
|
||||
ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor();
|
||||
ev2.fontSize=ev2.fontSize*parentMathText->getUnderbraceFactor();
|
||||
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
||||
ev2.fontSize=ev2.fontSize*parent->getUndersetFactor();
|
||||
ev2.fontSize=ev2.fontSize*parentMathText->getUndersetFactor();
|
||||
} else if (mode==MTFMfrac || mode==MTFMsfrac) {
|
||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor();
|
||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor();
|
||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor();
|
||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor();
|
||||
} else if (mode==MTFMtfrac || mode==MTFMstfrac) {
|
||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7;
|
||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7;
|
||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor()*0.7;
|
||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
||||
}
|
||||
|
||||
|
||||
@ -84,59 +81,99 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
||||
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1);
|
||||
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos2);
|
||||
|
||||
|
||||
const double maxHeight=qMax(overallHeight1,overallHeight2);
|
||||
const bool _isBraceParentNearerThanFrac=isBraceParentNearerThanFrac();
|
||||
const double height1OrMaxHeight=(_isBraceParentNearerThanFrac)?maxHeight:overallHeight1;
|
||||
const double height2OrMaxHeight=(_isBraceParentNearerThanFrac)?maxHeight:overallHeight2;
|
||||
overallHeight=0;
|
||||
baselineHeight=0;
|
||||
width=0;
|
||||
if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) {
|
||||
//std::cout<<"\nxh="<<xh;
|
||||
//std::cout<<"\n baselineHeight1="<<baselineHeight1<<", overallHeight1="<<overallHeight1;
|
||||
//std::cout<<"\n baselineHeight2="<<baselineHeight2<<", overallHeight2="<<overallHeight2<<std::endl;
|
||||
//overallHeight=overallHeight1+overallHeight2+sp*(2.0*parent->getFracShiftFactor());
|
||||
//baselineHeight=overallHeight1+xh*(2.0*parent->getFracShiftFactor());
|
||||
overallHeight=2.0*qMax(overallHeight1, overallHeight2)+sp*(2.0*parent->getFracShiftFactor());
|
||||
baselineHeight=qMax(overallHeight1, overallHeight2)+xh*(2.0*parent->getFracShiftFactor());
|
||||
//std::cout<<"=> baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight<<std::endl;
|
||||
width=qMax(width1, width2)+ xw;
|
||||
strikeoutPos=sp;
|
||||
if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac || mode==MTFMstackrel) {
|
||||
const double top_ascent=line_ascent+xheight*parentMathText->getFracShiftFactor();
|
||||
const double bot_ascent=line_ascent-xheight*parentMathText->getFracShiftFactor();
|
||||
// here we use maxHeight (as LaTeX does) so braces are centered around the xHieght!!!
|
||||
// if there are no braces, we can use the actual height
|
||||
const double newascent=height1OrMaxHeight+top_ascent;
|
||||
const double newdescent=height2OrMaxHeight-bot_ascent;
|
||||
width=qMax(width1, width2);
|
||||
if (mode!=MTFMstackrel) width+=xwidth/2.0;
|
||||
strikeoutPos=line_ascent;
|
||||
|
||||
overallHeight=newascent+newdescent;
|
||||
baselineHeight=newascent;
|
||||
|
||||
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
||||
overallHeight=2.0*qMax(overallHeight1, overallHeight2)+sp*(2.0*parent->getFracShiftFactor());
|
||||
baselineHeight=qMax(overallHeight1, overallHeight2)+xh*(2.0*parent->getFracShiftFactor());
|
||||
width=width1+width2+xw;
|
||||
strikeoutPos=sp;
|
||||
} else if (mode==MTFMstackrel) {
|
||||
//overallHeight=overallHeight1+overallHeight2+sp*(2.0*parent->getFracShiftFactor());
|
||||
//baselineHeight=overallHeight1+xh*(2.0*parent->getFracShiftFactor());
|
||||
overallHeight=2.0*qMax(overallHeight1, overallHeight2)+sp*(2.0*parent->getFracShiftFactor());
|
||||
baselineHeight=qMax(overallHeight1, overallHeight2)+xh*(2.0*parent->getFracShiftFactor());
|
||||
width=qMax(width1, width2)+ xw;
|
||||
strikeoutPos=sp;
|
||||
const double top_ascent=line_ascent;
|
||||
const double bot_ascent=line_ascent;
|
||||
// here we use maxHeight (as LaTeX does) so braces are centered around the xHieght!!!
|
||||
// if there are no braces, we can use the actual height
|
||||
const double newascent=height1OrMaxHeight+top_ascent;
|
||||
const double newdescent=height2OrMaxHeight-bot_ascent;
|
||||
width=width1+width2+xwidth/4.0;
|
||||
strikeoutPos=line_ascent;
|
||||
|
||||
overallHeight=newascent+newdescent;
|
||||
baselineHeight=newascent;
|
||||
} else if (mode==MTFMunderbrace) {
|
||||
overallHeight=overallHeight1+overallHeight2+Ah/2.0;
|
||||
overallHeight=overallHeight1+overallHeight2+Mheight/2.0;
|
||||
baselineHeight=baselineHeight1;
|
||||
width=qMax(width1, width2)+xw;
|
||||
strikeoutPos=sp;
|
||||
width=qMax(width1, width2)+xwidth;
|
||||
strikeoutPos=line_ascent;
|
||||
} else if (mode==MTFMoverbrace) {
|
||||
overallHeight=overallHeight1+overallHeight2+Ah/2.0;
|
||||
baselineHeight=baselineHeight1+overallHeight2+Ah/2.0;
|
||||
width=qMax(width1, width2)+xw;
|
||||
strikeoutPos=sp;
|
||||
overallHeight=overallHeight1+overallHeight2+Mheight/2.0;
|
||||
baselineHeight=baselineHeight1+overallHeight2+Mheight/2.0;
|
||||
width=qMax(width1, width2)+xwidth;
|
||||
strikeoutPos=line_ascent;
|
||||
} else if (mode==MTFMunderset) {
|
||||
overallHeight=overallHeight1+overallHeight2+xh/6.0;
|
||||
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
||||
baselineHeight=baselineHeight1;
|
||||
width=qMax(width1, width2)+xw;
|
||||
strikeoutPos=sp;
|
||||
width=qMax(width1, width2)+xwidth;
|
||||
strikeoutPos=line_ascent;
|
||||
} else if (mode==MTFMoverset) {
|
||||
overallHeight=overallHeight1+overallHeight2+xh/6.0;
|
||||
baselineHeight=baselineHeight1+overallHeight2+xh/6.0;
|
||||
width=qMax(width1, width2)+xw;
|
||||
strikeoutPos=sp;
|
||||
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
||||
baselineHeight=baselineHeight1+overallHeight2+xheight/6.0;
|
||||
width=qMax(width1, width2)+xwidth;
|
||||
strikeoutPos=line_ascent;
|
||||
}
|
||||
}
|
||||
|
||||
int JKQTMathTextFracNode::getNestingLevel(bool sameType) const
|
||||
{
|
||||
QList<const JKQTMathTextFracNode*> parents=getParents<JKQTMathTextFracNode>();
|
||||
int cnt=0;
|
||||
for (auto& p: parents) {
|
||||
if (p && p->getMode()==getMode()) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
double JKQTMathTextFracNode::getFracScalingFactor() const
|
||||
{
|
||||
if (mode!=MTFMdfrac) {
|
||||
const int level=getNestingLevel(true);
|
||||
if (level>=1) return parentMathText->getFracNestedFactor();
|
||||
}
|
||||
return parentMathText->getFracFactor();
|
||||
}
|
||||
|
||||
bool JKQTMathTextFracNode::isBraceParentNearerThanFrac() const
|
||||
{
|
||||
auto parents=getParents<JKQTMathTextNode>();
|
||||
for (const auto& p: parents) {
|
||||
if (p!=nullptr) {
|
||||
if (dynamic_cast<const JKQTMathTextBraceNode*>(p)!=nullptr) return true;
|
||||
if (dynamic_cast<const JKQTMathTextFracNode*>(p)!=nullptr) return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
doDrawBoxes(painter, x, y, currentEv);
|
||||
QFont f=currentEv.getFont(parent);
|
||||
QFontMetricsF fm(f, painter.device());
|
||||
QFont f=currentEv.getFont(parentMathText);
|
||||
const QFontMetricsF fm(f, painter.device());
|
||||
JKQTMathTextEnvironment ev1=currentEv;
|
||||
JKQTMathTextEnvironment ev2=currentEv;
|
||||
|
||||
@ -148,15 +185,15 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
double bw=Ah/2.0;
|
||||
|
||||
if (mode==MTFMunderbrace || mode==MTFMoverbrace) {
|
||||
ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor();
|
||||
ev2.fontSize=ev2.fontSize*parentMathText->getUnderbraceFactor();
|
||||
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
||||
ev2.fontSize=ev2.fontSize*parent->getUndersetFactor();
|
||||
ev2.fontSize=ev2.fontSize*parentMathText->getUndersetFactor();
|
||||
} else if (mode==MTFMfrac || mode==MTFMsfrac) {
|
||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor();
|
||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor();
|
||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor();
|
||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor();
|
||||
} else if (mode==MTFMtfrac || mode==MTFMstfrac) {
|
||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7;
|
||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7;
|
||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor()*0.7;
|
||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
||||
}
|
||||
|
||||
|
||||
@ -174,59 +211,65 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
|
||||
//double overallHeight=overallHeight1+overallHeight2+xh;
|
||||
//double baselineHeight=3.0*xh/2.0+overallHeight1;
|
||||
double width=qMax(width1, width2);
|
||||
double maxWidth=qMax(width1, width2);
|
||||
double deltaWidth=0;
|
||||
|
||||
QPen p=painter.pen();
|
||||
p.setColor(ev1.color);
|
||||
p.setStyle(Qt::SolidLine);
|
||||
p.setWidthF(qMax(parent->ABS_MIN_LINEWIDTH, lw));
|
||||
p.setWidthF(qMax(parentMathText->ABS_MIN_LINEWIDTH, lw));
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
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->getFracShiftFactor())-descent1, ev1);
|
||||
child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->getFracShiftFactor())+ascent2, ev2);
|
||||
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
||||
child1->draw(painter, x, yline-descent1, ev1);
|
||||
child2->draw(painter, x+width+xw, yline+ascent2, ev2);
|
||||
QLineF l(x+width+1.2*xw, yline-descent1-ascent1, x+width-0.2*xw, yline+ascent1+descent1);
|
||||
deltaWidth=xw/2.0;
|
||||
const QLineF l(x+p.widthF(), yline, x+maxWidth+deltaWidth-p.widthF(), yline);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
child1->draw(painter, x+deltaWidth/2.0+(maxWidth-width1)/2.0, yline-xh*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||
child2->draw(painter, x+deltaWidth/2.0+(maxWidth-width2)/2.0, yline+xh*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||
} else if (mode==MTFMstackrel) {
|
||||
child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->getFracShiftFactor())-descent1, ev1);
|
||||
child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->getFracShiftFactor())+ascent2, ev2);
|
||||
child1->draw(painter, x+(maxWidth-width1)/2.0, yline-xh*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||
child2->draw(painter, x+(maxWidth-width2)/2.0, yline+xh*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
||||
deltaWidth=xw/4.0;
|
||||
child1->draw(painter, x, yline-descent1, ev1);
|
||||
child2->draw(painter, x+width1+deltaWidth, yline+ascent2, ev2);
|
||||
const QLineF l(x+width1+deltaWidth/2.0+0.6*xw, yline-descent1-ascent1, x+width1+deltaWidth/2.0-0.6*xw, yline+ascent1+descent1);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
} 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);
|
||||
child1->draw(painter, x+xw/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||
child2->draw(painter, x+xw/2.0+(maxWidth-width2)/2.0, y+descent1+xh/6.0+ascent2, ev2);
|
||||
deltaWidth=xw;
|
||||
} else if (mode==MTFMunderbrace) {
|
||||
double ybrace=y+descent1+bw/2.0;
|
||||
QPainterPath path=JKQTMathTextMakeHBracePath(x+xw/2.0+(width1)/2.0, ybrace, width, bw);
|
||||
const QPainterPath path=JKQTMathTextMakeHBracePath(x+xw/2.0+(width1)/2.0, ybrace, maxWidth, 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);
|
||||
child1->draw(painter, x+xw/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||
child2->draw(painter, x+xw/2.0+(maxWidth-width2)/2.0, y+descent1+bw+ascent2, ev2);
|
||||
deltaWidth=xw;
|
||||
} 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);
|
||||
child1->draw(painter, x+xw/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||
child2->draw(painter, x+xw/2.0+(maxWidth-width2)/2.0, y-ascent1-xh/6.0-descent2, ev2);
|
||||
deltaWidth=xw;
|
||||
} else if (mode==MTFMoverbrace) {
|
||||
double ybrace=y-ascent1-bw/2.0;
|
||||
const double ybrace=y-ascent1-bw/2.0;
|
||||
|
||||
{
|
||||
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.translate(x+xw/2.0+(width1)/2.0, ybrace);
|
||||
painter.rotate(180);
|
||||
QPainterPath path=JKQTMathTextMakeHBracePath(0,0, width, bw);
|
||||
const QPainterPath path=JKQTMathTextMakeHBracePath(0,0, maxWidth, 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-ascent1-bw-descent2, ev2);
|
||||
child1->draw(painter, x+xw/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||
child2->draw(painter, x+xw/2.0+(maxWidth-width2)/2.0, y-ascent1-bw-descent2, ev2);
|
||||
deltaWidth=xw;
|
||||
}
|
||||
|
||||
|
||||
if (mode==MTFMstackrel) return x+width+ xw;
|
||||
else if (mode==MTFMstfrac || mode==MTFMsfrac) return x+width+width2+xw;
|
||||
else return x+width+xw;
|
||||
if (mode==MTFMstfrac || mode==MTFMsfrac) return x+width1+width2+deltaWidth;
|
||||
else return x+maxWidth+deltaWidth;
|
||||
|
||||
}
|
||||
|
||||
@ -238,22 +281,6 @@ bool JKQTMathTextFracNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*c
|
||||
return ok;
|
||||
}
|
||||
|
||||
void JKQTMathTextFracNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
this->drawBoxes=draw;
|
||||
child1->setDrawBoxes(draw);
|
||||
child2->setDrawBoxes(draw);
|
||||
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextFracNode::getChild1() const {
|
||||
return this->child1;
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextFracNode::getChild2() const {
|
||||
return this->child2;
|
||||
}
|
||||
|
||||
JKQTMathTextFracMode JKQTMathTextFracNode::getMode() const {
|
||||
return this->mode;
|
||||
}
|
||||
|
@ -34,8 +34,14 @@ class JKQTMathText; // forward
|
||||
|
||||
/** \brief subclass representing a \\frac node
|
||||
* \ingroup jkqtmathtext_items
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextNode {
|
||||
*
|
||||
* all fractions re drawn like this:
|
||||
* \image html jkqtmathtext_fracnode_geo.png
|
||||
*
|
||||
* slanted fractions are drawn like this:
|
||||
* \image html jkqtmathtext_sfracnode_geo.png
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChildNode {
|
||||
public:
|
||||
JKQTMathTextFracNode(JKQTMathText* parent, JKQTMathTextNode* child_top, JKQTMathTextNode* child_bottom, JKQTMathTextFracMode mode);
|
||||
virtual ~JKQTMathTextFracNode() override;
|
||||
@ -45,20 +51,19 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextNode {
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
/** \brief returns the 1st child node */
|
||||
JKQTMathTextNode* getChild1() const;
|
||||
/** \brief returns the 2nd child node */
|
||||
JKQTMathTextNode* getChild2() const;
|
||||
/** \copydoc mode */
|
||||
JKQTMathTextFracMode getMode() const;
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
JKQTMathTextNode* child1;
|
||||
JKQTMathTextNode* child2;
|
||||
/** \brief actual display type of fraction object */
|
||||
JKQTMathTextFracMode mode;
|
||||
/** \brief returns the nesting level of the node (of same type of \a sameType \c ==true) */
|
||||
int getNestingLevel(bool sameType=false) const;
|
||||
/** \brief determines the scaling factor of the fraction (takes into account the nesting level) */
|
||||
double getFracScalingFactor() const;
|
||||
/** \brief determines whether in the list of parents a brace-node or another frac-node appears first */
|
||||
bool isBraceParentNearerThanFrac() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -37,20 +37,18 @@
|
||||
|
||||
|
||||
JKQTMathTextInstruction1Node::JKQTMathTextInstruction1Node(JKQTMathText* _parent, const QString& name, JKQTMathTextNode* child, const QStringList& parameters):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextSingleChildNode(child, _parent)
|
||||
{
|
||||
this->name=name;
|
||||
this->child=child;
|
||||
this->parameters=parameters;
|
||||
|
||||
JKQTMathTextEnvironment ev;
|
||||
if (!setupMTenvironment(ev)) {
|
||||
parent->addToErrorList(QObject::tr("unknown instruction '%1' found!").arg(name));
|
||||
parentMathText->addToErrorList(QObject::tr("unknown instruction '%1' found!").arg(name));
|
||||
}
|
||||
}
|
||||
|
||||
JKQTMathTextInstruction1Node::~JKQTMathTextInstruction1Node() {
|
||||
if (child!=nullptr) delete child;
|
||||
}
|
||||
|
||||
QString JKQTMathTextInstruction1Node::getTypeName() const
|
||||
@ -65,7 +63,7 @@ void JKQTMathTextInstruction1Node::getSizeInternal(QPainter& painter, JKQTMathTe
|
||||
|
||||
child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
if (name=="colorbox" || name=="fbox" || name=="boxed") {
|
||||
QFontMetricsF fm(ev.getFont(parent));
|
||||
QFontMetricsF fm(ev.getFont(parentMathText));
|
||||
double xw=fm.boundingRect("x").width();
|
||||
width+=xw;
|
||||
overallHeight+=xw;
|
||||
@ -88,7 +86,7 @@ double JKQTMathTextInstruction1Node::draw(QPainter& painter, double x, double y,
|
||||
double width, baselineHeight, overallHeight, strikeoutPos;
|
||||
child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
QPen p=painter.pen();
|
||||
QFontMetricsF fm(currentEv.getFont(parent));
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText));
|
||||
double xw=fm.boundingRect("x").width();
|
||||
p.setColor(fcol);
|
||||
painter.setPen(p);
|
||||
@ -109,16 +107,6 @@ bool JKQTMathTextInstruction1Node::toHtml(QString &html, JKQTMathTextEnvironment
|
||||
return child->toHtml(html, ev, defaultEv);
|
||||
}
|
||||
|
||||
void JKQTMathTextInstruction1Node::setDrawBoxes(bool draw)
|
||||
{
|
||||
drawBoxes=draw;
|
||||
child->setDrawBoxes(draw);
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextInstruction1Node::getChild() const {
|
||||
return this->child;
|
||||
}
|
||||
|
||||
QString JKQTMathTextInstruction1Node::getName() const {
|
||||
return this->name;
|
||||
}
|
||||
@ -127,7 +115,7 @@ QStringList JKQTMathTextInstruction1Node::getParameters() const {
|
||||
return this->parameters;
|
||||
}
|
||||
|
||||
bool JKQTMathTextInstruction1Node::setupMTenvironment(JKQTMathTextEnvironment &ev)
|
||||
bool JKQTMathTextInstruction1Node::setupMTenvironment(JKQTMathTextEnvironment &ev) const
|
||||
{
|
||||
if (name=="bf" || name=="textbf" || name=="mathbf") ev.bold=true;
|
||||
else if (name=="em") ev.italic=!ev.italic;
|
||||
|
@ -34,7 +34,7 @@ class JKQTMathText; // forward
|
||||
/** \brief subclass representing an instruction node with exactly one argument in the syntax tree
|
||||
* \ingroup jkqtmathtext_items
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextInstruction1Node: public JKQTMathTextNode {
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextInstruction1Node: public JKQTMathTextSingleChildNode {
|
||||
public:
|
||||
explicit JKQTMathTextInstruction1Node(JKQTMathText* parent, const QString& name, JKQTMathTextNode* child, const QStringList& parameters=QStringList());
|
||||
virtual ~JKQTMathTextInstruction1Node() override;
|
||||
@ -45,10 +45,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextInstruction1Node: public JKQTMathTextN
|
||||
/** \brief convert node to HTML and returns \c true on success */
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
/** \brief returns the child node */
|
||||
JKQTMathTextNode* getChild() const;
|
||||
/** \copydoc name */
|
||||
QString getName() const;
|
||||
/** \copydoc parameters */
|
||||
@ -56,10 +52,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextInstruction1Node: public JKQTMathTextN
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
bool setupMTenvironment(JKQTMathTextEnvironment &ev);
|
||||
|
||||
JKQTMathTextNode* child;
|
||||
/** \brief set all properties in \a ev, as appropriate for the represented instruction */
|
||||
bool setupMTenvironment(JKQTMathTextEnvironment &ev) const;
|
||||
/** \brief instruction name */
|
||||
QString name;
|
||||
/** \brief additional string-parameters */
|
||||
QStringList parameters;
|
||||
};
|
||||
|
||||
|
@ -36,18 +36,17 @@
|
||||
#include <QFont>
|
||||
|
||||
|
||||
|
||||
QSet<QString> JKQTMathTextListNode::subsupOperations= (QSet<QString>()<<"sum"<<"prod"<<"coprod"
|
||||
<<"bigcap"<<"bigcup"<<"bigvee"<<"bighat"
|
||||
<<"int"<<"iint"<<"iiint"<<"oint"<<"oiint"<<"oiiint"
|
||||
<<"mod"<<"median"<<"max"<<"min"<<"argmax"<<"argmin"<<"sup"<<"inf"
|
||||
<<"liminf"<<"limsup"<<"lim"<<"max"<<"min");
|
||||
|
||||
JKQTMathTextListNode::JKQTMathTextListNode(JKQTMathText* _parent):
|
||||
JKQTMathTextNode(_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"
|
||||
<<"mod"<<"median"<<"max"<<"min"<<"argmax"<<"argmin"<<"sup"<<"inf"
|
||||
<<"liminf"<<"limsup"<<"lim"<<"max"<<"min";
|
||||
}
|
||||
|
||||
JKQTMathTextListNode::~JKQTMathTextListNode() {
|
||||
@ -67,7 +66,7 @@ void JKQTMathTextListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
||||
overallHeight=0;
|
||||
baselineHeight=0;
|
||||
strikeoutPos=0;
|
||||
QFontMetricsF fm(currentEv.getFont(parent));
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText));
|
||||
//QRectF tbr=parent->getTightBoundingRect(currentEv.getFont(parent), "M", painter.device());
|
||||
|
||||
|
||||
@ -166,7 +165,7 @@ void JKQTMathTextListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
||||
//std::cout<<"symbol ='"<<s.toStdString()<<"' subn="<<subn<<" supn="<<supn<<"\n";
|
||||
if (subn && supn) { // is this subscript and superscript?
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getOperatorsubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||
double w1=0, w2=0, w3=0;
|
||||
double oh1=0, oh2=0, oh3=0;
|
||||
double bh1=0, bh2=0, bh3=0;
|
||||
@ -224,7 +223,7 @@ void JKQTMathTextListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
||||
//qDebug()<<"### subsupop: sub+super";*/
|
||||
} else if (subn) { // is this subscript?
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getOperatorsubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||
double w1=0, w2=0;
|
||||
double oh1=0, oh2=0;
|
||||
double bh1=0, bh2=0;
|
||||
@ -280,7 +279,7 @@ double JKQTMathTextListNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
double ynew=y;
|
||||
double xnew=x;
|
||||
//qDebug()<<"listNode: "<<currentEv.fontSize;
|
||||
QFontMetricsF fm(currentEv.getFont(parent));
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText));
|
||||
bool wasBrace=false;
|
||||
for (int i=0; i<nodes.size(); i++) {
|
||||
bool doDraw=true;
|
||||
@ -340,7 +339,7 @@ double JKQTMathTextListNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
//std::cout<<"symbol ='"<<s.toStdString()<<"' subn="<<subn<<" supn="<<supn<<"\n";
|
||||
if (subn && supn) { // is this subscript and superscript?
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getOperatorsubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||
double w1=0, w2=0, w3=0;
|
||||
double oh1=0, oh2=0, oh3=0;
|
||||
double bh1=0, bh2=0, bh3=0, sp;
|
||||
@ -364,7 +363,7 @@ double JKQTMathTextListNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
xnew=qMax(qMax(xn1, xn2), xn3)+fm.boundingRect(' ').width();
|
||||
} else if (subn) { // is this subscript and not superscript?
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getOperatorsubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||
double w1=0, w2=0;
|
||||
double oh1=0, oh2=0;
|
||||
double bh1=0, bh2=0, sp=0;
|
||||
@ -384,7 +383,7 @@ double JKQTMathTextListNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
xnew=qMax(xn1, xn2);
|
||||
} else if (supn) { // is this subscript and superscript?
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getOperatorsubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getOperatorsubsuperSizeFactor();
|
||||
double w1=0, w3=0;
|
||||
double oh1=0, oh3=0;
|
||||
double bh1=0, bh3=0, sp;
|
||||
@ -415,6 +414,11 @@ double JKQTMathTextListNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
return xnew;
|
||||
}
|
||||
|
||||
void JKQTMathTextListNode::addNode(JKQTMathTextNode *n) {
|
||||
n->setParentNode(this);
|
||||
nodes.append(n);
|
||||
}
|
||||
|
||||
bool JKQTMathTextListNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
||||
bool ok=true;
|
||||
for (int i=0; i<nodes.size(); i++) {
|
||||
|
@ -44,7 +44,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextListNode: public JKQTMathTextNode {
|
||||
/** \copydoc JKQTMathTextNode::draw() */
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \brief add a child node */
|
||||
void addNode(JKQTMathTextNode* n) { nodes.append(n); }
|
||||
void addNode(JKQTMathTextNode* n);
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
@ -55,7 +55,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextListNode: public JKQTMathTextNode {
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
QList<JKQTMathTextNode*> nodes;
|
||||
QSet<QString> subsupOperations;
|
||||
/** \brief the instructions in this can have the sub-script/superscript set below/above, not besides the node */
|
||||
static QSet<QString> subsupOperations;
|
||||
};
|
||||
|
||||
#endif // JKQTMATHTEXTLISTNODE_H
|
||||
|
@ -43,10 +43,15 @@ JKQTMathTextMatrixNode::JKQTMathTextMatrixNode(JKQTMathText* _parent, QVector<QV
|
||||
{
|
||||
this->lines=children.size();
|
||||
this->columns=0;
|
||||
for (int i=0; i<children.size(); i++) {
|
||||
for (int i=0; i<children.size(); i++) {
|
||||
if (children[i].size()>this->columns) this->columns=children[i].size();
|
||||
}
|
||||
this->children=children;
|
||||
for (int i=0; i<children.size(); i++) {
|
||||
for (int j=0; j<children[i].size(); j++) {
|
||||
children[i].operator[](j)->setParentNode(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JKQTMathTextMatrixNode::~JKQTMathTextMatrixNode() {
|
||||
@ -64,7 +69,7 @@ QString JKQTMathTextMatrixNode::getTypeName() const
|
||||
}
|
||||
|
||||
void JKQTMathTextMatrixNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
JKQTMathTextEnvironment ev1=currentEv;
|
||||
|
||||
double xh=fm.strikeOutPos();//fm.xHeight();
|
||||
@ -108,7 +113,7 @@ void JKQTMathTextMatrixNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvi
|
||||
double JKQTMathTextMatrixNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
doDrawBoxes(painter, x, y, currentEv);
|
||||
|
||||
QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
JKQTMathTextEnvironment ev1=currentEv;
|
||||
|
||||
double xh=fm.strikeOutPos();//fm.xHeight();
|
||||
|
@ -41,7 +41,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextMatrixNode: public JKQTMathTextNode {
|
||||
virtual ~JKQTMathTextMatrixNode() override;
|
||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||
virtual QString getTypeName() const override;
|
||||
/** \copydoc JKQTMathTextNode::draw() */
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \brief returns the child nodes */
|
||||
QVector<QVector<JKQTMathTextNode*> > getChildren() const;
|
||||
@ -54,8 +56,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextMatrixNode: public JKQTMathTextNode {
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
/** \brief child nodes making up the matrix, vector of rows */
|
||||
QVector<QVector<JKQTMathTextNode*> > children;
|
||||
/** \brief number of columns in the matrix */
|
||||
int columns;
|
||||
/** \brief number of rows in the matrix */
|
||||
int lines;
|
||||
};
|
||||
|
||||
|
@ -36,9 +36,14 @@
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
// -- implementation of the JKQTMathTextNode's methods
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
JKQTMathTextNode::JKQTMathTextNode(JKQTMathText* parent) {
|
||||
this->parent=parent;
|
||||
drawBoxes=false;
|
||||
|
||||
|
||||
JKQTMathTextNode::JKQTMathTextNode(JKQTMathText *_parent):
|
||||
parentMathText(_parent),
|
||||
parentNode(nullptr),
|
||||
drawBoxes(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTMathTextNode::~JKQTMathTextNode()
|
||||
@ -113,3 +118,90 @@ QString JKQTMathTextNode::getTypeName() const
|
||||
{
|
||||
return "JKQTMathTextNode";
|
||||
}
|
||||
|
||||
void JKQTMathTextNode::setParentNode(JKQTMathTextNode *node)
|
||||
{
|
||||
parentNode=node;
|
||||
if (node) parentMathText=node->parentMathText;
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextNode::getParentNode()
|
||||
{
|
||||
return parentNode;
|
||||
}
|
||||
|
||||
const JKQTMathTextNode *JKQTMathTextNode::getParentNode() const
|
||||
{
|
||||
return parentNode;
|
||||
}
|
||||
|
||||
JKQTMathTextSingleChildNode::JKQTMathTextSingleChildNode(JKQTMathTextNode *_child, JKQTMathText *parentMathText):
|
||||
JKQTMathTextNode(parentMathText),
|
||||
child(_child)
|
||||
{
|
||||
if (child) child->setParentNode(this);
|
||||
}
|
||||
|
||||
JKQTMathTextSingleChildNode::~JKQTMathTextSingleChildNode()
|
||||
{
|
||||
if (child) delete child;
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextSingleChildNode::getChild()
|
||||
{
|
||||
return child;
|
||||
}
|
||||
|
||||
const JKQTMathTextNode *JKQTMathTextSingleChildNode::getChild() const
|
||||
{
|
||||
return child;
|
||||
}
|
||||
|
||||
void JKQTMathTextSingleChildNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
JKQTMathTextNode::setDrawBoxes(draw);
|
||||
if (child) child->setDrawBoxes(draw);
|
||||
}
|
||||
|
||||
|
||||
JKQTMathTextDualChildNode::JKQTMathTextDualChildNode(JKQTMathTextNode *_child1, JKQTMathTextNode *_child2, JKQTMathText *parentMathText):
|
||||
JKQTMathTextNode(parentMathText),
|
||||
child1(_child1),
|
||||
child2(_child2)
|
||||
{
|
||||
if (child1) child1->setParentNode(this);
|
||||
if (child2) child2->setParentNode(this);
|
||||
}
|
||||
|
||||
JKQTMathTextDualChildNode::~JKQTMathTextDualChildNode()
|
||||
{
|
||||
if (child1) delete child1;
|
||||
if (child2) delete child2;
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextDualChildNode::getChild1()
|
||||
{
|
||||
return child1;
|
||||
}
|
||||
|
||||
const JKQTMathTextNode *JKQTMathTextDualChildNode::getChild1() const
|
||||
{
|
||||
return child1;
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextDualChildNode::getChild2()
|
||||
{
|
||||
return child2;
|
||||
}
|
||||
|
||||
const JKQTMathTextNode *JKQTMathTextDualChildNode::getChild2() const
|
||||
{
|
||||
return child2;
|
||||
}
|
||||
|
||||
void JKQTMathTextDualChildNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
JKQTMathTextNode::setDrawBoxes(draw);
|
||||
if (child1) child1->setDrawBoxes(draw);
|
||||
if (child2) child2->setDrawBoxes(draw);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class JKQTMathText; // forward
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
||||
public:
|
||||
explicit JKQTMathTextNode(JKQTMathText* parent);
|
||||
explicit JKQTMathTextNode(JKQTMathText* parentMathText);
|
||||
JKQTMathTextNode(const JKQTMathTextNode&)=delete;
|
||||
JKQTMathTextNode& operator=(const JKQTMathTextNode&)=delete;
|
||||
virtual ~JKQTMathTextNode();
|
||||
@ -78,6 +78,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
||||
virtual void setDrawBoxes(bool draw);
|
||||
/** \brief return the name of this class as a string */
|
||||
virtual QString getTypeName() const;
|
||||
/** \copydoc parentNode */
|
||||
void setParentNode(JKQTMathTextNode* node);
|
||||
/** \copydoc parentNode */
|
||||
JKQTMathTextNode* getParentNode();
|
||||
/** \copydoc parentNode */
|
||||
const JKQTMathTextNode* getParentNode() const;
|
||||
protected:
|
||||
/** \brief determine the size of the node, overwrite this function in derived classes
|
||||
*
|
||||
@ -93,7 +99,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr)=0;
|
||||
|
||||
/** \brief parent JKQTMathText object (required for several drawing operations */
|
||||
JKQTMathText* parent;
|
||||
JKQTMathText* parentMathText;
|
||||
/** \brief parent node of this node (i.e. one level up, ode \c nullptr ) */
|
||||
JKQTMathTextNode* parentNode;
|
||||
/** \brief enables the drawing of colored boxes (for DEBUGGING) around the actual output of the node */
|
||||
bool drawBoxes;
|
||||
/** \brief draws colored boxes (for DEBUGGING) around the actual output of the node
|
||||
@ -104,15 +112,80 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNode {
|
||||
* \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
|
||||
*/
|
||||
void doDrawBoxes(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv);
|
||||
|
||||
|
||||
/** \brief returns the list of parent, parent-of-parent, ... that can be cast to type \a T */
|
||||
template<class T>
|
||||
inline QList<T*> getParents() {
|
||||
QList<T*> lst;
|
||||
JKQTMathTextNode* p=getParentNode();
|
||||
T* pT=dynamic_cast<T*>(p);
|
||||
while (p!=nullptr) {
|
||||
if (pT!=nullptr) lst.append(pT);
|
||||
p=p->getParentNode();
|
||||
pT=dynamic_cast<T*>(p);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
/** \brief returns the list of parent, parent-of-parent, ... that can be cast to type \a T */
|
||||
template<class T>
|
||||
inline QList<const T*> getParents() const {
|
||||
QList<const T*> lst;
|
||||
const JKQTMathTextNode* p=getParentNode();
|
||||
const T* pT=dynamic_cast<const T*>(p);
|
||||
while (p!=nullptr) {
|
||||
if (pT!=nullptr) lst.append(pT);
|
||||
p=p->getParentNode();
|
||||
pT=dynamic_cast<const T*>(p);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** \brief subclass representing a node in the syntax tree, that has one child
|
||||
* \ingroup jkqtmathtext_items
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSingleChildNode: public JKQTMathTextNode {
|
||||
public:
|
||||
explicit JKQTMathTextSingleChildNode(JKQTMathTextNode* _child, JKQTMathText* parentMathText);
|
||||
virtual ~JKQTMathTextSingleChildNode() override;
|
||||
|
||||
/** \copydoc child */
|
||||
JKQTMathTextNode* getChild();
|
||||
/** \copydoc child */
|
||||
const JKQTMathTextNode* getChild() const;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
protected:
|
||||
/** \brief child node of this node */
|
||||
JKQTMathTextNode* child;
|
||||
};
|
||||
|
||||
/** \brief subclass representing a node in the syntax tree, that has two children
|
||||
* \ingroup jkqtmathtext_items
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDualChildNode: public JKQTMathTextNode {
|
||||
public:
|
||||
explicit JKQTMathTextDualChildNode(JKQTMathTextNode* _child1, JKQTMathTextNode* _child2, JKQTMathText* parentMathText);
|
||||
virtual ~JKQTMathTextDualChildNode() override;
|
||||
|
||||
/** \copydoc child1 */
|
||||
JKQTMathTextNode* getChild1();
|
||||
/** \copydoc child1 */
|
||||
const JKQTMathTextNode* getChild1() const;
|
||||
/** \copydoc child2 */
|
||||
JKQTMathTextNode* getChild2();
|
||||
/** \copydoc child2 */
|
||||
const JKQTMathTextNode* getChild2() const;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
protected:
|
||||
/** \brief first child node of this node */
|
||||
JKQTMathTextNode* child1;
|
||||
/** \brief second child node of this node */
|
||||
JKQTMathTextNode* child2;
|
||||
};
|
||||
|
||||
#endif // JKQTMATHTEXTNODE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -36,18 +36,16 @@
|
||||
|
||||
|
||||
JKQTMathTextSqrtNode::JKQTMathTextSqrtNode(JKQTMathText* _parent, JKQTMathTextNode* child, int degree):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextSingleChildNode(child, _parent)
|
||||
{
|
||||
this->child=child;
|
||||
this->degree=degree;
|
||||
}
|
||||
|
||||
JKQTMathTextSqrtNode::~JKQTMathTextSqrtNode() {
|
||||
if (child!=nullptr) delete child;
|
||||
}
|
||||
|
||||
void JKQTMathTextSqrtNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
|
||||
child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
|
||||
@ -60,7 +58,7 @@ double JKQTMathTextSqrtNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
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 f=currentEv.getFont(parentMathText);
|
||||
QFont fsmall=f;
|
||||
QFontMetricsF fm(f, painter.device());
|
||||
double w=fm.boundingRect("A").width();
|
||||
@ -104,22 +102,11 @@ bool JKQTMathTextSqrtNode::toHtml(QString &html, JKQTMathTextEnvironment current
|
||||
return ok;
|
||||
}
|
||||
|
||||
void JKQTMathTextSqrtNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
this->drawBoxes=draw;
|
||||
child->setDrawBoxes(draw);
|
||||
|
||||
}
|
||||
|
||||
QString JKQTMathTextSqrtNode::getTypeName() const
|
||||
{
|
||||
return "MTsqrtNode";
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextSqrtNode::getChild() const {
|
||||
return this->child;
|
||||
}
|
||||
|
||||
int JKQTMathTextSqrtNode::getDegree() const {
|
||||
return this->degree;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class JKQTMathText; // forward
|
||||
/** \brief subclass representing a sqrt node
|
||||
* \ingroup jkqtmathtext_items
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSqrtNode: public JKQTMathTextNode {
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSqrtNode: public JKQTMathTextSingleChildNode {
|
||||
public:
|
||||
JKQTMathTextSqrtNode(JKQTMathText* parent, JKQTMathTextNode* child, int degree=2);
|
||||
virtual ~JKQTMathTextSqrtNode() override;
|
||||
@ -44,18 +44,14 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSqrtNode: public JKQTMathTextNode {
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||
virtual QString getTypeName() const override ;
|
||||
/** \brief returns the child node */
|
||||
JKQTMathTextNode *getChild() const;
|
||||
/** \copydoc degree */
|
||||
/** \copydoc degree */
|
||||
int getDegree() const;
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
JKQTMathTextNode* child;
|
||||
/** \brief degree of the radical (shown of !=2) */
|
||||
int degree;
|
||||
};
|
||||
|
||||
|
@ -38,22 +38,20 @@
|
||||
|
||||
|
||||
JKQTMathTextSuperscriptNode::JKQTMathTextSuperscriptNode(JKQTMathText* _parent, JKQTMathTextNode* child):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextSingleChildNode(child,_parent)
|
||||
{
|
||||
this->child=child;
|
||||
}
|
||||
|
||||
JKQTMathTextSuperscriptNode::~JKQTMathTextSuperscriptNode() {
|
||||
if (child!=nullptr) delete child;
|
||||
}
|
||||
|
||||
void JKQTMathTextSuperscriptNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize) {
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getSubsuperSizeFactor();
|
||||
QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parent), "M", painter.device());
|
||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||
child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
double shift=parent->getSuperShiftFactor()*tbr.height();
|
||||
double shift=parentMathText->getSuperShiftFactor()*tbr.height();
|
||||
|
||||
if (prevNodeSize!=nullptr && prevNodeSize->baselineHeight>tbr.height()) {
|
||||
shift=prevNodeSize->baselineHeight-(overallHeight-baselineHeight)-shift;
|
||||
@ -62,20 +60,20 @@ void JKQTMathTextSuperscriptNode::getSizeInternal(QPainter& painter, JKQTMathTex
|
||||
double yshift=shift+overallHeight-baselineHeight;
|
||||
baselineHeight=overallHeight=overallHeight+shift;
|
||||
strikeoutPos=strikeoutPos-yshift;
|
||||
if (currentEv.italic && prevNodeSize==nullptr) width=width+double(fm.boundingRect(' ').width())*parent->getItalicCorrectionFactor();
|
||||
if (currentEv.italic && prevNodeSize==nullptr) width=width+double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
||||
}
|
||||
|
||||
double JKQTMathTextSuperscriptNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize) {
|
||||
doDrawBoxes(painter, x, y, currentEv);
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getSubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||
|
||||
double cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos;
|
||||
child->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
||||
|
||||
QFontMetricsF fm(currentEv.getFont(parent), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parent), "M", painter.device());
|
||||
double shift=parent->getSuperShiftFactor()*tbr.height();
|
||||
QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||
double shift=parentMathText->getSuperShiftFactor()*tbr.height();
|
||||
|
||||
if (prevNodeSize!=nullptr && prevNodeSize->baselineHeight>tbr.height()) {
|
||||
shift=prevNodeSize->baselineHeight-(cOverallHeight-cBaselineHeight)-shift;
|
||||
@ -83,15 +81,11 @@ double JKQTMathTextSuperscriptNode::draw(QPainter& painter, double x, double y,
|
||||
|
||||
double yshift=shift+cOverallHeight-cBaselineHeight;
|
||||
double xx=x;
|
||||
if (currentEv.italic && prevNodeSize==nullptr) xx=xx+double(fm.boundingRect(' ').width())*parent->getItalicCorrectionFactor();
|
||||
if (currentEv.italic && prevNodeSize==nullptr) xx=xx+double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
||||
|
||||
return child->draw(painter, xx, y-yshift, ev);//+0.5*fm.boundingRect("A").width();
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextSuperscriptNode::getChild() const {
|
||||
return this->child;
|
||||
}
|
||||
|
||||
|
||||
QString JKQTMathTextSuperscriptNode::getTypeName() const
|
||||
{
|
||||
@ -107,13 +101,6 @@ bool JKQTMathTextSuperscriptNode::toHtml(QString &html, JKQTMathTextEnvironment
|
||||
return ok;
|
||||
}
|
||||
|
||||
void JKQTMathTextSuperscriptNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
this->drawBoxes=draw;
|
||||
child->setDrawBoxes(draw);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -121,24 +108,23 @@ void JKQTMathTextSuperscriptNode::setDrawBoxes(bool draw)
|
||||
|
||||
|
||||
JKQTMathTextSubscriptNode::JKQTMathTextSubscriptNode(JKQTMathText* _parent, JKQTMathTextNode* child):
|
||||
JKQTMathTextNode(_parent)
|
||||
JKQTMathTextSingleChildNode(child, _parent)
|
||||
{
|
||||
this->child=child;
|
||||
}
|
||||
|
||||
JKQTMathTextSubscriptNode::~JKQTMathTextSubscriptNode() {
|
||||
if (child!=nullptr) delete child;
|
||||
|
||||
}
|
||||
|
||||
void JKQTMathTextSubscriptNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize) {
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getSubsuperSizeFactor();
|
||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||
|
||||
child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
|
||||
QFontMetricsF fm(ev.getFont(parent), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parent), "M", painter.device());
|
||||
double shift=parent->getSubShiftFactor()*tbr.height();
|
||||
QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||
double shift=parentMathText->getSubShiftFactor()*tbr.height();
|
||||
|
||||
if (prevNodeSize!=nullptr && prevNodeSize->overallHeight-prevNodeSize->baselineHeight>shift) {
|
||||
shift=-1.0*(prevNodeSize->overallHeight-prevNodeSize->baselineHeight-shift);
|
||||
@ -147,19 +133,19 @@ void JKQTMathTextSubscriptNode::getSizeInternal(QPainter& painter, JKQTMathTextE
|
||||
double yshift=baselineHeight-shift;
|
||||
baselineHeight=shift;
|
||||
strikeoutPos=fm.strikeOutPos()+yshift;
|
||||
if (currentEv.italic && prevNodeSize==nullptr) width=width-double(fm.boundingRect(' ').width())*parent->getItalicCorrectionFactor();
|
||||
if (currentEv.italic && prevNodeSize==nullptr) width=width-double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
||||
}
|
||||
|
||||
double JKQTMathTextSubscriptNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize) {
|
||||
doDrawBoxes(painter, x, y, currentEv);
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
ev.fontSize=ev.fontSize*parent->getSubsuperSizeFactor();
|
||||
QFontMetricsF fm(ev.getFont(parent), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parent), "M", painter.device());
|
||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||
QFontMetricsF fm(ev.getFont(parentMathText), painter.device());
|
||||
QRectF tbr=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||
|
||||
double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0;
|
||||
child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
double shift=parent->getSubShiftFactor()*tbr.height();
|
||||
double shift=parentMathText->getSubShiftFactor()*tbr.height();
|
||||
|
||||
if (prevNodeSize!=nullptr && prevNodeSize->overallHeight-prevNodeSize->baselineHeight>shift) {
|
||||
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
||||
@ -171,7 +157,7 @@ double JKQTMathTextSubscriptNode::draw(QPainter& painter, double x, double y, JK
|
||||
//qDebug()<<"baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight<<", strikeoutPos="<<strikeoutPos;
|
||||
//qDebug()<<"shift="<<shift<<", yshift="<<yshift;
|
||||
double xx=x;
|
||||
if (currentEv.italic && prevNodeSize==nullptr) xx=xx-double(fm.boundingRect(' ').width())*parent->getItalicCorrectionFactor();
|
||||
if (currentEv.italic && prevNodeSize==nullptr) xx=xx-double(fm.boundingRect(' ').width())*parentMathText->getItalicCorrectionFactor();
|
||||
return child->draw(painter, xx, y+yshift, ev);//+0.5*fm.boundingRect("A").width();
|
||||
}
|
||||
|
||||
@ -180,24 +166,9 @@ QString JKQTMathTextSubscriptNode::getTypeName() const
|
||||
return "MTsubscriptNode";
|
||||
}
|
||||
|
||||
JKQTMathTextNode *JKQTMathTextSubscriptNode::getChild() const {
|
||||
return this->child;
|
||||
}
|
||||
|
||||
|
||||
bool JKQTMathTextSubscriptNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) {
|
||||
html=html+"<sub>";
|
||||
bool ok=child->toHtml(html, currentEv, defaultEv);
|
||||
html=html+"</sub>";
|
||||
return ok;
|
||||
}
|
||||
|
||||
void JKQTMathTextSubscriptNode::setDrawBoxes(bool draw)
|
||||
{
|
||||
this->drawBoxes=draw;
|
||||
child->setDrawBoxes(draw);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ class JKQTMathText; // forward
|
||||
*
|
||||
* \image html jkqtmathtext_subscriptnode_getSizeInternal.png
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSubscriptNode: public JKQTMathTextNode {
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSubscriptNode: public JKQTMathTextSingleChildNode {
|
||||
public:
|
||||
explicit JKQTMathTextSubscriptNode(JKQTMathText* parent, JKQTMathTextNode* child);
|
||||
virtual ~JKQTMathTextSubscriptNode() override;
|
||||
@ -45,16 +45,11 @@ public:
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||
virtual QString getTypeName() const override; /** \brief returns the child node */
|
||||
/** \brief returns the child node */
|
||||
JKQTMathTextNode *getChild() const;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
JKQTMathTextNode* child;
|
||||
};
|
||||
|
||||
/** \brief subclass representing an superscript node with exactly one argument in the syntax tree
|
||||
@ -64,24 +59,19 @@ protected:
|
||||
*
|
||||
* \note a MTlistNode might modify the positioning slightly for special cases (e.g. \c \\int , \c \\sum ... or after braces)
|
||||
*/
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSuperscriptNode: public JKQTMathTextNode {
|
||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSuperscriptNode: public JKQTMathTextSingleChildNode {
|
||||
public:
|
||||
explicit JKQTMathTextSuperscriptNode(JKQTMathText* parent, JKQTMathTextNode* child);
|
||||
virtual ~JKQTMathTextSuperscriptNode() override;
|
||||
/** \copydoc JKQTMathTextNode::draw() */
|
||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
/** \brief returns the child node */
|
||||
JKQTMathTextNode* getChild() const;
|
||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||
virtual QString getTypeName() const override;
|
||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||
/** \copydoc JKQTMathTextNode::setDrawBoxes() */
|
||||
virtual void setDrawBoxes(bool draw) override;
|
||||
protected:
|
||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||
JKQTMathTextNode* child;
|
||||
};
|
||||
|
||||
#endif // JKQTMATHTEXTSUBSUPERSCRIPTNODE_H
|
||||
|
@ -53,8 +53,8 @@ QString JKQTMathTextSymbolNode::getTypeName() const
|
||||
|
||||
bool JKQTMathTextSymbolNode::getWinSymbolProp(JKQTMathTextSymbolNode::SymbolProps& props, const QString &n, const JKQTMathTextEnvironment& currentEv, double mathFontFactor) const
|
||||
{
|
||||
auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntSym=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Symbols);
|
||||
auto fnt=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntSym=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Symbols);
|
||||
|
||||
//qDebug()<<" +--- getWinSymbolProp("<<n<<"): fnt: "<<fnt.first<<", "<<fnt.second<<" / sym: "<<fntSym.first<<", "<<fntSym.second;
|
||||
|
||||
@ -209,8 +209,8 @@ bool JKQTMathTextSymbolNode::getWinSymbolProp(JKQTMathTextSymbolNode::SymbolProp
|
||||
|
||||
bool JKQTMathTextSymbolNode::getGreekSymbolProp(JKQTMathTextSymbolNode::SymbolProps& props, const QString &n, const JKQTMathTextEnvironment& currentEv, double mathFontFactor) const
|
||||
{
|
||||
auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntGreek=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Greek);
|
||||
auto fnt=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntGreek=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Greek);
|
||||
|
||||
//qDebug()<<" +--- getGreekSymbolProp("<<n<<"): fnt: "<<fnt.first<<", "<<fnt.second<<" / greek: "<<fntGreek.first<<", "<<fntGreek.second;
|
||||
|
||||
@ -638,9 +638,9 @@ bool JKQTMathTextSymbolNode::getUnicodeFullSymbolProp(JKQTMathTextSymbolNode::Sy
|
||||
|
||||
bool JKQTMathTextSymbolNode::getSymbolProp(JKQTMathTextSymbolNode::SymbolProps& props, const QString &n, const JKQTMathTextEnvironment& currentEv, double mathFontFactor) const
|
||||
{
|
||||
auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntGreek=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Greek);
|
||||
auto fntSym=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Symbols);
|
||||
auto fnt=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntGreek=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Greek);
|
||||
auto fntSym=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Symbols);
|
||||
|
||||
//qDebug()<<"--- getSymbolProp("<<n<<"): "<<fnt.first<<", "<<fnt.second;
|
||||
|
||||
@ -729,9 +729,9 @@ bool JKQTMathTextSymbolNode::getSymbolProp(JKQTMathTextSymbolNode::SymbolProps&
|
||||
JKQTMathTextSymbolNode::SymbolProps JKQTMathTextSymbolNode::getSymbolProp(const QString &symName, const JKQTMathTextEnvironment& currentEv) const
|
||||
{
|
||||
|
||||
auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntSym=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Symbols);
|
||||
auto fntGreek=parent->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Greek);
|
||||
auto fnt=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Text);
|
||||
auto fntSym=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Symbols);
|
||||
auto fntGreek=parentMathText->getFontData(currentEv.font, currentEv.insideMath, JKQTMathText::FontSubclass::Greek);
|
||||
|
||||
JKQTMathTextSymbolNode::SymbolProps props;
|
||||
double mathFontFactor=1.8;
|
||||
@ -869,7 +869,7 @@ JKQTMathTextSymbolNode::SymbolProps JKQTMathTextSymbolNode::getSymbolProp(const
|
||||
}
|
||||
|
||||
if (props.symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) {
|
||||
parent->addToErrorList(QObject::tr("unknown symbol '%1' found (%2)!").arg(n).arg(errorExplanation));
|
||||
parentMathText->addToErrorList(QObject::tr("unknown symbol '%1' found (%2)!").arg(n).arg(errorExplanation));
|
||||
}
|
||||
|
||||
//qDebug()<<n<<": '"<<props.symbol<<"' / "<<props.font<<" {{{ def:"+fnt.first+"["+encoding2String(fnt.second)+"] / sym:"+fntSym.first+"["+encoding2String(fntSym.second)+"] / grk:"+fntGreek.first+"["+encoding2String(fntGreek.second)+"] }}}";
|
||||
@ -878,7 +878,7 @@ JKQTMathTextSymbolNode::SymbolProps JKQTMathTextSymbolNode::getSymbolProp(const
|
||||
}
|
||||
|
||||
void JKQTMathTextSymbolNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
QFont f=currentEv.getFont(parent);
|
||||
QFont f=currentEv.getFont(parentMathText);
|
||||
auto props=getSymbolProp(symbolName, currentEv);
|
||||
f.setFamily(props.font);
|
||||
f.setPointSizeF(f.pointSizeF()*props.fontFactor);
|
||||
@ -926,7 +926,7 @@ void JKQTMathTextSymbolNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvi
|
||||
}
|
||||
strikeoutPos=fm.strikeOutPos();
|
||||
|
||||
if (props.extendWidthInMathmode && currentEv.insideMath) width=width*parent->getMathoperatorWidthFactor();
|
||||
if (props.extendWidthInMathmode && currentEv.insideMath) width=width*parentMathText->getMathoperatorWidthFactor();
|
||||
|
||||
}
|
||||
|
||||
@ -938,7 +938,7 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
|
||||
getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
QPen pold=painter.pen();
|
||||
QFont fold=painter.font();
|
||||
QFont f=currentEv.getFont(parent);
|
||||
QFont f=currentEv.getFont(parentMathText);
|
||||
QFont f1=f;
|
||||
auto props=getSymbolProp(symbolName, currentEv);
|
||||
f.setFamily(props.font);
|
||||
@ -953,7 +953,7 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
|
||||
|
||||
double shift=0;
|
||||
if (props.extendWidthInMathmode && currentEv.insideMath) {
|
||||
double origwidth=width/parent->getMathoperatorWidthFactor();
|
||||
double origwidth=width/parentMathText->getMathoperatorWidthFactor();
|
||||
shift=0.5*(width-origwidth);
|
||||
//width=width*parent->getMathoperatorWidthFactor();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ JKQTMathTextTextNode::JKQTMathTextTextNode(JKQTMathText* _parent, const QString&
|
||||
JKQTMathTextTextNode::~JKQTMathTextTextNode() = default;
|
||||
|
||||
void JKQTMathTextTextNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
QFont f=currentEv.getFont(parent);
|
||||
QFont f=currentEv.getFont(parentMathText);
|
||||
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)))) {
|
||||
@ -111,7 +111,7 @@ double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
|
||||
QPen pold=painter.pen();
|
||||
QFont fold=painter.font();
|
||||
QFont f=currentEv.getFont(parent);
|
||||
QFont f=currentEv.getFont(parentMathText);
|
||||
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)))) {
|
||||
@ -138,7 +138,7 @@ double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
}*/
|
||||
|
||||
if (!hasDigits || !f.italic()) {
|
||||
if (currentEv.font==MTEblackboard && parent->isFontBlackboardSimulated()) {
|
||||
if (currentEv.font==MTEblackboard && parentMathText->isFontBlackboardSimulated()) {
|
||||
QPainterPath path;
|
||||
path.addText(QPointF(x+dx, y), f, txt);
|
||||
painter.drawPath(path);
|
||||
@ -153,7 +153,7 @@ double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
ff.setItalic(false);
|
||||
while (i<txt.size()) {
|
||||
if (txt[i].isDigit()) {
|
||||
if (currentEv.font==MTEblackboard && parent->isFontBlackboardSimulated()) {
|
||||
if (currentEv.font==MTEblackboard && parentMathText->isFontBlackboardSimulated()) {
|
||||
QPainterPath path;
|
||||
path.addText(QPointF(xx, y), ff, QString(txt[i]));
|
||||
painter.drawPath(path);
|
||||
@ -163,7 +163,7 @@ double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMat
|
||||
}
|
||||
xx=xx+fmff.boundingRect(txt[i]).width();
|
||||
} else {
|
||||
if (currentEv.font==MTEblackboard && parent->isFontBlackboardSimulated()) {
|
||||
if (currentEv.font==MTEblackboard && parentMathText->isFontBlackboardSimulated()) {
|
||||
QPainterPath path;
|
||||
path.addText(QPointF(xx, y), f, QString(txt[i]));
|
||||
painter.drawPath(path);
|
||||
@ -199,7 +199,7 @@ QString JKQTMathTextTextNode::getTypeName() const
|
||||
QString JKQTMathTextTextNode::textTransform(const QString &text, JKQTMathTextEnvironment currentEv, bool /*forSize*/)
|
||||
{
|
||||
QString txt=text;
|
||||
auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath);
|
||||
auto fnt=parentMathText->getFontData(currentEv.font, currentEv.insideMath);
|
||||
if (fnt.second==MTFEunicode || fnt.second==MTFEunicodeLimited) {
|
||||
if (currentEv.insideMath) {
|
||||
txt="";
|
||||
|
Loading…
Reference in New Issue
Block a user