From d4d9e7169ed68ba75024ab23f773fbb168ef2e55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicol=C3=A1s=20Dimov?= Date: Sun, 23 Nov 2003 23:15:49 +0000 Subject: [PATCH] -Cambie un poco lo que hizo Rich para dibujar los conectores -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... --- Constructor/include/cistern.h | 3 --- Constructor/include/constructor.h | 2 +- Constructor/include/exclusa.h | 3 --- Constructor/include/item.h | 7 +++++++ Constructor/include/pump.h | 3 --- Constructor/include/workplace.h | 3 +++ Constructor/src/conduct.cpp | 8 +++++--- Constructor/src/constructor.cpp | 6 ++++-- Constructor/src/drain.cpp | 1 + Constructor/src/item.cpp | 16 ++++++++++++++++ Constructor/src/pump.cpp | 18 ++---------------- Constructor/src/splitter.cpp | 1 + Constructor/src/union.cpp | 1 + Constructor/src/workplace.cpp | 13 ++++++++----- 14 files changed, 49 insertions(+), 36 deletions(-) diff --git a/Constructor/include/cistern.h b/Constructor/include/cistern.h index 793f2ba..6ef50a3 100644 --- a/Constructor/include/cistern.h +++ b/Constructor/include/cistern.h @@ -57,9 +57,6 @@ class Cistern : public CItem { */ 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; diff --git a/Constructor/include/constructor.h b/Constructor/include/constructor.h index 044e068..9e4fac2 100644 --- a/Constructor/include/constructor.h +++ b/Constructor/include/constructor.h @@ -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_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(); diff --git a/Constructor/include/exclusa.h b/Constructor/include/exclusa.h index 34e2fe9..c60fd51 100644 --- a/Constructor/include/exclusa.h +++ b/Constructor/include/exclusa.h @@ -52,9 +52,6 @@ class Exclusa : public CItem { 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 imageN; // 0 diff --git a/Constructor/include/item.h b/Constructor/include/item.h index 9a9ecfc..83aa0b2 100644 --- a/Constructor/include/item.h +++ b/Constructor/include/item.h @@ -119,6 +119,10 @@ public: */ 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; @@ -193,6 +197,9 @@ protected: ///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 diff --git a/Constructor/include/pump.h b/Constructor/include/pump.h index f4edf28..71c53e8 100644 --- a/Constructor/include/pump.h +++ b/Constructor/include/pump.h @@ -13,7 +13,6 @@ class Pump : public 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(); @@ -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: - ///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 diff --git a/Constructor/include/workplace.h b/Constructor/include/workplace.h index d01789e..41b6a22 100644 --- a/Constructor/include/workplace.h +++ b/Constructor/include/workplace.h @@ -56,6 +56,9 @@ class WorkPlace:public Gtk::Fixed { *conectarlo mediante una linea a un item de transporte */ static int pointed; + + ///Estado de diseño + bool *logica; }; #endif diff --git a/Constructor/src/conduct.cpp b/Constructor/src/conduct.cpp index 80147e4..b4c911c 100644 --- a/Constructor/src/conduct.cpp +++ b/Constructor/src/conduct.cpp @@ -2,6 +2,7 @@ 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"); @@ -133,6 +134,9 @@ bool Conduct::check_connection() 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; @@ -167,9 +171,7 @@ ConnectorType Conduct::get_connector_type(int _a, int _b) } 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() { diff --git a/Constructor/src/constructor.cpp b/Constructor/src/constructor.cpp index 82a73ec..bfd2b2b 100644 --- a/Constructor/src/constructor.cpp +++ b/Constructor/src/constructor.cpp @@ -79,7 +79,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtrsignal_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)); @@ -116,6 +116,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtrsignal_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; } @@ -220,10 +221,11 @@ void Constructor::on_edit_menu_delete_all() id = 0; } -void Constructor::on_chk_btn_clicked() +void Constructor::on_chk_btn_logica_clicked() { logica = !logica; CItem::logic_connect = !CItem::logic_connect; + workplace->queue_draw(); } void Constructor::on_load_from_xml() diff --git a/Constructor/src/drain.cpp b/Constructor/src/drain.cpp index afd71ec..202c6f3 100644 --- a/Constructor/src/drain.cpp +++ b/Constructor/src/drain.cpp @@ -2,6 +2,7 @@ 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"); diff --git a/Constructor/src/item.cpp b/Constructor/src/item.cpp index aa15a33..5f5ac15 100644 --- a/Constructor/src/item.cpp +++ b/Constructor/src/item.cpp @@ -189,3 +189,19 @@ void CItem::get_out_logic_connect_position(int& _a, int& _b) void CItem::update_logic_position() { } + +void CItem::draw_connectors() +{ + GdkEventExpose event; + if ( in_x != -1 ) { + CItem::on_expose_event(&event); + Glib::RefPtr 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); + } +} diff --git a/Constructor/src/pump.cpp b/Constructor/src/pump.cpp index 9663b0b..26a2841 100644 --- a/Constructor/src/pump.cpp +++ b/Constructor/src/pump.cpp @@ -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) { - 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(); - } 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); @@ -247,17 +247,3 @@ void Pump::update_logic_position() out_y = y + 32; } } - -bool Pump::on_expose_event(GdkEventExpose* event) -{ - CItem::on_expose_event(event); - Glib::RefPtr 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; -} diff --git a/Constructor/src/splitter.cpp b/Constructor/src/splitter.cpp index c228408..d0dc063 100644 --- a/Constructor/src/splitter.cpp +++ b/Constructor/src/splitter.cpp @@ -2,6 +2,7 @@ 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"); diff --git a/Constructor/src/union.cpp b/Constructor/src/union.cpp index d9c36b9..61e5838 100644 --- a/Constructor/src/union.cpp +++ b/Constructor/src/union.cpp @@ -2,6 +2,7 @@ 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"); diff --git a/Constructor/src/workplace.cpp b/Constructor/src/workplace.cpp index 1666c8a..548b771 100644 --- a/Constructor/src/workplace.cpp +++ b/Constructor/src/workplace.cpp @@ -23,11 +23,14 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) get_window()->draw_point (get_style()->get_black_gc(), x-1,y); } - Glib::RefPtr 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::iterator j = listaItems->begin(); + while ( j != listaItems->end() ) { + (*j)->draw_connectors(); + j++; + } + } + int a, b, w, z; std::list::iterator i = lista_lineas_in.begin(); while ( i != lista_lineas_in.end() ) { -- 2.43.0