Improve circuit plotting.

This commit is contained in:
jmsgrogan 2023-01-24 12:59:00 +00:00
parent 6274c41a80
commit df450a7be0
17 changed files with 321 additions and 13 deletions

View file

@ -0,0 +1,69 @@
#include "WireNode.h"
#include "LineNode.h"
WireNode::WireNode(const Transform& transform)
: AbstractVisualNode(transform)
{
}
void WireNode::setContent(Wire* wire)
{
mContent = wire;
mContentDirty = true;
}
void WireNode::setInputLocation(const Point& point)
{
if (mInputLocation != point)
{
mContentDirty = true;
mInputLocation = point;
}
}
void WireNode::setOutputLocation(const Point& point)
{
if (mOutputLocation != point)
{
mContentDirty = true;
mOutputLocation = point;
}
}
void WireNode::update(SceneInfo* sceneInfo)
{
if (mContentDirty)
{
createOrUpdateGeometry(sceneInfo);
mContentDirty = false;
}
}
void WireNode::createOrUpdateGeometry(SceneInfo*)
{
if (!mLine)
{
auto loc = mOutputLocation;
loc.move(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ());
std::vector<Point> points;
if (loc.getY() == 0.0)
{
points = { loc };
}
else
{
auto join0 = Point(loc.getX() * 3.0 / 4.0, 0.0);
auto join1 = Point(loc.getX() * 3.0 / 4.0, loc.getY());
points = { join0, join1 , loc};
}
mLine = std::make_unique<LineNode>(Transform(mInputLocation), points);
addChild(mLine.get());
}
}