Switch to template types for vectors
This commit is contained in:
parent
9f036d6438
commit
8192ef78e8
105 changed files with 1614 additions and 1424 deletions
|
@ -3,8 +3,8 @@
|
|||
#include "CircleNode.h"
|
||||
#include "LineNode.h"
|
||||
|
||||
BlochSphereNode::BlochSphereNode(const Point& location)
|
||||
: AbstractVisualNode(location, "BlochSphereNode")
|
||||
BlochSphereNode::BlochSphereNode(const Point2& location)
|
||||
: AbstractVisualNode(Transform(location))
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ void BlochSphereNode::update(SceneInfo*)
|
|||
|
||||
mOuterCircle = std::make_unique<CircleNode>(loc, mSize/2.0);
|
||||
|
||||
const auto end_point_x = Point(loc.getX() + 1.2 * mSize / 2.0, loc.getY());
|
||||
const std::vector<Point> points{end_point_x };
|
||||
const auto end_point_x = Point2(loc.getX() + 1.2 * mSize / 2.0, loc.getY());
|
||||
const std::vector<Point2> points{end_point_x };
|
||||
mXAxis = std::make_unique<LineNode>(loc, points);
|
||||
|
||||
mCentreCircle = std::make_unique<CircleNode>(loc, mSize / 50.0);
|
||||
|
|
|
@ -11,7 +11,7 @@ class LineNode;
|
|||
class BlochSphereNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
BlochSphereNode(const Point& location);
|
||||
BlochSphereNode(const Point2& location);
|
||||
|
||||
void setContent(BlochSphere* content);
|
||||
|
||||
|
|
|
@ -11,5 +11,5 @@ public:
|
|||
|
||||
virtual ~QuantumCircuitElementNode();
|
||||
|
||||
virtual Point getConnectionLocation(AbstractQuantumWire* wire) const = 0;
|
||||
virtual Point2 getConnectionLocation(AbstractQuantumWire* wire) const = 0;
|
||||
};
|
|
@ -123,7 +123,7 @@ void QuantumCircuitNode::createOrUpdateGeometry(SceneInfo*)
|
|||
wire_node->setInputLocation(start_loc);
|
||||
|
||||
auto end_loc = end_node->getConnectionLocation(wire);
|
||||
auto straight_end_loc = Point(end_loc.getX(), start_loc.getY());
|
||||
auto straight_end_loc = Point2(end_loc.getX(), start_loc.getY());
|
||||
wire_node->setOutputLocation(straight_end_loc);
|
||||
|
||||
addChild(wire_node.get());
|
||||
|
|
|
@ -72,7 +72,7 @@ void QuantumGateNode::createOrUpdateGeometry(SceneInfo*)
|
|||
}
|
||||
}
|
||||
|
||||
Point QuantumGateNode::getConnectionLocation(AbstractQuantumWire* wire) const
|
||||
Point2 QuantumGateNode::getConnectionLocation(AbstractQuantumWire* wire) const
|
||||
{
|
||||
bool is_input{ false };
|
||||
//std::size_t connection_id{ 0 };
|
||||
|
@ -96,16 +96,16 @@ Point QuantumGateNode::getConnectionLocation(AbstractQuantumWire* wire) const
|
|||
}
|
||||
}
|
||||
|
||||
Point loc;
|
||||
Point2 loc;
|
||||
if (is_input)
|
||||
{
|
||||
loc = Point(0.0, mBodyHeight/2.0);
|
||||
loc = Point2(0.0, mBodyHeight/2.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
loc = Point(mBodyWidth, mBodyHeight / 2.0);
|
||||
loc = Point2(mBodyWidth, mBodyHeight / 2.0);
|
||||
}
|
||||
|
||||
loc.move(mTransform.getLocation().getX(), mTransform.getLocation().getY());
|
||||
loc.moveBy(mTransform.getLocation().getX(), mTransform.getLocation().getY());
|
||||
return loc;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
|
||||
virtual ~QuantumGateNode();
|
||||
|
||||
Point getConnectionLocation(AbstractQuantumWire* wire) const override;
|
||||
Point2 getConnectionLocation(AbstractQuantumWire* wire) const override;
|
||||
|
||||
void setContent(QuantumGate* gate);
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ void QuantumTerminalNode::createOrUpdateGeometry(SceneInfo*)
|
|||
}
|
||||
}
|
||||
|
||||
Point QuantumTerminalNode::getConnectionLocation(AbstractQuantumWire*) const
|
||||
Point2 QuantumTerminalNode::getConnectionLocation(AbstractQuantumWire*) const
|
||||
{
|
||||
auto left = mTransform.getLocation();
|
||||
left.move(mWidth, mHeight/2.0);
|
||||
return left;
|
||||
left.moveBy(mWidth, mHeight/2.0);
|
||||
return { left.getX(), left.getY() };
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class QuantumTerminalNode : public QuantumCircuitElementNode
|
|||
public:
|
||||
QuantumTerminalNode(const Transform& transform);
|
||||
|
||||
Point getConnectionLocation(AbstractQuantumWire* wire) const override;
|
||||
Point2 getConnectionLocation(AbstractQuantumWire* wire) const override;
|
||||
|
||||
void setContent(QuantumTerminal* terminal);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ void QuantumWireNode::setContent(QuantumWire* content)
|
|||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void QuantumWireNode::setInputLocation(const Point& point)
|
||||
void QuantumWireNode::setInputLocation(const Point2& point)
|
||||
{
|
||||
if (mInputLocation != point)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ void QuantumWireNode::setInputLocation(const Point& point)
|
|||
}
|
||||
}
|
||||
|
||||
void QuantumWireNode::setOutputLocation(const Point& point)
|
||||
void QuantumWireNode::setOutputLocation(const Point2& point)
|
||||
{
|
||||
if (mOutputLocation != point)
|
||||
{
|
||||
|
@ -52,9 +52,9 @@ void QuantumWireNode::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)
|
||||
{
|
||||
|
@ -62,8 +62,8 @@ void QuantumWireNode::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 };
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ public:
|
|||
|
||||
virtual ~QuantumWireNode();
|
||||
|
||||
void setInputLocation(const Point& point);
|
||||
void setInputLocation(const Point2& point);
|
||||
|
||||
void setOutputLocation(const Point& point);
|
||||
void setOutputLocation(const Point2& point);
|
||||
|
||||
void setContent(QuantumWire* content);
|
||||
|
||||
|
@ -26,8 +26,8 @@ private:
|
|||
QuantumWire* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
Point mInputLocation;
|
||||
Point mOutputLocation;
|
||||
Point2 mInputLocation;
|
||||
Point2 mOutputLocation;
|
||||
|
||||
std::unique_ptr<LineNode> mLine;
|
||||
};
|
|
@ -11,7 +11,7 @@ TEST_CASE(TestBlochSphereNode, "quantum_computing")
|
|||
{
|
||||
TestRenderer renderer(100, 100);
|
||||
|
||||
auto node = std::make_unique<BlochSphereNode>(Point(0.5, 0.5));
|
||||
auto node = std::make_unique<BlochSphereNode>(Point2(0.5, 0.5));
|
||||
|
||||
Qubit state({ 1.0, 0.0 }, { 0.0, 0.0 });
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue