From 6fcc8fcf6b98f413f813904fe0f078d2782fb9d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicol=C3=A1s=20Dimov?= Date: Sat, 29 Nov 2003 17:14:11 +0000 Subject: [PATCH] -Arregle un poco el tema de que cada compuerta puede tener una sola salida pero la NOT esta fallando a veces creo que las demas andan bien - Falta hacer que las conexiones se guarden en el XML y un par de cositas mas relacionado con eso mismo.. --- Constructor/include/and.h | 1 + Constructor/include/item.h | 1 + Constructor/include/or.h | 1 + Constructor/src/and.cpp | 7 ++++++- Constructor/src/cistern.cpp | 2 +- Constructor/src/exclusa.cpp | 4 ++-- Constructor/src/item.cpp | 5 +++++ Constructor/src/not.cpp | 4 +--- Constructor/src/or.cpp | 7 ++++++- Constructor/src/pump.cpp | 2 +- 10 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Constructor/include/and.h b/Constructor/include/and.h index 56be2e9..a71b536 100644 --- a/Constructor/include/and.h +++ b/Constructor/include/and.h @@ -15,6 +15,7 @@ class And : public CItem { virtual void update_logic_position(); virtual void get_in_logic_connect_position(int& _a, int& _b); virtual void get_out_logic_connect_position(int& _a, int& _b); + virtual bool get_out_logic_connect(); virtual void set_out_connected(bool _o); virtual void draw_connectors(); private: diff --git a/Constructor/include/item.h b/Constructor/include/item.h index 140629b..7b277e3 100644 --- a/Constructor/include/item.h +++ b/Constructor/include/item.h @@ -126,6 +126,7 @@ public: virtual void set_out_connected(bool _o); virtual void set_in_connected(bool _o); + virtual bool get_out_logic_connect(); /**Dibuja los conectores logicos del Item, AZUL == SALIDA, ROJO == ENTRADA. */ virtual void draw_connectors(); diff --git a/Constructor/include/or.h b/Constructor/include/or.h index 177f699..0691903 100644 --- a/Constructor/include/or.h +++ b/Constructor/include/or.h @@ -15,6 +15,7 @@ class Or : public CItem { virtual void update_logic_position(); virtual void get_in_logic_connect_position(int& _a, int& _b); virtual void get_out_logic_connect_position(int& _a, int& _b); + virtual bool get_out_logic_connect(); virtual void set_out_connected(bool _o); virtual void draw_connectors(); private: diff --git a/Constructor/src/and.cpp b/Constructor/src/and.cpp index 3e52876..927aa61 100644 --- a/Constructor/src/and.cpp +++ b/Constructor/src/and.cpp @@ -57,7 +57,7 @@ bool And::on_button_press_event(GdkEventButton *event) std::cout << CItem::gate_id << std::endl; if (CItem::logic_connect) { if (CItem::gate_id != -1 ) { - if ( detect_click_position((int)event->x, (int)event->y ) == IN && CItem::gate_id != ID ) { + if ( detect_click_position((int)event->x, (int)event->y ) == IN && CItem::gate_id != ID && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()) { tmp_line.logic_id = CItem::gate_id; workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); tmp_line.store_id = ID; @@ -263,6 +263,11 @@ void And::set_out_connected(bool _o) out_connected = _o; } +bool And::get_out_logic_connect() +{ + return out_connected; +} + void And::draw_connectors() { Glib::RefPtr window = get_window(); diff --git a/Constructor/src/cistern.cpp b/Constructor/src/cistern.cpp index 628d69f..b363855 100644 --- a/Constructor/src/cistern.cpp +++ b/Constructor/src/cistern.cpp @@ -52,7 +52,7 @@ bool Cistern::on_button_press_event(GdkEventButton *event) combo_entry->set_popdown_strings(*list_pointed); combo_entry->get_entry()->set_text (name); if (CItem::logic_connect && CItem::gate_id != -1) { - if ( detect_click_position((int)event->x, (int)event->y) == IN ){ + if ( detect_click_position((int)event->x, (int)event->y) == IN && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()){ tmp_line.logic_id = workplace->get_logic_item(CItem::gate_id)->get_id(); workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); tmp_line.store_id = ID; diff --git a/Constructor/src/exclusa.cpp b/Constructor/src/exclusa.cpp index 048dd6c..5fc6cee 100644 --- a/Constructor/src/exclusa.cpp +++ b/Constructor/src/exclusa.cpp @@ -47,8 +47,8 @@ bool Exclusa::on_button_press_event(GdkEventButton *event) combo_entry->set_popdown_strings(*list_pointed); combo_entry->get_entry()->set_text (name); if (CItem::logic_connect && CItem::gate_id != -1) { - if ( detect_click_position((int)event->x, (int)event->y) == IN) { - tmp_line.logic_id = workplace->get_logic_item(CItem::gate_id)->get_id(); + if ( detect_click_position((int)event->x, (int)event->y) == IN && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()) { + tmp_line.logic_id = CItem::gate_id; workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); tmp_line.store_id = ID; workplace->lista_lineas_in.push_back(tmp_line); diff --git a/Constructor/src/item.cpp b/Constructor/src/item.cpp index e5027e0..0bbf005 100644 --- a/Constructor/src/item.cpp +++ b/Constructor/src/item.cpp @@ -197,6 +197,11 @@ void CItem::get_out_logic_connect_position(int& _a, int& _b) _b = y; } +bool CItem::get_out_logic_connect() +{ + return false; +} + void CItem::update_logic_position() { } diff --git a/Constructor/src/not.cpp b/Constructor/src/not.cpp index 8a33e1c..a946d8c 100644 --- a/Constructor/src/not.cpp +++ b/Constructor/src/not.cpp @@ -57,7 +57,7 @@ bool Not::on_button_press_event(GdkEventButton *event) t_line tmp_line; if (CItem::logic_connect) { if (CItem::gate_id != -1) { - if ( detect_click_position((int)event->x, (int)event->y) == IN && !in_connected) { + if ( detect_click_position((int)event->x, (int)event->y) == IN && !in_connected && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()) { tmp_line.logic_id = CItem::gate_id; workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); set_in_connected(true); @@ -68,8 +68,6 @@ bool Not::on_button_press_event(GdkEventButton *event) } } else CItem::gate_id = ID; - } - if ( CItem::logic_connect ) { if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected ) { CItem::gate_id = ID; } diff --git a/Constructor/src/or.cpp b/Constructor/src/or.cpp index 50ad73f..a96d48f 100644 --- a/Constructor/src/or.cpp +++ b/Constructor/src/or.cpp @@ -56,7 +56,7 @@ bool Or::on_button_press_event(GdkEventButton *event) t_line tmp_line; if (CItem::logic_connect) { if (CItem::gate_id != -1) { - if ( detect_click_position((int)event->x, (int)event->y) == IN) { + if ( detect_click_position((int)event->x, (int)event->y) == IN && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()) { tmp_line.logic_id = CItem::gate_id; workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); tmp_line.store_id = ID; @@ -264,6 +264,11 @@ void Or::set_out_connected(bool _o) out_connected = _o; } +bool Or::get_out_logic_connect() +{ + return out_connected; +} + void Or::draw_connectors() { Glib::RefPtr window = get_window(); diff --git a/Constructor/src/pump.cpp b/Constructor/src/pump.cpp index 47cf1b9..cafa7d5 100644 --- a/Constructor/src/pump.cpp +++ b/Constructor/src/pump.cpp @@ -49,7 +49,7 @@ bool Pump::on_button_press_event(GdkEventButton *event) WorkPlace::pointed = ID; std::cout<< "CItem::gate_id = "<x, (int)event->y) == IN) { + if ( detect_click_position((int)event->x, (int)event->y) == IN && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()) { tmp_line.logic_id = CItem::gate_id; workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); tmp_line.store_id = ID; -- 2.43.0