diff --git a/test/jkqtmathtext_test/testform.cpp b/test/jkqtmathtext_test/testform.cpp index 5a5badc824..ff530cabbc 100644 --- a/test/jkqtmathtext_test/testform.cpp +++ b/test/jkqtmathtext_test/testform.cpp @@ -110,6 +110,7 @@ TestForm::TestForm(QWidget *parent) : ui->cmbTestset->addItem(QLatin1String("Schrödinger's equation"), "$\\left[-\\frac{\\hbar^2}{2m}\\frac{\\partial^2}{\\partial x^2}+V\\right]\\Psi(x)=\\mathrm{i}\\hbar\\frac{\\partial}{\\partial t}\\Psi(x)$"); ui->cmbTestset->addItem("Cauchy-Schwarz inequality", "$\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)$"); ui->cmbTestset->addItem("Maxwell's equations", "$\\begin{aligned}\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac{1}{c}\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac{1}{c}\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \\end{aligned}$"); + ui->cmbTestset->addItem("User-Editable Text"); //ui->cmbTestset->addItem("", "$$"); //ui->cmbTestset->addItem("", "$$"); //ui->cmbTestset->addItem("", "$$"); @@ -132,7 +133,7 @@ TestForm::~TestForm() -double TestForm::draw(QPainter& painter, double X, double YY, JKQTmathText& mt, QString name) { +double TestForm::draw(QPainter& painter, double X, double YY, JKQTmathText& mt, QString name, double& durationSizingMS, double&durationTimingMS) { double Y=YY; @@ -140,7 +141,8 @@ double TestForm::draw(QPainter& painter, double X, double YY, JKQTmathText& mt, ht.start(); QSizeF s=mt.getSize(painter); Y=Y+mt.getAscent(painter); - qDebug()<<" sizing in "<chkBoxes->isChecked()); - qDebug()<<" drawing in "<(node); JKQTmathText::MTdecoratedNode* decoN=dynamic_cast(node); - QTreeWidgetItem* ti=NULL; + QTreeWidgetItem* ti=nullptr; if (parent) ti=new QTreeWidgetItem(parent); else ti=new QTreeWidgetItem(ui->tree); @@ -202,7 +205,7 @@ QTreeWidgetItem *TestForm::createTree(JKQTmathText::MTnode *node, QTreeWidgetIte QVector > children=matrixN->get_children(); for (int y=0; ysetText(0, QString("(%1,%2):").arg(y).arg(x)+it->text(0)); ti->addChild(it); @@ -274,9 +277,16 @@ void TestForm::updateMath() //QString text="x_0My Text$\\sqrt{a^2+b^2 } \\underbrace{underbrace}{x_0}$"; - mathTest=ui->cmbTestset->itemData(ui->cmbTestset->currentIndex()).toString(); - - ui->textBrowserSource->setPlainText(mathTest); + if (ui->cmbTestset->currentIndex()==ui->cmbTestset->count()-1) { + mathTest=ui->textBrowserSource->toPlainText(); + ui->textBrowserSource->setReadOnly(false); + ui->btnRender->setEnabled(true); + } else { + mathTest=ui->cmbTestset->itemData(ui->cmbTestset->currentIndex()).toString(); + ui->textBrowserSource->setPlainText(mathTest); + ui->textBrowserSource->setReadOnly(true); + ui->btnRender->setEnabled(false); + } ui->scrollArea->setBackgroundRole(QPalette::Dark); @@ -313,24 +323,32 @@ void TestForm::updateMath() } ui->tree->clear(); + ht.start(); + double durationParse=0; if (mt.parse(mathTest)) { + durationParse=ht.get_time()/1000.0; ui->tree->addTopLevelItem(createTree(mt.get_parsedNode())); + } else { + durationParse=ht.get_time()/1000.0; } + ui->labParsingTimes->setText(QString(" %1ms").arg(durationParse, 0, 'f', 3)); ui->tree->expandAll(); bool okh=true; ui->textBrowser->clear(); qDebug()<<"parse mathTest in "<edtSizes->text().split(","); + ui->labRenderTimes->setText(""); for (int i=0; icmbTestset->currentText()).arg(ui->cmbFont->currentText()).arg(size)); - + double durationSizingMS=0, durationTimingMS=0; + Y+=draw(painter, X1, Y, mt, QString("%1, %2, %3pt").arg(ui->cmbTestset->currentText()).arg(ui->cmbFont->currentText()).arg(size), durationSizingMS, durationTimingMS); + ui->labRenderTimes->setText(ui->labRenderTimes->text()+QString(" %1pt: %2ms/%3ms").arg(size).arg(durationSizingMS, 0, 'F', 1).arg(durationTimingMS, 0, 'F', 1)); ui->textBrowser->textCursor().insertHtml("
"+mt.toHtml(&okh)+"


"); qDebug()<<"HTML: ---------------------------------------------\n"< - + true @@ -25,7 +25,7 @@ 0 0 605 - 628 + 616 @@ -43,10 +43,16 @@ - - - - Qt::ScrollBarAlwaysOff + + + + + 75 + true + + + + render times (getSize()+getAscent()/draw()): @@ -186,6 +192,86 @@ + + + + left(left[sqrt{2picdotint_{-infty}^infty f(x);mathrm{d}x}right]right) + + + + + + + + + + 75 + true + + + + LaTeX source: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + &Render + + + + + + + + + true + + + + + + + + 75 + true + + + + rendered result: + + + + + + + + 75 + true + + + + HTML output: + + + @@ -266,7 +352,17 @@ + + + + + + + + + + true @@ -278,41 +374,36 @@ - - - - - - - HTML output: - - - - + + + + 75 + true + + node tree: - - + + + + + 75 + true + + - LaTeX source: + parsing times: - - + + - rendered result: - - - - - - - left(left[sqrt{2picdotint_{-infty}^infty f(x);mathrm{d}x}right]right) + @@ -366,7 +457,7 @@ updateMath() - 591 + 790 27 @@ -382,7 +473,7 @@ updateMath() - 669 + 868 27 @@ -398,7 +489,7 @@ updateMath() - 765 + 964 27 @@ -414,7 +505,7 @@ updateMath() - 867 + 1067 27 @@ -430,7 +521,7 @@ updateMath() - 520 + 679 29 @@ -510,8 +601,8 @@ updateMath() - 697 - 45 + 949 + 57 518 @@ -526,8 +617,8 @@ updateMath() - 941 - 54 + 1221 + 57 520 @@ -542,8 +633,8 @@ updateMath() - 905 - 22 + 1181 + 27 519 @@ -551,6 +642,22 @@ + + btnRender + clicked() + TestForm + updateMath() + + + 1187 + 83 + + + 617 + 380 + + + updateMath()