From: Nicolás Dimov Date: Wed, 12 Nov 2003 17:55:52 +0000 (+0000) Subject: el conexionado se verifica pero hay casos en que falla, estaria bueno que hagan algun... X-Git-Tag: svn_import~308 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/07b9abd79bb3f097d8bf67d217d077a7da4b1e46 el conexionado se verifica pero hay casos en que falla, estaria bueno que hagan algunas pruebas para ver si entre todos podemos descubrir cual es el item que me trae problemas. me imagino que para poder descubrir esto tendrian que ver la implementacion, pero cualquier cosa se las cuento hoy a la noche, igual es facil pero medio ilegible. Otra cosa, mas que nada para Richard, los items te los mando conectados o los conectas vos??? a mi me parcee que si los conecto yo tendrias una tarea engorrosa menos en el cliente, decime vos.. nada mas --- diff --git a/Constructor/cistern.cpp b/Constructor/cistern.cpp index 71d8cce..02bbbcb 100644 --- a/Constructor/cistern.cpp +++ b/Constructor/cistern.cpp @@ -118,14 +118,26 @@ bool Cistern::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) && - is_other_occupied_area( get_position_x() + 10, get_position_y() - 10) ) + if ( is_other_connection_area( get_position_x()+get_image()->get_width() + 5 , get_position_y()+get_image()->get_height() -16) && + is_other_connection_area( get_position_x() + 16, get_position_y() - 5) ) return true; - break; case 1: - if ( is_other_occupied_area( get_position_x() -10, get_position_y()+get_image()->get_height()-10) && - is_other_occupied_area( get_position_x()+get_image()->get_width() - 10, get_position_y() - 10) ) + if ( is_other_connection_area( get_position_x() -5, get_position_y()+get_image()->get_height()-16) && + is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() - 5) ) return true; } return false; } + +bool Cistern::is_connection_area(int _a, int _b) +{ + switch (imgActual) { + case 0: if ( ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) ) || + ( (_a <= x+image->get_width()-1)&&(_a >=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) ) ) + return true; + case 1: if ( ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+10)&&(_b > y) ) || + ( (_a <= x +10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) ) ) + return true; + } + return false; +} diff --git a/Constructor/cistern.h b/Constructor/cistern.h index 1bb290c..c2d0f3c 100644 --- a/Constructor/cistern.h +++ b/Constructor/cistern.h @@ -14,11 +14,12 @@ class Cistern : public CItem { virtual void on_menu_popup_rotar(); virtual void on_menu_popup_propiedades(); void set_capacidad(double _cap); - double get_capacidad(); void set_contenido_inicial(double _ini); double get_contenido_inicial(); + double get_capacidad(); virtual void save(FILE *archivo); virtual bool check_connection(); + virtual bool is_connection_area(int _a, int _b); protected: double capacidad, contenido_inicial; Glib::RefPtr imageE; // 0 diff --git a/Constructor/conduct.cpp b/Constructor/conduct.cpp index 8c540e8..1a75aef 100644 --- a/Constructor/conduct.cpp +++ b/Constructor/conduct.cpp @@ -91,13 +91,28 @@ bool Conduct::check_connection() { switch (get_img_actual()) { case 0: - if ( is_other_occupied_area( get_position_x()+10, get_position_y()-10) && - 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()+16, get_position_y()-5) && + is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5) ) return true; break; case 1: - if ( is_other_occupied_area( get_position_x()-10, get_position_y()+10) && - 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()-5, get_position_y()+16) && + is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) ) + return true; + } + return false; +} + +bool Conduct::is_connection_area(int _a, int _b) +{ + switch (imgActual){ + case 0: + if ( ((_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 )) || + ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) ) + return true; + case 1: + if ( ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) || + ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) ) return true; } return false; diff --git a/Constructor/conduct.h b/Constructor/conduct.h index 4937caf..bb22740 100644 --- a/Constructor/conduct.h +++ b/Constructor/conduct.h @@ -12,6 +12,7 @@ class Conduct : public CItem { virtual void on_menu_popup_propiedades(); virtual void save(FILE *archivo); virtual bool check_connection(); + virtual bool is_connection_area(int _a, int _b); private: Glib::RefPtr imageN; // 0 Glib::RefPtr imageS; // 1 diff --git a/Constructor/exclusa.cpp b/Constructor/exclusa.cpp index c0348f8..e8547d6 100644 --- a/Constructor/exclusa.cpp +++ b/Constructor/exclusa.cpp @@ -55,6 +55,16 @@ bool Exclusa::on_button_press_event(GdkEventButton *event) return true; } +void Exclusa::set_estado(bool _state) +{ + estado = _state; +} + +bool Exclusa::get_estado() +{ + return estado; +} + void Exclusa::on_menu_popup_rotar() { GdkEventButton event; @@ -98,24 +108,29 @@ bool Exclusa::check_connection() { switch (get_img_actual()) { case 0: - if ( is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+10) && - is_other_occupied_area( get_position_x()-10, get_position_y() + 10) ) + if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) && + is_other_connection_area( get_position_x()-5, get_position_y() + 16) ) return true; break; case 1: - if ( is_other_occupied_area( get_position_x()+10, get_position_y()-10 ) && - 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()+16, get_position_y()-5 ) && + is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5) ) return true; } return false; } -void Exclusa::set_estado(bool _state) +bool Exclusa::is_connection_area(int _a, int _b) { - estado = _state; -} - -bool Exclusa::get_estado() -{ - return estado; + switch (imgActual){ + case 0: + if ( ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) || + ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) ) + return true; + case 1: + if ( ((_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 )) || + ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) ) + return true; + } + return false; } diff --git a/Constructor/exclusa.h b/Constructor/exclusa.h index 31e21a4..86a5c1c 100644 --- a/Constructor/exclusa.h +++ b/Constructor/exclusa.h @@ -14,6 +14,7 @@ class Exclusa : public CItem { virtual void on_menu_popup_propiedades(); virtual void save(FILE *archivo); virtual bool check_connection(); + virtual bool is_connection_area(int _a, int _b); void set_estado(bool _state); bool get_estado(); private: diff --git a/Constructor/item.cpp b/Constructor/item.cpp index 31d955d..5eb5721 100644 --- a/Constructor/item.cpp +++ b/Constructor/item.cpp @@ -138,12 +138,12 @@ bool CItem::is_occupied_area(int _a, int _b) else return false; } -bool CItem::is_other_occupied_area(int _a, int _b) +bool CItem::is_other_connection_area(int _a, int _b) { std::list::iterator i = listaItems->begin(); while ( i != listaItems->end() ){ CItem *temp = *i; - if ( temp->is_occupied_area(_a,_b) ) + if ( temp->is_connection_area(_a,_b) ) return true; i++; } diff --git a/Constructor/item.h b/Constructor/item.h index facb96d..5b8b583 100644 --- a/Constructor/item.h +++ b/Constructor/item.h @@ -38,9 +38,10 @@ public: void set_conector_in(int _in); void set_conector_out(int _out); bool is_occupied_area(int _a, int _b); - bool is_other_occupied_area(int _a, int _b); + bool is_other_connection_area(int _a, int _b); virtual void save(FILE *archivo) = 0; virtual bool check_connection()=0; + virtual bool is_connection_area(int _a, int _b)=0; Glib::ustring get_name(); WorkPlace *workplace; Gtk::Entry *combo_entry; diff --git a/Constructor/pump.cpp b/Constructor/pump.cpp index 9ff057d..719a1f9 100644 --- a/Constructor/pump.cpp +++ b/Constructor/pump.cpp @@ -105,12 +105,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() +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; +} diff --git a/Constructor/pump.h b/Constructor/pump.h index 6c47b1a..17a4748 100644 --- a/Constructor/pump.h +++ b/Constructor/pump.h @@ -17,6 +17,7 @@ class Pump : public CItem { double get_entrega(); virtual void save(FILE *archivo); virtual bool check_connection(); + virtual bool is_connection_area(int _a, int _b); protected: double entrega; Glib::RefPtr imageE; // 0 diff --git a/Constructor/splitter.cpp b/Constructor/splitter.cpp index 3e17b49..c7ca0e6 100644 --- a/Constructor/splitter.cpp +++ b/Constructor/splitter.cpp @@ -96,24 +96,43 @@ bool Splitter::check_connection() { switch (get_img_actual()) { case 0: - if ( is_other_occupied_area( get_position_x()-10, get_position_y()+10) && - 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()-5, get_position_y()+16) && + is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5) ) return true; break; case 1: - if ( is_other_occupied_area( get_position_x()+get_image()->get_width() - 10, get_position_y() -10) && - is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()-10) ) + if ( is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5) && + is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16) ) return true; break; case 2: - if ( is_other_occupied_area( get_position_x() + 10, get_position_y() -10) && - 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() + 16, get_position_y() -5) && + is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16) ) return true; break; case 3: - if ( is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y() +10) && - is_other_occupied_area( get_position_x() + 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) && + is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) ) return true; } return false; } + +bool Splitter::is_connection_area(int _a, int _b) +{ + switch (imgActual) { + case 0: if ( ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) || + ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) ) + return true; + case 1: if ( ( (_a <= x+image->get_width()-10)&&(_a >= x+image->get_width()-22) && (_b <=y+10)&&(_b > y) ) || + ( (_a <= x+10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) ) + return true; + case 2: if ( ( (_a <= x+22)&&(_a >= x+10) && (_b <=y+10)&&(_b > y) ) || + ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) ) + return true; + case 3: if ( ( (_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <=y+22)&&(_b>=y+10) ) || + ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) ) + return true; + } + return false; +} diff --git a/Constructor/splitter.h b/Constructor/splitter.h index 206aa24..a3942a6 100644 --- a/Constructor/splitter.h +++ b/Constructor/splitter.h @@ -12,6 +12,7 @@ class Splitter : public CItem { virtual void on_menu_popup_propiedades(); virtual void save(FILE *archivo); virtual bool check_connection(); + virtual bool is_connection_area(int _a, int _b); private: Glib::RefPtr imageN; // 0 Glib::RefPtr imageS; // 1 diff --git a/Constructor/union.cpp b/Constructor/union.cpp index cb0a6c4..e422133 100644 --- a/Constructor/union.cpp +++ b/Constructor/union.cpp @@ -97,28 +97,51 @@ bool Union::check_connection() { switch (get_img_actual()) { case 0: - if ( is_other_occupied_area( get_position_x() - 10, get_position_y() +10) && - is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+10) && - is_other_occupied_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+10) ) + if ( is_other_connection_area( get_position_x() - 5, get_position_y() +16) && + is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) && + is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+5) ) return true; break; case 1: - if ( is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()/2) && - is_other_occupied_area( get_position_x()+get_image()->get_width()-10, get_position_y()-10) && - 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()-5, get_position_y()+get_image()->get_height()/2) && + is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()-5) && + is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()+get_image()->get_height()+5) ) return true; break; case 2: - if ( is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()-10) && - is_other_occupied_area( get_position_x()+get_image()->get_width()/2, get_position_y()-10) && - 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()-5, get_position_y()+get_image()->get_height()-16) && + is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()-5) && + is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16) ) return true; break; case 3: - if ( is_other_occupied_area( get_position_x()+10, get_position_y()-10) && - is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+get_image()->get_height()/2) && - is_other_occupied_area( get_position_x()+10, get_position_y()+get_image()->get_height()+10) ) + if ( is_other_connection_area( get_position_x()+16, get_position_y()-5) && + is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()/2) && + is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5) ) return true; } return false; } + +bool Union::is_connection_area(int _a, int _b) +{ + switch ( imgActual) { + case 0: if ( ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10)) || + ((_a <= x+image->get_width()-1) && (_a >= x+image->get_width()-10)&&(_b <= y+22) && (_b >= y+10)) || + ((_a <= x+image->get_width()/2 + 5)&&( _a>= x+image->get_width()/2 - 5) && (_b<=y+image->get_height()-1)&&(_b >= y+image->get_height()-10)) ) + return true; + case 1: if ( ((_a <= x+image->get_width()-10) && (_a >= x+image->get_width() -22) && (_b<= y + 10) && (_b > y )) || + ((_a <= x +10) && (_a > x )&&(_b <= y+image->get_height()/2+5 ) && (_b >= y+image->get_height()/2-5)) || + ((_a <= x+image->get_width() - 10)&&( _a>= x+image->get_width()-22) && (_b<=y+image->get_height()-1)&&(_b >= y+image->get_height()-10)) ) + return true; + case 2: if ( ((_a <= x+10) && (_a > x+1) && (_b<= y+image->get_height()-1) && (_b >= y+image->get_height()-10)) || + ((_a <= x+image->get_width()-1) && (_a >= x+image->get_width()-10)&&(_b <= y+image->get_height()-10) && (_b >= y+image->get_height()-22)) || + ((_a <= x+image->get_width()/2 + 5)&&( _a>= x+image->get_width()/2 - 5) && (_b<=y+10)&&(_b > y)) ) + return true; + case 3: if ( ((_a <= x+22) && (_a >= x+10) && (_b<= y + 10) && (_b > y )) || + ((_a <= x+22) && (_a >= x+10 )&&(_b <= y+image->get_height()-1 ) && (_b >= y+image->get_height()+10)) || + ((_a <= x+image->get_width() -1)&&( _a>= x+image->get_width()-10) && (_b<=y+image->get_height()/2+5)&&(_b >= y+image->get_height()/2-5)) ) + return true; + } + return false; +} diff --git a/Constructor/union.h b/Constructor/union.h index 2376c79..12c3566 100644 --- a/Constructor/union.h +++ b/Constructor/union.h @@ -13,6 +13,7 @@ class Union : public CItem { virtual void on_menu_popup_propiedades(); virtual void save(FILE *archivo); virtual bool check_connection(); + virtual bool is_connection_area(int _a, int _b); private: Glib::RefPtr imageN; // 0 Glib::RefPtr imageS; // 1