]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Constructor/pump.cpp
-ahi borre lo que se me escapo
[z.facultad/75.42/plaqui.git] / Constructor / pump.cpp
index 51993a225eeeca7caf473960aa15f6621d195eb4..c2f2edb22f8b187769f0d02ad2a709db515823fb 100644 (file)
@@ -10,10 +10,9 @@ Pump::Pump()
        image = imageE;
        set_size_request(image->get_width(), image->get_height());
 
-       Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "item_pty_wnd");
-       ref->get_widget_derived("item_pty_wnd",pump_pty_wnd);
+       Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "pump_pty_wnd");
+       ref->get_widget_derived("pump_pty_wnd",pump_pty_wnd);
        pump_pty_wnd->pump = this;
-       pump_pty_wnd->set_title("Propiedades de la Bomba");     
        name = "bomba";
 }
 
@@ -48,8 +47,8 @@ bool Pump::on_button_press_event(GdkEventButton *event)
        }
        
        if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
-               pump_pty_wnd->spin_caudal->set_value( entrega );
-               pump_pty_wnd->txt_item_name->set_text( name );
+               pump_pty_wnd->spin_fluid->set_value( entrega );
+               pump_pty_wnd->txt_pump_name->set_text( name );
                pump_pty_wnd->show();
        }               
        return true;
@@ -76,14 +75,27 @@ void Pump::set_entrega(double _ent)
        entrega = _ent;
 }
 
+void Pump::set_liquid_color(Gdk::Color _color)
+{
+       liquid_color = _color;
+}
+
 double Pump::get_entrega()
 {
        return entrega;
 }
 
+Gdk::Color Pump::get_liquid_color()
+{
+       return liquid_color;
+}
+
 void Pump::save(FILE *archivo)
 {
-       char c_id[50], c_entrega[50], c_x[50], c_y[50], c_img[50];
+       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];
+       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());
        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);
@@ -94,10 +106,15 @@ void Pump::save(FILE *archivo)
        dato += c_id;
        dato += "\">\n";
        dato += c_entrega;
+       dato += "\t<color>\n";
+       dato += c_red;
+       dato += c_green;
+       dato += c_blue;
+       dato += "\t</color>\n";
        dato += c_img;
        dato += c_x; 
        dato += c_y;
-       dato += "\t</entrega>\n";
+       dato += "\t</bomba>\n";
        fprintf(archivo,dato.c_str());  
 }
 
@@ -105,12 +122,23 @@ bool Pump::check_connection()
 {
        switch (get_img_actual()) {
                case 0:
-                       if ( is_other_occupied_area( get_position_x()+get_image()->get_width()+10 , get_position_y()+get_image()->get_height() +10) )
+                       if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16) )
                                return true;                            
                        break;
                case 1:
-                       if ( is_other_occupied_area( get_position_x() -10, get_position_y() -10) )
+                       if ( is_other_connection_area( get_position_x() -5, get_position_y() +16) )
                                return true;
        }
        return false;
 }
+
+bool Pump::is_connection_area(int _a, int _b)
+{
+       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;
+}