]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
-se pueden tirar cables de una manera mas comoda pero como diria TU SAM puede fallar...
authorNicolás Dimov <ndimov@gmail.com>
Wed, 19 Nov 2003 03:35:04 +0000 (03:35 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Wed, 19 Nov 2003 03:35:04 +0000 (03:35 +0000)
MODO DE USO
-accionar el boton logica
-click en una compuerta
-click en la entrada o salida de un item
esto es:
exclusa entrada: al medio y arriba (en el pingorcho)
salida: al medio y abajo
bomba entrada: (en el conector) la mitad superior
salida: mitad inferior
tanque entrada conector superior
salida conector inferior

todo esto es aproximado
igual se van a dar cuenta
ojo que las primeras lineas las tira en cualquier lado (no se por que)
pero cuando rota el item se acomodan

-Se cuelga bastante, asi que tengan cuidado
intenten eliminar lo menos posible

chauuu

14 files changed:
Constructor/include/cistern.h
Constructor/include/exclusa.h
Constructor/include/item.h
Constructor/include/pump.h
Constructor/include/workplace.h
Constructor/src/and.cpp
Constructor/src/cistern.cpp
Constructor/src/constructor.cpp
Constructor/src/exclusa.cpp
Constructor/src/item.cpp
Constructor/src/not.cpp
Constructor/src/or.cpp
Constructor/src/pump.cpp
Constructor/src/workplace.cpp

index 1c874eaa01b39a853ff829d289f1dcba06eb537f..793f2ba2922b33357bf4555ec96abdbce06266a5 100644 (file)
@@ -41,10 +41,25 @@ class Cistern : public CItem {
                */
                virtual ConnectorType get_connector_type(int _a, int _b);       
                
                */
                virtual ConnectorType get_connector_type(int _a, int _b);       
                
-               /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
+               /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la entrada.
                */
                */
-               virtual void get_logic_connect_position(int& _a, int& _b);
+               virtual void get_in_logic_connect_position(int& _a, int& _b);
+
+               /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la salida.
+               */              
+               virtual void get_out_logic_connect_position(int& _a, int& _b);
+
+               /**Actualiza la posicion de los conectores logicos ante un movimiento.
+               */
+               virtual void update_logic_position();
+               
+               /**Detecta si el click fue en el area de entrada o salida logica, devuelve UNDEF si no fue ninguna de las dos
+               */
+               ConnectorType detect_click_position(int _a, int _b);
        protected:
        protected:
+               /**Coordenadas de las entrada y salida logica.
+               */
+               int in_x, in_y, out_x, out_y;
                /**Atributos que definen su comportamiento
                */
                double capacidad, contenido_inicial;
                /**Atributos que definen su comportamiento
                */
                double capacidad, contenido_inicial;
index d2a673715bd49d61ec625010d556a4c4cdd65dca..34e2fe93371c144b771fe723b67ec3b975825e73 100644 (file)
@@ -31,15 +31,30 @@ class Exclusa : public CItem {
                */
                virtual ConnectorType get_connector_type(int _a, int _b);
                
                */
                virtual ConnectorType get_connector_type(int _a, int _b);
                
-               /**Los valores _a y _b se setean en el punto donde se deben conectar los cables logicos
+               /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la entrada.
                */
                */
-               virtual void get_logic_connect_position(int& _a, int& _b);
-               
+               virtual void get_in_logic_connect_position(int& _a, int& _b);
+
+               /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la salida.
+               */              
+               virtual void get_out_logic_connect_position(int& _a, int& _b);
+
+               /**Actualiza la posicion de los conectores logicos ante un movimiento.
+               */
+               virtual void update_logic_position();
+
+               /**Detecta si el click fue en el area de entrada o salida logica, devuelve UNDEF si no fue ninguna de las dos
+               */
+               ConnectorType detect_click_position(int _a, int _b);
+
                /**Funciones para obtener y setear sus propiedades
                */
                void set_estado(bool _state);
                bool get_estado();
                /**Funciones para obtener y setear sus propiedades
                */
                void set_estado(bool _state);
                bool get_estado();
-       private:
+       protected:
+               /**Coordenadas de las entrada y salida logica.
+               */
+               int in_x, in_y, out_x, out_y;
                /**Imagenes en sus 2 posiciones
                */
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                /**Imagenes en sus 2 posiciones
                */
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
index c7a4d4791b26786f8f1e9216bd1df9316f14f9a7..4763bcb230db8fe1c40850892b84d14e4ba3720c 100644 (file)
@@ -94,7 +94,10 @@ public:
        ///TODO: hacer abstractas estas funciones... en item no hacen nada....
        virtual void set_default_connector();   
        virtual ConnectorType get_connector_type( int _a, int _b );
        ///TODO: hacer abstractas estas funciones... en item no hacen nada....
        virtual void set_default_connector();   
        virtual ConnectorType get_connector_type( int _a, int _b );
-       virtual void get_logic_connect_position(int& _a, int& _b);
+       
+       virtual void get_in_logic_connect_position(int& _a, int& _b);
+       virtual void get_out_logic_connect_position(int& _a, int& _b);
+       virtual void update_logic_position();
        
        ///Puntero al area de trabajo de la ventana principal
        WorkPlace *workplace;
        
        ///Puntero al area de trabajo de la ventana principal
        WorkPlace *workplace;
@@ -119,7 +122,9 @@ public:
        
        ///Indica si puede realizarse la conexion logica con una compuerta
        static bool logic_connect;
        
        ///Indica si puede realizarse la conexion logica con una compuerta
        static bool logic_connect;
-       static int quien;
+       
+       ///Almacena el ID de la compuerta logica seleccionada
+       static int gate_id;
        
        /**Vector de connectores donde se mantiene la siguiente referencia:
         * indice 0 = "arriba/izquierda" para la exclusa, el tubo, el codo, el empalme y el tanque.
        
        /**Vector de connectores donde se mantiene la siguiente referencia:
         * indice 0 = "arriba/izquierda" para la exclusa, el tubo, el codo, el empalme y el tanque.
index 95cd6ab1238f20bd70ac3ab1ce43a6125a602bf7..dfe3452f8cbb2c4f40152276d7abfdcba2f8305e 100644 (file)
@@ -30,8 +30,16 @@ class Pump : public CItem {
                ///Devuelve el tipo de conector que posee en las coordenadas (_a,_b) segun su orientacion
                virtual ConnectorType get_connector_type(int _a, int _b);
                ///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
                ///Devuelve el tipo de conector que posee en las coordenadas (_a,_b) segun su orientacion
                virtual ConnectorType get_connector_type(int _a, int _b);
                ///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
-               virtual void get_logic_connect_position(int& _a, int& _b);
+               virtual void get_in_logic_connect_position(int& _a, int& _b);
+               ///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
+               virtual void get_out_logic_connect_position(int& _a, int& _b);
+               ///Actualiza la posicion de los conectores logicos ante un movimiento.
+               virtual void update_logic_position();
+               ///Detecta si el click fue en el area de entrada o salida logica, devuelve UNDEF si no fue ninguna de las dos
+               ConnectorType detect_click_position(int _a, int _b);
        protected:
        protected:
+               ///Coordenadas de las entrada y salida logica.
+               int in_x, in_y, out_x, out_y;
                ///Indica la maxima capacidad de entrega de la bomba
                double entrega;
                /// Indica el color del liquido que entrega
                ///Indica la maxima capacidad de entrega de la bomba
                double entrega;
                /// Indica el color del liquido que entrega
index 9f96eb52439d6282dc17e55eca1b9aed09057de9..415368b23af8983dfade9b20a9f1a6db2a5d5c5c 100644 (file)
@@ -20,8 +20,11 @@ class WorkPlace:public Gtk::Fixed {
                void delete_item(int _id);
                void delete_line(int _id);      
                CItem *get_logic_item(int _id);
                void delete_item(int _id);
                void delete_line(int _id);      
                CItem *get_logic_item(int _id);
+               void update_logic_position();
                std::list<CItem *> *listaItems, *lista_logic_Items;
                std::list<CItem *> *listaItems, *lista_logic_Items;
-               std::list<t_line> lista_lineas;
+               /** Listas de lineas que van de una compuerta a un item y de un item a una compuerta
+               */
+               std::list<t_line> lista_lineas_in, lista_lineas_out;
                static int pointed;
 };
 
                static int pointed;
 };
 
index 0d8a795f98af04019ccda274002c543b051c5b50..c73b062c8d804df6efdc69f9b7e9d943a909302e 100644 (file)
@@ -22,7 +22,7 @@ bool And::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if (CItem::logic_connect)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if (CItem::logic_connect)
-                       CItem::quien = ID;
+                       CItem::gate_id = ID;
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        }
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        }
@@ -52,6 +52,7 @@ bool And::on_button_press_event(GdkEventButton *event)
                menu_popup.popup(event->button, event->time);
                 return true; //It has been handled.
        }
                menu_popup.popup(event->button, event->time);
                 return true; //It has been handled.
        }
+       workplace->queue_draw();
        return true;
 }
 void And::on_menu_popup_rotar()
        return true;
 }
 void And::on_menu_popup_rotar()
index d39a66c6368c76fba1d36539092e0e07fbb92b15..ba58da5dee6dd32b014c974acd671d1b54c448ac 100644 (file)
@@ -3,6 +3,10 @@
 
 Cistern::Cistern(int orientacion)
 {
 
 Cistern::Cistern(int orientacion)
 {
+       in_x = x;
+       in_y = y+16;
+       out_x = x + 48;
+       out_y = y + 64;
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/tanque_e.png");
        imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/tanque_o.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/tanque_null.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/tanque_e.png");
        imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/tanque_o.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/tanque_null.png");
@@ -43,10 +47,17 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect) {
-                       tmp_line.logic =  workplace->get_logic_item(CItem::quien);
-                       tmp_line.store = this;
-                       workplace->lista_lineas.push_back(tmp_line);
-                       workplace->on_expose_event(&e);
+                       if ( detect_click_position(event->x, event->y) == IN ){
+                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
+                               tmp_line.store = this;
+                               workplace->lista_lineas_in.push_back(tmp_line);
+                               workplace->queue_draw();
+                       } else { 
+                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
+                               tmp_line.store = this;
+                               workplace->lista_lineas_out.push_back(tmp_line);
+                               workplace->queue_draw();
+                       }
                }
        }
        
                }
        }
        
@@ -57,10 +68,18 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                switch (imgActual) {
                        case 1:
                                image = imageO;
                switch (imgActual) {
                        case 1:
                                image = imageO;
+                               in_x = x + image->get_width();
+                               in_y = y + 16;
+                               out_x = x+16;
+                               out_y = y + image->get_height();
                                break;
                        default: 
                                imgActual = 0;
                                image = imageE;                 
                                break;
                        default: 
                                imgActual = 0;
                                image = imageE;                 
+                               in_x = x;
+                               in_y = y+16;
+                               out_x = x + image->get_width() -16;
+                               out_y = y + image->get_height();
                }
                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);
                }
                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);
@@ -77,7 +96,7 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                cistern_pty_wnd->txt_cistern_name->set_text( name );
                cistern_pty_wnd->show();
        }               
                cistern_pty_wnd->txt_cistern_name->set_text( name );
                cistern_pty_wnd->show();
        }               
-       workplace->on_expose_event(&e);
+       workplace->queue_draw();
        return true;
 }
 
        return true;
 }
 
@@ -204,15 +223,50 @@ void Cistern::set_default_connector()
        connect_vec[1].type = OUT;
 }
 
        connect_vec[1].type = OUT;
 }
 
-void Cistern::get_logic_connect_position(int& _a, int& _b)
+void Cistern::get_in_logic_connect_position(int& _a, int& _b)
 {
 {
+       _a = in_x;
+       _b = in_y;
+}
+
+void Cistern::get_out_logic_connect_position(int& _a, int& _b)
+{
+       _a = out_x;
+       _b = out_y;
+}
+       
+ConnectorType Cistern::detect_click_position(int _a, int _b)
+{
+       //VER DONDE CAEN LOS CLICKS!!!!!!!!!!!!!! SI ES CON RESPECTO AL WORKPLACE O AL ITEM!!!
        switch(imgActual) {
        switch(imgActual) {
-               case 0: 
-                       _a = x;
-                       _b = y + 10;
+               case 0:
+                       if ( (_a<=32) &&(_a>=0)&&(_b<=32)&&(_b>=0) )
+                               return IN;
+                       if ( (_a<=image->get_width())&&(_a>=image->get_width()-32)&&(_b<=image->get_height())&&(_b>=image->get_height()-32) )
+                               return OUT;
                        break;
                        break;
-               case 1: 
-                       _a = x +image->get_width();
-                       _b = y + 10;
+               case 1:
+                       if ( (_a<=image->get_width()) &&(_a>=image->get_width()-32)&&(_b<=32)&&(_b>=0) )
+                               return IN;
+                       if ( (_a<=32)&&(_a>=0)&&(_b<=image->get_height())&&(_b>=image->get_height()-32) )
+                               return OUT;
+               }
+               return UNDEF;
+}
+               
+void Cistern::update_logic_position()
+{
+       switch (imgActual) {
+               case 1:
+                       in_x = x + image->get_width();
+                       in_y = y + 16;
+                       out_x = x+16;
+                       out_y = y + image->get_height();
+                       break;
+               case 0: 
+                       in_x = x;
+                       in_y = y+16;
+                       out_x = x + image->get_width() -16;
+                       out_y = y + image->get_height();
        }
 }
        }
 }
index 3447a2eb441ec2118dbfe303654fdfe1f8257bdf..b2df77c9005d49b7a0978c68cf97b21c4e6a77fa 100644 (file)
@@ -362,7 +362,8 @@ void Constructor::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& conte
 {
        GdkEventExpose e;
        context->set_icon(item->get_image(), 5, 5);
 {
        GdkEventExpose e;
        context->set_icon(item->get_image(), 5, 5);
-       workplace->on_expose_event(&e);
+       workplace->update_logic_position();
+       workplace->queue_draw();
 }
 
 void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
 }
 
 void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
@@ -427,7 +428,7 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                        } else if (strcmp((const char *)selection_data->data, "or_e.png")==0) {
                                a = new Or(); a->is_logic = true;
                                } else if (strcmp((const char *)selection_data->data, "not_e.png")==0) {
                        } else if (strcmp((const char *)selection_data->data, "or_e.png")==0) {
                                a = new Or(); a->is_logic = true;
                                } else if (strcmp((const char *)selection_data->data, "not_e.png")==0) {
-                                       a = new Not();  a->is_logic = true;
+                                       a = new Not(); a->is_logic = true;
                                        }
                
                        char char_id[10];
                                        }
                
                        char char_id[10];
index ea152b3e6a3a1450966584c17e682cec614b143f..c15db37f8a17bf19f8f5004039996f23a9a40804 100644 (file)
@@ -3,6 +3,10 @@
 
 Exclusa::Exclusa(int orientacion)
 {
 
 Exclusa::Exclusa(int orientacion)
 {
+       in_x = x + 48;
+       in_y = y;
+       out_x = in_x;
+       out_y = y + 32;
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_h.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_s.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_h.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_s.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
@@ -35,17 +39,23 @@ Exclusa::~Exclusa()
 
 bool Exclusa::on_button_press_event(GdkEventButton *event)
 {
 
 bool Exclusa::on_button_press_event(GdkEventButton *event)
 {
-       GdkEventExpose e;
        t_line tmp_line;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect) {
        t_line tmp_line;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect) {
-                       tmp_line.logic =  workplace->get_logic_item(CItem::quien);
-                       tmp_line.store = this;
-                       workplace->lista_lineas.push_back(tmp_line);
-                       workplace->on_expose_event(&e);
-               }       
+                       if ( detect_click_position(event->x, event->y) == IN) {
+                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
+                               tmp_line.store = this;
+                               workplace->lista_lineas_in.push_back(tmp_line);
+                               workplace->queue_draw();        
+                       } else {        
+                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
+                               tmp_line.store = this;
+                               workplace->lista_lineas_out.push_back(tmp_line);
+                               workplace->queue_draw();
+                       }
+               }
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
@@ -55,10 +65,18 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
                switch (imgActual) {
                        case 1:
                                image = imageS;
                switch (imgActual) {
                        case 1:
                                image = imageS;
+                               in_x = x + image->get_width();
+                               in_y = y + image->get_height()/2;
+                               out_x = x;
+                               out_y = in_y;
                                break;
                        default: 
                                imgActual = 0;
                                image = imageN;                 
                                break;
                        default: 
                                imgActual = 0;
                                image = imageN;                 
+                               in_x = x + image->get_width()/2;
+                               in_y = y;
+                               out_x = in_x;
+                               out_y = y +image->get_height();
                }
                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);
                }
                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);
@@ -73,7 +91,7 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
                if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
                exclusa_pty_wnd->show();
        }
                if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
                exclusa_pty_wnd->show();
        }
-       workplace->on_expose_event(&e);
+       workplace->queue_draw();
        return true;
 }
 
        return true;
 }
 
@@ -194,22 +212,56 @@ ConnectorType Exclusa::get_connector_type(int _a, int _b)
        }
        return UNDEF;
 }
        }
        return UNDEF;
 }
+       
+void Exclusa::set_default_connector()
+{
+       connect_vec[0].type = UNDEF;
+       connect_vec[1].type = UNDEF;
+}
 
 
-void Exclusa::get_logic_connect_position(int& _a, int& _b)
+void Exclusa::get_in_logic_connect_position(int& _a, int& _b)
+{
+       _a = in_x;
+       _b = in_y;
+}
+
+void Exclusa::get_out_logic_connect_position(int& _a, int& _b)
+{
+       _a = out_x;
+       _b = out_y;
+}
+       
+ConnectorType Exclusa::detect_click_position(int _a, int _b)
 {
        switch (imgActual) {
 {
        switch (imgActual) {
-               case 0: 
-                       _a = x + image->get_width()/2;
-                       _b = y;
+               case 0:
+                       if ( (_a <= image->get_width()/2+10)&&(_a>=image->get_width()/2-10)&&(_b<=16)&&(_b >= 0) )
+                               return IN;
+                       if ( (_a <= image->get_width()/2+10)&&(_a>=image->get_width()/2-10)&&(_b<=32)&&(_b > 16) )
+                               return OUT;
                        break;
                        break;
-               case 1: 
-                       _a = x + image->get_width();
-                       _b = y + image->get_height()/2;
-       }
+               case 1:
+                       if ( (_a <=32)&&(_a> 16)&&(_b<=image->get_height()/2+10)&&(_b >= image->get_height()/2-10) )
+                               return IN;
+                       if ( (_a <= 16)&&(_a>=0)&&(_b<=image->get_height()/2+10)&&(_b >= image->get_height()/2-10) )
+                               return OUT;
+               }
+               return UNDEF;
 }
 }
-       
-void Exclusa::set_default_connector()
+
+void Exclusa::update_logic_position()
 {
 {
-       connect_vec[0].type = UNDEF;
-       connect_vec[1].type = UNDEF;
+       switch (imgActual) {
+               case 1:
+                       in_x = x + image->get_width();
+                       in_y = y + image->get_height()/2;
+                       out_x = x;
+                       out_y = in_y;
+                       break;
+               case 0: 
+                       in_x = x + image->get_width()/2;
+                       in_y = y;
+                       out_x = in_x;
+                       out_y = y +image->get_height();
+       }
 }
 }
index 4c25467207c966d10b07199efb743e047aa7c394..b4bf5416138a5dd90b39fc44c92ed5cd47c22e7f 100644 (file)
@@ -1,7 +1,7 @@
 #include "item.h"
 
 bool CItem::logic_connect = false;
 #include "item.h"
 
 bool CItem::logic_connect = false;
-int CItem::quien = -1;
+int CItem::gate_id = -1;
 
 
 CItem::CItem(const char *filename):Gtk::DrawingArea()
 
 
 CItem::CItem(const char *filename):Gtk::DrawingArea()
@@ -157,8 +157,18 @@ void CItem::set_default_connector()
 {
 }
 
 {
 }
 
-void CItem::get_logic_connect_position(int& _a, int& _b)
+void CItem::get_in_logic_connect_position(int& _a, int& _b)
 {
        _a = x;
        _b = y;
 }
 {
        _a = x;
        _b = y;
 }
+
+void CItem::get_out_logic_connect_position(int& _a, int& _b)
+{
+       _a = x;
+       _b = y;
+}
+
+void CItem::update_logic_position()
+{
+}
index 34fccf7a746d1946a0146c434611dd068d587cb6..dcf95c207d90b0edfef453f557b77b705057f636 100644 (file)
@@ -22,7 +22,7 @@ bool Not::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if (CItem::logic_connect)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if (CItem::logic_connect)
-                       CItem::quien = ID;
+                       CItem::gate_id = ID;
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        }
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        }
@@ -52,6 +52,7 @@ bool Not::on_button_press_event(GdkEventButton *event)
                menu_popup.popup(event->button, event->time);
                 return true; //It has been handled.
        }
                menu_popup.popup(event->button, event->time);
                 return true; //It has been handled.
        }
+       workplace->queue_draw();
        return true;
 }
 void Not::on_menu_popup_rotar()
        return true;
 }
 void Not::on_menu_popup_rotar()
index 2dd66a0d33c0ed09f673f3b580101efb09511041..60f8eedc8e21b1114ea1a62740e875931762bd3a 100644 (file)
@@ -22,7 +22,7 @@ bool Or::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if (CItem::logic_connect)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if (CItem::logic_connect)
-                       CItem::quien = ID;
+                       CItem::gate_id = ID;
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        }
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        }
@@ -52,6 +52,7 @@ bool Or::on_button_press_event(GdkEventButton *event)
                menu_popup.popup(event->button, event->time);
                 return true; //It has been handled.
        }
                menu_popup.popup(event->button, event->time);
                 return true; //It has been handled.
        }
+       workplace->queue_draw();
        return true;
 }
 
        return true;
 }
 
index 5dd52c863d7f1bf3aadae946200630dd96c234b7..7526f6b86aa6703932c666806c73606041ec9a3d 100644 (file)
@@ -3,6 +3,10 @@
 
 Pump::Pump(int orientacion)
 {
 
 Pump::Pump(int orientacion)
 {
+       in_x = x + 48;
+       in_y = y;
+       out_x = in_x;
+       out_y = y + 32;
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/bomba_e.png");
        imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/bomba_o.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/bomba_null.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/bomba_e.png");
        imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/bomba_o.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/bomba_null.png");
@@ -34,16 +38,22 @@ Pump::~Pump()
 
 bool Pump::on_button_press_event(GdkEventButton *event)
 {
 
 bool Pump::on_button_press_event(GdkEventButton *event)
 {
-       GdkEventExpose e;
        t_line tmp_line;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect) {
        t_line tmp_line;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect) {
-                       tmp_line.logic =  workplace->get_logic_item(CItem::quien);
-                       tmp_line.store = this;
-                       workplace->lista_lineas.push_back(tmp_line);
-                       workplace->on_expose_event(&e);
+                       if ( detect_click_position(event->x, event->y) == IN) {
+                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
+                               tmp_line.store = this;
+                               workplace->lista_lineas_in.push_back(tmp_line);
+                               workplace->queue_draw();
+                       } else {
+                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
+                               tmp_line.store = this;
+                               workplace->lista_lineas_out.push_back(tmp_line);
+                               workplace->queue_draw();
+                       }
                }
        }
        
                }
        }
        
@@ -54,10 +64,18 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                switch (imgActual) {
                        case 1:
                                image = imageO;
                switch (imgActual) {
                        case 1:
                                image = imageO;
+                               in_x = x + 16;
+                               in_y = y;                       
+                               out_x = in_x;
+                               out_y = y + 32;
                                break;
                        default: 
                                imgActual = 0;
                                image = imageE;                 
                                break;
                        default: 
                                imgActual = 0;
                                image = imageE;                 
+                               in_x = x + image->get_width()-16;
+                               in_y = y;
+                               out_x = in_x;
+                               out_y = y + 32;
                }
                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);
                }
                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);
@@ -73,7 +91,7 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                pump_pty_wnd->txt_pump_name->set_text( name );
                pump_pty_wnd->show();
        }               
                pump_pty_wnd->txt_pump_name->set_text( name );
                pump_pty_wnd->show();
        }               
-       workplace->on_expose_event(&e);
+       workplace->queue_draw();
        return true;
 }
 
        return true;
 }
 
@@ -182,15 +200,49 @@ void Pump::set_default_connector()
        connect_vec[0].type = OUT;
 }
 
        connect_vec[0].type = OUT;
 }
 
-void Pump::get_logic_connect_position(int& _a, int& _b)
+void Pump::get_in_logic_connect_position(int& _a, int& _b)
 {
 {
-       switch(imgActual) {
-               case 0: 
-                       _a = x + image->get_width() - 10;
-                       _b = y;
+       _a = in_x;
+       _b = in_y;
+}
+
+void Pump::get_out_logic_connect_position(int& _a, int& _b)
+{
+       _a = out_x;
+       _b = out_y;
+}
+       
+ConnectorType Pump::detect_click_position(int _a, int _b)
+{
+       switch (imgActual) {
+               case 0:
+                       if ( (_a <=image->get_width())&&(_a>=image->get_width()-32)&&(_b<=16)&&(_b >= 0) )
+                               return IN;
+                       if ( (_a <= image->get_width())&&(_a>=image->get_width()-32)&&(_b<=32)&&(_b > 16) )
+                               return OUT;
                        break;
                        break;
-               case 1: 
-                       _a = x + 10;
-                       _b = y;
+               case 1:
+                       if ( (_a <= 32)&&(_a>=0)&&(_b<=16)&&(_b >= 0) )
+                               return IN;
+                       if ( (_a <= 32)&&(_a>=0)&&(_b<=32)&&(_b > 16) )
+                               return OUT;
+               }
+               return UNDEF;
+}
+
+void Pump::update_logic_position()
+{
+       switch (imgActual) {
+               case 1:
+                       in_x = x + 16;
+                       in_y = y;                       
+                       out_x = in_x;
+                       out_y = y + 32;
+                       break;
+               case 0: 
+                       in_x = x + image->get_width()-16;
+                       in_y = y;
+                       out_x = in_x;
+                       out_y = y + 32;
        }
 }
        }
 }
index 46b1bcd470aa2ff0242c46a739be0245801dd7f4..f526cb56da8a27eb68d9886bbe620169a291d2cd 100644 (file)
@@ -30,13 +30,21 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
        gc->set_rgb_bg_color(color);
        get_style()->set_black(color);
        int w, z;               
        gc->set_rgb_bg_color(color);
        get_style()->set_black(color);
        int w, z;               
-       std::list<t_line>::iterator i = lista_lineas.begin();
-       while ( i != lista_lineas.end() ) {
+       std::list<t_line>::iterator i = lista_lineas_in.begin();
+       while ( i != lista_lineas_in.end() ) {
                t_line temp = *i;
                t_line temp = *i;
-               temp.store->get_logic_connect_position(w,z);
+               temp.store->get_in_logic_connect_position(w,z);
                get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
                i++;
        }
                get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
                i++;
        }
+       i = lista_lineas_out.begin();
+       while ( i != lista_lineas_out.end() ) {
+               t_line temp = *i;
+               temp.store->get_out_logic_connect_position(w,z);
+               get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
+               i++;
+       }
+       
        return true;
 }
 
        return true;
 }
 
@@ -82,20 +90,29 @@ CItem* WorkPlace::get_logic_item(int _id)
 
 void WorkPlace::delete_line(int _id)
 {
 
 void WorkPlace::delete_line(int _id)
 {
-       std::list<t_line>::iterator i = lista_lineas.begin();
-       while ( i != lista_lineas.end() ){
+       std::list<t_line>::iterator i = lista_lineas_in.begin();
+       while ( i != lista_lineas_in.end() ){
                if ( (*i).store->get_id() == _id ) {
                if ( (*i).store->get_id() == _id ) {
-                       lista_lineas.erase(i);
-                       i = lista_lineas.begin();
+                       lista_lineas_in.erase(i);
+                       i = lista_lineas_in.begin();
                }
                i++;
        }
                }
                i++;
        }
-       i = lista_lineas.begin();
-       while ( i != lista_lineas.end() ){
+       i = lista_lineas_in.begin();
+       while ( i != lista_lineas_in.end() ){
                if ( (*i).logic->get_id() == _id ) {
                if ( (*i).logic->get_id() == _id ) {
-                       lista_lineas.erase(i);
-                       i = lista_lineas.begin();
+                       lista_lineas_in.erase(i);
+                       i = lista_lineas_in.begin();
                }
                i++;
        }       
 }
                }
                i++;
        }       
 }
+
+void WorkPlace::update_logic_position()
+{
+       std::list<CItem*>::iterator i = listaItems->begin();
+       while ( i != listaItems->end() ){
+               (*i)->update_logic_position();
+               i++;
+       }
+}