#include "TerminalNode.h"

#include "CircleNode.h"

TerminalNode::TerminalNode(const Transform& transform)
    : CircuitElementNode(transform)
{

}

void TerminalNode::setContent(Terminal* terminal)
{
    mContent = terminal;
}

void TerminalNode::createOrUpdateGeometry(SceneInfo*)
{
    if (!mMarker)
    {
        mMarker = std::make_unique<CircleNode>(Transform{}, 3);
        mMarker->setFillColor(Color(0, 0, 0));
        mMarker->setHasStrokeColor(false);

        addChild(mMarker.get());
    }
}

void TerminalNode::update(SceneInfo* sceneInfo)
{
    if (mContentDirty)
    {
        createOrUpdateGeometry(sceneInfo);
        mContentDirty = false;
    }
}

Point TerminalNode::getConnectionLocation(Wire*) const
{
    return mTransform.getLocation();
}
