Clean up some rendering.
This commit is contained in:
parent
5ddd54dd6d
commit
77ce58c612
6 changed files with 55 additions and 19 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "LatexMathExpression.h"
|
||||
#include "TextNode.h"
|
||||
#include "LineNode.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
|
||||
|
@ -31,31 +32,37 @@ void EquationNode::update(SceneInfo* sceneInfo)
|
|||
}
|
||||
}
|
||||
|
||||
void EquationNode::addExpression(const LatexMathExpression* expression)
|
||||
void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression* expression)
|
||||
{
|
||||
if (expression->getType() == LatexMathExpression::Type::LINEAR)
|
||||
{
|
||||
MLOG_INFO("Processing linear expr with : " << expression->getExpressions().size() << " children");
|
||||
for (const auto& expression : expression->getExpressions())
|
||||
for (const auto& child : expression->getExpressions())
|
||||
{
|
||||
addExpression(expression.get());
|
||||
addExpression(sceneInfo, child.get());
|
||||
}
|
||||
}
|
||||
else if(expression->getType() == LatexMathExpression::Type::LEAF)
|
||||
{
|
||||
std::string content = "_";
|
||||
std::string content;
|
||||
for (const auto& symbol : expression->getSymbols())
|
||||
{
|
||||
content += symbol.mUnicode;
|
||||
}
|
||||
MLOG_INFO("Processing leaf expr with content: " << content);
|
||||
|
||||
if (content.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MLOG_INFO("Processing leaf expr with content: " << content << " and size " << content.size());
|
||||
auto node = std::make_unique<TextNode>(content, Transform(mTextCursor));
|
||||
node->setWidth(100);
|
||||
node->setFont(mDefaultFont);
|
||||
addChild(node.get());
|
||||
mText.push_back(std::move(node));
|
||||
|
||||
mTextCursor.move(20.0, 0.0);
|
||||
mTextCursor.move(node->getContentWidth(sceneInfo), 0.0);
|
||||
|
||||
mText.push_back(std::move(node));
|
||||
}
|
||||
else if (expression->getType() == LatexMathExpression::Type::FRACTION)
|
||||
{
|
||||
|
@ -63,13 +70,19 @@ void EquationNode::addExpression(const LatexMathExpression* expression)
|
|||
if (expression->getExpressions().size() == 2)
|
||||
{
|
||||
auto x_cache = mTextCursor.getX();
|
||||
mTextCursor.move(0.0, -10.0);
|
||||
addExpression(expression->getExpressions()[0].get());
|
||||
mTextCursor.move(0.0, -9.0);
|
||||
addExpression(sceneInfo, expression->getExpressions()[0].get());
|
||||
|
||||
mTextCursor.move(mTextCursor.getX() - x_cache, 20.0);
|
||||
addExpression(expression->getExpressions()[1].get());
|
||||
mTextCursor.move(x_cache - mTextCursor.getX(), 16.0);
|
||||
std::vector<Point> end_loc{ { 25.0, 0.0 } };
|
||||
auto dividing_line = std::make_unique<LineNode>(Transform(mTextCursor), end_loc);
|
||||
addChild(dividing_line.get());
|
||||
mLines.push_back(std::move(dividing_line));
|
||||
|
||||
mTextCursor.move(0.0, -10.0);
|
||||
mTextCursor.move(0.0, 2.0);
|
||||
addExpression(sceneInfo, expression->getExpressions()[1].get());
|
||||
|
||||
mTextCursor.move(0.0, -9.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,5 +92,5 @@ void EquationNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
|||
mChildren.clear();
|
||||
mText.clear();
|
||||
|
||||
addExpression(mContent);
|
||||
addExpression(sceneInfo, mContent);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue