mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
NEW: JKQTMathText supports new instructions: \cancel, \xcancel, \bcancel, \sout
This commit is contained in:
parent
00cd589483
commit
0f0c03772e
@ -38,7 +38,7 @@ This page lists several todos and wishes for future version of JKQTPlotter
|
||||
<li></li>
|
||||
</ul></li
|
||||
<li>JKQTMathText:<ul>
|
||||
<li>new instructions: \cancel, \xcancel, ...</li>
|
||||
<li></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
|
@ -26,6 +26,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
||||
<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 supports new instructions: \cancel, \xcancel, \bcancel, \sout</li>
|
||||
</ul>
|
||||
|
||||
\subsection page_whatsnew_TRUNK_DOWNLOAD trunk: Download
|
||||
|
BIN
doc/images/mathparser/MTDbcancel.png
Normal file
BIN
doc/images/mathparser/MTDbcancel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
doc/images/mathparser/MTDcancel.png
Normal file
BIN
doc/images/mathparser/MTDcancel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
doc/images/mathparser/MTDstrike.png
Normal file
BIN
doc/images/mathparser/MTDstrike.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
doc/images/mathparser/MTDxcancel.png
Normal file
BIN
doc/images/mathparser/MTDxcancel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
@ -29,7 +29,8 @@ TestForm::TestForm(QWidget *parent) :
|
||||
ui->cmbTestset->addItem("text 0", "text");
|
||||
ui->cmbTestset->addItem("text 1", "text \\mathbf{bold}");
|
||||
ui->cmbTestset->addItem("text 2", "text \\mathbf{bold}\\textcolor{red}{RED}");
|
||||
ui->cmbTestset->addItem("decoration", "$\\vec{x}\\vec{X}\\vec{\\psi} -- \\dot{x}\\dot{X}\\dot{\\psi} -- \\ddot{x}\\ddot{X}\\ddot{\\psi} -- \\overline{x}\\overline{X}\\overline{\\psi} -- \\underline{x}\\underline{X}\\underline{\\psi} -- \\hat{x}\\hat{X}\\hat{\\psi} -- \\tilde{x}\\tilde{X}\\tilde{\\psi} -- \\uul{x}\\uul{X}\\uul{\\psi} -- \\ool{x}\\ool{X}\\ool{\\psi} -- \\bar{x}\\bar{X}\\bar{\\psi} -- \\arrow{x}\\arrow{X}\\arrow{\\psi}$");
|
||||
ui->cmbTestset->addItem("decoration: math", "$\\vec{x}\\vec{X}\\vec{\\psi} -- \\dot{x}\\dot{X}\\dot{\\psi} -- \\ddot{x}\\ddot{X}\\ddot{\\psi} -- \\overline{x}\\overline{X}\\overline{\\psi} -- \\underline{x}\\underline{X}\\underline{\\psi} -- \\hat{x}\\hat{X}\\hat{\\psi} -- \\tilde{x}\\tilde{X}\\tilde{\\psi} -- \\uul{x}\\uul{X}\\uul{\\psi} -- \\ool{x}\\ool{X}\\ool{\\psi} -- \\bar{x}\\bar{X}\\bar{\\psi} -- \\arrow{x}\\arrow{X}\\arrow{\\psi} -- \\cancel{x}\\cancel{X}\\cancel{\\psi} -- \\bcancel{x}\\bcancel{X}\\bcancel{\\psi} -- \\xcancel{x}\\xcancel{X}\\xcancel{\\psi} -- \\sout{x}\\sout{X}\\sout{\\psi}$");
|
||||
ui->cmbTestset->addItem("decoration: text", "Text \\ul{underlined Text Equator} -- \\ol{overlined Text Equator} -- \\sout{striked out Text Equator} -- \\cancel{canceled out Text Equator} -- \\bcancel{b-canceled out Text Equator} -- \\xcancel{x-canceled out Text Equator}");
|
||||
ui->cmbTestset->addItem("mathtest", "This is normal text: $this is math:\\langle r^2(\\tau)\\rangle=\\left\\langle (\\vec{r}(t)-\\vec{r}(t+\\tau) )^2\\right\\rangle\\ \\ \\ g(\\tau)=\\frac{1}{N}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-1} \\lfloor\\rfloor\\lceil\\rceil\\langle\\rangle\\left\\{\\va\\left|\\|\\va\\|_2\\geq2\\right.\\right\\} \\vr\\vR\\frac{\\sqrt{\\sqrt{\\sqrt{\\sum_{i=0}^\\infty \\hat{i}^2}+y^\\alpha}+1}}{\\dot{v}\\equiv\\ddot{r}}\\argmin_{\\vec{k}}\\sum_{\\sqrt{i}=0}^{N}\\int_{x_0}^{x_1}\\left(\\left(\\left(x\\right)\\right)\\right)\\underbrace{\\left[\\left\\{\\frac{\\partial f}{\\partial x}\\right\\}\\cdot\\frac{1}{2}\\right]}{\\text{underbraced text \\hbar}}\\cdots\\frac{\\sqrt{\\sum_{i=0}^2 \\hat{i}^2}+y^\\alpha}{\\dot{v}\\equiv\\ddot{r}}, \\hat{t}\\hat{T} \\overbrace{\\left|\\sqrt{x\\cdot Y}\\right|}{\\propto\\bbN\\circ\\bbZ} \\left<\\arrow{x(\\tau)}\\cdot\\vec{R}(t+\\bar{\\tau})\\right> \\alpha\\beta\\gamma\\delta\\epsilon\\Gamma\\Delta\\Theta\\Omega \\left\\_\\left~\\cbrt{\\hbar\\omega}\\right~\\right\\_$");
|
||||
ui->cmbTestset->addItem("upper/lower parantheses test:", "$\\text{bblabla} \\frac{1}{2}\\cdot\\left(\\frac{1}{\\mathrm{e}^x+\\mathrm{e}^{-x}}\\right)\\cdot\\left(\\frac{1}{\\frac{1+2}{5+x}}\\right)\\cdot\\left(\\frac{1}{\\exp\\left[-\\frac{y^2}{\\sqrt{x}}\\right]\\cdot\\exp\\left[-\\frac{1}{\\frac{1}{2}}\\right]}\\right) $");
|
||||
ui->cmbTestset->addItem("ACF test", "$g_{rg}^{ab}(\\tau)=\\frac{1}{N}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-1}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-\\frac{1}{2}}$");
|
||||
@ -376,9 +377,9 @@ void TestForm::updateMath()
|
||||
//QString symbolTest="\\lfloor\\rfloor\\lceil\\rceil\\langle\\rangle\\sum\\int \\iint \\oint \\prod \\leftrightarrow \\leftarrow\\Leftarrow\\rightarrow\\Rightarrow\\pm\\mp\\leq\\geq\\ll\\gg\\hbar\\euro\\bbC\\bbH\\bbN\\bbP\\bbQ\\bbZ\\bbR\\Angstrom\\Alef\\Bet\\Gimel\\Dalet\\nexists\\ni\\notni\\circ\\tilde\\oiint\\oiiint\\emptyset\\odot\\ominus\\subsetnot\\DC\\bot\\cdots\\perthousand\\leftharpoonup\\rightharpoonup \\upharpoonleft \\downharpoonleft \\leftrightharpoon \\rightleftharpoon \\coprod \\leftharpoondown \\rightharpoondown \\nwarrow \\nearrow \\mapsto \\cent \\pound \\yen \\div \\multimap \\maporiginal \\mapimage \\bigcap \\bigcup \\benzene \\times \\cdot \\propto \\equiv \\Im \\Re \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ ";
|
||||
//QString mathTest="$\\left\\|\\stackrel{1}{2}\\right\\|\\cdot\\left|\\begin{Bmatrix}1123&2^2&\\frac{3}{4}\\\\4&5_5&6\\\\72_8&8_{\\text{längerer Index}}&9&10&11\\end{Bmatrix}\\right|\\cdots f(x)$";
|
||||
//QString mathTest="0";
|
||||
//QString text="x_0 \\sqrt{a^2+b^2}\\underbrace{underbrace}{x_0} (\\bf{Test})\\_\\it{Text} ... ! Äquator\\alpha\\beta $f(x)=\\sin(x{\\cdot}y)$ \\ul{Text\\ol{\\gamma}} \\script{Script}, \\tt{Typewriter}, \\sf{sans serif}";
|
||||
//QString text="$\\sum_{i=0_{j=-1_{k=-45}}}^{n^{m^{123456789}}}\\left(\\left(\\left(\\int_0^\\inf\\left[r+i^{\\left\\{2^2\\right\\}}\\right]{\\dd}r\\right)\\right)\\right)$ \\bf{Test}\\_\\it{Text} ... ! \\sc{&Äquator \\&}\\alpha\\beta $f(x)=\\sin(x\\cdot\\cos(a+{\\ii}b))$ \\ul{Text\\gamma} \\script{Script-Text}\\tt{ and Typewriter} \\sf{also sans serif}";
|
||||
//QString text="$\\sum_{i=0_{j=-1_{k=-45}}}^2\\left(\\left(\\left(\\int_0^\\inf\\left[r+i^{\\left\\{2^2\\right\\}}\\right]{\\dd}r\\right)\\right)\\right)$ \\bf{Test}\\_\\it{Text} ... ! \\sc{&Äquator \\&}\\alpha\\beta $f(x)=\\sin(x\\cdot\\cos(a+{\\ii}b))$ \\ul{Text\\gamma} \\script{Script-Text}\\tt{ and Typewriter} \\sf{also sans serif}";
|
||||
//QString text="x_0 \\sqrt{a^2+b^2}\\underbrace{underbrace}{x_0} (\\bf{Test})\\_\\it{Text} ... ! Equator\\alpha\\beta $f(x)=\\sin(x{\\cdot}y)$ \\ul{Text\\ol{\\gamma}} \\script{Script}, \\tt{Typewriter}, \\sf{sans serif}";
|
||||
//QString text="$\\sum_{i=0_{j=-1_{k=-45}}}^{n^{m^{123456789}}}\\left(\\left(\\left(\\int_0^\\inf\\left[r+i^{\\left\\{2^2\\right\\}}\\right]{\\dd}r\\right)\\right)\\right)$ \\bf{Test}\\_\\it{Text} ... ! \\sc{&Equator \\&}\\alpha\\beta $f(x)=\\sin(x\\cdot\\cos(a+{\\ii}b))$ \\ul{Text\\gamma} \\script{Script-Text}\\tt{ and Typewriter} \\sf{also sans serif}";
|
||||
//QString text="$\\sum_{i=0_{j=-1_{k=-45}}}^2\\left(\\left(\\left(\\int_0^\\inf\\left[r+i^{\\left\\{2^2\\right\\}}\\right]{\\dd}r\\right)\\right)\\right)$ \\bf{Test}\\_\\it{Text} ... ! \\sc{&Equator \\&}\\alpha\\beta $f(x)=\\sin(x\\cdot\\cos(a+{\\ii}b))$ \\ul{Text\\gamma} \\script{Script-Text}\\tt{ and Typewriter} \\sf{also sans serif}";
|
||||
|
||||
//QString text="x_0My Text$\\sqrt{a^2+b^2 } \\underbrace{underbrace}{x_0}$";
|
||||
|
||||
|
@ -1171,6 +1171,7 @@ double JKQTMathText::MTdecoratedNode::draw(QPainter& painter, double x, double y
|
||||
//double d=overallHeight-baselineHeight;
|
||||
double dheightfactor=parent->getDecorationHeightFactor();
|
||||
double dpos=y-a*(1.0+dheightfactor);
|
||||
double spos=y-a/2.0;
|
||||
double dposb=y+qMax((overallHeight-baselineHeight)*(1.0+dheightfactor), fm.xHeight()*dheightfactor);
|
||||
double deltax=0;//(wc-ll)/2.0;
|
||||
double dheight=dheightfactor*a;
|
||||
@ -1266,7 +1267,30 @@ double JKQTMathText::MTdecoratedNode::draw(QPainter& painter, double x, double y
|
||||
painter.setBrush(bold);
|
||||
painter.setPen(pold);
|
||||
painter.setBrush(bold);
|
||||
} else if (decoration==MTDstrike) {
|
||||
painter.setPen(p);
|
||||
QLineF l(x+deltax, spos, xnew+deltax-0.2*wc, spos);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDcancel) {
|
||||
painter.setPen(p);
|
||||
QLineF l(x+deltax, dposb, xnew+deltax-0.2*wc, dpos);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDbcancel) {
|
||||
painter.setPen(p);
|
||||
QLineF l(x+deltax, dpos, xnew+deltax-0.2*wc, dposb);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDxcancel) {
|
||||
painter.setPen(p);
|
||||
QLineF l(x+deltax, dpos, xnew+deltax-0.2*wc, dposb);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
QLineF l1(x+deltax, dposb, xnew+deltax-0.2*wc, dpos);
|
||||
if (l1.length()>0) painter.drawLine(l1);
|
||||
painter.setPen(pold);
|
||||
}
|
||||
//
|
||||
return xnew+0.3*wc;
|
||||
}
|
||||
|
||||
@ -4343,6 +4367,14 @@ JKQTMathText::MTnode* JKQTMathText::parseLatexString(bool get, const QString& qu
|
||||
nl->addNode(new MTdecoratedNode(this, MTDtilde, parseLatexString(true)));
|
||||
} else if (name=="ddot") {
|
||||
nl->addNode(new MTdecoratedNode(this, MTDddot, parseLatexString(true)));
|
||||
} else if (name=="cancel") {
|
||||
nl->addNode(new MTdecoratedNode(this, MTDcancel, parseLatexString(true)));
|
||||
} else if (name=="xcancel") {
|
||||
nl->addNode(new MTdecoratedNode(this, MTDxcancel, parseLatexString(true)));
|
||||
} else if (name=="bcancel") {
|
||||
nl->addNode(new MTdecoratedNode(this, MTDbcancel, parseLatexString(true)));
|
||||
} else if (name=="strike" || name=="st" || name=="sout") {
|
||||
nl->addNode(new MTdecoratedNode(this, MTDstrike, parseLatexString(true)));
|
||||
} else {
|
||||
if (name=="textcolor" || name=="mathcolor" || name=="color" || name=="colorbox") {
|
||||
bool foundError=true;
|
||||
@ -4803,6 +4835,14 @@ QString JKQTMathText::decorationToString(JKQTMathText::MTdecoration mode)
|
||||
return "underline";
|
||||
case MTDdoubleunderline:
|
||||
return "double underline";
|
||||
case MTDcancel:
|
||||
return "cancel";
|
||||
case MTDbcancel:
|
||||
return "bcancel";
|
||||
case MTDxcancel:
|
||||
return "xcancel";
|
||||
case MTDstrike:
|
||||
return "strike";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
@ -193,6 +193,10 @@ private:
|
||||
- \c \\script{...} \c \\textscript{...} \c \\mathscript{...} : draw the contained text in a script font face \image html jkqtmathtext_fonts.png
|
||||
- \c \\sc{...} : draw the text in small caps \image html jkqtmathtext_sc.png
|
||||
- \c \\ul{...} \c \\underline{...} \c \\underlined{...} : draw the text with underlining \image html jkqtmathtext_ul.png
|
||||
- \c \\sout{...} : strike out the text \image html mathparser/MTDstrike.png
|
||||
- \c \\cancel{...} : slanted strike out the text \image html mathparser/MTDcancel.png
|
||||
- \c \\bcancel{...} : back-strike out the text \image html mathparser/MTDbcancel.png
|
||||
- \c \\xcancel{...} : x-strike out the text \image html mathparser/MTDxcancel.png
|
||||
- \c \\ol{...} \c \\overline{...} \c \\overlined{...} : draw the text with overlining \image html jkqtmathtext_ol.png
|
||||
- \c \\tt{...} \c \\texttt{...} \c \\mathtt{...} : draw text in typewriter font \image html jkqtmathtext_fonts.png
|
||||
- \c \\textcolor{color}{...} \c \\color{color} \c \\mathcolor{color}{...} : draw colored text \image html jkqtmathtext_colored.png
|
||||
@ -1092,8 +1096,13 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
||||
MTDdoubleoverline, /*!< \brief double overline over block \image html mathparser/MTDdoubleoverline.png */
|
||||
MTDunderline, /*!< \brief underline under block \image html mathparser/MTDunderline.png */
|
||||
MTDdoubleunderline, /*!< \brief double underline under block \image html mathparser/MTDdoubleunderline.png */
|
||||
MTDtilde /*!< \brief tilde over block \image html mathparser/MTDtilde.png */
|
||||
MTDtilde, /*!< \brief tilde over block \image html mathparser/MTDtilde.png */
|
||||
MTDcancel, /*!< \brief cancel text with sloped line \image html mathparser/MTDcancel.png */
|
||||
MTDbcancel, /*!< \brief cancel text with backward sloped line \image html mathparser/MTDbcancel.png */
|
||||
MTDxcancel, /*!< \brief cancel text with X \image html mathparser/MTDxcancel.png */
|
||||
MTDstrike /*!< \brief strikethrough text \image html mathparser/MTDstrike.png */
|
||||
};
|
||||
/** \brief convert a MTdecoration into a string */
|
||||
static QString decorationToString(MTdecoration mode);
|
||||
|
||||
/** \brief subclass representing a decorated text m (e.g. \c \\vec \c \\hat ...) node
|
||||
|
Loading…
Reference in New Issue
Block a user