From: Nicolás Dimov Date: Sun, 30 Nov 2003 22:53:13 +0000 (+0000) Subject: despues de estar como un pelotudo buscando el error, lo encontre, era un == ( yo... X-Git-Tag: svn_import~145 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/c45e0693cd6b07a5123955102de53d96143f7fd8 despues de estar como un pelotudo buscando el error, lo encontre, era un == ( yo estaba poniendo = ), asi que ahora las compuertas se salvan bien cuando estan conectadas a un tanque --- diff --git a/Constructor/include/item.h b/Constructor/include/item.h index 7b277e3..3259d8d 100644 --- a/Constructor/include/item.h +++ b/Constructor/include/item.h @@ -25,6 +25,7 @@ typedef enum { UNDEF, IN, OUT } ConnectorType; typedef struct { ConnectorType type; Glib::ustring name_dest; + int cistern_connector; }t_logic_connector; ///Clase que define un conector del item diff --git a/Constructor/include/workplace.h b/Constructor/include/workplace.h index a559f37..c85d76a 100644 --- a/Constructor/include/workplace.h +++ b/Constructor/include/workplace.h @@ -12,7 +12,9 @@ ///Indico que la clase CItem existe para poder compilar. class CItem; -///Esta estructura define una linea entre un item logico y uno de transporte. +/**Esta estructura define una linea entre un item logico y uno de transporte, + *tambien indica cual de las dos salidas del tanque esta conectada. + */ typedef struct { int logic_id, store_id; bool cistern_out1; diff --git a/Constructor/src/and.cpp b/Constructor/src/and.cpp index 504747b..86b774f 100644 --- a/Constructor/src/and.cpp +++ b/Constructor/src/and.cpp @@ -1,5 +1,5 @@ #include "and.h" - +#include "cistern.h" And::And(int orientacion) { is_logic = true; @@ -153,8 +153,18 @@ void And::save(FILE *archivo) dato += c_y; for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) { if ( vec_connector[i].type == IN ) { - dato += "\t\t"; - dato += vec_connector[i].name_dest + "\n"; + if ( vec_connector[i].cistern_connector == 1 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } + if ( vec_connector[i].cistern_connector == 0 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } + if ( vec_connector[i].cistern_connector == -1 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } } else { dato += "\t\t"; dato += vec_connector[i].name_dest + "\n"; @@ -182,6 +192,13 @@ bool And::check_connection() if ( (*i).logic_id== ID ) { temp.type = IN; temp.name_dest = workplace->get_item((*i).store_id)->get_name(); + if ( dynamic_cast(workplace->get_item((*i).store_id)) ) { + if ( (*i).cistern_out1 ) + temp.cistern_connector = 1; //arriba + else + temp.cistern_connector = 0; //abajo + } else + temp.cistern_connector = -1; //si no es tanque. vec_connector.push_back(temp); } i++; diff --git a/Constructor/src/cistern.cpp b/Constructor/src/cistern.cpp index 2db315f..bdc2190 100644 --- a/Constructor/src/cistern.cpp +++ b/Constructor/src/cistern.cpp @@ -52,13 +52,23 @@ 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 && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()){ - tmp_line.logic_id = workplace->get_logic_item(CItem::gate_id)->get_id(); - tmp_line.cistern_out1 = true; - //workplace->get_logic_item(CItem::gate_id)->set_out_connected(true); - tmp_line.store_id = ID; - workplace->lista_lineas_out.push_back(tmp_line); - workplace->queue_draw(); + if ( detect_click_position((int)event->x, (int)event->y) == IN){ + if (dynamic_cast(workplace->get_logic_item(CItem::gate_id))) { + if ( !dynamic_cast(workplace->get_logic_item(CItem::gate_id))->get_out_logic_connect()) { + workplace->get_logic_item(CItem::gate_id)->set_in_connected(true); + tmp_line.logic_id = CItem::gate_id; + tmp_line.cistern_out1 = true; + tmp_line.store_id = ID; + workplace->lista_lineas_out.push_back(tmp_line); + workplace->queue_draw(); + } + } else { + tmp_line.logic_id = CItem::gate_id; + tmp_line.cistern_out1 = true; + tmp_line.store_id = ID; + workplace->lista_lineas_out.push_back(tmp_line); + workplace->queue_draw(); + } } else if (detect_click_position((int)event->x, (int)event->y) == OUT ) { if (dynamic_cast(workplace->get_logic_item(CItem::gate_id))) { if ( !dynamic_cast(workplace->get_logic_item(CItem::gate_id))->get_in_logic_connect()) { @@ -72,6 +82,7 @@ bool Cistern::on_button_press_event(GdkEventButton *event) } else { tmp_line.logic_id = CItem::gate_id; tmp_line.store_id = ID; + tmp_line.cistern_out1 = false; workplace->lista_lineas_out.push_back(tmp_line); workplace->queue_draw(); } diff --git a/Constructor/src/not.cpp b/Constructor/src/not.cpp index 2be71fe..e69a94a 100644 --- a/Constructor/src/not.cpp +++ b/Constructor/src/not.cpp @@ -1,4 +1,5 @@ #include "not.h" +#include "cistern.h" Not::Not(int orientacion) { @@ -155,8 +156,18 @@ void Not::save(FILE *archivo) dato += c_y; for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) { if ( vec_connector[i].type == IN ) { - dato += "\t\t"; - dato += vec_connector[i].name_dest + "\n"; + if ( vec_connector[i].cistern_connector == 1 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } + if ( vec_connector[i].cistern_connector == 0 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } + if ( vec_connector[i].cistern_connector == -1 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } } else { dato += "\t\t"; dato += vec_connector[i].name_dest + "\n"; @@ -186,6 +197,13 @@ bool Not::check_connection() if ( (*i).logic_id == ID ) { temp.type = IN; temp.name_dest = workplace->get_item((*i).store_id)->get_name(); + if ( dynamic_cast(workplace->get_item((*i).store_id)) ) { + if ( (*i).cistern_out1 ) + temp.cistern_connector = 1; //arriba + else + temp.cistern_connector = 0; //abajo + } else + temp.cistern_connector = -1; //si no es tanque. vec_connector.push_back(temp); cant_in++; } diff --git a/Constructor/src/or.cpp b/Constructor/src/or.cpp index ee96e22..2c17f7a 100644 --- a/Constructor/src/or.cpp +++ b/Constructor/src/or.cpp @@ -1,4 +1,5 @@ #include "or.h" +#include "cistern.h" Or::Or(int orientacion) { @@ -152,8 +153,18 @@ void Or::save(FILE *archivo) dato += c_y; for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) { if ( vec_connector[i].type == IN ) { - dato += "\t\t"; - dato += vec_connector[i].name_dest + "\n"; + if ( vec_connector[i].cistern_connector == 1 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } + if ( vec_connector[i].cistern_connector == 0 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } + if ( vec_connector[i].cistern_connector == -1 ) { + dato += "\t\t"; + dato += vec_connector[i].name_dest + "\n"; + } } else { dato += "\t\t"; dato += vec_connector[i].name_dest + "\n"; @@ -163,6 +174,8 @@ void Or::save(FILE *archivo) fprintf(archivo, dato.c_str() ); } +//tanque1 + bool Or::check_connection() { int cant_in = 0, cant_out =0; @@ -172,6 +185,7 @@ bool Or::check_connection() if ( (*i).logic_id== ID ) { temp.type = OUT; temp.name_dest = workplace->get_item((*i).store_id)->get_name(); + temp.cistern_connector = -1; vec_connector.push_back(temp); cant_out++; } @@ -183,6 +197,14 @@ bool Or::check_connection() if ( (*i).logic_id== ID ) { temp.type = IN; temp.name_dest = workplace->get_item((*i).store_id)->get_name(); + if ( dynamic_cast(workplace->get_item((*i).store_id)) ) { + if ( (*i).cistern_out1 ) + temp.cistern_connector = 1; //arriba + else + temp.cistern_connector = 0; //abajo + } else + temp.cistern_connector = -1; //si no es tanque. + std::cout<<"cistern_connector = "<get_logic_item((*i).logic_id)->get_name(); + temp.cistern_connector = -1; vec_connector.push_back(temp); cant_out++; }