]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Constructor/pump.cpp
es precario pero se tiran los cablecitos, iupi
[z.facultad/75.42/plaqui.git] / Constructor / pump.cpp
index fbc09376ede292e6f4f25974bbbdba42cb75b5ed..664b55d094a712e825b2da5a5b0ec4b39cf58836 100644 (file)
@@ -27,8 +27,18 @@ Pump::~Pump()
 
 bool Pump::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       GdkEventExpose e;
+       t_line tmp_line;
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
+               if (CItem::logic_connect) {
+                       tmp_line.logic =  workplace->get_logic_item(CItem::quien);
+                       tmp_line.store = this;
+                       workplace->lista_lineas.push_back(tmp_line);
+                       workplace->on_expose_event(&e);
+               }
+               CItem::logic_connect = false;   
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
                image = null; 
@@ -98,6 +108,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 +124,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 +139,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)
@@ -149,15 +168,8 @@ ConnectorType Pump::get_connector_type(int _a, int _b)
        }
        return UNDEF;
 }
-/*
-bool Pump::is_connection_area(int _a, int _b)
+
+void Pump::set_default_connector()
 {
-       switch (imgActual) {
-               case 0: if ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+22)&&(_b > y) ) 
-                                               return true;
-               case 1: if ( (_a <= x+10)&&(_a > x)&&(_b<=y+22)&&(_b > y) ) 
-                                               return true;
-       }
-       return false;
+       connect_vec[0].type = OUT;
 }
-*/