]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
-cambios en la implementacion de algunos items, get_connector_type..
authorRicardo Markiewicz <gazer.arg@gmail.com>
Tue, 25 Nov 2003 20:57:49 +0000 (20:57 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Tue, 25 Nov 2003 20:57:49 +0000 (20:57 +0000)
-modificaciones en el constructor
-algunas cosas mas...

Constructor/src/conduct.cpp
Constructor/src/constructor.cpp
Constructor/src/exclusa.cpp
Constructor/src/workplace.cpp

index c6dd0743270bb0499db9abae7a5b7a6b547824ea..6cad0bf1a1854a60704b2ac862155dcead518d33 100644 (file)
@@ -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;
 }
 
index 21bdbca48bb699f7c5b063756d4873db15ef337f..e6f413e9fcf647ea12c36ce113be02571f7d25b4 100644 (file)
@@ -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<CItem *>::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()
index b0210f27dc137f271671e70d8e58158890be1d9e..90f8645b2e887d384c65aa4f7f79b840233f4c70 100644 (file)
@@ -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;
 }
        
index f8893521a43bb0db96b2a93be34e0fa3eb91c350..37b0aa49ca018b23b892ac64ad138fb536756ee9 100644 (file)
@@ -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<t_line>::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<Pump *>(get_item(temp.store_id))) {
+                               item_y_offset = -15;
+                       } else if (dynamic_cast<Exclusa *>(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++;