]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
el conexionado se verifica pero hay casos en que falla, estaria bueno que hagan algun...
authorNicolás Dimov <ndimov@gmail.com>
Wed, 12 Nov 2003 17:55:52 +0000 (17:55 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Wed, 12 Nov 2003 17:55:52 +0000 (17:55 +0000)
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

14 files changed:
Constructor/cistern.cpp
Constructor/cistern.h
Constructor/conduct.cpp
Constructor/conduct.h
Constructor/exclusa.cpp
Constructor/exclusa.h
Constructor/item.cpp
Constructor/item.h
Constructor/pump.cpp
Constructor/pump.h
Constructor/splitter.cpp
Constructor/splitter.h
Constructor/union.cpp
Constructor/union.h

index 71d8cceb92fac1d70a6d1641fadb31019e0b4f19..02bbbcb36339c294e6e11330f0f5ced3f7a08581 100644 (file)
@@ -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;
+}
index 1bb290c4706e149d4148078181c50cdfae81ffb1..c2d0f3ccd4f4c9c9869ee1fdce967cdba054104b 100644 (file)
@@ -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<Gdk::Pixbuf> imageE; // 0 
index 8c540e82472778036102894c01401204a5d63b92..1a75aef33bfeab6c0d0a8f72b19201e2b68ad131 100644 (file)
@@ -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;
index 4937caf285b95cc17007a74f6f988bbca20b3a6b..bb227405404af8a8af59f7b7baf435b6afa07cbd 100644 (file)
@@ -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<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index c0348f8d3ceab52a334504e106d07b67db70a3f8..e8547d6961c8b31b0a96fe854add2407045bda86 100644 (file)
@@ -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;
 }
index 31e21a4e0f3e8c3fa7a3fdfe6f8572e97a78cb2c..86a5c1c01f41568e56d51397a7016e57dfb41d49 100644 (file)
@@ -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:
index 31d955dbebb8ea4faabfccc8aae3f8635fe2d8e4..5eb572146cd34ccc52e0b0e7e9ee3eb365810d43 100644 (file)
@@ -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<CItem *>::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++;
        }
index facb96d12b4be43b88125447a53fb380f9c43236..5b8b5836436cad54784d6da9d2095d7c29e4bcc1 100644 (file)
@@ -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;
index 9ff057d9d58e2d446b69ad496e3197ae7e981c3f..719a1f9c83a84967b69731da8f58e43abce8cd4d 100644 (file)
@@ -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;
+}
index 6c47b1ae85023e76f0c31d88d4c35ed469d8a52e..17a47488fbaafa6c78b4c7737e53ff9cc9356694 100644 (file)
@@ -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<Gdk::Pixbuf> imageE; // 0 
index 3e17b496007fdad123f6be4913a093bfc8517137..c7ca0e6feeda1f8aaebce49ce4780dd6f4647807 100644 (file)
@@ -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;
+}
index 206aa24db139cf5e98eaf721ff584b2277b9adba..a3942a6939b07423d57d3e7031455d00ad418e4c 100644 (file)
@@ -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<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index cb0a6c4aee0ff893460832bd0dff4ef5a939ab00..e422133aee9c647797cc7c73f7a78bbb16702145 100644 (file)
@@ -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;
+}
index 2376c79fa9de7ba6c57ac9698ee430a8a4dabb63..12c35663b3bec984dfea4cfd026da9eec88d6463 100644 (file)
@@ -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<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1