#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 Point2& point) { if (mInputLocation != point) { mContentDirty = true; mInputLocation = point; } } void WireNode::setOutputLocation(const Point2& 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.moveBy(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ()); std::vector points; if (loc.getY() == 0.0) { points = { loc }; } else { auto join0 = Point2(loc.getX() * 3.0 / 4.0, 0.0); auto join1 = Point2(loc.getX() * 3.0 / 4.0, loc.getY()); points = { join0, join1 , loc}; } mLine = std::make_unique(Transform(mInputLocation), points); addChild(mLine.get()); } }