- 2 bombas, una union y un drenaje se conectan bien
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];
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());
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());
dato += "\">\n";
dato += c_cap;
dato += c_ini;
dato += "\">\n";
dato += c_cap;
dato += c_ini;
+ dato += "\t\t<color>\n";
dato += c_red;
dato += c_green;
dato += c_blue;
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;
dato += c_img;
dato += c_x;
dato += c_y;
bool Cistern::check_connection()
{
bool Cistern::check_connection()
{
+ CItem * _item, *_item1;
ConnectorType temp0, temp1;
switch (get_img_actual()) {
case 0:
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);
- 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 = true);
void Conduct::save(FILE *archivo)
{
char c_id[50], c_caudal[50], c_x[50], c_y[50], c_img[50];
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);
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);
dato += c_id;
dato += "\">\n";
dato += c_caudal;
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;
dato += c_img;
dato += c_x;
dato += c_y;
bool Conduct::check_connection()
{
bool Conduct::check_connection()
{
+ CItem *_item0, *_item1;
switch (get_img_actual()) {
case 0:
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);
- 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) );
return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
+ }
+ else return is_connected;
}
ConnectorType Conduct::get_connector_type(int _a, int _b)
}
ConnectorType Conduct::get_connector_type(int _a, int _b)
if ( ! is_connected ) {
switch (imgActual) {
case 0:
if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
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
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
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
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) {
}
} else {
switch (imgActual) {
void Constructor::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, CItem *item)
{
context->set_icon(item->get_image(), 5, 5);
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)
}
void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
void Constructor::on_btn_check_clicked()
{
std::list<CItem *>::iterator i = listaItems.begin();
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;
if ( !listaItems.empty() ) {
while ( i != listaItems.end() ) {
CItem *temp = *i;
void Drain::save(FILE *archivo)
{
char c_id[50], c_x[50], c_y[50], c_img[50];
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);
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);
dato = "\t<drenaje nombre=\""+name+"\" id=\"";
dato += c_id;
dato += "\">\n";
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;
dato += c_img;
dato += c_x;
dato += c_y;
bool Drain::check_connection()
{
bool Drain::check_connection()
{
ConnectorType temp;
switch (get_img_actual()) {
case 0:
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);
- 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);
- 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);
- 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)
}
ConnectorType Drain::get_connector_type(int _a, int _b)
{
char c_id[50], c_est[50], c_x[50], c_y[50], c_img[50];
int est;
{
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);
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);
dato = "\t<exclusa nombre=\""+name+"\" id=\"";
dato += c_id;
dato += "\">\n";
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;
dato += c_img;
dato += c_est;
dato += c_x;
bool Exclusa::check_connection()
{
bool Exclusa::check_connection()
{
+ CItem *_item0, *_item1;
switch (get_img_actual()) {
case 0:
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);
- 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) );
return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
+ }
+ else return is_connected;
}
ConnectorType Exclusa::get_connector_type(int _a, int _b)
{
}
ConnectorType Exclusa::get_connector_type(int _a, int _b)
{
if ( ! is_connected ) {
switch (imgActual) {
case 0:
if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
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
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
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
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) {
}
} else {
switch (imgActual) {
+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;
int CItem::get_img_actual()
{
return imgActual;
-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)
{
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;
int get_position_y();
int get_id();
int get_img_actual();
int get_position_y();
int get_id();
int get_img_actual();
- Glib::ustring get_name();
+ 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);
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();
virtual void save(FILE *archivo) = 0;
virtual bool check_connection()=0;
virtual void set_default_connector();
void ItemPtyWnd::on_rd_btn_union_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->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()
{
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->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;
}
item->is_union = false;
}
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];
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());
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());
dato += c_id;
dato += "\">\n";
dato += c_entrega;
dato += c_id;
dato += "\">\n";
dato += c_entrega;
+ dato += "\t\t<color>\n";
dato += c_red;
dato += c_green;
dato += c_blue;
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;
dato += c_img;
dato += c_x;
dato += c_y;
bool Pump::check_connection()
{
bool Pump::check_connection()
{
ConnectorType temp;
switch (get_img_actual()) {
case 0:
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);
- 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)
}
ConnectorType Pump::get_connector_type(int _a, int _b)
void Splitter::save(FILE *archivo)
{
char c_id[50], c_caudal[50], c_x[50], c_y[50], c_img[50];
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);
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);
dato += c_id;
dato += "\">\n";
dato += c_caudal;
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;
dato += c_img;
dato += c_x;
dato += c_y;
bool Splitter::check_connection()
{
bool Splitter::check_connection()
{
+ CItem *_item0, *_item1;
switch (get_img_actual()) {
case 0:
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
- 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
- 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
- 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) );
return ( is_connected = (connect_vec[0].type == connect_vec[1].type) );
+ }
+ else return is_connected;
}
ConnectorType Splitter::get_connector_type(int _a, int _b)
{
}
ConnectorType Splitter::get_connector_type(int _a, int _b)
{
if ( ! is_connected ) {
switch (imgActual) {
case 0:
if ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) // arriba - izquierda h
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
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
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
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
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
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
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
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) {
}
} else {
switch (imgActual) {
void Union::save(FILE *archivo)
{
char c_id[50], c_caudal[50], c_x[50], c_y[50], c_img[50];
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);
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);
dato += c_id;
dato += "\">\n";
dato += c_type;
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;
dato += c_caudal;
dato += c_img;
dato += c_x;
bool Union::check_connection()
{
bool Union::check_connection()
{
+ CItem * _item0, *_item1, *_item2;
ConnectorType temp0, temp1, temp2;
switch (get_img_actual()) {
case 0:
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);
- 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);
- 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);
- 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 ( 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);
return (is_connected = true);
} else {
if ( temp0 == IN && temp1 == IN && temp2 == OUT )
return (is_connected = true);
}
} else {
if ( temp0 == IN && temp1 == IN && temp2 == OUT )
return (is_connected = true);
}
}
ConnectorType Union::get_connector_type(int _a, int _b)
}
ConnectorType Union::get_connector_type(int _a, int _b)