]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
-Cambie un poco lo que hizo Rich para dibujar los conectores
authorNicolás Dimov <ndimov@gmail.com>
Sun, 23 Nov 2003 23:15:49 +0000 (23:15 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Sun, 23 Nov 2003 23:15:49 +0000 (23:15 +0000)
-Se  dibujan cuando se activa la logica
-Tengo que modificar las posiciones de los cuadraditos porque algunos quedan
 afuera de la figura
-Hay que arreglar algunos detalles para que no se borren cuando se hace click sobre algun item o cuando se rota el mismo
Pero la idea esta, me parece que asi queda lindo...

14 files changed:
Constructor/include/cistern.h
Constructor/include/constructor.h
Constructor/include/exclusa.h
Constructor/include/item.h
Constructor/include/pump.h
Constructor/include/workplace.h
Constructor/src/conduct.cpp
Constructor/src/constructor.cpp
Constructor/src/drain.cpp
Constructor/src/item.cpp
Constructor/src/pump.cpp
Constructor/src/splitter.cpp
Constructor/src/union.cpp
Constructor/src/workplace.cpp

index 793f2ba2922b33357bf4555ec96abdbce06266a5..6ef50a3cd5ecd886d02012be105d4a53e53535c0 100644 (file)
@@ -57,9 +57,6 @@ class Cistern : public CItem {
                */
                ConnectorType detect_click_position(int _a, int _b);
        protected:
                */
                ConnectorType detect_click_position(int _a, int _b);
        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 044e06893da375fd79d97e2a404de5ac52ce803e..9e4fac2293098a0d6a783e21ae0f0493e11cd20b 100644 (file)
@@ -69,7 +69,7 @@ class Constructor : public Gtk::Window {
        virtual void on_main_menu_save();
        virtual void on_edit_menu_del();
        virtual void on_edit_menu_delete_all();
        virtual void on_main_menu_save();
        virtual void on_edit_menu_del();
        virtual void on_edit_menu_delete_all();
-       virtual void on_chk_btn_clicked();
+       virtual void on_chk_btn_logica_clicked();
        virtual void on_btn_open_cancel_clicked();
        virtual void on_btn_file_ok_clicked();
        virtual void on_btn_file_cancel_clicked();
        virtual void on_btn_open_cancel_clicked();
        virtual void on_btn_file_ok_clicked();
        virtual void on_btn_file_cancel_clicked();
index 34e2fe93371c144b771fe723b67ec3b975825e73..c60fd51022cd41ec923dd06080351d442c73d210 100644 (file)
@@ -52,9 +52,6 @@ class Exclusa : public CItem {
                void set_estado(bool _state);
                bool get_estado();
        protected:
                void set_estado(bool _state);
                bool get_estado();
        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 9a9ecfc16c616c4c5567f11d8254049aa143c0e7..83aa0b2d57459854ef99683b907aa120ec417284 100644 (file)
@@ -119,6 +119,10 @@ public:
        */
        virtual void update_logic_position();
        
        */
        virtual void update_logic_position();
        
+       /**Dibuja los conectores logicos del Item, AZUL == ENTRADA, ROJO == SALIDA.
+       */
+       virtual void draw_connectors();
+       
        ///Puntero al area de trabajo de la ventana principal
        WorkPlace *workplace;
        
        ///Puntero al area de trabajo de la ventana principal
        WorkPlace *workplace;
        
@@ -193,6 +197,9 @@ protected:
 
        ///Posicion del item en el area de trabajo
        int x, y;
 
        ///Posicion del item en el area de trabajo
        int x, y;
+       
+       ///Posicion de los conectores logicos.
+       int in_x, in_y, out_x, out_y;
 };
 
 #endif
 };
 
 #endif
index f4edf28aad612d2e43807e075cf97037451f0255..71c53e89a09da0572cf991dbc8508b1ac1c06e76 100644 (file)
@@ -13,7 +13,6 @@ class Pump : public CItem {
                ///Destructor
                virtual ~Pump();
                ///Funciones redefinidas de CItem
                ///Destructor
                virtual ~Pump();
                ///Funciones redefinidas de CItem
-               virtual bool on_expose_event(GdkEventExpose* event);
                virtual bool on_button_press_event(GdkEventButton *event);
                virtual void on_menu_popup_rotar();
                virtual void on_menu_popup_propiedades();
                virtual bool on_button_press_event(GdkEventButton *event);
                virtual void on_menu_popup_rotar();
                virtual void on_menu_popup_propiedades();
@@ -39,8 +38,6 @@ class Pump : public CItem {
                ///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:
                ///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:
-               ///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 d01789e8d3e7171978c1c254310004e02c161949..41b6a22788a69097fd3918abfb8f43c7b994a6fc 100644 (file)
@@ -56,6 +56,9 @@ class WorkPlace:public Gtk::Fixed {
                  *conectarlo mediante una linea a un item de transporte
                  */
                static int pointed;
                  *conectarlo mediante una linea a un item de transporte
                  */
                static int pointed;
+               
+               ///Estado de diseño
+               bool *logica;
 };
 
 #endif
 };
 
 #endif
index 80147e44924fe2eb3dfa844d0bcc7c2dd5038ee4..b4c911ce66063eb06d64f3ea4c192baf508d0cbb 100644 (file)
@@ -2,6 +2,7 @@
 
 Conduct::Conduct(int orientacion)
 {
 
 Conduct::Conduct(int orientacion)
 {
+       in_x = -1;
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/canio_n.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/canio_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/canio_n.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/canio_s.png");
        null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
@@ -133,6 +134,9 @@ bool Conduct::check_connection()
        else return is_connected;
 }
 
        else return is_connected;
 }
 
+/*si no estoy conectado pregunto por el del otro lado, y ahi puedo setear los dos
+ *si ya estoy devuelvo.
+*/
 ConnectorType Conduct::get_connector_type(int _a, int _b)
 { 
        CItem *_item;
 ConnectorType Conduct::get_connector_type(int _a, int _b)
 { 
        CItem *_item;
@@ -167,9 +171,7 @@ ConnectorType Conduct::get_connector_type(int _a, int _b)
        }
        return UNDEF;
 }
        }
        return UNDEF;
 }
-/*si no estoy conectado pregunto por el del otro lado, y ahi puedo setear los dos
- *si ya estoy devuelvo.
-*/
+
 
 void Conduct::set_default_connector()
 {
 
 void Conduct::set_default_connector()
 {
index 82a73ec383659e4ed3e341e1b52022711c128887..bfd2b2b827a49313d7fd37ccc54b407bb65624b5 100644 (file)
@@ -79,7 +79,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        btn_check->signal_clicked().connect(SigC::slot(*this,&Constructor::on_btn_check_clicked));
        btn_dlg_close->signal_clicked().connect(SigC::slot(*this,&Constructor::on_btn_dlg_connect_clicked));
        btn_find->signal_clicked().connect(SigC::slot(*this,&Constructor::on_btn_find_clicked));        
        btn_check->signal_clicked().connect(SigC::slot(*this,&Constructor::on_btn_check_clicked));
        btn_dlg_close->signal_clicked().connect(SigC::slot(*this,&Constructor::on_btn_dlg_connect_clicked));
        btn_find->signal_clicked().connect(SigC::slot(*this,&Constructor::on_btn_find_clicked));        
-       chk_btn_logica->signal_clicked().connect(SigC::slot(*this, &Constructor::on_chk_btn_clicked));
+       chk_btn_logica->signal_clicked().connect(SigC::slot(*this, &Constructor::on_chk_btn_logica_clicked));
        quick_btn_new->signal_clicked().connect(SigC::slot(*this, &Constructor::on_quick_btn_new_clicked));
        quick_btn_save->signal_clicked().connect(SigC::slot(*this, &Constructor::on_quick_btn_save_clicked));
        quick_btn_open->signal_clicked().connect(SigC::slot(*this, &Constructor::on_main_menu_open));
        quick_btn_new->signal_clicked().connect(SigC::slot(*this, &Constructor::on_quick_btn_new_clicked));
        quick_btn_save->signal_clicked().connect(SigC::slot(*this, &Constructor::on_quick_btn_save_clicked));
        quick_btn_open->signal_clicked().connect(SigC::slot(*this, &Constructor::on_main_menu_open));
@@ -116,6 +116,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        workplace->signal_drag_data_received().connect( SigC::slot(*this, &Constructor::on_item_drop_drag_received) );  
        workplace->listaItems = &listaItems;    
        workplace->lista_logic_Items = &lista_logic_Items;      
        workplace->signal_drag_data_received().connect( SigC::slot(*this, &Constructor::on_item_drop_drag_received) );  
        workplace->listaItems = &listaItems;    
        workplace->lista_logic_Items = &lista_logic_Items;      
+       workplace->logica = &logica;
        logica = false;
 }
 
        logica = false;
 }
 
@@ -220,10 +221,11 @@ void Constructor::on_edit_menu_delete_all()
        id = 0;
 }
 
        id = 0;
 }
 
-void Constructor::on_chk_btn_clicked()
+void Constructor::on_chk_btn_logica_clicked()
 {
        logica = !logica;
        CItem::logic_connect = !CItem::logic_connect;
 {
        logica = !logica;
        CItem::logic_connect = !CItem::logic_connect;
+       workplace->queue_draw();
 }
 
 void Constructor::on_load_from_xml()
 }
 
 void Constructor::on_load_from_xml()
index afd71ec0de72646fae693f6a92d39945511386dc..202c6f3062cdb03955f5d2ffa47757db62c38bad 100644 (file)
@@ -2,6 +2,7 @@
 
 Drain::Drain(int orientacion)
 {
 
 Drain::Drain(int orientacion)
 {
+       in_x = -1;
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/drain_e.png");
        imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/drain_o.png");
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/drain_n.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/drain_e.png");
        imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/drain_o.png");
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/drain_n.png");
index aa15a3330bb6fbfe0a026b50e8810568bde2e88b..5f5ac1581b370f88a2265110deb405d44978258f 100644 (file)
@@ -189,3 +189,19 @@ void CItem::get_out_logic_connect_position(int& _a, int& _b)
 void CItem::update_logic_position()
 {
 }
 void CItem::update_logic_position()
 {
 }
+
+void CItem::draw_connectors()
+{
+       GdkEventExpose event;
+       if ( in_x != -1 ) {
+               CItem::on_expose_event(&event);
+               Glib::RefPtr<Gdk::Window> window = get_window();
+       
+               gc->set_foreground(red);
+               gc->set_background(red);
+               window->draw_rectangle(gc, 1, in_x-5-x, in_y-y, 10, 10);
+               gc->set_foreground(blue);
+               gc->set_background(blue);
+               window->draw_rectangle(gc, 1, out_x-5-x, out_y-y-10, 10, 10);
+       }
+}
index 9663b0bb0c4d737c9991c81ff52d315de1415926..26a2841a64f962e4ace2fc7d548547da5f527a38 100644 (file)
@@ -44,12 +44,12 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect && CItem::gate_id != -1) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
                if (CItem::logic_connect && CItem::gate_id != -1) {
-                       if ( detect_click_position(event->x, event->y) == IN) {
+                       if ( detect_click_position((int)event->x, (int)event->y) == IN) {
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
-                       } else if (detect_click_position(event->x, event->y) == OUT) {
+                       } else if (detect_click_position((int)event->x, (int)event->y) == OUT) {
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_out.push_back(tmp_line);
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_out.push_back(tmp_line);
@@ -247,17 +247,3 @@ void Pump::update_logic_position()
                        out_y = y + 32;
        }
 }
                        out_y = y + 32;
        }
 }
-
-bool Pump::on_expose_event(GdkEventExpose* event)
-{
-       CItem::on_expose_event(event);
-       Glib::RefPtr<Gdk::Window> window = get_window();
-
-       gc->set_foreground(red);
-       gc->set_background(red);
-       window->draw_rectangle(gc, 1, image->get_width()-32, 0, 32, 16);
-       gc->set_foreground(blue);
-       gc->set_background(blue);
-       window->draw_rectangle(gc, 1, image->get_width()-32, 16, 32, 16);
-       return true;
-}
index c2284087343bbcaca51aa1f4c57981ee52147d39..d0dc0638c43b9def7322ce0bc79ea1f9e61a7455 100644 (file)
@@ -2,6 +2,7 @@
 
 Splitter::Splitter(int orientacion)
 {
 
 Splitter::Splitter(int orientacion)
 {
+       in_x = -1;
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/codo_n.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/codo_s.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/codo_e.png");
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/codo_n.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/codo_s.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/codo_e.png");
index d9c36b9f6e437df5cdf09bfc7f56830ecd4fad75..61e583816eececb3a070d9127e6b32dc5466afd4 100644 (file)
@@ -2,6 +2,7 @@
 
 Union::Union(int orientacion)
 {
 
 Union::Union(int orientacion)
 {
+       in_x = -1;
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/y_n.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/y_s.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/y_e.png");
        imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/y_n.png");
        imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/y_s.png");
        imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/y_e.png");
index 1666c8a7d68b53d8ef668ae645e6bfe2fdc69fef..548b771808d7a820885fc9774e11b1b93bbb292e 100644 (file)
@@ -23,11 +23,14 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
                        get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
                }
                
                        get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
                }
                
-       Glib::RefPtr<Gdk::GC> gc = get_style()->get_black_gc();
-       Gdk::Color color;
-       color.set_rgb(255,0,0);
-       gc->set_rgb_bg_color(color);
-       get_style()->set_black(color);
+       if ( *logica ) {        
+               std::list<CItem *>::iterator j = listaItems->begin();
+               while ( j != listaItems->end() ) {
+                       (*j)->draw_connectors();
+                       j++;
+               }
+       }
+       
        int a, b, w, z;         
        std::list<t_line>::iterator i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ) {
        int a, b, w, z;         
        std::list<t_line>::iterator i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ) {