X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/d53ded00c10a30a17c7f0aad90acca933a7f4db9..6983220ff84632481c1628720fe15b8f3ac1c9cb:/Constructor/pump.cpp?ds=sidebyside
diff --git a/Constructor/pump.cpp b/Constructor/pump.cpp
index c2f2edb..b26cda1 100644
--- a/Constructor/pump.cpp
+++ b/Constructor/pump.cpp
@@ -14,6 +14,11 @@ Pump::Pump()
ref->get_widget_derived("pump_pty_wnd",pump_pty_wnd);
pump_pty_wnd->pump = this;
name = "bomba";
+
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = OUT;
+ connect_vec.push_back(temp);
}
Pump::~Pump()
@@ -93,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"+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());
@@ -106,11 +114,12 @@ void Pump::save(FILE *archivo)
dato += c_id;
dato += "\">\n";
dato += c_entrega;
- dato += "\t\n";
+ dato += "\t\t\n";
dato += c_red;
dato += c_green;
dato += c_blue;
- dato += "\t\n";
+ dato += "\t\t\n";
+ dato += "\t\t\n"+con0+"\t\t\n";
dato += c_img;
dato += c_x;
dato += c_y;
@@ -120,25 +129,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;
}