mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 18:11:38 +08:00
JKQTMathText: moved some node-specific enums into the node classes
This commit is contained in:
parent
b5418d3ad7
commit
c8ef57bb66
@ -331,7 +331,7 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathTextNode *node, QTreeWidgetItem* p
|
|||||||
else ti=new QTreeWidgetItem(ui->tree);
|
else ti=new QTreeWidgetItem(ui->tree);
|
||||||
|
|
||||||
if (decoN) {
|
if (decoN) {
|
||||||
name=QString("MTdecoratedNode: mode='%1'").arg(JKQTMathTextDecorationToString(decoN->getDecoration()));
|
name=QString("MTdecoratedNode: mode='%1'").arg(JKQTMathTextDecoratedNode::DecorationType2String(decoN->getDecoration()));
|
||||||
if (decoN->getChild()) ti->addChild(createTree(decoN->getChild(), ti));
|
if (decoN->getChild()) ti->addChild(createTree(decoN->getChild(), ti));
|
||||||
} else if (matrixN) {
|
} else if (matrixN) {
|
||||||
int l=matrixN->getLines();
|
int l=matrixN->getLines();
|
||||||
@ -348,7 +348,7 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathTextNode *node, QTreeWidgetItem* p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fracN) {
|
} else if (fracN) {
|
||||||
name=QString("MTfracNode: mode='%1'").arg(JKQTMathTextFracModeToString(fracN->getMode()));
|
name=QString("MTfracNode: mode='%1'").arg(JKQTMathTextFracNode::FracType2String(fracN->getMode()));
|
||||||
if (fracN->getChild1()) ti->addChild(createTree(fracN->getChild1(), ti));
|
if (fracN->getChild1()) ti->addChild(createTree(fracN->getChild1(), ti));
|
||||||
if (fracN->getChild2()) ti->addChild(createTree(fracN->getChild2(), ti));
|
if (fracN->getChild2()) ti->addChild(createTree(fracN->getChild2(), ti));
|
||||||
} else if (sqrtN) {
|
} else if (sqrtN) {
|
||||||
|
@ -974,67 +974,67 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, const QString& quitOn
|
|||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMfrac));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMfrac));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="dfrac" || name=="cfrac") {
|
} else if (name=="dfrac" || name=="cfrac") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMdfrac));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMdfrac));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="sfrac" || name=="slantfrac" || name=="xfrac") {
|
} else if (name=="sfrac" || name=="slantfrac" || name=="xfrac") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMsfrac));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMsfrac));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="stfrac" || name=="nicefrac" || name=="slanttextfrac" || name=="xtfrac") {
|
} else if (name=="stfrac" || name=="nicefrac" || name=="slanttextfrac" || name=="xtfrac") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMstfrac));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMstfrac));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="tfrac") {
|
} else if (name=="tfrac") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMtfrac));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMtfrac));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="stackrel") {
|
} else if (name=="stackrel") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMstackrel));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMstackrel));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="binom") {
|
} else if (name=="binom") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextBraceNode(this, "(", ")", new JKQTMathTextFracNode(this, n1, n2, MTFMstackrel)));
|
if (n1 && n2) nl->addNode(new JKQTMathTextBraceNode(this, "(", ")", new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMstackrel)));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="underbrace") {
|
} else if (name=="underbrace") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMunderbrace));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMunderbrace));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="underset") {
|
} else if (name=="underset") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMunderset));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMunderset));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="overbrace") {
|
} else if (name=="overbrace") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMoverbrace));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMoverbrace));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="overset") {
|
} else if (name=="overset") {
|
||||||
JKQTMathTextNode* n1=parseLatexString(true);
|
JKQTMathTextNode* n1=parseLatexString(true);
|
||||||
JKQTMathTextNode* n2=nullptr;
|
JKQTMathTextNode* n2=nullptr;
|
||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, MTFMoverset));
|
if (n1 && n2) nl->addNode(new JKQTMathTextFracNode(this, n1, n2, JKQTMathTextFracNode::MTFMoverset));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="begin") {
|
} else if (name=="begin") {
|
||||||
if (getToken()==MTTtext) {
|
if (getToken()==MTTtext) {
|
||||||
@ -1092,47 +1092,47 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, const QString& quitOn
|
|||||||
getNew=true;
|
getNew=true;
|
||||||
}
|
}
|
||||||
} else if (name=="vec") {
|
} else if (name=="vec") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDvec, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDvec, parseLatexString(true)));
|
||||||
} else if (name=="overline"||name=="oline"||name=="ol") {
|
} else if (name=="overline"||name=="oline"||name=="ol") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDoverline, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDoverline, parseLatexString(true)));
|
||||||
} else if (name=="underline"||name=="uline"||name=="ul") {
|
} else if (name=="underline"||name=="uline"||name=="ul") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDunderline, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDunderline, parseLatexString(true)));
|
||||||
} else if (name=="uuline"||name=="uul") {
|
} else if (name=="uuline"||name=="uul") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDdoubleunderline, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDdoubleunderline, parseLatexString(true)));
|
||||||
} else if (name=="ooline"||name=="ool") {
|
} else if (name=="ooline"||name=="ool") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDdoubleoverline, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDdoubleoverline, parseLatexString(true)));
|
||||||
} else if (name=="arrow"||name=="overrightarrow"||name=="overarrow") {
|
} else if (name=="arrow"||name=="overrightarrow"||name=="overarrow") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDarrow, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDarrow, parseLatexString(true)));
|
||||||
} else if (name=="hat" || name=="^") {
|
} else if (name=="hat" || name=="^") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDhat, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDhat, parseLatexString(true)));
|
||||||
} else if (name=="widehat") {
|
} else if (name=="widehat") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDwidehat, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDwidehat, parseLatexString(true)));
|
||||||
} else if (name=="check" || name=="v") {
|
} else if (name=="check" || name=="v") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDcheck, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDcheck, parseLatexString(true)));
|
||||||
} else if (name=="widecheck") {
|
} else if (name=="widecheck") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDwidecheck, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDwidecheck, parseLatexString(true)));
|
||||||
} else if (name=="bar") {
|
} else if (name=="bar") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDbar, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDbar, parseLatexString(true)));
|
||||||
} else if (name=="dot" || name==".") {
|
} else if (name=="dot" || name==".") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDdot, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDdot, parseLatexString(true)));
|
||||||
} else if (name=="ocirc") {
|
} else if (name=="ocirc") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDocirc, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDocirc, parseLatexString(true)));
|
||||||
} else if (name=="tilde" || name=="~") {
|
} else if (name=="tilde" || name=="~") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDtilde, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDtilde, parseLatexString(true)));
|
||||||
} else if (name=="breve" || name=="u") {
|
} else if (name=="breve" || name=="u") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDbreve, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDbreve, parseLatexString(true)));
|
||||||
} else if (name=="widetilde") {
|
} else if (name=="widetilde") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDwidetilde, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDwidetilde, parseLatexString(true)));
|
||||||
} else if (name=="ddot") {
|
} else if (name=="ddot") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDddot, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDddot, parseLatexString(true)));
|
||||||
} else if (name=="cancel") {
|
} else if (name=="cancel") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDcancel, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDcancel, parseLatexString(true)));
|
||||||
} else if (name=="xcancel") {
|
} else if (name=="xcancel") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDxcancel, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDxcancel, parseLatexString(true)));
|
||||||
} else if (name=="bcancel") {
|
} else if (name=="bcancel") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDbcancel, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDbcancel, parseLatexString(true)));
|
||||||
} else if (name=="strike" || name=="st" || name=="sout") {
|
} else if (name=="strike" || name=="st" || name=="sout") {
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDstrike, parseLatexString(true)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDstrike, parseLatexString(true)));
|
||||||
} else {
|
} else {
|
||||||
if (name=="textcolor" || name=="mathcolor" || name=="color" || name=="colorbox") {
|
if (name=="textcolor" || name=="mathcolor" || name=="color" || name=="colorbox") {
|
||||||
bool foundError=true;
|
bool foundError=true;
|
||||||
@ -1269,7 +1269,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, const QString& quitOn
|
|||||||
if (n0=='v' && n1.isLetter()) {
|
if (n0=='v' && n1.isLetter()) {
|
||||||
done=true;
|
done=true;
|
||||||
//std::cout<<"found \\v... command\n";
|
//std::cout<<"found \\v... command\n";
|
||||||
nl->addNode(new JKQTMathTextDecoratedNode(this, MTDvec, new JKQTMathTextTextNode(this, QString(n1), false, parsingMathEnvironment)));
|
nl->addNode(new JKQTMathTextDecoratedNode(this, JKQTMathTextDecoratedNode::MTDvec, new JKQTMathTextTextNode(this, QString(n1), false, parsingMathEnvironment)));
|
||||||
} else if (n0=='c' && n1.isLetter()) {
|
} else if (n0=='c' && n1.isLetter()) {
|
||||||
done=true;
|
done=true;
|
||||||
//std::cout<<"found \\v... command\n";
|
//std::cout<<"found \\v... command\n";
|
||||||
|
@ -421,82 +421,6 @@ JKQTMathTextFontDefinition::JKQTMathTextFontDefinition():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString JKQTMathTextFracModeToString(JKQTMathTextFracMode mode)
|
|
||||||
{
|
|
||||||
switch(mode) {
|
|
||||||
case MTFMfrac:
|
|
||||||
return "frac";
|
|
||||||
case MTFMdfrac:
|
|
||||||
return "dfrac";
|
|
||||||
case MTFMsfrac:
|
|
||||||
return "sfrac";
|
|
||||||
case MTFMstfrac:
|
|
||||||
return "stfrac";
|
|
||||||
case MTFMtfrac:
|
|
||||||
return "tfrac";
|
|
||||||
case MTFMunderbrace:
|
|
||||||
return "underbrace";
|
|
||||||
case MTFMoverbrace:
|
|
||||||
return "overbrace";
|
|
||||||
case MTFMunderset:
|
|
||||||
return "underset";
|
|
||||||
case MTFMoverset:
|
|
||||||
return "overset";
|
|
||||||
case MTFMstackrel:
|
|
||||||
return "stackrel";
|
|
||||||
}
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString JKQTMathTextDecorationToString(JKQTMathTextDecoration mode)
|
|
||||||
{
|
|
||||||
switch(mode) {
|
|
||||||
case MTDvec:
|
|
||||||
return "vec";
|
|
||||||
case MTDtilde:
|
|
||||||
return "tilde";
|
|
||||||
case MTDbreve:
|
|
||||||
return "breve";
|
|
||||||
case MTDwidetilde:
|
|
||||||
return "widetilde";
|
|
||||||
case MTDhat:
|
|
||||||
return "hat";
|
|
||||||
case MTDwidehat:
|
|
||||||
return "widehat";
|
|
||||||
case MTDcheck:
|
|
||||||
return "check";
|
|
||||||
case MTDwidecheck:
|
|
||||||
return "widecheck";
|
|
||||||
case MTDocirc:
|
|
||||||
return "ocirc";
|
|
||||||
case MTDdot:
|
|
||||||
return "dot";
|
|
||||||
case MTDddot:
|
|
||||||
return "ddot";
|
|
||||||
case MTDbar:
|
|
||||||
return "bar";
|
|
||||||
case MTDarrow:
|
|
||||||
return "arrow";
|
|
||||||
case MTDoverline:
|
|
||||||
return "overline";
|
|
||||||
case MTDdoubleoverline:
|
|
||||||
return "double overline";
|
|
||||||
case MTDunderline:
|
|
||||||
return "underline";
|
|
||||||
case MTDdoubleunderline:
|
|
||||||
return "double underline";
|
|
||||||
case MTDcancel:
|
|
||||||
return "cancel";
|
|
||||||
case MTDbcancel:
|
|
||||||
return "bcancel";
|
|
||||||
case MTDxcancel:
|
|
||||||
return "xcancel";
|
|
||||||
case MTDstrike:
|
|
||||||
return "strike";
|
|
||||||
}
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
QPainterPath JKQTMathTextMakeDArrow(double x, double y, double width, double arrowW, bool left, bool right) {
|
QPainterPath JKQTMathTextMakeDArrow(double x, double y, double width, double arrowW, bool left, bool right) {
|
||||||
double x1=x;
|
double x1=x;
|
||||||
|
@ -232,61 +232,6 @@ struct JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFontDefinition {
|
|||||||
JKQTMathTextFontEncoding symbolfontSymbolEncoding;
|
JKQTMathTextFontEncoding symbolfontSymbolEncoding;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief type of ffractions represented by JKQTMathTextFracNode
|
|
||||||
* \ingroup jkqtmathtext
|
|
||||||
* \see JKQTMathTextFracNode, JKQTMathTextFracModeToString()
|
|
||||||
*/
|
|
||||||
enum JKQTMathTextFracMode {
|
|
||||||
MTFMfrac, /*!< \brief normal fraction \image html jkqtmathtext/MTFMfrac.png */
|
|
||||||
MTFMdfrac, /*!< \brief normal fraction, without scaling of under/over text \image html jkqtmathtext/MTFMdfrac.png */
|
|
||||||
MTFMtfrac, /*!< \brief text fraction (smaller than MTFMfrac) \image html jkqtmathtext/MTFMtfrac.png */
|
|
||||||
MTFMsfrac, /*!< \brief slanted fraction \image html jkqtmathtext/MTFMsfrac.png */
|
|
||||||
MTFMstfrac, /*!< \brief slanted text fraction \image html jkqtmathtext/MTFMstfrac.png */
|
|
||||||
MTFMunderbrace, /*!< \brief curly underbrace \image html jkqtmathtext/MTFMunderbrace.png */
|
|
||||||
MTFMoverbrace, /*!< \brief curly overbrace \image html jkqtmathtext/MTFMoverbrace.png */
|
|
||||||
MTFMstackrel, /*!< \brief binom/fraction without line \image html jkqtmathtext/MTFMstackrel.png */
|
|
||||||
MTFMunderset, /*!< \brief underset text \image html jkqtmathtext/MTFMunderset.png */
|
|
||||||
MTFMoverset /*!< \brief overset text \image html jkqtmathtext/MTFMoverset.png */
|
|
||||||
};
|
|
||||||
|
|
||||||
/** \brief convert a JKQTMathTextFracMode into a QString
|
|
||||||
* \ingroup jkqtmathtext
|
|
||||||
* \see JKQTMathTextFracMode
|
|
||||||
*/
|
|
||||||
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextFracModeToString(JKQTMathTextFracMode mode);
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief types of decoration available in a JKQTMathTextDecoratedNode
|
|
||||||
* \ingroup jkqtmathtext
|
|
||||||
*/
|
|
||||||
enum JKQTMathTextDecoration {
|
|
||||||
MTDvec, /*!< \brief vector arrow over block \image html jkqtmathtext/MTDvec.png */
|
|
||||||
MTDhat, /*!< \brief small hat over block \image html jkqtmathtext/MTDhat.png */
|
|
||||||
MTDwidehat, /*!< \brief full-width hat over block \image html jkqtmathtext/MTDwidehat.png */
|
|
||||||
MTDcheck, /*!< \brief small v over block \image html jkqtmathtext/MTDcheck.png */
|
|
||||||
MTDwidecheck, /*!< \brief full-width v over block \image html jkqtmathtext/MTDwidecheck.png */
|
|
||||||
MTDbreve, /*!< \brief small tilde over block \image html jkqtmathtext/MTDbreve.png */
|
|
||||||
MTDocirc, /*!< \brief single circle over block \image html jkqtmathtext/MTDocirc.png */
|
|
||||||
MTDdot, /*!< \brief single dot over block \image html jkqtmathtext/MTDvec.png */
|
|
||||||
MTDddot, /*!< \brief double dot over block \image html jkqtmathtext/MTDddot.png */
|
|
||||||
MTDbar, /*!< \brief bar over block \image html jkqtmathtext/MTDbar.png */
|
|
||||||
MTDarrow, /*!< \brief arrow over block \image html jkqtmathtext/MTDarrow.png */
|
|
||||||
MTDoverline, /*!< \brief overline over block \image html jkqtmathtext/MTDoverline.png */
|
|
||||||
MTDdoubleoverline, /*!< \brief double overline over block \image html jkqtmathtext/MTDdoubleoverline.png */
|
|
||||||
MTDunderline, /*!< \brief underline under block \image html jkqtmathtext/MTDunderline.png */
|
|
||||||
MTDdoubleunderline, /*!< \brief double underline under block \image html jkqtmathtext/MTDdoubleunderline.png */
|
|
||||||
MTDtilde, /*!< \brief small tilde over block \image html jkqtmathtext/MTDtilde.png */
|
|
||||||
MTDwidetilde, /*!< \brief full width tilde over block \image html jkqtmathtext/MTDwidetilde.png */
|
|
||||||
MTDcancel, /*!< \brief cancel text with sloped line \image html jkqtmathtext/MTDcancel.png */
|
|
||||||
MTDbcancel, /*!< \brief cancel text with backward sloped line \image html jkqtmathtext/MTDbcancel.png */
|
|
||||||
MTDxcancel, /*!< \brief cancel text with X \image html jkqtmathtext/MTDxcancel.png */
|
|
||||||
MTDstrike /*!< \brief strikethrough text \image html jkqtmathtext/MTDstrike.png */
|
|
||||||
};
|
|
||||||
/** \brief convert a JKQTMathTextDecoration into a string
|
|
||||||
* \ingroup jkqtmathtext
|
|
||||||
*/
|
|
||||||
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextDecorationToString(JKQTMathTextDecoration mode);
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief create a QPainterPath for drawing horizontal braces
|
/** \brief create a QPainterPath for drawing horizontal braces
|
||||||
* \ingroup jkqtmathtext
|
* \ingroup jkqtmathtext
|
||||||
|
@ -37,8 +37,58 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString JKQTMathTextDecoratedNode::DecorationType2String(JKQTMathTextDecoratedNode::DecorationType mode)
|
||||||
|
{
|
||||||
|
switch(mode) {
|
||||||
|
case MTDvec:
|
||||||
|
return "vec";
|
||||||
|
case MTDtilde:
|
||||||
|
return "tilde";
|
||||||
|
case MTDbreve:
|
||||||
|
return "breve";
|
||||||
|
case MTDwidetilde:
|
||||||
|
return "widetilde";
|
||||||
|
case MTDhat:
|
||||||
|
return "hat";
|
||||||
|
case MTDwidehat:
|
||||||
|
return "widehat";
|
||||||
|
case MTDcheck:
|
||||||
|
return "check";
|
||||||
|
case MTDwidecheck:
|
||||||
|
return "widecheck";
|
||||||
|
case MTDocirc:
|
||||||
|
return "ocirc";
|
||||||
|
case MTDdot:
|
||||||
|
return "dot";
|
||||||
|
case MTDddot:
|
||||||
|
return "ddot";
|
||||||
|
case MTDbar:
|
||||||
|
return "bar";
|
||||||
|
case MTDarrow:
|
||||||
|
return "arrow";
|
||||||
|
case MTDoverline:
|
||||||
|
return "overline";
|
||||||
|
case MTDdoubleoverline:
|
||||||
|
return "double overline";
|
||||||
|
case MTDunderline:
|
||||||
|
return "underline";
|
||||||
|
case MTDdoubleunderline:
|
||||||
|
return "double underline";
|
||||||
|
case MTDcancel:
|
||||||
|
return "cancel";
|
||||||
|
case MTDbcancel:
|
||||||
|
return "bcancel";
|
||||||
|
case MTDxcancel:
|
||||||
|
return "xcancel";
|
||||||
|
case MTDstrike:
|
||||||
|
return "strike";
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
JKQTMathTextDecoratedNode::JKQTMathTextDecoratedNode(JKQTMathText* _parent, JKQTMathTextDecoration decoration, JKQTMathTextNode* child):
|
|
||||||
|
|
||||||
|
JKQTMathTextDecoratedNode::JKQTMathTextDecoratedNode(JKQTMathText* _parent, DecorationType decoration, JKQTMathTextNode* child):
|
||||||
JKQTMathTextSingleChildNode(child, _parent)
|
JKQTMathTextSingleChildNode(child, _parent)
|
||||||
{
|
{
|
||||||
this->decoration=decoration;
|
this->decoration=decoration;
|
||||||
@ -282,7 +332,7 @@ QString JKQTMathTextDecoratedNode::getTypeName() const
|
|||||||
return "MTdecoratedNode";
|
return "MTdecoratedNode";
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTMathTextDecoration JKQTMathTextDecoratedNode::getDecoration() const {
|
JKQTMathTextDecoratedNode::DecorationType JKQTMathTextDecoratedNode::getDecoration() const {
|
||||||
return this->decoration;
|
return this->decoration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,36 @@ class JKQTMathText; // forward
|
|||||||
*/
|
*/
|
||||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSingleChildNode {
|
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSingleChildNode {
|
||||||
public:
|
public:
|
||||||
JKQTMathTextDecoratedNode(JKQTMathText* parent, JKQTMathTextDecoration decoration, JKQTMathTextNode* child);
|
/** \brief types of decoration available in a JKQTMathTextDecoratedNode
|
||||||
|
*/
|
||||||
|
enum DecorationType {
|
||||||
|
MTDvec, /*!< \brief vector arrow over block \image html jkqtmathtext/MTDvec.png */
|
||||||
|
MTDhat, /*!< \brief small hat over block \image html jkqtmathtext/MTDhat.png */
|
||||||
|
MTDwidehat, /*!< \brief full-width hat over block \image html jkqtmathtext/MTDwidehat.png */
|
||||||
|
MTDcheck, /*!< \brief small v over block \image html jkqtmathtext/MTDcheck.png */
|
||||||
|
MTDwidecheck, /*!< \brief full-width v over block \image html jkqtmathtext/MTDwidecheck.png */
|
||||||
|
MTDbreve, /*!< \brief small tilde over block \image html jkqtmathtext/MTDbreve.png */
|
||||||
|
MTDocirc, /*!< \brief single circle over block \image html jkqtmathtext/MTDocirc.png */
|
||||||
|
MTDdot, /*!< \brief single dot over block \image html jkqtmathtext/MTDvec.png */
|
||||||
|
MTDddot, /*!< \brief double dot over block \image html jkqtmathtext/MTDddot.png */
|
||||||
|
MTDbar, /*!< \brief bar over block \image html jkqtmathtext/MTDbar.png */
|
||||||
|
MTDarrow, /*!< \brief arrow over block \image html jkqtmathtext/MTDarrow.png */
|
||||||
|
MTDoverline, /*!< \brief overline over block \image html jkqtmathtext/MTDoverline.png */
|
||||||
|
MTDdoubleoverline, /*!< \brief double overline over block \image html jkqtmathtext/MTDdoubleoverline.png */
|
||||||
|
MTDunderline, /*!< \brief underline under block \image html jkqtmathtext/MTDunderline.png */
|
||||||
|
MTDdoubleunderline, /*!< \brief double underline under block \image html jkqtmathtext/MTDdoubleunderline.png */
|
||||||
|
MTDtilde, /*!< \brief small tilde over block \image html jkqtmathtext/MTDtilde.png */
|
||||||
|
MTDwidetilde, /*!< \brief full width tilde over block \image html jkqtmathtext/MTDwidetilde.png */
|
||||||
|
MTDcancel, /*!< \brief cancel text with sloped line \image html jkqtmathtext/MTDcancel.png */
|
||||||
|
MTDbcancel, /*!< \brief cancel text with backward sloped line \image html jkqtmathtext/MTDbcancel.png */
|
||||||
|
MTDxcancel, /*!< \brief cancel text with X \image html jkqtmathtext/MTDxcancel.png */
|
||||||
|
MTDstrike /*!< \brief strikethrough text \image html jkqtmathtext/MTDstrike.png */
|
||||||
|
};
|
||||||
|
/** \brief convert a DecorationType into a string
|
||||||
|
*/
|
||||||
|
static QString DecorationType2String(DecorationType mode);
|
||||||
|
|
||||||
|
JKQTMathTextDecoratedNode(JKQTMathText* parent, DecorationType decoration, JKQTMathTextNode* child);
|
||||||
virtual ~JKQTMathTextDecoratedNode() override;
|
virtual ~JKQTMathTextDecoratedNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::draw() */
|
/** \copydoc JKQTMathTextNode::draw() */
|
||||||
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
@ -49,12 +78,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing
|
|||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override ;
|
virtual QString getTypeName() const override ;
|
||||||
/** \copydoc decoration */
|
/** \copydoc decoration */
|
||||||
JKQTMathTextDecoration getDecoration() const;
|
DecorationType getDecoration() const;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
/** \brief type of decoration that is added to the child node */
|
/** \brief type of decoration that is added to the child node */
|
||||||
JKQTMathTextDecoration decoration;
|
DecorationType decoration;
|
||||||
};
|
};
|
||||||
#endif // JKQTMATHTEXTDECORATEDNODE_H
|
#endif // JKQTMATHTEXTDECORATEDNODE_H
|
||||||
|
|
||||||
|
@ -36,10 +36,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString JKQTMathTextFracNode::FracType2String(JKQTMathTextFracNode::FracType mode)
|
||||||
|
{
|
||||||
|
switch(mode) {
|
||||||
|
case JKQTMathTextFracNode::MTFMfrac:
|
||||||
|
return "frac";
|
||||||
|
case JKQTMathTextFracNode::MTFMdfrac:
|
||||||
|
return "dfrac";
|
||||||
|
case JKQTMathTextFracNode::MTFMsfrac:
|
||||||
|
return "sfrac";
|
||||||
|
case JKQTMathTextFracNode::MTFMstfrac:
|
||||||
|
return "stfrac";
|
||||||
|
case JKQTMathTextFracNode::MTFMtfrac:
|
||||||
|
return "tfrac";
|
||||||
|
case JKQTMathTextFracNode::MTFMunderbrace:
|
||||||
|
return "underbrace";
|
||||||
|
case JKQTMathTextFracNode::MTFMoverbrace:
|
||||||
|
return "overbrace";
|
||||||
|
case JKQTMathTextFracNode::MTFMunderset:
|
||||||
|
return "underset";
|
||||||
|
case JKQTMathTextFracNode::MTFMoverset:
|
||||||
|
return "overset";
|
||||||
|
case JKQTMathTextFracNode::MTFMstackrel:
|
||||||
|
return "stackrel";
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JKQTMathTextFracNode::JKQTMathTextFracNode(JKQTMathText* _parent, JKQTMathTextNode* child_top, JKQTMathTextNode* child_bottom, JKQTMathTextFracMode mode):
|
JKQTMathTextFracNode::JKQTMathTextFracNode(JKQTMathText* _parent, JKQTMathTextNode* child_top, JKQTMathTextNode* child_bottom, JKQTMathTextFracNode::FracType mode):
|
||||||
JKQTMathTextDualChildNode(child_top, child_bottom, _parent)
|
JKQTMathTextDualChildNode(child_top, child_bottom, _parent)
|
||||||
{
|
{
|
||||||
this->mode=mode;
|
this->mode=mode;
|
||||||
@ -65,14 +91,14 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
|||||||
const double xwidth=JKQTMathTextGetTightBoundingRect(f, "x", painter.device()).width();
|
const double xwidth=JKQTMathTextGetTightBoundingRect(f, "x", painter.device()).width();
|
||||||
const double qheight=JKQTMathTextGetTightBoundingRect(f, "q", painter.device()).height();//fm.ascent();
|
const double qheight=JKQTMathTextGetTightBoundingRect(f, "q", painter.device()).height();//fm.ascent();
|
||||||
|
|
||||||
if (mode==MTFMunderbrace || mode==MTFMoverbrace) {
|
if (mode==JKQTMathTextFracNode::MTFMunderbrace || mode==JKQTMathTextFracNode::MTFMoverbrace) {
|
||||||
ev2.fontSize=ev2.fontSize*parentMathText->getUnderbraceFactor();
|
ev2.fontSize=ev2.fontSize*parentMathText->getUnderbraceFactor();
|
||||||
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderset || mode==JKQTMathTextFracNode::MTFMoverset) {
|
||||||
ev2.fontSize=ev2.fontSize*parentMathText->getUndersetFactor();
|
ev2.fontSize=ev2.fontSize*parentMathText->getUndersetFactor();
|
||||||
} else if (mode==MTFMfrac || mode==MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor();
|
ev1.fontSize=ev1.fontSize*getFracScalingFactor();
|
||||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor();
|
ev2.fontSize=ev2.fontSize*getFracScalingFactor();
|
||||||
} else if (mode==MTFMtfrac || mode==MTFMstfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMtfrac || mode==JKQTMathTextFracNode::MTFMstfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor()*0.7;
|
ev1.fontSize=ev1.fontSize*getFracScalingFactor()*0.7;
|
||||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
||||||
}
|
}
|
||||||
@ -87,19 +113,19 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
|||||||
overallHeight=0;
|
overallHeight=0;
|
||||||
baselineHeight=0;
|
baselineHeight=0;
|
||||||
width=0;
|
width=0;
|
||||||
if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac || mode==MTFMstackrel) {
|
if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMdfrac || mode==JKQTMathTextFracNode::MTFMtfrac || mode==JKQTMathTextFracNode::MTFMstackrel) {
|
||||||
const double top_ascent=line_ascent+xheight*parentMathText->getFracShiftFactor();
|
const double top_ascent=line_ascent+xheight*parentMathText->getFracShiftFactor();
|
||||||
const double bot_ascent=line_ascent-xheight*parentMathText->getFracShiftFactor();
|
const double bot_ascent=line_ascent-xheight*parentMathText->getFracShiftFactor();
|
||||||
const double newascent=overallHeight1+top_ascent;
|
const double newascent=overallHeight1+top_ascent;
|
||||||
const double newdescent=overallHeight2-bot_ascent;
|
const double newdescent=overallHeight2-bot_ascent;
|
||||||
width=qMax(width1, width2);
|
width=qMax(width1, width2);
|
||||||
if (mode!=MTFMstackrel) width+=xwidth/2.0;
|
if (mode!=JKQTMathTextFracNode::MTFMstackrel) width+=xwidth/2.0;
|
||||||
strikeoutPos=line_ascent;
|
strikeoutPos=line_ascent;
|
||||||
|
|
||||||
overallHeight=newascent+newdescent;
|
overallHeight=newascent+newdescent;
|
||||||
baselineHeight=newascent;
|
baselineHeight=newascent;
|
||||||
|
|
||||||
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
const double top_ascent=line_ascent;
|
const double top_ascent=line_ascent;
|
||||||
const double newascent=overallHeight1+top_ascent;
|
const double newascent=overallHeight1+top_ascent;
|
||||||
const double newdescent=qMax(overallHeight2-baselineHeight2, qheight-xheight);
|
const double newdescent=qMax(overallHeight2-baselineHeight2, qheight-xheight);
|
||||||
@ -108,22 +134,22 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
|||||||
|
|
||||||
overallHeight=newascent+newdescent;
|
overallHeight=newascent+newdescent;
|
||||||
baselineHeight=newascent;
|
baselineHeight=newascent;
|
||||||
} else if (mode==MTFMunderbrace) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderbrace) {
|
||||||
overallHeight=overallHeight1+overallHeight2+Mheight/2.0;
|
overallHeight=overallHeight1+overallHeight2+Mheight/2.0;
|
||||||
baselineHeight=baselineHeight1;
|
baselineHeight=baselineHeight1;
|
||||||
width=qMax(width1, width2)+xwidth;
|
width=qMax(width1, width2)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
strikeoutPos=line_ascent;
|
||||||
} else if (mode==MTFMoverbrace) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverbrace) {
|
||||||
overallHeight=overallHeight1+overallHeight2+Mheight/2.0;
|
overallHeight=overallHeight1+overallHeight2+Mheight/2.0;
|
||||||
baselineHeight=baselineHeight1+overallHeight2+Mheight/2.0;
|
baselineHeight=baselineHeight1+overallHeight2+Mheight/2.0;
|
||||||
width=qMax(width1, width2)+xwidth;
|
width=qMax(width1, width2)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
strikeoutPos=line_ascent;
|
||||||
} else if (mode==MTFMunderset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderset) {
|
||||||
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
||||||
baselineHeight=baselineHeight1;
|
baselineHeight=baselineHeight1;
|
||||||
width=qMax(width1, width2)+xwidth;
|
width=qMax(width1, width2)+xwidth;
|
||||||
strikeoutPos=line_ascent;
|
strikeoutPos=line_ascent;
|
||||||
} else if (mode==MTFMoverset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverset) {
|
||||||
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
overallHeight=overallHeight1+overallHeight2+xheight/6.0;
|
||||||
baselineHeight=baselineHeight1+overallHeight2+xheight/6.0;
|
baselineHeight=baselineHeight1+overallHeight2+xheight/6.0;
|
||||||
width=qMax(width1, width2)+xwidth;
|
width=qMax(width1, width2)+xwidth;
|
||||||
@ -143,7 +169,7 @@ int JKQTMathTextFracNode::getNestingLevel(bool sameType) const
|
|||||||
|
|
||||||
double JKQTMathTextFracNode::getFracScalingFactor() const
|
double JKQTMathTextFracNode::getFracScalingFactor() const
|
||||||
{
|
{
|
||||||
if (mode!=MTFMdfrac) {
|
if (mode!=JKQTMathTextFracNode::MTFMdfrac) {
|
||||||
const int level=getNestingLevel(true);
|
const int level=getNestingLevel(true);
|
||||||
if (level>=1) return parentMathText->getFracNestedFactor();
|
if (level>=1) return parentMathText->getFracNestedFactor();
|
||||||
}
|
}
|
||||||
@ -165,14 +191,14 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
const double qheight=JKQTMathTextGetTightBoundingRect(f, "q", painter.device()).height();//fm.ascent();
|
const double qheight=JKQTMathTextGetTightBoundingRect(f, "q", painter.device()).height();//fm.ascent();
|
||||||
const double bw=Mheight/2.0;
|
const double bw=Mheight/2.0;
|
||||||
|
|
||||||
if (mode==MTFMunderbrace || mode==MTFMoverbrace) {
|
if (mode==JKQTMathTextFracNode::MTFMunderbrace || mode==JKQTMathTextFracNode::MTFMoverbrace) {
|
||||||
ev2.fontSize=ev2.fontSize*parentMathText->getUnderbraceFactor();
|
ev2.fontSize=ev2.fontSize*parentMathText->getUnderbraceFactor();
|
||||||
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderset || mode==JKQTMathTextFracNode::MTFMoverset) {
|
||||||
ev2.fontSize=ev2.fontSize*parentMathText->getUndersetFactor();
|
ev2.fontSize=ev2.fontSize*parentMathText->getUndersetFactor();
|
||||||
} else if (mode==MTFMfrac || mode==MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor();
|
ev1.fontSize=ev1.fontSize*getFracScalingFactor();
|
||||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor();
|
ev2.fontSize=ev2.fontSize*getFracScalingFactor();
|
||||||
} else if (mode==MTFMtfrac || mode==MTFMstfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMtfrac || mode==JKQTMathTextFracNode::MTFMstfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*getFracScalingFactor()*0.7;
|
ev1.fontSize=ev1.fontSize*getFracScalingFactor()*0.7;
|
||||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
||||||
}
|
}
|
||||||
@ -201,26 +227,26 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
p.setWidthF(qMax(parentMathText->ABS_MIN_LINEWIDTH, linewideth));
|
p.setWidthF(qMax(parentMathText->ABS_MIN_LINEWIDTH, linewideth));
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) {
|
if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMdfrac || mode==JKQTMathTextFracNode::MTFMtfrac) {
|
||||||
deltaWidth=xwidth/2.0;
|
deltaWidth=xwidth/2.0;
|
||||||
const QLineF l(x+p.widthF(), yline, x+maxWidth+deltaWidth-p.widthF(), yline);
|
const QLineF l(x+p.widthF(), yline, x+maxWidth+deltaWidth-p.widthF(), yline);
|
||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
child1->draw(painter, x+deltaWidth/2.0+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+deltaWidth/2.0+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+deltaWidth/2.0+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+deltaWidth/2.0+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||||
} else if (mode==MTFMstackrel) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstackrel) {
|
||||||
child1->draw(painter, x+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||||
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
deltaWidth=xwidth/2.0;
|
deltaWidth=xwidth/2.0;
|
||||||
child1->draw(painter, x, yline, ev1);
|
child1->draw(painter, x, yline, ev1);
|
||||||
child2->draw(painter, x+width1+deltaWidth, y, ev2);
|
child2->draw(painter, x+width1+deltaWidth, y, ev2);
|
||||||
const QLineF l(x+width1+deltaWidth, y-Mheight, x+width1, y+(qheight-xheight));
|
const QLineF l(x+width1+deltaWidth, y-Mheight, x+width1, y+(qheight-xheight));
|
||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
} else if (mode==MTFMunderset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderset) {
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y+descent1+xheight/6.0+ascent2, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y+descent1+xheight/6.0+ascent2, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==MTFMunderbrace) {
|
} else if (mode==JKQTMathTextFracNode::MTFMunderbrace) {
|
||||||
double ybrace=y+descent1+bw/2.0;
|
double ybrace=y+descent1+bw/2.0;
|
||||||
const QPainterPath path=JKQTMathTextMakeHBracePath(x+xwidth/2.0+(width1)/2.0, ybrace, maxWidth, bw);
|
const QPainterPath path=JKQTMathTextMakeHBracePath(x+xwidth/2.0+(width1)/2.0, ybrace, maxWidth, bw);
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
@ -228,11 +254,11 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y+descent1+bw+ascent2, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y+descent1+bw+ascent2, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==MTFMoverset) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverset) {
|
||||||
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
child1->draw(painter, x+xwidth/2.0+(maxWidth-width1)/2.0, y, ev1);
|
||||||
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y-ascent1-xheight/6.0-descent2, ev2);
|
child2->draw(painter, x+xwidth/2.0+(maxWidth-width2)/2.0, y-ascent1-xheight/6.0-descent2, ev2);
|
||||||
deltaWidth=xwidth;
|
deltaWidth=xwidth;
|
||||||
} else if (mode==MTFMoverbrace) {
|
} else if (mode==JKQTMathTextFracNode::MTFMoverbrace) {
|
||||||
const double ybrace=y-ascent1-bw/2.0;
|
const double ybrace=y-ascent1-bw/2.0;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -249,7 +275,7 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mode==MTFMstfrac || mode==MTFMsfrac) return x+width1+width2+deltaWidth;
|
if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) return x+width1+width2+deltaWidth;
|
||||||
else return x+maxWidth+deltaWidth;
|
else return x+maxWidth+deltaWidth;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -262,7 +288,7 @@ bool JKQTMathTextFracNode::toHtml(QString &/*html*/, JKQTMathTextEnvironment /*c
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTMathTextFracMode JKQTMathTextFracNode::getMode() const {
|
JKQTMathTextFracNode::FracType JKQTMathTextFracNode::getMode() const {
|
||||||
return this->mode;
|
return this->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,32 @@ class JKQTMathText; // forward
|
|||||||
*/
|
*/
|
||||||
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChildNode {
|
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChildNode {
|
||||||
public:
|
public:
|
||||||
JKQTMathTextFracNode(JKQTMathText* parent, JKQTMathTextNode* child_top, JKQTMathTextNode* child_bottom, JKQTMathTextFracMode mode);
|
|
||||||
|
/** \brief type of ffractions represented by JKQTMathTextFracNode
|
||||||
|
* \ingroup jkqtmathtext
|
||||||
|
* \see JKQTMathTextFracNode, JKQTMathTextFracNode::FracType2String()
|
||||||
|
*/
|
||||||
|
enum FracType {
|
||||||
|
MTFMfrac, /*!< \brief normal fraction \image html jkqtmathtext/MTFMfrac.png */
|
||||||
|
MTFMdfrac, /*!< \brief normal fraction, without scaling of under/over text \image html jkqtmathtext/MTFMdfrac.png */
|
||||||
|
MTFMtfrac, /*!< \brief text fraction (smaller than MTFMfrac) \image html jkqtmathtext/MTFMtfrac.png */
|
||||||
|
MTFMsfrac, /*!< \brief slanted fraction \image html jkqtmathtext/MTFMsfrac.png */
|
||||||
|
MTFMstfrac, /*!< \brief slanted text fraction \image html jkqtmathtext/MTFMstfrac.png */
|
||||||
|
MTFMunderbrace, /*!< \brief curly underbrace \image html jkqtmathtext/MTFMunderbrace.png */
|
||||||
|
MTFMoverbrace, /*!< \brief curly overbrace \image html jkqtmathtext/MTFMoverbrace.png */
|
||||||
|
MTFMstackrel, /*!< \brief binom/fraction without line \image html jkqtmathtext/MTFMstackrel.png */
|
||||||
|
MTFMunderset, /*!< \brief underset text \image html jkqtmathtext/MTFMunderset.png */
|
||||||
|
MTFMoverset /*!< \brief overset text \image html jkqtmathtext/MTFMoverset.png */
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief convert a JKQTMathTextFracNode::FracType into a QString
|
||||||
|
* \ingroup jkqtmathtext
|
||||||
|
* \see JKQTMathTextFracNode::FracType
|
||||||
|
*/
|
||||||
|
static QString FracType2String(FracType mode);
|
||||||
|
|
||||||
|
|
||||||
|
JKQTMathTextFracNode(JKQTMathText* parent, JKQTMathTextNode* child_top, JKQTMathTextNode* child_bottom, JKQTMathTextFracNode::FracType mode);
|
||||||
virtual ~JKQTMathTextFracNode() override;
|
virtual ~JKQTMathTextFracNode() override;
|
||||||
/** \copydoc JKQTMathTextNode::getTypeName() */
|
/** \copydoc JKQTMathTextNode::getTypeName() */
|
||||||
virtual QString getTypeName() const override;
|
virtual QString getTypeName() const override;
|
||||||
@ -52,12 +77,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChild
|
|||||||
/** \copydoc JKQTMathTextNode::toHtml() */
|
/** \copydoc JKQTMathTextNode::toHtml() */
|
||||||
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
|
||||||
/** \copydoc mode */
|
/** \copydoc mode */
|
||||||
JKQTMathTextFracMode getMode() const;
|
JKQTMathTextFracNode::FracType getMode() const;
|
||||||
protected:
|
protected:
|
||||||
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
/** \copydoc JKQTMathTextNode::getSizeInternal() */
|
||||||
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
virtual void getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* prevNodeSize=nullptr) override;
|
||||||
/** \brief actual display type of fraction object */
|
/** \brief actual display type of fraction object */
|
||||||
JKQTMathTextFracMode mode;
|
JKQTMathTextFracNode::FracType mode;
|
||||||
/** \brief returns the nesting level of the node (of same type of \a sameType \c ==true) */
|
/** \brief returns the nesting level of the node (of same type of \a sameType \c ==true) */
|
||||||
int getNestingLevel(bool sameType=false) const;
|
int getNestingLevel(bool sameType=false) const;
|
||||||
/** \brief determines the scaling factor of the fraction (takes into account the nesting level) */
|
/** \brief determines the scaling factor of the fraction (takes into account the nesting level) */
|
||||||
|
Loading…
Reference in New Issue
Block a user