From 167e63926ec8b06511bc03a897731c17e4564719 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Wed, 24 Jun 2020 11:21:58 +0930 Subject: possibly fix logic bug and add options panel the option panel shows input types and output state. logic now updates when a new link is made --- Gate.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) (limited to 'Gate.cpp') diff --git a/Gate.cpp b/Gate.cpp index 4a789c3..9ffa50d 100644 --- a/Gate.cpp +++ b/Gate.cpp @@ -22,7 +22,7 @@ Gate::Gate(GATE_TYPE type, int x, int y, int width, int height) this->gate_type = type; this->input_gate1 = nullptr; this->input_gate2 = nullptr; - this->output_gate = nullptr; + //this->output_gate = nullptr; this->id = Gate::gate_id_counter++; // increment counter after assigning this->x = x; this->y = y; @@ -56,7 +56,6 @@ void Gate::update_state() break; } - case AND: { if (!input_gate1 || !input_gate2) {this->output_state = false; return; } @@ -117,3 +116,67 @@ void Gate::update_state() break; } } +std::string +Gate::get_output_type_text() +{ + std::string out; + switch (this->gate_type) + { + case INPUT: + { + return "INPUT"; + } + + case OUTPUT: + { + return "OUTPUT"; + } + + case AND: + { + return "AND"; + } + + + case OR: + { + return "OR"; + } + + + case NOT: + { + return "NOT"; + } + + + case NAND: + { + return "NAND"; + } + + + case NOR: + { + return "NOR"; + } + + + case XOR: + { + return "XOR"; + } + + + case XNOR: + { + return "XNOR"; + } + + default: + return "?"; + } + +} + + -- cgit v1.2.3