Fix linux compilation.
This commit is contained in:
parent
ec57e3b534
commit
990cde402b
28 changed files with 245 additions and 161 deletions
|
@ -5,68 +5,73 @@
|
|||
#include "LogicGateNode.h"
|
||||
|
||||
ElectronicCircuitNode::ElectronicCircuitNode(const Transform& transform)
|
||||
: AbstractVisualNode(transform)
|
||||
: AbstractVisualNode(transform)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ElectronicCircuitNode::~ElectronicCircuitNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ElectronicCircuitNode::setContent(ElectronicCircuit* content)
|
||||
{
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void ElectronicCircuitNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
mInputTerminalNodes.clear();
|
||||
mWireNodes.clear();
|
||||
mLogicGateNodes.clear();
|
||||
mInputTerminalNodes.clear();
|
||||
mWireNodes.clear();
|
||||
mLogicGateNodes.clear();
|
||||
|
||||
// Layout terminals
|
||||
double terminal_vertical_spacing = 100;
|
||||
double terminal_left_margin = 10;
|
||||
// Layout terminals
|
||||
double terminal_vertical_spacing = 100;
|
||||
double terminal_left_margin = 10;
|
||||
|
||||
double terminal_y = 0;
|
||||
for (auto terminal : mContent->getInputTerminals())
|
||||
{
|
||||
Point loc{ terminal_left_margin, terminal_y };
|
||||
auto terminal_node = std::make_unique<TerminalNode>(Transform(loc));
|
||||
double terminal_y = 0;
|
||||
for (auto terminal : mContent->getInputTerminals())
|
||||
{
|
||||
Point loc{ terminal_left_margin, terminal_y };
|
||||
auto terminal_node = std::make_unique<TerminalNode>(Transform(loc));
|
||||
|
||||
terminal_node->setContent(terminal);
|
||||
terminal_node->setContent(terminal);
|
||||
|
||||
addChild(terminal_node.get());
|
||||
mInputTerminalNodes.push_back(std::move(terminal_node));
|
||||
addChild(terminal_node.get());
|
||||
mInputTerminalNodes.push_back(std::move(terminal_node));
|
||||
|
||||
terminal_y += terminal_vertical_spacing;
|
||||
}
|
||||
terminal_y += terminal_vertical_spacing;
|
||||
}
|
||||
|
||||
// Layout logic gates
|
||||
double logic_gate_vertical_spacing = 100;
|
||||
double logic_gate_horizontal_spacing = 100;
|
||||
// Layout logic gates
|
||||
double logic_gate_vertical_spacing = 100;
|
||||
double logic_gate_horizontal_spacing = 100;
|
||||
|
||||
double gate_x = logic_gate_vertical_spacing;
|
||||
double gate_y = 0;
|
||||
for (auto gate : mContent->getLogicGates())
|
||||
{
|
||||
Point loc{ gate_x, gate_y };
|
||||
auto gate_node = std::make_unique<LogicGateNode>(Transform(loc));
|
||||
double gate_x = logic_gate_vertical_spacing;
|
||||
double gate_y = 0;
|
||||
for (auto gate : mContent->getLogicGates())
|
||||
{
|
||||
Point loc{ gate_x, gate_y };
|
||||
auto gate_node = std::make_unique<LogicGateNode>(Transform(loc));
|
||||
|
||||
gate_node->setContent(gate);
|
||||
gate_node->setContent(gate);
|
||||
|
||||
addChild(gate_node.get());
|
||||
mLogicGateNodes.push_back(std::move(gate_node));
|
||||
addChild(gate_node.get());
|
||||
mLogicGateNodes.push_back(std::move(gate_node));
|
||||
|
||||
gate_x += logic_gate_vertical_spacing;
|
||||
gate_y += logic_gate_horizontal_spacing;
|
||||
}
|
||||
gate_x += logic_gate_vertical_spacing;
|
||||
gate_y += logic_gate_horizontal_spacing;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ElectronicCircuitNode::update(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,21 @@ class LogicGateNode;
|
|||
class ElectronicCircuitNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
ElectronicCircuitNode(const Transform& transform);
|
||||
ElectronicCircuitNode(const Transform& transform);
|
||||
|
||||
void setContent(ElectronicCircuit* content);
|
||||
virtual ~ElectronicCircuitNode();
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
void setContent(ElectronicCircuit* content);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
|
||||
ElectronicCircuit* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
ElectronicCircuit* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::vector<std::unique_ptr<TerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<WireNode> > mWireNodes;
|
||||
std::vector<std::unique_ptr<LogicGateNode> > mLogicGateNodes;
|
||||
};
|
||||
std::vector<std::unique_ptr<TerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<WireNode> > mWireNodes;
|
||||
std::vector<std::unique_ptr<LogicGateNode> > mLogicGateNodes;
|
||||
};
|
||||
|
|
|
@ -8,42 +8,47 @@
|
|||
#include "LogicGatePrimitiveShapes.h"
|
||||
|
||||
LogicGateNode::LogicGateNode(const Transform& transform)
|
||||
: AbstractVisualNode(transform)
|
||||
: AbstractVisualNode(transform)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LogicGateNode::~LogicGateNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LogicGateNode::setContent(LogicGate* content)
|
||||
{
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void LogicGateNode::update(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LogicGateNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (!mPrimaryPath)
|
||||
{
|
||||
if (mContent->getGateType() == LogicGate::GateType::AND)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getAndGateShape());
|
||||
}
|
||||
else if (mContent->getGateType() == LogicGate::GateType::OR)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getOrGateShape());
|
||||
}
|
||||
|
||||
if (mPrimaryPath)
|
||||
{
|
||||
addChild(mPrimaryPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mPrimaryPath)
|
||||
{
|
||||
if (mContent->getGateType() == LogicGate::GateType::AND)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getAndGateShape());
|
||||
}
|
||||
else if (mContent->getGateType() == LogicGate::GateType::OR)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getOrGateShape());
|
||||
}
|
||||
|
||||
if (mPrimaryPath)
|
||||
{
|
||||
addChild(mPrimaryPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,24 +2,27 @@
|
|||
|
||||
#include "AbstractVisualNode.h"
|
||||
|
||||
#include "CircleNode.h"
|
||||
|
||||
class LogicGate;
|
||||
class PathNode;
|
||||
class CircleNode;
|
||||
|
||||
class LogicGateNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
LogicGateNode(const Transform& transform);
|
||||
LogicGateNode(const Transform& transform);
|
||||
|
||||
void setContent(LogicGate* content);
|
||||
virtual ~LogicGateNode();
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
void setContent(LogicGate* content);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
|
||||
LogicGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
LogicGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::unique_ptr<PathNode> mPrimaryPath;
|
||||
std::unique_ptr<CircleNode> mNegationGlyph;
|
||||
};
|
||||
std::unique_ptr<PathNode> mPrimaryPath;
|
||||
std::unique_ptr<CircleNode> mNegationGlyph;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue