]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
- Se actualiza la funcion save() de todos los item
authorNicolás Dimov <ndimov@gmail.com>
Mon, 17 Nov 2003 16:39:49 +0000 (16:39 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Mon, 17 Nov 2003 16:39:49 +0000 (16:39 +0000)
- 2 bombas, una union y un drenaje se conectan bien

Constructor/cistern.cpp
Constructor/conduct.cpp
Constructor/constructor.cpp
Constructor/drain.cpp
Constructor/exclusa.cpp
Constructor/item.cpp
Constructor/item.h
Constructor/itemptywnd.cpp
Constructor/pump.cpp
Constructor/splitter.cpp
Constructor/union.cpp

index fd49a6eb4d0c88b9c71b5603f0c4bab01ef3cf26..198d94047c304a896f7df4fa381b055fc1026c60 100644 (file)
@@ -112,6 +112,16 @@ Gdk::Color Cistern::get_liquid_color()
 void Cistern::save(FILE *archivo)
 {
        char c_id[50], c_cap[50], c_x[50], c_y[50], c_img[50], c_ini[50], c_red[50], c_green[50], c_blue[50];
+       Glib::ustring  con0, con1;
+       if (connect_vec[0].type == IN)
+               con0 = "\t\t\t<entrada>"+get_other_name(connect_vec[0].id_dest)+"</entrada>\n";
+       else
+               con0 = "\t\t\t<salida>"+get_other_name(connect_vec[0].id_dest)+"</salida>\n";
+       if (connect_vec[1].type == IN) 
+               con1 = "\t\t\t<entrada>"+get_other_name(connect_vec[1].id_dest)+"</entrada>\n";
+       else 
+               con1 = "\t\t\t<salida>"+get_other_name(connect_vec[1].id_dest)+"</salida>\n";
+       
        sprintf(c_red,"\t\t\t<rojo>%d</rojo>\n",liquid_color.get_red());
        sprintf(c_green,"\t\t\t<verde>%d</verde>\n",liquid_color.get_green());
        sprintf(c_blue,"\t\t\t<azul>%d</azul>\n",liquid_color.get_blue());
@@ -127,11 +137,12 @@ void Cistern::save(FILE *archivo)
        dato += "\">\n";
        dato += c_cap;
        dato += c_ini;
-       dato += "\t<color>\n";
+       dato += "\t\t<color>\n";
        dato += c_red;
        dato += c_green;
        dato += c_blue;
-       dato += "\t</color>\n";
+       dato += "\t\t</color>\n";
+       dato += "\t\t<conector>\n"+con0+con1+"\t\t</conector>\n";
        dato += c_img;
        dato += c_x; 
        dato += c_y;
@@ -141,18 +152,22 @@ void Cistern::save(FILE *archivo)
 
 bool Cistern::check_connection()
 {
+       CItem * _item, *_item1;
        ConnectorType temp0, temp1;
        switch (get_img_actual()) {
                case 0:
-                       temp0 = is_other_connection_area( get_position_x()+get_image()->get_width() + 5 , get_position_y()+get_image()->get_height() -16);
-                       temp1 = is_other_connection_area( get_position_x() + 16, get_position_y() - 5);
+                       temp0 = is_other_connection_area( get_position_x()+get_image()->get_width() + 5 , get_position_y()+get_image()->get_height() -16, &_item);
+                       temp1 = is_other_connection_area( get_position_x() + 16, get_position_y() - 5, &_item1);
                        break;
                case 1:
-                       temp0 = is_other_connection_area( get_position_x() -5, get_position_y()+get_image()->get_height()-16);
-                       temp1 = is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() - 5);
+                       temp0 = is_other_connection_area( get_position_x() -5, get_position_y()+get_image()->get_height()-16, &_item);
+                       temp1 = is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() - 5, &_item1);
        }
-       if (temp0 == OUT && temp1 == IN)
+       if (temp0 == OUT && temp1 == IN) { 
+               connect_vec[0].id_dest = _item->get_id();
+               connect_vec[1].id_dest = _item1->get_id();
                return (is_connected = true);
+       }
        return is_connected;
 }
 
index 1e5bde343e3691d544ae0ea3769b9103796499b7..b286e684ef6968c109f5c362ea353bc64586d285 100644 (file)
@@ -75,6 +75,15 @@ void Conduct::on_menu_popup_propiedades()
 void Conduct::save(FILE *archivo)
 {
        char c_id[50], c_caudal[50], c_x[50], c_y[50], c_img[50];
+       Glib::ustring  con0, con1;
+       if (connect_vec[0].type == IN)
+               con0 = "\t\t\t<entrada>"+get_other_name(connect_vec[0].id_dest)+"</entrada>\n";
+       else
+               con0 = "\t\t\t<salida>"+get_other_name(connect_vec[0].id_dest)+"</salida>\n";
+       if (connect_vec[1].type == IN) 
+               con1 = "\t\t\t<entrada>"+get_other_name(connect_vec[1].id_dest)+"</entrada>\n";
+       else
+               con1 = "\t\t\t<salida>"+get_other_name(connect_vec[1].id_dest)+"</salida>\n";
        sprintf(c_x,"\t\t<x>%d</x>\n",x);
        sprintf(c_y,"\t\t<y>%d</y>\n",y);
        sprintf(c_id,"%d",ID);
@@ -85,6 +94,7 @@ void Conduct::save(FILE *archivo)
        dato += c_id;
        dato += "\">\n";
        dato += c_caudal;
+       dato += "\t\t<conector>\n"+con0 + con1+"\t\t</conector>\n";     
        dato += c_img;
        dato += c_x; 
        dato += c_y;
@@ -94,35 +104,40 @@ void Conduct::save(FILE *archivo)
 
 bool Conduct::check_connection()
 {
+       CItem *_item0, *_item1;
        switch (get_img_actual()) {
                        case 0:
-                               connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5);
-                               connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5);
+                               connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5, &_item0);
+                               connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5,& _item1);
                        break;          
                        case 1:
-                               connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16);
-                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
+                               connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16, &_item0);
+                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item1);
        }
-       if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
+       if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF ) {
+               connect_vec[0].id_dest = _item0->get_id();
+               connect_vec[1].id_dest = _item1->get_id();
                return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
-       else return false;
+       }
+       else return is_connected;
 }
 
 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); //pregunto que hay abajo
+                                       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);//pregunto que hay arriba.
+                                       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);//pregunto por la derecha
+                                       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); //pregunto por la izquierda.
+                                       return is_other_connection_area(get_position_x()-5, get_position_y()+16, &_item); //pregunto por la izquierda.
                }
        } else {
                switch (imgActual) {
index aa162e92f67c90acd0de27a4a7de06fbc7a1bb9c..4b26ee4364ff3fb9666d8cb63ff4f3da3cd6bbed 100644 (file)
@@ -272,11 +272,6 @@ void Constructor::on_not_drag_begin(const Glib::RefPtr<Gdk::DragContext>& contex
 void Constructor::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, CItem *item)
 {
        context->set_icon(item->get_image(), 5, 5);
-       std::list<CItem *>::iterator i = listaItems.begin();
-       while ( i != listaItems.end() ){
-               (*i)->set_default_connector();
-               i++;
-       }
 }
 
 void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
@@ -382,6 +377,13 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
 void Constructor::on_btn_check_clicked()
 {
        std::list<CItem *>::iterator i = listaItems.begin();
+       while ( i != listaItems.end() ){
+               (*i)->set_default_connector();
+               (*i)->is_connected = false;
+               i++;
+       }
+       
+       i = listaItems.begin();
        if ( !listaItems.empty() ) {
                while ( i != listaItems.end() ) {
                        CItem *temp = *i;
index cd4ee57d73f591ea306a297c669b541514969a44..76f15a28a45782362013fa13bfe257b4fa496491 100644 (file)
@@ -83,6 +83,8 @@ void Drain::on_menu_popup_propiedades()
 void Drain::save(FILE *archivo)
 {
        char c_id[50], c_x[50], c_y[50], c_img[50];
+       Glib::ustring con0;
+       con0 = "\t\t\t<entrada>"+get_other_name(connect_vec[0].id_dest)+"</entrada>\n";
        sprintf(c_x,"\t\t<x>%d</x>\n",x);
        sprintf(c_y,"\t\t<y>%d</y>\n",y);
        sprintf(c_id,"%d",ID);
@@ -91,6 +93,7 @@ void Drain::save(FILE *archivo)
        dato = "\t<drenaje nombre=\""+name+"\" id=\"";
        dato += c_id;
        dato += "\">\n";
+       dato += "\t\t<conector>\n"+con0+"\t\t</conector>\n";
        dato += c_img;
        dato += c_x; 
        dato += c_y;
@@ -100,21 +103,26 @@ void Drain::save(FILE *archivo)
 
 bool Drain::check_connection()
 {
+       CItem *_item0;
        ConnectorType temp;
        switch (get_img_actual()) {
                case 0:
-                       temp = is_other_connection_area( get_position_x()+16 , get_position_y() -5);
+                       temp = is_other_connection_area( get_position_x()+16 , get_position_y() -5,& _item0);
                        break;  
                case 1:
-                       temp = is_other_connection_area( get_position_x()+image->get_width() + 5, get_position_y()+16);
+                       temp = is_other_connection_area( get_position_x()+image->get_width() + 5, get_position_y()+16,& _item0);
                        break;
                case 2:
-                       temp = is_other_connection_area( get_position_x()+16, get_position_y()+image->get_height()+5);
+                       temp = is_other_connection_area( get_position_x()+16, get_position_y()+image->get_height()+5, &_item0);
                        break;
                case 3:         
-                       temp = is_other_connection_area( get_position_x()-5, get_position_y()+16);
+                       temp = is_other_connection_area( get_position_x()-5, get_position_y()+16,& _item0);
        }
-       return ( is_connected = (temp == OUT) );
+       if ( is_connected = (temp == OUT) ) {
+               connect_vec[0].id_dest = _item0->get_id();
+               return is_connected;
+       }
+       return is_connected;
 }
 
 ConnectorType Drain::get_connector_type(int _a, int _b)
index b759ea7649450e25c5bf48465126740336deffa7..4035ad704609d055cad2e96d9919ee3e4bda6c50 100644 (file)
@@ -91,6 +91,15 @@ void Exclusa::save(FILE *archivo)
 {
        char c_id[50], c_est[50], c_x[50], c_y[50], c_img[50];
        int est;
+       Glib::ustring  con0, con1;
+       if (connect_vec[0].type == IN)
+               con0 = "\t\t\t<entrada>"+get_other_name(connect_vec[0].id_dest)+"</entrada>\n";
+       else
+               con0 = "\t\t\t<salida>"+get_other_name(connect_vec[0].id_dest)+"</salida>\n";
+       if (connect_vec[1].type == IN) 
+               con1 = "\t\t\t<entrada>"+get_other_name(connect_vec[1].id_dest)+"</entrada>\n";
+       else
+               con1 = "\t\t\t<salida>"+get_other_name(connect_vec[1].id_dest)+"</salida>\n";
        sprintf(c_x,"\t\t<x>%d</x>\n",x);
        sprintf(c_y,"\t\t<y>%d</y>\n",y);
        sprintf(c_id,"%d",ID);
@@ -102,6 +111,7 @@ void Exclusa::save(FILE *archivo)
        dato = "\t<exclusa nombre=\""+name+"\" id=\"";
        dato += c_id;
        dato += "\">\n";
+       dato += "\t\t<conector>\n"+con0 + con1+"\t\t</conector>\n";
        dato += c_img;
        dato += c_est;
        dato += c_x; 
@@ -112,35 +122,40 @@ void Exclusa::save(FILE *archivo)
 
 bool Exclusa::check_connection()
 {
+       CItem *_item0, *_item1;
        switch (get_img_actual()) {
                        case 0:
-                               connect_vec[0].type =  is_other_connection_area( get_position_x()+16, get_position_y()-5);
-                               connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5);
+                               connect_vec[0].type =  is_other_connection_area( get_position_x()+16, get_position_y()-5, &_item0);
+                               connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5, &_item1);
                        break;          
                        case 1:
-                               connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16);
-                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
+                               connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16, &_item0);
+                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16,& _item1);
        }
-       if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
+       if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF ) {
+               connect_vec[0].id_dest = _item0->get_id();
+               connect_vec[1].id_dest = _item1->get_id();
                return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
-       else return false;
+       }
+       else return is_connected;
 }
 
 ConnectorType Exclusa::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); //pregunto que hay abajo
+                                       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);//pregunto que hay arriba.
+                                       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);//pregunto por la derecha
+                                       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); //pregunto por la izquierda.
+                                       return is_other_connection_area(get_position_x()-5, get_position_y()+16, &_item); //pregunto por la izquierda.
                }
        } else {
                switch (imgActual) {
index de9c4cd6ee5ab04a6a5a83d5fcfcf9268204211b..4bec05d93d57dcc623d4e12b1152914f63075e93 100644 (file)
@@ -87,6 +87,17 @@ Glib::ustring CItem::get_name()
        return name;
 }
 
+Glib::ustring CItem::get_other_name(int _id)
+{
+       std::list<CItem *>::iterator i = listaItems->begin();
+       while ( i != listaItems->end() ) {
+               if ( (*i)->get_id() == _id ) 
+                       return (*i)->get_name();
+               i++;
+       }
+       return name;
+}
+
 int CItem::get_img_actual()
 {
        return imgActual;
@@ -120,15 +131,17 @@ bool CItem::is_occupied_area(int _a, int _b)
                else return false;
 }
 
-ConnectorType CItem::is_other_connection_area(int _a, int _b)
+ConnectorType CItem::is_other_connection_area(int _a, int _b, CItem **_item)
 {
        ConnectorType temp2;
        std::list<CItem *>::iterator i = listaItems->begin();
        while ( i != listaItems->end() ) {
                CItem *temp = *i;
                if (temp != this) 
-                       if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF )
+                       if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF ) {
+                               *_item = temp;
                                return temp2;
+                       }
                i++;
        }
        return UNDEF;
index 10070b8b30379f00208447c54f2f62bf17ced0b5..64c504904e67d292e48c20d78f0762cb0fe2e018 100644 (file)
@@ -42,14 +42,15 @@ public:
        int get_position_y();
        int get_id();
        int get_img_actual();
-       Glib::ustring get_name();
        double get_caudal();
+       Glib::ustring get_name();
+       Glib::ustring get_other_name(int _id);
        void set_position(int _x, int _y);
        void set_id(int _id);
        void set_caudal(double _caudal);
        void set_name(Glib::ustring _name);
        bool is_occupied_area(int _a, int _b);
-       ConnectorType is_other_connection_area(int _a, int _b);
+       ConnectorType is_other_connection_area(int _a, int _b, CItem ** _item);
        virtual void save(FILE *archivo) = 0;
        virtual bool check_connection()=0;
        virtual void set_default_connector();   
index 7810e7c58fd4af51066d2eddaac309e48e35e3bf..b550ba5567a5769c4aed3f88726f5cdac65faf8d 100644 (file)
@@ -37,16 +37,30 @@ void ItemPtyWnd::on_btn_cancel_clicked()
 
 void ItemPtyWnd::on_rd_btn_union_clicked()
 {
+       Glib::ustring name;
+       char char_id[10];
+       sprintf(char_id,"%d",item->get_id());
+       name = "union";
+       name += char_id;
        item->connect_vec[0].type = IN;
        item->connect_vec[1].type = IN; 
        item->connect_vec[2].type = OUT;
+       item->set_name(name);
+       txt_item_name->set_text( item->get_name() );
        item->is_union = true;
 }
 
 void ItemPtyWnd::on_rd_btn_division_clicked()
 {
+       Glib::ustring name;
+       char char_id[10];
+       sprintf(char_id,"%d",item->get_id());
+       name = "division";
+       name += char_id;
        item->connect_vec[0].type = OUT;
        item->connect_vec[1].type = OUT;
        item->connect_vec[2].type = IN;
+       item->set_name(name);
+       txt_item_name->set_text( item->get_name() );
        item->is_union = false;
 }
index 515dc908d848c2df294bd75eab9fc10c99693bc5..b26cda1b73160586b5d102f33d840c0e4959b99d 100644 (file)
@@ -98,6 +98,9 @@ Gdk::Color Pump::get_liquid_color()
 void Pump::save(FILE *archivo)
 {
        char c_id[50], c_entrega[50], c_x[50], c_y[50], c_img[50], c_red[50], c_green[50], c_blue[50];
+       Glib::ustring con0;
+       
+       con0 = "\t\t\t<salida>"+get_other_name(connect_vec[0].id_dest)+"</salida>\n";
        sprintf(c_red,"\t\t\t<rojo>%d</rojo>\n",liquid_color.get_red());
        sprintf(c_green,"\t\t\t<verde>%d</verde>\n",liquid_color.get_green());
        sprintf(c_blue,"\t\t\t<azul>%d</azul>\n",liquid_color.get_blue());
@@ -111,11 +114,12 @@ void Pump::save(FILE *archivo)
        dato += c_id;
        dato += "\">\n";
        dato += c_entrega;
-       dato += "\t<color>\n";
+       dato += "\t\t<color>\n";
        dato += c_red;
        dato += c_green;
        dato += c_blue;
-       dato += "\t</color>\n";
+       dato += "\t\t</color>\n";
+       dato += "\t\t<conector>\n"+con0+"\t\t</conector>\n";
        dato += c_img;
        dato += c_x; 
        dato += c_y;
@@ -125,15 +129,20 @@ void Pump::save(FILE *archivo)
 
 bool Pump::check_connection()
 {
+       CItem * _item;
        ConnectorType temp;
        switch (get_img_actual()) {
                case 0:
-                       temp = is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16);
+                       temp = is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16,& _item);
                        break;
                case 1:
-                       temp =  is_other_connection_area( get_position_x() -5, get_position_y() +16);
+                       temp =  is_other_connection_area( get_position_x() -5, get_position_y() +16, &_item);
        }
-       return (is_connected = ( temp == IN) );
+        if (is_connected = ( temp == IN) ) {
+                connect_vec[0].id_dest = _item->get_id();
+                return is_connected;
+        }
+        return is_connected;
 }
 
 ConnectorType Pump::get_connector_type(int _a, int _b)
index 4804849f998c131bb09e2463e5e13bc05c5a4497..32b32804eda2f8b144d356b98c6d2fa4c967552e 100644 (file)
@@ -80,6 +80,15 @@ void Splitter::on_menu_popup_propiedades()
 void Splitter::save(FILE *archivo)
 {
        char c_id[50], c_caudal[50], c_x[50], c_y[50], c_img[50];
+       Glib::ustring  con0, con1;
+       if (connect_vec[0].type == IN)
+               con0 = "\t\t\t<entrada>"+get_other_name(connect_vec[0].id_dest)+"</entrada>\n";
+       else
+               con0 = "\t\t\t<salida>"+get_other_name(connect_vec[0].id_dest)+"</salida>\n";
+       if (connect_vec[1].type == IN) 
+               con1 = "\t\t\t<entrada>"+get_other_name(connect_vec[1].id_dest)+"</entrada>\n";
+       else
+               con1 = "\t\t\t<salida>"+get_other_name(connect_vec[1].id_dest)+"</salida>\n";
        sprintf(c_x,"\t\t<x>%d</x>\n",x);
        sprintf(c_y,"\t\t<y>%d</y>\n",y);
        sprintf(c_id,"%d",ID);
@@ -90,6 +99,7 @@ void Splitter::save(FILE *archivo)
        dato += c_id;
        dato += "\">\n";
        dato += c_caudal;
+       dato += "\t\t<conector>\n"+con0 + con1+"\t\t</conector>\n";
        dato += c_img;
        dato += c_x; 
        dato += c_y;
@@ -99,55 +109,60 @@ void Splitter::save(FILE *archivo)
 
 bool Splitter::check_connection()
 {
+       CItem *_item0, *_item1;
        switch (get_img_actual()) {
                        case 0:
-                               connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16); //arriba-izquierda h
-                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5);//abajo-derecha v
+                               connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16, &_item0); //arriba-izquierda h
+                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5, &_item1);//abajo-derecha v
                                break;  
                        case 1:
-                               connect_vec[0].type = is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5);//arriba-derecha v
-                               connect_vec[1].type = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16);//abajo-izquierda h
+                               connect_vec[0].type = is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5,& _item0);//arriba-derecha v
+                               connect_vec[1].type = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16, &_item1);//abajo-izquierda h
                                break;
                        case 2:
-                               connect_vec[1].type = is_other_connection_area( get_position_x() + 16, get_position_y() - 5);//arriba-izquierda v
-                               connect_vec[0].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height() - 16); //abajo-derecha h
+                               connect_vec[1].type = is_other_connection_area( get_position_x() + 16, get_position_y() - 5, &_item1);//arriba-izquierda v
+                               connect_vec[0].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height() - 16, &_item0); //abajo-derecha h
                                break;
                        case 3:
-                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16);//arriba-derecha h
-                               connect_vec[0].type = is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5); //abajo-izquierda v
+                               connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16,& _item1);//arriba-derecha h
+                               connect_vec[0].type = is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5, &_item0); //abajo-izquierda v
        }
-       if (connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF) 
+       if (connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF) {
+               connect_vec[0].id_dest = _item0->get_id();
+               connect_vec[1].id_dest = _item1->get_id();
                return ( is_connected = (connect_vec[0].type == connect_vec[1].type) );
-       else return false;
+       }
+       else return is_connected;
 }
 
 ConnectorType Splitter::get_connector_type(int _a, int _b)
 {
+       CItem *_item;
        if ( ! is_connected ) {
                switch (imgActual) {
                        case 0: 
                                if ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) // arriba - izquierda h
-                                       return is_other_connection_area (get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5);
+                                       return is_other_connection_area (get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5, &_item);
                                if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) )//abajo-derecha v
-                                       return is_other_connection_area( get_position_x()-5, get_position_y()+16);
+                                       return is_other_connection_area( get_position_x()-5, get_position_y()+16,& _item);
                                break;
                        case 1:
                                 if ( (_a <= x+image->get_width()-10)&&(_a >= x+image->get_width()-22) && (_b <=y+10)&&(_b > y) ) //arriba-derecha v
-                                        return  is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16);
+                                        return  is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16, &_item);
                                 if ( (_a <= x+10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-izquierda h
-                                        return is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5);
+                                        return is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5, &_item);
                                 break;
                        case 2:
                                if ( (_a <= x+22)&&(_a >= x+10) && (_b <=y+10)&&(_b > y) ) //arriba-izquierda v
-                                       return is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height() - 16); 
+                                       return is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height() - 16, &_item); 
                                if  ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-derecha h
-                                       return is_other_connection_area( get_position_x() + 16, get_position_y() - 5);
+                                       return is_other_connection_area( get_position_x() + 16, get_position_y() - 5,& _item);
                                break;
                        case 3:
                                if ( (_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <=y+22)&&(_b>=y+10) ) //arriba-derecha h
-                                       return is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5);
+                                       return is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5, &_item);
                                if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) // abajo-izquierda v
-                                       return is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16);
+                                       return is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16,& _item);
                }
        } else {
                switch (imgActual) {
index 1311bd509c7336bb479da53d58ae1de6d140a7f1..4508b89cf792f8182280dc8905677c9f52182492 100644 (file)
@@ -87,9 +87,18 @@ void Union::on_menu_popup_propiedades()
 void Union::save(FILE *archivo)
 {
        char c_id[50], c_caudal[50], c_x[50], c_y[50], c_img[50];
-       Glib::ustring c_type;   
-       if ( is_union ) c_type = "\t\t<tipo>union</tipo>\n";
-       else c_type = "\t\t<tipo>division</tipo>\n";
+       Glib::ustring  con0, con1, con2, c_type;
+       if (is_union){
+               con0 = "\t\t\t<entrada>"+get_other_name(connect_vec[0].id_dest)+"</entrada>\n";
+               con1 = "\t\t\t<entrada>"+get_other_name(connect_vec[1].id_dest)+"</entrada>\n";
+               con2 = "\t\t\t<salida>"+get_other_name(connect_vec[2].id_dest)+"</salida>\n";
+               c_type = "\t\t<tipo>union</tipo>\n";
+       } else {
+               con0 = "\t\t\t<salida>"+get_other_name(connect_vec[0].id_dest)+"</salida>\n";
+               con1 = "\t\t\t<salida>"+get_other_name(connect_vec[1].id_dest)+"</salida>\n";
+               con2 = "\t\t\t<entrada>"+get_other_name(connect_vec[2].id_dest)+"</entrada>\n";         
+               c_type = "\t\t<tipo>division</tipo>\n";
+       }
        sprintf(c_x,"\t\t<x>%d</x>\n",x);
        sprintf(c_y,"\t\t<y>%d</y>\n",y);
        sprintf(c_id,"%d",ID);
@@ -100,6 +109,7 @@ void Union::save(FILE *archivo)
        dato += c_id;
        dato += "\">\n";
        dato += c_type;
+       dato += "\t\t<conector>\n"+con0+con1+con2+"\t\t</conector>\n";
        dato += c_caudal;
        dato += c_img;
        dato += c_x; 
@@ -110,36 +120,41 @@ void Union::save(FILE *archivo)
 
 bool Union::check_connection()
 {
+       CItem * _item0, *_item1, *_item2;
        ConnectorType temp0, temp1, temp2;
        switch (get_img_actual()) {
                        case 0:
-                               temp0 = is_other_connection_area( get_position_x() - 5, get_position_y() +16);
-                               temp1 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
-                               temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+5);
+                               temp0 = is_other_connection_area( get_position_x() - 5, get_position_y() +16, &_item0);
+                               temp1 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item1);
+                               temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+5, &_item2);
                                break;
                        case 1:
-                               temp2 = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()/2);
-                               temp0 = is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()-5);
-                               temp1 = is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()+get_image()->get_height()+5);
+                               temp2 = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()/2, &_item2);
+                               temp0 = is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()-5, &_item0);
+                               temp1 = is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()+get_image()->get_height()+5,& _item1);
                                break;
                        case 2:
-                               temp1 = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16);
-                               temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()-5);
-                               temp0 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16);
+                               temp1 = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16,& _item1);
+                               temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()-5, &_item2);
+                               temp0 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16, &_item0);
                                break;
                        case 3:
-                               temp1 = is_other_connection_area( get_position_x()+16, get_position_y()-5);
-                               temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()/2);
-                               temp0 = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5);
+                               temp1 = is_other_connection_area( get_position_x()+16, get_position_y()-5, &_item1);
+                               temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()/2,& _item0);
+                               temp0 = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5, &_item1);
        }
        if ( is_union ) {
-               if ( temp0 == OUT && temp1 == OUT && temp2 == IN ) 
+               if ( temp0 == OUT && temp1 == OUT && temp2 == IN ) {
+                       connect_vec[0].id_dest = _item0->get_id();
+                       connect_vec[1].id_dest = _item1->get_id();
+                       connect_vec[2].id_dest = _item2->get_id();
                        return (is_connected = true);
+               }
        } else {
                if ( temp0 == IN && temp1 == IN && temp2 == OUT )
                        return (is_connected = true);
        }
-       return false;
+       return is_connected;
 }
 
 ConnectorType Union::get_connector_type(int _a, int _b)