From fdff87853fcabe0b987f2706aad0e78503fa2058 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 25 Nov 2003 20:57:49 +0000 Subject: [PATCH 1/1] -cambios en la implementacion de algunos items, get_connector_type.. -modificaciones en el constructor -algunas cosas mas... --- Constructor/src/conduct.cpp | 105 +++++++++++++++++++++++--------- Constructor/src/constructor.cpp | 20 ++---- Constructor/src/exclusa.cpp | 105 +++++++++++++++++++++++--------- Constructor/src/workplace.cpp | 28 ++++++--- 4 files changed, 179 insertions(+), 79 deletions(-) diff --git a/Constructor/src/conduct.cpp b/Constructor/src/conduct.cpp index c6dd074..6cad0bf 100644 --- a/Constructor/src/conduct.cpp +++ b/Constructor/src/conduct.cpp @@ -117,6 +117,8 @@ bool Conduct::check_connection() { ConnectorType aux; CItem *_item0, *_item1; + if ( is_connected ) + return is_connected; switch (get_img_actual()) { case 0: connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5, &_item0); @@ -143,35 +145,82 @@ bool Conduct::check_connection() ConnectorType Conduct::get_connector_type(int _a, int _b) { CItem *_item; - if ( ! is_connected ) { - switch (imgActual) { - case 0: - if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba - return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5, &_item); //pregunto que hay abajo - if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 ))//abajo - return is_other_connection_area( get_position_x()+16, get_position_y()-5,& _item);//pregunto que hay arriba. - break; - case 1: - if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda - return is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item);//pregunto por la derecha - if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha - return is_other_connection_area(get_position_x()-5, get_position_y()+16, &_item); //pregunto por la izquierda. - } - } else { - switch (imgActual) { - case 0: - if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba - return connect_vec[0].type; - if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo - return connect_vec[1].type; - break; - case 1: - if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda - return connect_vec[0].type; - if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha - return connect_vec[1].type; + switch (imgActual) { + case 0: + if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ){ //arriba + if ( is_connected ) return connect_vec[0].type; + connect_vec[1].type = is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5, &_item); //pregunto que hay abajo + switch ( connect_vec[1].type ) { + case IN: + connect_vec[1] = OUT; + connect_vec[0] = IN; + break; + case OUT: + connect_vec[1] = IN; + connect_vec[0] = OUT; + break; + case UNDEF: + return UNDEF; + } + return connect_vec[0].type; + } + + if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) {//abajo + if ( is_connected ) return connect_vec[1].type; + connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5,& _item);//pregunto que hay arriba. + switch ( connect_vec[0].type ) { + case IN: + connect_vec[0] = OUT; + connect_vec[1] = IN; + break; + case OUT: + connect_vec[0] = IN; + connect_vec[1] = OUT; + break; + case UNDEF: + return UNDEF; + } + return connect_vec[1].type; + } + break; + case 1: + if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )){ //izquierda + if ( is_connected ) return connect_vec[0].type; + connect_vec[1].type = is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item);//pregunto por la derecha + switch ( connect_vec[1].type ) { + case IN: + connect_vec[1] = OUT; + connect_vec[0] = IN; + break; + case OUT: + connect_vec[1] = IN; + connect_vec[0] = OUT; + break; + case UNDEF: + return UNDEF; + } + is_connected = true; + return connect_vec[0].type; + } + if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) {//derecha + if ( is_connected ) return connect_vec[1].type; + connect_vec[0].type = is_other_connection_area(get_position_x()-5, get_position_y()+16, &_item); //pregunto por la izquierda. + switch ( connect_vec[0].type ) { + case IN: + connect_vec[0] = OUT; + connect_vec[1] = IN; + break; + case OUT: + connect_vec[0] = IN; + connect_vec[1] = OUT; + break; + case UNDEF: + return UNDEF; + } + is_connected = true; + return connect_vec[1].type; + } } - } return UNDEF; } diff --git a/Constructor/src/constructor.cpp b/Constructor/src/constructor.cpp index 21bdbca..e6f413e 100644 --- a/Constructor/src/constructor.cpp +++ b/Constructor/src/constructor.cpp @@ -219,6 +219,10 @@ void Constructor::on_edit_menu_delete_all() i=lista_logic_Items.begin(); } id = 0; + list_pointed.clear(); + list_pointed.push_back(" "); + combo_entry->set_popdown_strings(list_pointed); + combo_entry->get_entry()->set_text(""); } void Constructor::on_chk_btn_logica_clicked() @@ -343,21 +347,7 @@ void Constructor::on_quick_btn_new_clicked() void Constructor::on_quick_btn_delete_all_clicked() { - std::list::iterator i = listaItems.begin(); - while ( i != listaItems.end() ){ - CItem *temp = *i; - listaItems.erase(i); - delete temp; - i = listaItems.begin(); - } - i = lista_logic_Items.begin(); - while ( i != lista_logic_Items.end() ){ - CItem *temp2 = *i; - lista_logic_Items.erase(i); - delete temp2; - i = lista_logic_Items.begin(); - } - id = 0; + on_edit_menu_delete_all(); } void Constructor::on_btn_find_clicked() diff --git a/Constructor/src/exclusa.cpp b/Constructor/src/exclusa.cpp index b0210f2..90f8645 100644 --- a/Constructor/src/exclusa.cpp +++ b/Constructor/src/exclusa.cpp @@ -182,36 +182,83 @@ bool Exclusa::check_connection() ConnectorType Exclusa::get_connector_type(int _a, int _b) { - CItem * _item; - if ( ! is_connected ) { - switch (imgActual) { - case 0: - if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda - return is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item);//pregunto por la derecha - if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha - return is_other_connection_area(get_position_x()-5, get_position_y()+16, &_item); //pregunto por la izquierda. - break; - case 1: - if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba - return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5, &_item); //pregunto que hay abajo - if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 ))//abajo - return is_other_connection_area( get_position_x()+16, get_position_y()-5, &_item);//pregunto que hay arriba. - } - } else { - switch (imgActual) { - case 0: - if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda - return connect_vec[0].type; - if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha - return connect_vec[1].type; - break; - case 1: - if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba - return connect_vec[0].type; - if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo - return connect_vec[1].type; + CItem *_item; + switch (imgActual) { + case 0: + if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ){ //arriba + if ( is_connected ) return connect_vec[0].type; + connect_vec[1].type = is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5, &_item); //pregunto que hay abajo + switch ( connect_vec[1].type ) { + case IN: + connect_vec[1] = OUT; + connect_vec[0] = IN; + break; + case OUT: + connect_vec[1] = IN; + connect_vec[0] = OUT; + break; + case UNDEF: + return UNDEF; + } + return connect_vec[0].type; + } + + if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) {//abajo + if ( is_connected ) return connect_vec[1].type; + connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5,& _item);//pregunto que hay arriba. + switch ( connect_vec[0].type ) { + case IN: + connect_vec[0] = OUT; + connect_vec[1] = IN; + break; + case OUT: + connect_vec[0] = IN; + connect_vec[1] = OUT; + break; + case UNDEF: + return UNDEF; + } + return connect_vec[1].type; + } + break; + case 1: + if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )){ //izquierda + if ( is_connected ) return connect_vec[0].type; + connect_vec[1].type = is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item);//pregunto por la derecha + switch ( connect_vec[1].type ) { + case IN: + connect_vec[1] = OUT; + connect_vec[0] = IN; + break; + case OUT: + connect_vec[1] = IN; + connect_vec[0] = OUT; + break; + case UNDEF: + return UNDEF; + } + is_connected = true; + return connect_vec[0].type; + } + if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) {//derecha + if ( is_connected ) return connect_vec[1].type; + connect_vec[0].type = is_other_connection_area(get_position_x()-5, get_position_y()+16, &_item); //pregunto por la izquierda. + switch ( connect_vec[0].type ) { + case IN: + connect_vec[0] = OUT; + connect_vec[1] = IN; + break; + case OUT: + connect_vec[0] = IN; + connect_vec[1] = OUT; + break; + case UNDEF: + return UNDEF; + } + is_connected = true; + return connect_vec[1].type; + } } - } return UNDEF; } diff --git a/Constructor/src/workplace.cpp b/Constructor/src/workplace.cpp index f889352..37b0aa4 100644 --- a/Constructor/src/workplace.cpp +++ b/Constructor/src/workplace.cpp @@ -1,5 +1,7 @@ #include "workplace.h" #include "item.h" +#include "pump.h" +#include "exclusa.h" int WorkPlace::pointed = -1; @@ -54,12 +56,23 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) } int a, b, w, z, x_offset, y_offset, img; + int item_x_offset, item_y_offset; std::list::iterator i = lista_lineas_in.begin(); while ( i != lista_lineas_in.end() ) { t_line temp = *i; if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) { img = get_logic_item(temp.logic_id)->get_img_actual(); + item_y_offset = item_x_offset = 0; x_offset = y_offset = 0; + if (dynamic_cast(get_item(temp.store_id))) { + item_y_offset = -15; + } else if (dynamic_cast(get_item(temp.store_id))) { + if (get_item(temp.store_id)->get_img_actual()==0) { + item_y_offset = -15; + } else { + item_x_offset = 15; + } + } switch (img) { case 0: x_offset = 15; @@ -75,8 +88,9 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) } get_logic_item(temp.logic_id)->get_out_logic_connect_position(a, b); get_item(temp.store_id)->get_in_logic_connect_position(w,z); - draw_line(a+x_offset, b+y_offset, w,z, color_in); + draw_line(a+x_offset, b+y_offset, w+item_x_offset, z+item_y_offset, color_in); get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset); + get_window()->draw_line(gc, w, z, w+item_x_offset, z+item_y_offset); } i++; } @@ -85,24 +99,24 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) t_line temp = *i; if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) { img = get_logic_item(temp.logic_id)->get_img_actual(); + item_y_offset = item_x_offset = 0; x_offset = y_offset = 0; switch (img) { case 0: - x_offset = 15; + x_offset = -15; break; case 1: - y_offset = 15; + y_offset = -15; break; case 2: - x_offset = -15; + x_offset = 15; break; case 3: - y_offset = -15; + y_offset = 15; } get_item(temp.store_id)->get_out_logic_connect_position(w,z); get_logic_item(temp.logic_id)->get_in_logic_connect_position(a, b); -// draw_line(w, z, a, b, color_out); - draw_line(w, z, a+x_offset, b+y_offset,color_out); + draw_line(w+item_y_offset, z+item_y_offset, a+x_offset, b+y_offset,color_out); get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset); } i++; -- 2.43.0