Switch to template types for vectors
This commit is contained in:
parent
9f036d6438
commit
8192ef78e8
105 changed files with 1614 additions and 1424 deletions
|
@ -11,5 +11,5 @@ public:
|
|||
|
||||
virtual ~CircuitElementNode();
|
||||
|
||||
virtual Point getConnectionLocation(Wire* wire) const = 0;
|
||||
virtual Point2 getConnectionLocation(Wire* wire) const = 0;
|
||||
};
|
|
@ -18,7 +18,7 @@ LogicGateNode::~LogicGateNode()
|
|||
|
||||
}
|
||||
|
||||
Point LogicGateNode::getConnectionLocation(Wire* wire) const
|
||||
Point2 LogicGateNode::getConnectionLocation(Wire* wire) const
|
||||
{
|
||||
bool is_input{ false };
|
||||
std::size_t connection_id{ 0 };
|
||||
|
@ -42,7 +42,7 @@ Point LogicGateNode::getConnectionLocation(Wire* wire) const
|
|||
}
|
||||
}
|
||||
|
||||
Point loc;
|
||||
Point2 loc;
|
||||
if (mContent->getGateType() == LogicGate::GateType::AND)
|
||||
{
|
||||
loc = LogicGatePrimitiveShapes::getAndGateConnectionLocation(is_input, connection_id);
|
||||
|
@ -52,7 +52,7 @@ Point LogicGateNode::getConnectionLocation(Wire* wire) const
|
|||
loc = LogicGatePrimitiveShapes::getOrGateConnectionLocation(is_input, connection_id);
|
||||
}
|
||||
|
||||
loc.move(mTransform.getLocation().getX(), mTransform.getLocation().getY());
|
||||
loc.moveBy(mTransform.getLocation().getX(), mTransform.getLocation().getY());
|
||||
return loc;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
|
||||
virtual ~LogicGateNode();
|
||||
|
||||
Point getConnectionLocation(Wire* wire) const override;
|
||||
Point2 getConnectionLocation(Wire* wire) const override;
|
||||
|
||||
void setContent(LogicGate* content);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ std::string LogicGatePrimitiveShapes::getAndGateShape()
|
|||
return "M4 8 h24 a16 16 0 0 1 0 32 h-24Z";
|
||||
}
|
||||
|
||||
Point LogicGatePrimitiveShapes::getAndGateConnectionLocation(bool isInput, std::size_t idx)
|
||||
Point2 LogicGatePrimitiveShapes::getAndGateConnectionLocation(bool isInput, std::size_t idx)
|
||||
{
|
||||
if (isInput)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ std::string LogicGatePrimitiveShapes::getOrGateShape()
|
|||
return "M4 8 h16 q16 2 24 16 q-12 16 -24 16 h-16 q12 -16 0 -32Z";
|
||||
}
|
||||
|
||||
Point LogicGatePrimitiveShapes::getOrGateConnectionLocation(bool isInput, std::size_t idx)
|
||||
Point2 LogicGatePrimitiveShapes::getOrGateConnectionLocation(bool isInput, std::size_t idx)
|
||||
{
|
||||
if (isInput)
|
||||
{
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
class LogicGatePrimitiveShapes
|
||||
{
|
||||
public:
|
||||
static Point getAndGateConnectionLocation(bool isInput, std::size_t idx);
|
||||
static Point2 getAndGateConnectionLocation(bool isInput, std::size_t idx);
|
||||
|
||||
static std::string getAndGateShape();
|
||||
|
||||
static Point getOrGateConnectionLocation(bool isInput, std::size_t idx);
|
||||
static Point2 getOrGateConnectionLocation(bool isInput, std::size_t idx);
|
||||
|
||||
static std::string getOrGateShape();
|
||||
};
|
|
@ -34,7 +34,7 @@ void TerminalNode::update(SceneInfo* sceneInfo)
|
|||
}
|
||||
}
|
||||
|
||||
Point TerminalNode::getConnectionLocation(Wire*) const
|
||||
Point2 TerminalNode::getConnectionLocation(Wire*) const
|
||||
{
|
||||
return mTransform.getLocation();
|
||||
return { mTransform.getLocation().getX(), mTransform.getLocation().getY() };
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class TerminalNode : public CircuitElementNode
|
|||
public:
|
||||
TerminalNode(const Transform& transform);
|
||||
|
||||
Point getConnectionLocation(Wire* wire) const override;
|
||||
Point2 getConnectionLocation(Wire* wire) const override;
|
||||
|
||||
void setContent(Terminal* terminal);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ void WireNode::setContent(Wire* wire)
|
|||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void WireNode::setInputLocation(const Point& point)
|
||||
void WireNode::setInputLocation(const Point2& point)
|
||||
{
|
||||
if (mInputLocation != point)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ void WireNode::setInputLocation(const Point& point)
|
|||
}
|
||||
}
|
||||
|
||||
void WireNode::setOutputLocation(const Point& point)
|
||||
void WireNode::setOutputLocation(const Point2& point)
|
||||
{
|
||||
if (mOutputLocation != point)
|
||||
{
|
||||
|
@ -46,9 +46,9 @@ void WireNode::createOrUpdateGeometry(SceneInfo*)
|
|||
if (!mLine)
|
||||
{
|
||||
auto loc = mOutputLocation;
|
||||
loc.move(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ());
|
||||
loc.moveBy(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ());
|
||||
|
||||
std::vector<Point> points;
|
||||
std::vector<Point2> points;
|
||||
|
||||
if (loc.getY() == 0.0)
|
||||
{
|
||||
|
@ -56,8 +56,8 @@ void WireNode::createOrUpdateGeometry(SceneInfo*)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto join0 = Point(loc.getX() * 3.0 / 4.0, 0.0);
|
||||
auto join1 = Point(loc.getX() * 3.0 / 4.0, loc.getY());
|
||||
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};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ public:
|
|||
|
||||
void setContent(Wire* wire);
|
||||
|
||||
void setInputLocation(const Point& point);
|
||||
void setInputLocation(const Point2& point);
|
||||
|
||||
void setOutputLocation(const Point& point);
|
||||
void setOutputLocation(const Point2& point);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
private:
|
||||
|
@ -23,8 +23,8 @@ private:
|
|||
Wire* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
Point mInputLocation;
|
||||
Point mOutputLocation;
|
||||
Point2 mInputLocation;
|
||||
Point2 mOutputLocation;
|
||||
|
||||
std::unique_ptr<LineNode> mLine;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue