]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
cambios drasticos producen cuelgues obvios, etapa de revision, pueden mirarlo libremente
authorNicolás Dimov <ndimov@gmail.com>
Mon, 17 Nov 2003 00:04:14 +0000 (00:04 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Mon, 17 Nov 2003 00:04:14 +0000 (00:04 +0000)
36 files changed:
Constructor/and.cpp
Constructor/and.h
Constructor/cistern.cpp
Constructor/cistern.h
Constructor/cisternptywnd.cpp
Constructor/cisternptywnd.h
Constructor/conduct.cpp
Constructor/conduct.h
Constructor/constructor.cpp
Constructor/constructor.glade
Constructor/constructor.h
Constructor/drain.cpp [new file with mode: 0644]
Constructor/drain.h [new file with mode: 0644]
Constructor/drain_e.png [new file with mode: 0644]
Constructor/drain_n.png [new file with mode: 0644]
Constructor/drain_o.png [new file with mode: 0644]
Constructor/drain_s.png [new file with mode: 0644]
Constructor/exclusa.cpp
Constructor/exclusa.h
Constructor/item.cpp
Constructor/item.h
Constructor/itemptywnd.cpp
Constructor/itemptywnd.h
Constructor/not.cpp
Constructor/not.h
Constructor/or.cpp
Constructor/or.h
Constructor/propertywnd.h
Constructor/pump.cpp
Constructor/pump.h
Constructor/pumpptywnd.cpp
Constructor/pumpptywnd.h
Constructor/splitter.cpp
Constructor/splitter.h
Constructor/union.cpp
Constructor/union.h

index debe5f5bac5a7c7c6b64caf78716f53a7984906f..768390a5792a38048e5d79e731a2e1d2a0b27e00 100644 (file)
@@ -66,30 +66,29 @@ void And::save(FILE *archivo)
 // CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 bool And::check_connection()
 {
 // CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 bool And::check_connection()
 {
-       switch (get_img_actual()) {
+       /*switch (get_img_actual()) {
                        case 0:
                                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;                            
                        case 0:
                                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_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;
                        case 1:
                                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_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;
                        case 2:
                                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_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;
        }
                        case 3:
                                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;
+       return false;*/
+       return true;
 }
 
 }
 
+/*
 bool And::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
 bool And::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
@@ -108,3 +107,4 @@ bool And::is_connection_area(int _a, int _b)
        }
        return false;
 }
        }
        return false;
 }
+*/
index cca48a10b03468b45d488f5dde2d2b48bcbff472..28956687f458777755d0656a18a340eb63eede8d 100644 (file)
@@ -11,7 +11,7 @@ class And : public CItem {
                virtual void on_menu_popup_rotar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_rotar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+//             virtual bool is_connection_area(int _a, int _b);
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index 88eae2de4e82aaa32b97502637bdd159ce99fcce..b42f690dba6a90d968207cbd0a71ccd019ba7936 100644 (file)
@@ -15,6 +15,13 @@ Cistern::Cistern()
        cistern_pty_wnd->cistern = this;
        cistern_pty_wnd->set_title("Propiedades del Tanque");   
        name = "tanque";
        cistern_pty_wnd->cistern = this;
        cistern_pty_wnd->set_title("Propiedades del Tanque");   
        name = "tanque";
+       
+       Connector temp;
+       temp.id_dest = -1;
+       temp.type = IN;
+       connect_vec.push_back(temp); // entrada arriba
+       temp.type = OUT;
+       connect_vec.push_back(temp); // salida abajo
 }
 
 Cistern::~Cistern()
 }
 
 Cistern::~Cistern()
@@ -134,28 +141,54 @@ void Cistern::save(FILE *archivo)
 
 bool Cistern::check_connection()
 {
 
 bool Cistern::check_connection()
 {
+       ConnectorType temp0, temp1;
        switch (get_img_actual()) {
                case 0:
        switch (get_img_actual()) {
                case 0:
-                       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;                            
+                       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);
+                       break;
                case 1:
                case 1:
-                       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;
+                       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);
        }
        }
-       return false;
+       if (temp0 == OUT && temp1 == IN)
+               return (is_connected = true);
+       return is_connected;
 }
 
 }
 
-bool Cistern::is_connection_area(int _a, int _b)
+ConnectorType Cistern::get_connector_type(int _a, int _b)
+{
+       switch (imgActual) {
+               case 0: if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) )
+                                               return connect_vec[0].type;
+                                       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) )
+                                               return connect_vec[1].type;
+                                       break;
+               case 1: if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+10)&&(_b > y) )
+                                               return connect_vec[0].type;
+                                       if ( (_a <= x +10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) )
+                                               return connect_vec[1].type;
+       }
+       return UNDEF;
+}
+       
+/*
+ConnectorType Cistern::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
 {
        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;
+               case 0: 
+                       if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) )
+                               return connect_vec[0].type;
+                       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) )
+                               return connect_vec[1].type;
+                       break;
+               case 1: 
+                       if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+10)&&(_b > y) )
+                               return connect_vec[0].type;
+                       if ( (_a <= x +10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) )
+                               return connect_vec[1].type;
+                       break;
        }
        }
-       return false;
+       return UNDEF;
 }
 }
+*/
index 006555495a1ec4ada7039fba5c7863ff5da624f1..67184c2841de892d08e7650d4cd971e72828e1bf 100644 (file)
@@ -21,7 +21,8 @@ class Cistern : public CItem {
                Gdk::Color get_liquid_color();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                Gdk::Color get_liquid_color();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+//             virtual ConnectorType is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);       
        protected:
                double capacidad, contenido_inicial;
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
        protected:
                double capacidad, contenido_inicial;
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
index e5ca32d1f744359fc1df70aec548bb906970dbf1..12617e2da23d283bde1e39ea956f3e106f768226 100644 (file)
@@ -7,6 +7,8 @@ CisternPtyWnd::CisternPtyWnd(BaseObjectType* cobject, const Glib::RefPtr<Gnome::
        refGlade->get_widget("spin_inicial", spin_inicial);
        refGlade->get_widget("txt_cistern_name", txt_cistern_name);
        refGlade->get_widget("btn_select_color", btn_select_color);             
        refGlade->get_widget("spin_inicial", spin_inicial);
        refGlade->get_widget("txt_cistern_name", txt_cistern_name);
        refGlade->get_widget("btn_select_color", btn_select_color);             
+       refGlade->get_widget("color_preview",color_preview);
+       
        Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "color_select_dlg");
        ref->get_widget("color_select_dlg",color_select_dlg);
        ref->get_widget("dlg_select_color_cancel",dlg_select_color_cancel);
        Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "color_select_dlg");
        ref->get_widget("color_select_dlg",color_select_dlg);
        ref->get_widget("dlg_select_color_cancel",dlg_select_color_cancel);
@@ -49,5 +51,6 @@ void CisternPtyWnd::on_dlg_select_color_cancel_clicked()
 void CisternPtyWnd::on_dlg_select_color_ok_clicked()
 {
        cistern->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
 void CisternPtyWnd::on_dlg_select_color_ok_clicked()
 {
        cistern->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
+       color_preview->modify_bg( Gtk::STATE_NORMAL , cistern->get_liquid_color() );
        color_select_dlg->hide();
 }
        color_select_dlg->hide();
 }
index 81af75c70ac6b813c986e3db45d3cb71291277cd..276e889f5e7c26f08c0ec85f1eb292aca9a6bef8 100644 (file)
@@ -14,6 +14,7 @@ class CisternPtyWnd : public PropertyWnd {
                Gtk::Button  *btn_select_color, *dlg_select_color_ok, *dlg_select_color_cancel;
                Gtk::Entry *txt_cistern_name;
                Gtk::ColorSelectionDialog *color_select_dlg;
                Gtk::Button  *btn_select_color, *dlg_select_color_ok, *dlg_select_color_cancel;
                Gtk::Entry *txt_cistern_name;
                Gtk::ColorSelectionDialog *color_select_dlg;
+               Gtk::DrawingArea *color_preview;
                virtual void on_btn_accept_clicked();
                virtual void on_btn_apply_clicked();
                virtual void on_btn_select_color_clicked();
                virtual void on_btn_accept_clicked();
                virtual void on_btn_apply_clicked();
                virtual void on_btn_select_color_clicked();
index 9b2e31fcbf459580c20a609a546259930f9382f8..c2ca140992ac9995c3b0bfb0ea33c42cd4c9ec5d 100644 (file)
@@ -10,6 +10,11 @@ Conduct::Conduct()
        set_size_request(image->get_width(), image->get_height());
        property_wnd->set_title("Propiedades del Tubo");
        name="tubo";
        set_size_request(image->get_width(), image->get_height());
        property_wnd->set_title("Propiedades del Tubo");
        name="tubo";
+       Connector temp;
+       temp.id_dest = -1;
+       temp.type = UNDEF;
+       connect_vec.push_back(temp);
+       connect_vec.push_back(temp);
 }
 
 Conduct::~Conduct()
 }
 
 Conduct::~Conduct()
@@ -91,17 +96,55 @@ bool Conduct::check_connection()
 {
        switch (get_img_actual()) {
                        case 0:
 {
        switch (get_img_actual()) {
                        case 0:
-                               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;                            
+                               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);
+                       break;          
                        case 1:
                        case 1:
-                               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;
+                               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);
        }
        }
-       return false;
+       if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
+               return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
+       else return false;
 }
 
 }
 
+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
+                                       return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5); //pregunto que hay 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.
+                               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
+                               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.
+               }
+       } else {
+               switch (imgActual) {
+                       case 0: 
+                               if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
+                                       return connect_vec[0].type;
+                               if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo
+                                       return connect_vec[1].type;
+                               break;
+                       case 1:
+                               if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
+                                       return connect_vec[0].type;
+                               if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
+                                       return connect_vec[1].type;
+               }
+       }
+       return UNDEF;
+}
+/*si no estoy conectado pregunto por el del otro lado, y ahi puedo setear los dos
+ *si ya estoy devuelvo.
+*/
+/*
 bool Conduct::is_connection_area(int _a, int _b)
 {
        switch (imgActual){
 bool Conduct::is_connection_area(int _a, int _b)
 {
        switch (imgActual){
@@ -116,3 +159,4 @@ bool Conduct::is_connection_area(int _a, int _b)
        }
        return false;
 }
        }
        return false;
 }
+*/
index bb227405404af8a8af59f7b7baf435b6afa07cbd..21773ed414b1473570f2e3353728a9ed18468ef7 100644 (file)
@@ -12,7 +12,8 @@ class Conduct : public CItem {
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+//             virtual bool is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index deb918d6e0dc93aeede3e880b527459b5a1a75c9..8aa6655ecfa92f64a998a259bf07adf369ebdab0 100644 (file)
@@ -11,6 +11,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        ico_codo  = Gdk::Pixbuf::create_from_file("codo_o.png");
        ico_tanque  = Gdk::Pixbuf::create_from_file("tanque_e.png");
        ico_exclusa = Gdk::Pixbuf::create_from_file("exclusa_h.png");
        ico_codo  = Gdk::Pixbuf::create_from_file("codo_o.png");
        ico_tanque  = Gdk::Pixbuf::create_from_file("tanque_e.png");
        ico_exclusa = Gdk::Pixbuf::create_from_file("exclusa_h.png");
+       ico_drain = Gdk::Pixbuf::create_from_file("drain_n.png");
        ico_bomba = Gdk::Pixbuf::create_from_file("bomba_e.png");
        ico_and = Gdk::Pixbuf::create_from_file("and_e.png");
        ico_or = Gdk::Pixbuf::create_from_file("or_e.png");
        ico_bomba = Gdk::Pixbuf::create_from_file("bomba_e.png");
        ico_and = Gdk::Pixbuf::create_from_file("and_e.png");
        ico_or = Gdk::Pixbuf::create_from_file("or_e.png");
@@ -22,6 +23,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        refGlade->get_widget("btn_tanque",btn_tanque);
        refGlade->get_widget("btn_bomba", btn_bomba);
        refGlade->get_widget("btn_exclusa", btn_exclusa);
        refGlade->get_widget("btn_tanque",btn_tanque);
        refGlade->get_widget("btn_bomba", btn_bomba);
        refGlade->get_widget("btn_exclusa", btn_exclusa);
+       refGlade->get_widget("btn_drain", btn_drain);
        refGlade->get_widget("btn_and", btn_and);
        refGlade->get_widget("btn_or", btn_or);
        refGlade->get_widget("btn_not", btn_not);
        refGlade->get_widget("btn_and", btn_and);
        refGlade->get_widget("btn_or", btn_or);
        refGlade->get_widget("btn_not", btn_not);
@@ -49,6 +51,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        btn_codo->drag_source_set(listTargets);
        btn_tanque->drag_source_set(listTargets);
        btn_bomba->drag_source_set(listTargets);
        btn_codo->drag_source_set(listTargets);
        btn_tanque->drag_source_set(listTargets);
        btn_bomba->drag_source_set(listTargets);
+       btn_drain->drag_source_set(listTargets);
        btn_exclusa->drag_source_set(listTargets);
        btn_and->drag_source_set(listTargets);
        btn_or->drag_source_set(listTargets);
        btn_exclusa->drag_source_set(listTargets);
        btn_and->drag_source_set(listTargets);
        btn_or->drag_source_set(listTargets);
@@ -60,6 +63,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        btn_y->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_y_drag_get));
        btn_codo->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_codo_drag_get));
        btn_tanque->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_tanque_drag_get));
        btn_y->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_y_drag_get));
        btn_codo->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_codo_drag_get));
        btn_tanque->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_tanque_drag_get));
+       btn_drain->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_drain_drag_get));
        btn_and->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_and_drag_get));
        btn_or->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_or_drag_get));
        btn_not->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_not_drag_get));
        btn_and->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_and_drag_get));
        btn_or->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_or_drag_get));
        btn_not->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_not_drag_get));
@@ -83,6 +87,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        btn_tanque->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_tanque_drag_begin));
        btn_bomba->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_bomba_drag_begin));
        btn_exclusa->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_exclusa_drag_begin));
        btn_tanque->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_tanque_drag_begin));
        btn_bomba->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_bomba_drag_begin));
        btn_exclusa->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_exclusa_drag_begin));
+       btn_drain->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_drain_drag_begin));
        btn_and->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_and_drag_begin));
        btn_or->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_or_drag_begin));
        btn_not->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_not_drag_begin));
        btn_and->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_and_drag_begin));
        btn_or->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_or_drag_begin));
        btn_not->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_not_drag_begin));
@@ -133,6 +138,11 @@ void Constructor::on_btn_exclusa_drag_get(const Glib::RefPtr<Gdk::DragContext>&
        gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"exclusa_h.png",15);
 }
 
        gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"exclusa_h.png",15);
 }
 
+void Constructor::on_btn_drain_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
+{
+       gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"drain_n.png",11);
+}
+
 void Constructor::on_btn_and_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
 {
        gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"and_e.png",9);
 void Constructor::on_btn_and_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
 {
        gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"and_e.png",9);
@@ -185,6 +195,7 @@ void Constructor::on_btn_file_ok_clicked()
        std::list<CItem *>::iterator i = listaItems.begin();
        std::string file_name = file_selection->get_filename();
        if ( (archivo = fopen( file_name.c_str(), "w+")) != NULL ){
        std::list<CItem *>::iterator i = listaItems.begin();
        std::string file_name = file_selection->get_filename();
        if ( (archivo = fopen( file_name.c_str(), "w+")) != NULL ){
+               fprintf(archivo, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n");
                fprintf (archivo,"<planta>\n");
                while ( i != listaItems.end() ){
                        CItem *temp = *i;
                fprintf (archivo,"<planta>\n");
                while ( i != listaItems.end() ){
                        CItem *temp = *i;
@@ -238,6 +249,11 @@ void Constructor::on_exclusa_drag_begin(const Glib::RefPtr<Gdk::DragContext>& co
        context->set_icon(ico_exclusa, 5, 5); 
 }
 
        context->set_icon(ico_exclusa, 5, 5); 
 }
 
+void Constructor::on_drain_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+       context->set_icon(ico_drain, 5, 5); 
+}
+
 void Constructor::on_and_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
 {
        context->set_icon(ico_and, 5, 5); 
 void Constructor::on_and_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
 {
        context->set_icon(ico_and, 5, 5); 
@@ -313,15 +329,17 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                                                                                                a =new Pump();
                                                                                                        else if (strcmp((const char *)selection_data->data, "exclusa_h.png")==0) 
                                                                                                                a = new Exclusa();
                                                                                                a =new Pump();
                                                                                                        else if (strcmp((const char *)selection_data->data, "exclusa_h.png")==0) 
                                                                                                                a = new Exclusa();
-                                                                                                                       else if (strcmp((const char *)selection_data->data, "and_e.png")==0) 
-                                                                                                                               a = new And();
-                                                                                                                                       else if (strcmp((const char *)selection_data->data, "or_e.png")==0) 
-                                                                                                                                               a = new Or();
-                                                                                                                                                       else if (strcmp((const char *)selection_data->data, "not_e.png")==0) 
-                                                                                                                                                               a = new Not();  
+                                                                                                                       else if (strcmp((const char *)selection_data->data, "drain_n.png")==0) 
+                                                                                                                               a = new Drain();
+                                                                                                                                       else if (strcmp((const char *)selection_data->data, "and_e.png")==0) 
+                                                                                                                                               a = new And();
+                                                                                                                                                       else if (strcmp((const char *)selection_data->data, "or_e.png")==0) 
+                                                                                                                                                               a = new Or();
+                                                                                                                                                                       else if (strcmp((const char *)selection_data->data, "not_e.png")==0) 
+                                                                                                                                                                               a = new Not();  
                
                        char char_id[10];
                
                        char char_id[10];
-                       sprintf(char_id," %d",id);
+                       sprintf(char_id,"%d",id);
                        a->set_id(++id);                
                        a->set_name( a->get_name()+char_id );
                        if ( can_drop(a, i*32, j*32) ) {
                        a->set_id(++id);                
                        a->set_name( a->get_name()+char_id );
                        if ( can_drop(a, i*32, j*32) ) {
index cf1bea92d6da3383b67c38191f54846c7efe03b0..5deafe93ffa0ecb5938816ca03bc85d7a8bea9c5 100644 (file)
@@ -4,8 +4,8 @@
 <glade-interface>
 
 <widget class="GtkWindow" id="wnd_constructor">
 <glade-interface>
 
 <widget class="GtkWindow" id="wnd_constructor">
-  <property name="width_request">640</property>
-  <property name="height_request">573</property>
+  <property name="width_request">738</property>
+  <property name="height_request">689</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Constuctor</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Constuctor</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
                          </child>
                        </widget>
                      </child>
                          </child>
                        </widget>
                      </child>
+
+                     <child>
+                       <widget class="GtkButton" id="btn_drain">
+                         <property name="visible">True</property>
+                         <property name="can_default">True</property>
+                         <property name="can_focus">True</property>
+                         <property name="relief">GTK_RELIEF_NORMAL</property>
+
+                         <child>
+                           <widget class="GtkAlignment" id="alignment8">
+                             <property name="visible">True</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xscale">0</property>
+                             <property name="yscale">0</property>
+
+                             <child>
+                               <widget class="GtkHBox" id="hbox10">
+                                 <property name="visible">True</property>
+                                 <property name="homogeneous">False</property>
+                                 <property name="spacing">2</property>
+
+                                 <child>
+                                   <widget class="GtkImage" id="image17">
+                                     <property name="visible">True</property>
+                                     <property name="pixbuf">drain_n.png</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+                               </widget>
+                             </child>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
                    </widget>
                    <packing>
                      <property name="padding">0</property>
                    </widget>
                    <packing>
                      <property name="padding">0</property>
 </widget>
 
 <widget class="GtkDialog" id="cistern_pty_wnd">
 </widget>
 
 <widget class="GtkDialog" id="cistern_pty_wnd">
-  <property name="width_request">272</property>
+  <property name="width_request">304</property>
   <property name="height_request">182</property>
   <property name="title" translatable="yes">Propiedades del Tanque</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="height_request">182</property>
   <property name="title" translatable="yes">Propiedades del Tanque</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
              <property name="y_options"></property>
            </packing>
          </child>
              <property name="y_options"></property>
            </packing>
          </child>
+
+         <child>
+           <widget class="GtkDrawingArea" id="color_preview">
+             <property name="visible">True</property>
+           </widget>
+           <packing>
+             <property name="left_attach">1</property>
+             <property name="right_attach">2</property>
+             <property name="top_attach">3</property>
+             <property name="bottom_attach">4</property>
+             <property name="x_options">fill</property>
+             <property name="y_options">fill</property>
+           </packing>
+         </child>
        </widget>
        <packing>
          <property name="padding">0</property>
        </widget>
        <packing>
          <property name="padding">0</property>
          </child>
 
          <child>
          </child>
 
          <child>
-           <widget class="GtkLabel" id="lbl_property">
+           <widget class="GtkLabel" id="lb_max_fluid">
              <property name="visible">True</property>
              <property name="label" translatable="yes">Flujo Máximo</property>
              <property name="use_underline">False</property>
              <property name="visible">True</property>
              <property name="label" translatable="yes">Flujo Máximo</property>
              <property name="use_underline">False</property>
              <property name="y_options"></property>
            </packing>
          </child>
              <property name="y_options"></property>
            </packing>
          </child>
+
+         <child>
+           <widget class="GtkDrawingArea" id="color_preview">
+             <property name="visible">True</property>
+           </widget>
+           <packing>
+             <property name="left_attach">1</property>
+             <property name="right_attach">2</property>
+             <property name="top_attach">2</property>
+             <property name="bottom_attach">3</property>
+             <property name="x_options">fill</property>
+             <property name="y_options">fill</property>
+           </packing>
+         </child>
        </widget>
        <packing>
          <property name="padding">10</property>
        </widget>
        <packing>
          <property name="padding">10</property>
index b9297fb77b039ececdd90ae460a07c1eb428da9c..aa15f54020d5df1cc99bda0d8b0845fbd2b62365 100644 (file)
@@ -21,6 +21,7 @@
 #include "cistern.h"
 #include "exclusa.h"
 #include "pump.h"
 #include "cistern.h"
 #include "exclusa.h"
 #include "pump.h"
+#include "drain.h"
 #include "and.h"
 #include "or.h"
 #include "not.h"
 #include "and.h"
 #include "or.h"
 #include "not.h"
@@ -34,7 +35,7 @@ class Constructor : public Gtk::Window {
        protected: 
        int id;
                // / defino los elementos de la ventana.
        protected: 
        int id;
                // / defino los elementos de la ventana.
-       Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_bomba, *btn_exclusa, *btn_file_ok, *btn_file_cancel, *btn_check, *btn_dlg_close,
+       Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_bomba, *btn_exclusa, *btn_drain, *btn_file_ok, *btn_file_cancel, *btn_check, *btn_dlg_close,
                                                *btn_and, *btn_or, *btn_not;
        Gtk::ImageMenuItem *main_menu_quit, *edit_menu_del, *main_menu_save;
        Gtk::CheckButton *chk_btn_logica;
                                                *btn_and, *btn_or, *btn_not;
        Gtk::ImageMenuItem *main_menu_quit, *edit_menu_del, *main_menu_save;
        Gtk::CheckButton *chk_btn_logica;
@@ -42,7 +43,7 @@ class Constructor : public Gtk::Window {
        Gtk::Entry *combo_entry;
        Gtk::Dialog *dlg_connect;
        Gtk::Label *dlg_label;
        Gtk::Entry *combo_entry;
        Gtk::Dialog *dlg_connect;
        Gtk::Label *dlg_label;
-       Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo, ico_tanque, ico_bomba, ico_exclusa, ico_and, ico_or, ico_not;
+       Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo, ico_tanque, ico_bomba, ico_exclusa, ico_drain, ico_and, ico_or, ico_not;
        Glib::RefPtr<Gdk::Pixbuf> ico_last;
        std::list<Gtk::TargetEntry> listTargets;
        std::list<CItem *> listaItems;
        Glib::RefPtr<Gdk::Pixbuf> ico_last;
        std::list<Gtk::TargetEntry> listTargets;
        std::list<CItem *> listaItems;
@@ -57,6 +58,7 @@ class Constructor : public Gtk::Window {
        virtual void on_btn_tanque_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_bomba_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_exclusa_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_tanque_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_bomba_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_exclusa_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
+       virtual void on_btn_drain_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_and_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_or_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_not_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_and_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_or_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_not_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
@@ -76,6 +78,7 @@ class Constructor : public Gtk::Window {
        virtual void on_tanque_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_bomba_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_exclusa_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_tanque_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_bomba_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_exclusa_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
+       virtual void on_drain_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_and_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_or_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_not_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_and_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_or_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
        virtual void on_not_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
diff --git a/Constructor/drain.cpp b/Constructor/drain.cpp
new file mode 100644 (file)
index 0000000..e1f0792
--- /dev/null
@@ -0,0 +1,140 @@
+#include "drain.h"
+
+Drain::Drain()
+{
+       imageE = Gdk::Pixbuf::create_from_file("drain_e.png");
+       imageO = Gdk::Pixbuf::create_from_file("drain_o.png");
+       imageN = Gdk::Pixbuf::create_from_file("drain_n.png");
+       imageS = Gdk::Pixbuf::create_from_file("drain_s.png");
+       null = Gdk::Pixbuf::create_from_file("null.png");
+       imgActual = 0;
+       image = imageN;
+       set_size_request(image->get_width(), image->get_height());
+       property_wnd->item = this;
+       property_wnd->lb_max_fluid->property_visible() = false;
+       property_wnd->spin_caudal->property_visible() = false;
+       property_wnd->set_title("Propiedades del Drenaje");     
+       name = "drenaje";
+       Connector temp;
+       temp.id_dest = -1;
+       temp.type = IN;
+       connect_vec.push_back(temp);
+}
+
+Drain::~Drain()
+{
+}
+
+bool Drain::on_button_press_event(GdkEventButton *event)
+{
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+               combo_entry->set_text(name);
+       
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
+               image = null; 
+               image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
+               imgActual++;
+               switch (imgActual) {
+                       case 1:
+                               image = imageE;
+                               break;
+                       case 2:
+                               image = imageS;
+                               break;
+                       case 3: 
+                               image = imageO;
+                               break;
+                       default: 
+                               imgActual = 0;
+                               image = imageN;                 
+               }
+               set_size_request(image->get_width(),image->get_height());
+               image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
+       }
+       
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
+               menu_popup.popup(event->button, event->time);
+                return true; //It has been handled.
+       }
+       
+       if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
+               property_wnd->txt_item_name->set_text( name );
+               property_wnd->show();
+       }               
+       return true;
+}
+
+void Drain::on_menu_popup_rotar()
+{
+       GdkEventButton event; 
+               event.type = GDK_BUTTON_PRESS;
+               event.button = 2;
+       Drain::on_button_press_event(&event);
+}
+
+void Drain::on_menu_popup_propiedades()
+{
+       GdkEventButton event; 
+               event.type = GDK_2BUTTON_PRESS;
+               event.button = 1;
+       Drain::on_button_press_event(&event);
+}
+
+void Drain::save(FILE *archivo)
+{
+       char c_id[50], c_x[50], c_y[50], c_img[50];
+       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_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
+       Glib::ustring dato;
+       dato = "\t<drenaje nombre=\""+name+"\" id=\"";
+       dato += c_id;
+       dato += "\">\n";
+       dato += c_img;
+       dato += c_x; 
+       dato += c_y;
+       dato += "\t</drenaje>\n";
+       fprintf(archivo,dato.c_str());  
+}
+
+bool Drain::check_connection()
+{
+       ConnectorType temp;
+       switch (get_img_actual()) {
+               case 0:
+                       temp = is_other_connection_area( get_position_x()+16 , get_position_y() -5);
+                       break;  
+               case 1:
+                       temp = is_other_connection_area( get_position_x()+image->get_width() + 5, get_position_y()+16);
+                       break;
+               case 2:
+                       temp = is_other_connection_area( get_position_x()+16, get_position_y()+image->get_height()+5);
+                       break;
+               case 3:         
+                       temp = is_other_connection_area( get_position_x()-5, get_position_y()+16);
+       }
+       return ( is_connected = (temp == OUT) );
+}
+
+ConnectorType Drain::get_connector_type(int _a, int _b)
+{
+       switch (imgActual) {
+               case 0: 
+                       if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) ) 
+                               return connect_vec[0].type;
+                       break;
+               case 1: 
+                       if ( (_a <= x+image->get_width() -1)&&(_a>=x+image->get_width()-10)&&(_b<=y+22)&&(_b >= y+10) )
+                               return connect_vec[0].type;
+                       break;
+               case 2:
+                       if ( (_a <= x +22)&&(_a >= x+10)&&(_b<=y+image->get_height() -1)&&(_b >=y+image->get_height()-10) ) 
+                               return connect_vec[0].type;
+                       break;
+               case 3:
+                       if ( (_a <= x+10)&&(_a >x)&&(_b<=y+22)&&(_b >=y+10) ) 
+                               return connect_vec[0].type;
+       }
+       return UNDEF;   
+}
diff --git a/Constructor/drain.h b/Constructor/drain.h
new file mode 100644 (file)
index 0000000..2c6ab7b
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _DRAIN_H_
+#define _DRAIN_H_
+
+#include <iostream>
+#include "item.h"
+
+
+class Drain : public CItem {
+       public:
+               Drain();
+               virtual ~Drain();
+               virtual bool on_button_press_event(GdkEventButton *event);
+               virtual void on_menu_popup_rotar();
+               virtual void on_menu_popup_propiedades();
+               double get_contenido_inicial();
+               double get_capacidad();
+               virtual void save(FILE *archivo);
+               virtual bool check_connection();
+               //virtual ConnectorType is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);
+       protected:
+               Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
+               Glib::RefPtr<Gdk::Pixbuf> imageO; // 1
+               Glib::RefPtr<Gdk::Pixbuf> imageN; // 1
+               Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
+               Glib::RefPtr<Gdk::Pixbuf> null; 
+};
+#endif
diff --git a/Constructor/drain_e.png b/Constructor/drain_e.png
new file mode 100644 (file)
index 0000000..bc3d60b
Binary files /dev/null and b/Constructor/drain_e.png differ
diff --git a/Constructor/drain_n.png b/Constructor/drain_n.png
new file mode 100644 (file)
index 0000000..2f11c9b
Binary files /dev/null and b/Constructor/drain_n.png differ
diff --git a/Constructor/drain_o.png b/Constructor/drain_o.png
new file mode 100644 (file)
index 0000000..9138db7
Binary files /dev/null and b/Constructor/drain_o.png differ
diff --git a/Constructor/drain_s.png b/Constructor/drain_s.png
new file mode 100644 (file)
index 0000000..8e8b9b5
Binary files /dev/null and b/Constructor/drain_s.png differ
index e8547d6961c8b31b0a96fe854add2407045bda86..6a386d14d2fc0509bd12be4429427b964b872581 100644 (file)
@@ -108,19 +108,55 @@ bool Exclusa::check_connection()
 {
        switch (get_img_actual()) {
                        case 0:
 {
        switch (get_img_actual()) {
                        case 0:
-                               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;
+                               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);
+                       break;          
                        case 1:
                        case 1:
-                               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;
+                               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);
        }
        }
-       return false;
+       if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
+               return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
+       else return false;
 }
 
 }
 
-bool Exclusa::is_connection_area(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
+                                       return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5); //pregunto que hay 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.
+                               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
+                               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.
+               }
+       } else {
+               switch (imgActual) {
+                       case 0: 
+                               if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
+                                       return connect_vec[0].type;
+                               if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo
+                                       return connect_vec[1].type;
+                               break;
+                       case 1:
+                               if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
+                                       return connect_vec[0].type;
+                               if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
+                                       return connect_vec[1].type;
+               }
+       }
+       return UNDEF;
+}
+/*si no estoy conectado pregunto por el del otro lado, y ahi puedo setear los dos
+ *si ya estoy devuelvo.
+*/
+/*bool Exclusa::is_connection_area(int _a, int _b)
 {
        switch (imgActual){
                case 0: 
 {
        switch (imgActual){
                case 0: 
@@ -134,3 +170,4 @@ bool Exclusa::is_connection_area(int _a, int _b)
        }
        return false;
 }
        }
        return false;
 }
+*/
index 86a5c1c01f41568e56d51397a7016e57dfb41d49..b65e6168147d10953c1035ef0ac1215ff3efc0f3 100644 (file)
@@ -14,7 +14,8 @@ class Exclusa : public CItem {
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+//             virtual ConnectorType is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);
                void set_estado(bool _state);
                bool get_estado();
        private:
                void set_estado(bool _state);
                bool get_estado();
        private:
index c08f894c7d1d6d354f50d623d3d54d288863854e..72f63930554a284452052d2515d066aede363fb6 100644 (file)
@@ -14,6 +14,7 @@ CItem::CItem()
        ref->get_widget_derived("item_pty_wnd",property_wnd);
        caudal_max = 0.0;
        is_union = true;
        ref->get_widget_derived("item_pty_wnd",property_wnd);
        caudal_max = 0.0;
        is_union = true;
+       is_connected = false;
        property_wnd->item = this;
        menu_image_propiedades.set(Gtk::Stock::PREFERENCES, Gtk::ICON_SIZE_MENU);
        menu_image_delete.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
        property_wnd->item = this;
        menu_image_propiedades.set(Gtk::Stock::PREFERENCES, Gtk::ICON_SIZE_MENU);
        menu_image_delete.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
@@ -60,37 +61,6 @@ void CItem::on_menu_popup_conectar()
 {
 }
 
 {
 }
 
-void CItem::set_position(int _x, int _y)
-{
-       this->x = _x;
-       this->y = _y;
-}
-
-void CItem::set_id(int _id)
-{
-       ID = _id;
-}
-
-void CItem::set_caudal(double _caudal)
-{
-        caudal_max = _caudal;
-}
-
-void CItem::set_name(Glib::ustring _name)
-{
-       name = _name;
-}
-
-void CItem::set_conector_in(int _in)
-{
-       conector_in = _in;
-}
-
-void CItem::set_conector_out(int _out)
-{
-       conector_out = _out;
-}
-
 int CItem::get_position_x()
 {
        return x;
 int CItem::get_position_x()
 {
        return x;
@@ -117,19 +87,30 @@ Glib::ustring CItem::get_name()
        return name;
 }
 
        return name;
 }
 
-int CItem::get_conector_in()
+int CItem::get_img_actual()
 {
 {
-       return conector_in;
+       return imgActual;
 }
 
 }
 
-int CItem::get_conector_out()
+void CItem::set_position(int _x, int _y)
 {
 {
-       return conector_out;
+       this->x = _x;
+       this->y = _y;
 }
 
 }
 
-int CItem::get_img_actual()
+void CItem::set_id(int _id)
 {
 {
-       return imgActual;
+       ID = _id;
+}
+
+void CItem::set_caudal(double _caudal)
+{
+        caudal_max = _caudal;
+}
+
+void CItem::set_name(Glib::ustring _name)
+{
+       name = _name;
 }
 
 bool CItem::is_occupied_area(int _a, int _b)
 }
 
 bool CItem::is_occupied_area(int _a, int _b)
@@ -139,14 +120,21 @@ bool CItem::is_occupied_area(int _a, int _b)
                else return false;
 }
 
                else return false;
 }
 
-bool CItem::is_other_connection_area(int _a, int _b)
+ConnectorType CItem::is_other_connection_area(int _a, int _b)
 {
 {
+       ConnectorType temp2;
        std::list<CItem *>::iterator i = listaItems->begin();
        std::list<CItem *>::iterator i = listaItems->begin();
-       while ( i != listaItems->end() ){
+       while ( i != listaItems->end() ) {
                CItem *temp = *i;
                CItem *temp = *i;
-               if ( temp->is_connection_area(_a,_b) )
-                       return true;
-               i++;
+               if (temp != this) {
+                       if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF )
+                               return temp2;
+                       i++;
+               }
        }
        }
-       return false;
+       return UNDEF;
+}
+ConnectorType CItem::get_connector_type( int _a, int _b )
+{
+       return UNDEF;
 }
 }
index 7c1e771e8c8643c0f85bc55a9de45d82d5637104..1654bf3dfda7171931e50136542f1e25da359ecd 100644 (file)
 #include <gtkmm/entry.h>
 #include "itemptywnd.h"
 
 #include <gtkmm/entry.h>
 #include "itemptywnd.h"
 
+typedef enum { NONE, RIGHT, LEFT, MIDDLE } ConnectorSide;
+typedef enum { UNDEF, IN, OUT } ConnectorType;
+
+class Connector {
+       public: 
+               int id_dest;
+               ConnectorType type;
+               Connector& operator= (Connector & c) {
+                       id_dest = c.id_dest;
+                       type = c.type;
+                       return *this;
+               }
+};
+
 class WorkPlace;
        
 class CItem:public Gtk::DrawingArea {
 class WorkPlace;
        
 class CItem:public Gtk::DrawingArea {
@@ -27,8 +41,6 @@ public:
        int get_position_x();
        int get_position_y();
        int get_id();
        int get_position_x();
        int get_position_y();
        int get_id();
-       int get_conector_in();
-       int get_conector_out();
        int get_img_actual();
        Glib::ustring get_name();
        double get_caudal();
        int get_img_actual();
        Glib::ustring get_name();
        double get_caudal();
@@ -36,20 +48,23 @@ public:
        void set_id(int _id);
        void set_caudal(double _caudal);
        void set_name(Glib::ustring _name);
        void set_id(int _id);
        void set_caudal(double _caudal);
        void set_name(Glib::ustring _name);
-       void set_conector_in(int _in);
-       void set_conector_out(int _out);
        bool is_occupied_area(int _a, int _b);
        bool is_occupied_area(int _a, int _b);
-       bool is_other_connection_area(int _a, int _b);
+       ConnectorType is_other_connection_area(int _a, int _b);
        virtual void save(FILE *archivo) = 0;
        virtual bool check_connection()=0;
        virtual void save(FILE *archivo) = 0;
        virtual bool check_connection()=0;
-       virtual bool is_connection_area(int _a, int _b)=0;
+//     virtual ConnectorType is_connection_area(int _a, int _b)=0;
+       virtual ConnectorType get_connector_type( int _a, int _b );
        WorkPlace *workplace;
        Gtk::Entry *combo_entry;
        std::list<CItem *> *listaItems;
        bool is_union;
        WorkPlace *workplace;
        Gtk::Entry *combo_entry;
        std::list<CItem *> *listaItems;
        bool is_union;
+       bool is_connected;
+       //  Hay que ocultarlo --- problemas con el get y el set!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+       //  0 = izquierda/arriba , 1 = derecha/abajo , 2 = medio.   tomando como referencia la imagen inicial de cada item cuando corresponda
+       std::vector<Connector> connect_vec;
 protected:
        int imgActual;
 protected:
        int imgActual;
-       int ID, conector_in, conector_out; 
+       int ID;
        Glib::ustring name;
        double caudal_max;
        Gtk::Menu menu_popup;
        Glib::ustring name;
        double caudal_max;
        Gtk::Menu menu_popup;
index 44d7392aa06d107cdd4f557203d423fffa790f7e..7810e7c58fd4af51066d2eddaac309e48e35e3bf 100644 (file)
@@ -8,7 +8,7 @@ ItemPtyWnd::ItemPtyWnd(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
        refGlade->get_widget("rd_btn_division", rd_btn_division);
        refGlade->get_widget("rd_btn_union", rd_btn_union);
        refGlade->get_widget("lb_type", lb_type);
        refGlade->get_widget("rd_btn_division", rd_btn_division);
        refGlade->get_widget("rd_btn_union", rd_btn_union);
        refGlade->get_widget("lb_type", lb_type);
-       
+       refGlade->get_widget("lb_max_fluid", lb_max_fluid);
        rd_btn_division->signal_clicked().connect(SigC::slot(*this,&ItemPtyWnd::on_rd_btn_division_clicked));
        rd_btn_union->signal_clicked().connect(SigC::slot(*this,&ItemPtyWnd::on_rd_btn_union_clicked));
 }
        rd_btn_division->signal_clicked().connect(SigC::slot(*this,&ItemPtyWnd::on_rd_btn_division_clicked));
        rd_btn_union->signal_clicked().connect(SigC::slot(*this,&ItemPtyWnd::on_rd_btn_union_clicked));
 }
@@ -37,10 +37,16 @@ void ItemPtyWnd::on_btn_cancel_clicked()
 
 void ItemPtyWnd::on_rd_btn_union_clicked()
 {
 
 void ItemPtyWnd::on_rd_btn_union_clicked()
 {
+       item->connect_vec[0].type = IN;
+       item->connect_vec[1].type = IN; 
+       item->connect_vec[2].type = OUT;
        item->is_union = true;
 }
 
 void ItemPtyWnd::on_rd_btn_division_clicked()
 {
        item->is_union = true;
 }
 
 void ItemPtyWnd::on_rd_btn_division_clicked()
 {
+       item->connect_vec[0].type = OUT;
+       item->connect_vec[1].type = OUT;
+       item->connect_vec[2].type = IN;
        item->is_union = false;
 }
        item->is_union = false;
 }
index 6f82c2226ab445a3d76e731e1b229b142f22f359..c8f4dd1649c967e804dbe0caa4b35a562c8f58ae 100644 (file)
@@ -9,7 +9,7 @@ class ItemPtyWnd : public PropertyWnd {
                virtual ~ItemPtyWnd();
                Gtk::SpinButton *spin_caudal;
                Gtk::RadioButton *rd_btn_union, *rd_btn_division;
                virtual ~ItemPtyWnd();
                Gtk::SpinButton *spin_caudal;
                Gtk::RadioButton *rd_btn_union, *rd_btn_division;
-               Gtk::Label *lb_type;
+               Gtk::Label *lb_type, *lb_max_fluid;
                Gtk::Entry *txt_item_name;
        protected:
                virtual void on_btn_cancel_clicked();
                Gtk::Entry *txt_item_name;
        protected:
                virtual void on_btn_cancel_clicked();
index 1107030ebbca29dd1d4e7a585e9393907f65e538..ca112fe5133f72ecebb92c71239b0e92af80615b 100644 (file)
@@ -66,7 +66,7 @@ void Not::save(FILE *archivo)
 // CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 bool Not::check_connection()
 {
 // CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 bool Not::check_connection()
 {
-       switch (get_img_actual()) {
+/*     switch (get_img_actual()) {
                        case 0:
                                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) )
                        case 0:
                                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) )
@@ -87,12 +87,14 @@ bool Not::check_connection()
                                         is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
                                        return true;
        }
                                         is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
                                        return true;
        }
-       return false;
+       return false;*/
+       return true;
 }
 
 }
 
+/*
 bool Not::is_connection_area(int _a, int _b)
 {
 bool Not::is_connection_area(int _a, int _b)
 {
-       switch (imgActual) {
+       /*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 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;
@@ -107,4 +109,6 @@ bool Not::is_connection_area(int _a, int _b)
                                                return true;
        }
        return false;
                                                return true;
        }
        return false;
+       return true;
 }
 }
+*/
index dd572fef36b6bdd3242a9f41c44769d7142bb264..4e0480ca6c12176ed2e8f7fc7daa6bc48318be5d 100644 (file)
@@ -11,7 +11,7 @@ class Not : public CItem {
                virtual void on_menu_popup_rotar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_rotar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+               //virtual bool is_connection_area(int _a, int _b);
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index d68dc6d9f9b2c4000ce20587948ab302bfe8f9a7..c162ecb45b6cd65932a49577e4327db75fd08e81 100644 (file)
@@ -66,7 +66,7 @@ void Or::save(FILE *archivo)
 // CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 bool Or::check_connection()
 {
 // CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 bool Or::check_connection()
 {
-       switch (get_img_actual()) {
+       /*switch (get_img_actual()) {
                        case 0:
                                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) )
                        case 0:
                                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) )
@@ -87,12 +87,14 @@ bool Or::check_connection()
                                         is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
                                        return true;
        }
                                         is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
                                        return true;
        }
-       return false;
+       return false;*/
+       return true;
 }
 
 }
 
+/*
 bool Or::is_connection_area(int _a, int _b)
 {
 bool Or::is_connection_area(int _a, int _b)
 {
-       switch (imgActual) {
+       /*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 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;
@@ -108,3 +110,4 @@ bool Or::is_connection_area(int _a, int _b)
        }
        return false;
 }
        }
        return false;
 }
+*/
index b0de3dad4cb284d996bb0872f00f1d483d23a4c8..617ab1b1b2c121b8938cece1585e6c8958bce69a 100644 (file)
@@ -11,7 +11,7 @@ class Or : public CItem {
                virtual void on_menu_popup_rotar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_rotar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+               //virtual ConnectorType is_connection_area(int _a, int _b);
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index 383552b3809b2ede30b0974e979614ea53fef75a..b510a2102c46ac21e62684650c301f3c117d2914 100644 (file)
@@ -6,6 +6,7 @@
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/entry.h>
 #include <gtkmm/colorselection.h>
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/entry.h>
 #include <gtkmm/colorselection.h>
+#include <gtkmm/drawingarea.h>
 #include <gdkmm.h>
 #include <libglademm.h>
 
 #include <gdkmm.h>
 #include <libglademm.h>
 
index c2f2edb22f8b187769f0d02ad2a709db515823fb..fbc09376ede292e6f4f25974bbbdba42cb75b5ed 100644 (file)
@@ -14,6 +14,11 @@ Pump::Pump()
        ref->get_widget_derived("pump_pty_wnd",pump_pty_wnd);
        pump_pty_wnd->pump = this;
        name = "bomba";
        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()
 }
 
 Pump::~Pump()
@@ -120,18 +125,31 @@ void Pump::save(FILE *archivo)
 
 bool Pump::check_connection()
 {
 
 bool Pump::check_connection()
 {
+       ConnectorType temp;
        switch (get_img_actual()) {
                case 0:
        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);
                        break;
                case 1:
                        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);
        }
        }
-       return false;
+       return (is_connected = ( temp == IN) );
 }
 
 }
 
+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) )  //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 UNDEF;
+}
+/*
 bool Pump::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
 bool Pump::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
@@ -142,3 +160,4 @@ bool Pump::is_connection_area(int _a, int _b)
        }
        return false;
 }
        }
        return false;
 }
+*/
index 0fd2d077faf8416ddff99bb9b0befe6586666a18..201475fbb433d5b58bdd3c446981e3030facb68e 100644 (file)
@@ -19,7 +19,7 @@ class Pump : public CItem {
                Gdk::Color get_liquid_color();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                Gdk::Color get_liquid_color();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);
        protected:
                double entrega;
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
        protected:
                double entrega;
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
index d4510f348e5783af3f371ca4353557f0388dfe44..cc5adba40d8bcb65fd280d5abc02f79b4664095f 100644 (file)
@@ -6,6 +6,7 @@ PumpPtyWnd::PumpPtyWnd(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
        refGlade->get_widget("btn_select_color",btn_select_color);
        refGlade->get_widget("spin_fluid",spin_fluid);
        refGlade->get_widget("txt_pump_name",txt_pump_name);
        refGlade->get_widget("btn_select_color",btn_select_color);
        refGlade->get_widget("spin_fluid",spin_fluid);
        refGlade->get_widget("txt_pump_name",txt_pump_name);
+       refGlade->get_widget("color_preview",color_preview);
        
        Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "color_select_dlg");
        ref->get_widget("color_select_dlg",color_select_dlg);
        
        Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "color_select_dlg");
        ref->get_widget("color_select_dlg",color_select_dlg);
@@ -47,7 +48,8 @@ void PumpPtyWnd::on_dlg_select_color_cancel_clicked()
 }
 
 void PumpPtyWnd::on_dlg_select_color_ok_clicked()
 }
 
 void PumpPtyWnd::on_dlg_select_color_ok_clicked()
-{
+{      
        pump->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
        pump->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
+       color_preview->modify_bg( Gtk::STATE_NORMAL , pump->get_liquid_color() );
        color_select_dlg->hide();
 }
        color_select_dlg->hide();
 }
index 5ad59ab11eea1dcb8a45d8c905b5faf6c1176581..296cddda87fdf4a467377b6743f7b9d8e51445aa 100644 (file)
@@ -14,6 +14,7 @@ class PumpPtyWnd : public PropertyWnd{
                Gtk::Entry *txt_pump_name;
                Gtk::Button *btn_select_color, *dlg_select_color_cancel, *dlg_select_color_ok;
                Gtk::ColorSelectionDialog *color_select_dlg;
                Gtk::Entry *txt_pump_name;
                Gtk::Button *btn_select_color, *dlg_select_color_cancel, *dlg_select_color_ok;
                Gtk::ColorSelectionDialog *color_select_dlg;
+               Gtk::DrawingArea *color_preview;
                virtual void on_btn_accept_clicked();
                virtual void on_btn_apply_clicked();
                virtual void on_btn_select_color_clicked();
                virtual void on_btn_accept_clicked();
                virtual void on_btn_apply_clicked();
                virtual void on_btn_select_color_clicked();
index c7ca0e6feeda1f8aaebce49ce4780dd6f4647807..2e11992c5839e09999e50d434677b39bcce96129 100644 (file)
@@ -12,6 +12,11 @@ Splitter::Splitter()
        set_size_request(image->get_width(), image->get_height());
        property_wnd->set_title("Propiedades del Codo");        
        name = "codo";
        set_size_request(image->get_width(), image->get_height());
        property_wnd->set_title("Propiedades del Codo");        
        name = "codo";
+       Connector temp;
+       temp.id_dest = -1;
+       temp.type = UNDEF;
+       connect_vec.push_back(temp);
+       connect_vec.push_back(temp);
 }
 
 Splitter::~Splitter()
 }
 
 Splitter::~Splitter()
@@ -96,28 +101,85 @@ bool Splitter::check_connection()
 {
        switch (get_img_actual()) {
                        case 0:
 {
        switch (get_img_actual()) {
                        case 0:
-                               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;                            
+                               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
                                break;  
                        case 1:
                                break;  
                        case 1:
-                               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;
+                               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
                                break;
                        case 2:
                                break;
                        case 2:
-                               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;
+                               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
                                break;
                        case 3:
                                break;
                        case 3:
-                               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;
+                               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
        }
        }
-       return false;
+       if (connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF) 
+               return ( is_connected = (connect_vec[0].type == connect_vec[1].type) );
+       else return false;
 }
 
 }
 
+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
+                                       return is_other_connection_area (get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5);
+                               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);
+                               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);
+                                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);
+                                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); 
+                               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);
+                               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);
+                               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);
+               }
+       } else {
+               switch (imgActual) {
+                       case 0: 
+                               if ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) // arriba - izquierda h
+                                       return connect_vec[0].type;
+                               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 connect_vec[1].type;
+                               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  connect_vec[0].type;
+                                if ( (_a <= x+10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-izquierda h
+                                        return connect_vec[1].type;
+                                break;
+                       case 2:
+                               if ( (_a <= x+22)&&(_a >= x+10) && (_b <=y+10)&&(_b > y) ) //arriba-izquierda v
+                                       return connect_vec[1].type;
+                               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 connect_vec[0].type;
+                               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 connect_vec[1].type;
+                               if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) // abajo-izquierda v
+                                       return connect_vec[0].type;
+               }
+       }
+       return UNDEF;
+}      
+
+/*
 bool Splitter::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
 bool Splitter::is_connection_area(int _a, int _b)
 {
        switch (imgActual) {
@@ -136,3 +198,4 @@ bool Splitter::is_connection_area(int _a, int _b)
        }
        return false;
 }
        }
        return false;
 }
+*/
index a3942a6939b07423d57d3e7031455d00ad418e4c..bcd13e43c4107b56d9be8c6efd66d1797e4141ff 100644 (file)
@@ -12,7 +12,8 @@ class Splitter : public CItem {
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+//             virtual ConnectorType is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index d0955bbd2e31c565b06e73b216a46fe99768e923..b7b97bd3d9e64bd322b7695676c68a87601e8437 100644 (file)
@@ -15,6 +15,13 @@ Union::Union()
        property_wnd->rd_btn_union->property_visible() = true;
        property_wnd->lb_type->property_visible() = true;
        name = "union";
        property_wnd->rd_btn_union->property_visible() = true;
        property_wnd->lb_type->property_visible() = true;
        name = "union";
+       Connector temp;
+       temp.id_dest = -1;
+       temp.type = IN;
+       connect_vec.push_back(temp); //izquierda
+       connect_vec.push_back(temp); //derecha
+       temp.type = OUT;
+       connect_vec.push_back(temp); //medio
 }
 
 Union::~Union()
 }
 
 Union::~Union()
@@ -103,38 +110,78 @@ void Union::save(FILE *archivo)
 
 bool Union::check_connection()
 {
 
 bool Union::check_connection()
 {
+       ConnectorType temp0, temp1, temp2;
        switch (get_img_actual()) {
                        case 0:
        switch (get_img_actual()) {
                        case 0:
-                               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;                            
+                               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);
                                break;
                        case 1:
                                break;
                        case 1:
-                               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;                            
+                               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);
                                break;
                        case 2:
                                break;
                        case 2:
-                               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;
+                               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);
                                break;
                        case 3:
                                break;
                        case 3:
-                               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;
+                               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);
        }
        }
-       return false;   
+       if ( is_union ) {
+               if ( temp0 == OUT && temp1 == OUT && temp2 == IN ) 
+                       return (is_connected = true);
+       } else {
+               if ( temp0 == IN && temp1 == IN && temp2 == OUT )
+                       return (is_connected = true);
+       }
+       return false;
+}
+
+ConnectorType Union::get_connector_type(int _a, int _b)
+{
+       switch ( imgActual) {
+               case 0: if ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10))
+                                               return connect_vec[0].type;
+                                       if ((_a <= x+image->get_width()-1) && (_a >= x+image->get_width()-10)&&(_b <= y+22) && (_b >= y+10))
+                                               return connect_vec[1].type;
+                                       if ((_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 connect_vec[2].type;
+                                       break;
+               case 1: if ((_a <= x+image->get_width()-10) && (_a >= x+image->get_width() -22) && (_b<= y + 10) && (_b > y ))
+                                               return connect_vec[0].type;
+                                       if ((_a <= x +10) && (_a > x )&&(_b <= y+image->get_height()/2+5 ) && (_b >= y+image->get_height()/2-5))
+                                               return connect_vec[2].type;
+                                       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))
+                                               return connect_vec[1].type;
+                                       break;
+               case 2: if ((_a <= x+10) && (_a > x) && (_b<= y+image->get_height()-10) && (_b >= y+image->get_height()-22))
+                                               return connect_vec[1].type;
+                                       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))
+                                               return connect_vec[0].type;
+                                       if ((_a <= x+image->get_width()/2 + 5)&&( _a>= x+image->get_width()/2 - 5) && (_b<=y+10)&&(_b > y))
+                                               return connect_vec[2].type;
+                                       break;
+               case 3: if ((_a <= x+22) && (_a >= x+10) && (_b<= y + 10) && (_b > y ))
+                                               return connect_vec[1].type;
+                                       if ((_a <= x+22) && (_a >= x+10 )&&(_b <= y+image->get_height()-1 ) && (_b >= y+image->get_height()-10))
+                                               return connect_vec[0].type;
+                                       if ((_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 connect_vec[2].type;
+       }
+       return UNDEF;
 }
 
 }
 
-bool Union::is_connection_area(int _a, int _b)
+/*
+ConnectorType Union::is_connection_area(int _a, int _b)
 {
        switch ( imgActual) {
 {
        switch ( imgActual) {
-               case 0: if ( ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10)) ||
+               case 0: if ( ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10))
+                                               retur
                                                  ((_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;
                                                  ((_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;
@@ -152,4 +199,4 @@ bool Union::is_connection_area(int _a, int _b)
                                                return true;
        }
        return false;
                                                return true;
        }
        return false;
-}
+}*/
index 12c35663b3bec984dfea4cfd026da9eec88d6463..18aba4f7056936e33c3797a9f55a9290a31398be 100644 (file)
@@ -13,7 +13,8 @@ class Union : public CItem {
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
-               virtual bool is_connection_area(int _a, int _b);
+               //virtual ConnectorType is_connection_area(int _a, int _b);
+               virtual ConnectorType get_connector_type(int _a, int _b);
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
        private:
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1