mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-26 10:31:39 +08:00
Add unknown symbols and instructions to error_list
This commit is contained in:
parent
ed8c136185
commit
4578b66de8
@ -445,6 +445,10 @@ JKQTmathText::MTinstruction1Node::MTinstruction1Node(JKQTmathText* parent, QStri
|
|||||||
this->name=name;
|
this->name=name;
|
||||||
this->child=child;
|
this->child=child;
|
||||||
this->parameters=parameters;
|
this->parameters=parameters;
|
||||||
|
|
||||||
|
if (!setupMTenvironment()) {
|
||||||
|
parent->error_list.append(tr("unknown instruction '%1' found!").arg(name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JKQTmathText::MTinstruction1Node::~MTinstruction1Node() {
|
JKQTmathText::MTinstruction1Node::~MTinstruction1Node() {
|
||||||
@ -513,7 +517,7 @@ void JKQTmathText::MTinstruction1Node::set_drawBoxes(bool draw)
|
|||||||
child->set_drawBoxes(draw);
|
child->set_drawBoxes(draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTmathText::MTinstruction1Node::setupMTenvironment(JKQTmathText::MTenvironment &ev)
|
bool JKQTmathText::MTinstruction1Node::setupMTenvironment(JKQTmathText::MTenvironment &ev)
|
||||||
{
|
{
|
||||||
if (name=="bf" || name=="textbf" || name=="mathbf") ev.bold=true;
|
if (name=="bf" || name=="textbf" || name=="mathbf") ev.bold=true;
|
||||||
else if (name=="em") ev.italic=!ev.italic;
|
else if (name=="em") ev.italic=!ev.italic;
|
||||||
@ -535,13 +539,16 @@ void JKQTmathText::MTinstruction1Node::setupMTenvironment(JKQTmathText::MTenviro
|
|||||||
else if (name=="displaystyle") { ev.fontSize=ev.fontSize/0.8; }
|
else if (name=="displaystyle") { ev.fontSize=ev.fontSize/0.8; }
|
||||||
else if (name=="scriptstyle") { ev.fontSize=ev.fontSize*0.8; }
|
else if (name=="scriptstyle") { ev.fontSize=ev.fontSize*0.8; }
|
||||||
else if (name=="scriptscriptstyle") { ev.fontSize=ev.fontSize*0.8*0.8; }
|
else if (name=="scriptscriptstyle") { ev.fontSize=ev.fontSize*0.8*0.8; }
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JKQTmathText::MTsubscriptNode::MTsubscriptNode(JKQTmathText* parent, MTnode* child):
|
JKQTmathText::MTsubscriptNode::MTsubscriptNode(JKQTmathText* parent, MTnode* child):
|
||||||
JKQTmathText::MTnode(parent)
|
JKQTmathText::MTnode(parent)
|
||||||
{
|
{
|
||||||
@ -2683,6 +2690,19 @@ JKQTmathText::MTsymbolNode::MTsymbolNode(JKQTmathText* parent, QString name, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addWhitespace) symbol=symbol+" ";
|
if (addWhitespace) symbol=symbol+" ";
|
||||||
|
|
||||||
|
static QSet<QString> extraSymbolName = {
|
||||||
|
"infty",
|
||||||
|
"|", " ", "quad", ";", ":", ",", "!",
|
||||||
|
"longleftarrow", "longrightarrow",
|
||||||
|
"Longleftarrow", "Longrightarrow",
|
||||||
|
"longleftrightarrow", "Longleftrightarrow"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) {
|
||||||
|
parent->error_list.append(tr("unknown symbol '%1' found!").arg(n));
|
||||||
|
}
|
||||||
|
|
||||||
//std::cout<<"symbol node '"<<symbolName.toStdString()<<"': symbol='"<<symbol.toStdString()<<"'\n";
|
//std::cout<<"symbol node '"<<symbolName.toStdString()<<"': symbol='"<<symbol.toStdString()<<"'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2872,7 +2892,6 @@ double JKQTmathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J
|
|||||||
} else { // draw a box to indicate an unavailable symbol
|
} else { // draw a box to indicate an unavailable symbol
|
||||||
QRectF tbr=parent->getTBR(f, "M", painter.device());
|
QRectF tbr=parent->getTBR(f, "M", painter.device());
|
||||||
painter.drawRect(QRectF(x+shift,y-tbr.height(), xwi, tbr.height()*0.8));
|
painter.drawRect(QRectF(x+shift,y-tbr.height(), xwi, tbr.height()*0.8));
|
||||||
parent->error_list<<"unknown symbol '"<<symbolName<<"' found!";
|
|
||||||
}
|
}
|
||||||
painter.setPen(pold);
|
painter.setPen(pold);
|
||||||
painter.setFont(fold);
|
painter.setFont(fold);
|
||||||
|
@ -388,7 +388,7 @@ class LIB_EXPORT JKQTmathText : public QObject {
|
|||||||
JKQTPGET_MACRO(QString, name)
|
JKQTPGET_MACRO(QString, name)
|
||||||
JKQTPGET_MACRO(QStringList, parameters)
|
JKQTPGET_MACRO(QStringList, parameters)
|
||||||
protected:
|
protected:
|
||||||
void setupMTenvironment(JKQTmathText::MTenvironment &ev);
|
bool setupMTenvironment(JKQTmathText::MTenvironment &ev = JKQTmathText::MTenvironment());
|
||||||
|
|
||||||
MTnode* child;
|
MTnode* child;
|
||||||
QString name;
|
QString name;
|
||||||
|
Loading…
Reference in New Issue
Block a user