X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/07b9abd79bb3f097d8bf67d217d077a7da4b1e46..41db5fd837b5e51244fb37ae3e016cc630c3a872:/Constructor/pump.cpp diff --git a/Constructor/pump.cpp b/Constructor/pump.cpp index 719a1f9..664b55d 100644 --- a/Constructor/pump.cpp +++ b/Constructor/pump.cpp @@ -10,11 +10,15 @@ Pump::Pump() image = imageE; set_size_request(image->get_width(), image->get_height()); - Glib::RefPtr ref = Gnome::Glade::Xml::create("constructor.glade", "item_pty_wnd"); - ref->get_widget_derived("item_pty_wnd",pump_pty_wnd); + Glib::RefPtr 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"; + + Connector temp; + temp.id_dest = -1; + temp.type = OUT; + connect_vec.push_back(temp); } Pump::~Pump() @@ -23,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; @@ -48,8 +62,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 +90,30 @@ 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]; + Glib::ustring con0; + + con0 = "\t\t\t"+get_other_name(connect_vec[0].id_dest)+"\n"; + sprintf(c_red,"\t\t\t%d\n",liquid_color.get_red()); + sprintf(c_green,"\t\t\t%d\n",liquid_color.get_green()); + sprintf(c_blue,"\t\t\t%d\n",liquid_color.get_blue()); sprintf(c_x,"\t\t%d\n",x); sprintf(c_y,"\t\t%d\n",y); sprintf(c_id,"%d",ID); @@ -94,6 +124,12 @@ void Pump::save(FILE *archivo) dato += c_id; dato += "\">\n"; dato += c_entrega; + dato += "\t\t\n"; + dato += c_red; + dato += c_green; + dato += c_blue; + dato += "\t\t\n"; + dato += "\t\t\n"+con0+"\t\t\n"; dato += c_img; dato += c_x; dato += c_y; @@ -103,25 +139,37 @@ void Pump::save(FILE *archivo) bool Pump::check_connection() { + CItem * _item; + ConnectorType temp; switch (get_img_actual()) { case 0: - if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16) ) - return true; + temp = is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16,& _item); break; case 1: - if ( is_other_connection_area( get_position_x() -5, get_position_y() +16) ) - return true; + temp = is_other_connection_area( get_position_x() -5, get_position_y() +16, &_item); } - return false; + if (is_connected = ( temp == IN) ) { + connect_vec[0].id_dest = _item->get_id(); + return is_connected; + } + return is_connected; } -bool Pump::is_connection_area(int _a, int _b) +ConnectorType Pump::get_connector_type(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; + case 0: + if ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+22)&&(_b > y) ) //derecha. + return connect_vec[0].type; + break; + case 1: + if ( (_a <= x+10)&&(_a > x)&&(_b<=y+22)&&(_b > y) ) //izquierda + return connect_vec[0].type; } - return false; + return UNDEF; +} + +void Pump::set_default_connector() +{ + connect_vec[0].type = OUT; }