]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
-Se arregla lo del id cuando se carga una planta
authorNicolás Dimov <ndimov@gmail.com>
Tue, 18 Nov 2003 22:25:37 +0000 (22:25 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Tue, 18 Nov 2003 22:25:37 +0000 (22:25 +0000)
-si esta checkeado el boton "logica" haciendo click sobre una compuerta y luego sobre
 un item, tira un cable
-si se elimina un item, los cables se borran
-se muevene todos juntos cables+items, pero al rotar un item conectado me falta hacer un repinte
 ya lo van a ver...
-el constructor tiene un metodo para borrar todos los itmes pero no hay boton para llamarlo (depues lo pongo)
 pero igual la funcion es llamada en el destructor del constructor (con esa los mate)
-en el tanque la bomba y la exclusa los cables se conectan en una posicion mas linda (por lo menos en la exclusa)
-para los cables que salen de las compuertas se me ocurrio discriminar por la posicion donde se clickea en la misma
 aunque eso se me hace que va a ser medio incomodo porque son pequenias, pero me parece que estaria bueno igual
-mirenlo y pasen los bugs!

19 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/and.cpp
Constructor/src/cistern.cpp
Constructor/src/conduct.cpp
Constructor/src/constructor.cpp
Constructor/src/drain.cpp
Constructor/src/exclusa.cpp
Constructor/src/item.cpp
Constructor/src/not.cpp
Constructor/src/or.cpp
Constructor/src/pump.cpp
Constructor/src/splitter.cpp
Constructor/src/union.cpp
Constructor/src/workplace.cpp

index 87b6ef6d7f4440c60576a99922f1826470247c4f..1c874eaa01b39a853ff829d289f1dcba06eb537f 100644 (file)
@@ -40,6 +40,10 @@ class Cistern : 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.
+               */
+               virtual void get_logic_connect_position(int& _a, int& _b);
        protected:
                /**Atributos que definen su comportamiento
                */
index ecc6fe7feaf0e78f429afee62ebd1576fc7c08b6..ad2a14ea1cddee1ccfd4ec3a60e058501b2267bc 100644 (file)
@@ -50,8 +50,8 @@ class Constructor : public Gtk::Window {
        WorkPlace *workplace;
        bool logica;
        bool can_drop(CItem *, int , int);
+       
        // /señales de control para los elementos de la ventana.
-               
        virtual void on_btn_canio_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_y_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
        virtual void on_btn_codo_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
@@ -66,6 +66,7 @@ class Constructor : public Gtk::Window {
        virtual void on_main_menu_open();
        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_btn_open_cancel_clicked();
        virtual void on_btn_file_ok_clicked();
index 016b77e648af72a7ca7041c0985fb9c4ff841126..d2a673715bd49d61ec625010d556a4c4cdd65dca 100644 (file)
@@ -30,6 +30,11 @@ class Exclusa : 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);
+               
+               /**Los valores _a y _b se setean en el punto donde se deben conectar los cables logicos
+               */
+               virtual void get_logic_connect_position(int& _a, int& _b);
+               
                /**Funciones para obtener y setear sus propiedades
                */
                void set_estado(bool _state);
index 5db334182c026d25382d2b030317c08cedacf441..c7a4d4791b26786f8f1e9216bd1df9316f14f9a7 100644 (file)
@@ -94,6 +94,7 @@ 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 );
+       virtual void get_logic_connect_position(int& _a, int& _b);
        
        ///Puntero al area de trabajo de la ventana principal
        WorkPlace *workplace;
index 514548c12e1a54955d7380f04fb22f04f0806aee..95cd6ab1238f20bd70ac3ab1ce43a6125a602bf7 100644 (file)
@@ -29,6 +29,8 @@ class Pump : public CItem {
                virtual void set_default_connector();
                ///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);
        protected:
                ///Indica la maxima capacidad de entrega de la bomba
                double entrega;
index 2bb065318914f57221a27a0d2a582299affbe941..9f96eb52439d6282dc17e55eca1b9aed09057de9 100644 (file)
@@ -22,6 +22,7 @@ class WorkPlace:public Gtk::Fixed {
                CItem *get_logic_item(int _id);
                std::list<CItem *> *listaItems, *lista_logic_Items;
                std::list<t_line> lista_lineas;
+               static int pointed;
 };
 
 #endif
index 9ee2867a39b443a0f227a3ed0ae0eb049f06c3ba..0d8a795f98af04019ccda274002c543b051c5b50 100644 (file)
@@ -20,8 +20,12 @@ And::~And()
 
 bool And::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
+               if (CItem::logic_connect)
+                       CItem::quien = ID;
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
index a03d3bed1e381929d007d9745003bdf559aebf22..d39a66c6368c76fba1d36539092e0e07fbb92b15 100644 (file)
@@ -41,13 +41,13 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
        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);
                }
-               CItem::logic_connect = false;   
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
@@ -77,6 +77,7 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                cistern_pty_wnd->txt_cistern_name->set_text( name );
                cistern_pty_wnd->show();
        }               
+       workplace->on_expose_event(&e);
        return true;
 }
 
@@ -202,3 +203,16 @@ void Cistern::set_default_connector()
        connect_vec[0].type = IN;
        connect_vec[1].type = OUT;
 }
+
+void Cistern::get_logic_connect_position(int& _a, int& _b)
+{
+       switch(imgActual) {
+               case 0: 
+                       _a = x;
+                       _b = y + 10;
+                       break;
+               case 1: 
+                       _a = x +image->get_width();
+                       _b = y + 10;
+       }
+}
index f753a67bb398db155ebd46fee99623bd7d114322..80147e44924fe2eb3dfa844d0bcc7c2dd5038ee4 100644 (file)
@@ -30,9 +30,10 @@ Conduct::~Conduct()
 
 bool Conduct::on_button_press_event(GdkEventButton *event)
 {
-       int w, h;
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
                image = null; 
@@ -46,8 +47,7 @@ bool Conduct::on_button_press_event(GdkEventButton *event)
                                imgActual = 0;
                                image = imageN;                 
                }
-               get_size_request(w, h);
-               set_size_request(h, w);         
+               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)){
index 212057390590a412b4726dd63fefbcc1ab4c0393..3447a2eb441ec2118dbfe303654fdfe1f8257bdf 100644 (file)
@@ -108,13 +108,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
 
 Constructor::~Constructor()
 {
-       std::list<CItem *>::iterator i = listaItems.begin();
-       while ( i != listaItems.end() ){
-               CItem *temp = *i;
-               listaItems.erase(i);
-               delete temp;
-               i = listaItems.begin();
-       }
+       Constructor::on_edit_menu_delete_all();
 }
 
 void Constructor::on_btn_canio_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
@@ -188,22 +182,28 @@ void Constructor::on_main_menu_save()
 }
 
 void Constructor::on_edit_menu_del()
-{  // OJO que borra al primero que encuentra con el mismo nombre!!!
+{ 
+       workplace->delete_item(WorkPlace::pointed);
+}
+
+void Constructor::on_edit_menu_delete_all()
+{
        std::list<CItem *>::iterator i = listaItems.begin();
-       Glib::ustring pointed = combo_entry->get_text();
-       while ( i != listaItems.end() ){
-               CItem *temp = *i;
-               if ( temp->get_name() == pointed ){ 
-                       workplace->delete_item(temp->get_id());
-                       break;
-               }
-       i++;
+       while ( i != listaItems.end() ) {
+               (*i)->workplace->delete_item((*i)->get_id());
+               i = listaItems.begin();
+       }
+       i = lista_logic_Items.begin();
+       while ( i != lista_logic_Items.end() ) {
+               (*i)->workplace->delete_item((*i)->get_id());
+               i=lista_logic_Items.begin();
        }
 }
 
 void Constructor::on_chk_btn_clicked()
 {
        logica = !logica;
+       CItem::logic_connect = !CItem::logic_connect;
 }
 
 void Constructor::on_load_from_xml()
@@ -272,6 +272,7 @@ void Constructor::on_load_from_xml()
        }
        std::cout << "CARGA COMPLETA" << std::endl;
        file_open_selection->hide();
+       id = listaItems.size()+lista_logic_Items.size()+1;
 }
 void Constructor::on_btn_file_ok_clicked()
 {
@@ -727,4 +728,3 @@ Splitter *Constructor::loadCodo(xmlNodePtr nodo)
 
        return p;
 }
-
index 9eefcefefbf280801c5328e0542f6cfc818e229e..afd71ec0de72646fae693f6a92d39945511386dc 100644 (file)
@@ -40,8 +40,10 @@ Drain::~Drain()
 
 bool Drain::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
                image = null; 
index 4d079948219ca7a4e843bc5d1ecfde3201988c5c..ea152b3e6a3a1450966584c17e682cec614b143f 100644 (file)
@@ -39,13 +39,13 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
        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);
-               }
-               CItem::logic_connect = false;   
+               }       
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
@@ -73,6 +73,7 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
                if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
                exclusa_pty_wnd->show();
        }
+       workplace->on_expose_event(&e);
        return true;
 }
 
@@ -194,6 +195,19 @@ ConnectorType Exclusa::get_connector_type(int _a, int _b)
        return UNDEF;
 }
 
+void Exclusa::get_logic_connect_position(int& _a, int& _b)
+{
+       switch (imgActual) {
+               case 0: 
+                       _a = x + image->get_width()/2;
+                       _b = y;
+                       break;
+               case 1: 
+                       _a = x + image->get_width();
+                       _b = y + image->get_height()/2;
+       }
+}
+       
 void Exclusa::set_default_connector()
 {
        connect_vec[0].type = UNDEF;
index de63b6914b017e5534b241cdcb6c1316625846f4..4c25467207c966d10b07199efb743e047aa7c394 100644 (file)
@@ -1,6 +1,6 @@
 #include "item.h"
 
-bool CItem::   logic_connect = false;
+bool CItem::logic_connect = false;
 int CItem::quien = -1;
 
 
@@ -62,8 +62,6 @@ void CItem::on_menu_popup_eliminar()
 
 void CItem::on_menu_popup_conectar()
 {
-       CItem::logic_connect = true;
-       CItem::quien = ID;      
 }
 
 int CItem::get_position_x()
@@ -158,3 +156,9 @@ ConnectorType CItem::get_connector_type( int _a, int _b )
 void CItem::set_default_connector()
 {
 }
+
+void CItem::get_logic_connect_position(int& _a, int& _b)
+{
+       _a = x;
+       _b = y;
+}
index b006f5e2184a77cc65fa6ce5a162a834dd6f4dba..34fccf7a746d1946a0146c434611dd068d587cb6 100644 (file)
@@ -20,8 +20,12 @@ Not::~Not()
 
 bool Not::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
+               if (CItem::logic_connect)
+                       CItem::quien = ID;
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
index 1d1534bcaf28b680ae449967ca6ede021faed886..2dd66a0d33c0ed09f673f3b580101efb09511041 100644 (file)
@@ -20,8 +20,12 @@ Or::~Or()
 
 bool Or::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
+               if (CItem::logic_connect)
+                       CItem::quien = ID;
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
index e2510f6081279d2ca4bf2139bb303d36652f7375..5dd52c863d7f1bf3aadae946200630dd96c234b7 100644 (file)
@@ -38,13 +38,13 @@ bool Pump::on_button_press_event(GdkEventButton *event)
        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);
                }
-               CItem::logic_connect = false;   
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
@@ -73,6 +73,7 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                pump_pty_wnd->txt_pump_name->set_text( name );
                pump_pty_wnd->show();
        }               
+       workplace->on_expose_event(&e);
        return true;
 }
 
@@ -180,3 +181,16 @@ void Pump::set_default_connector()
 {
        connect_vec[0].type = OUT;
 }
+
+void Pump::get_logic_connect_position(int& _a, int& _b)
+{
+       switch(imgActual) {
+               case 0: 
+                       _a = x + image->get_width() - 10;
+                       _b = y;
+                       break;
+               case 1: 
+                       _a = x + 10;
+                       _b = y;
+       }
+}
index 45d60ce731b214468499ac916766c600bf429a0c..c2284087343bbcaca51aa1f4c57981ee52147d39 100644 (file)
@@ -38,8 +38,10 @@ Splitter::~Splitter()
 
 bool Splitter::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
index d130c7a517386aff9137a66ebb26c787a24b88d1..d9c36b9f6e437df5cdf09bfc7f56830ecd4fad75 100644 (file)
@@ -43,8 +43,10 @@ Union::~Union()
 
 bool Union::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
+               WorkPlace::pointed = ID;
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && (event->button == 2 )){
                image = null;   
index 293aaf58020a06993693364a00150ea771db2ba1..46b1bcd470aa2ff0242c46a739be0245801dd7f4 100644 (file)
@@ -1,6 +1,8 @@
 #include "workplace.h"
 #include "item.h"
 
+int WorkPlace::pointed = -1;
+
 WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
 {
 }
@@ -27,10 +29,12 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
        color.set_rgb(255,0,0);
        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() ) {
                t_line temp = *i;
-               get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), temp.store->get_position_x(),temp.store->get_position_y());
+               temp.store->get_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;
@@ -38,6 +42,7 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
 
 void WorkPlace::delete_item(int _id)
 {
+       CItem::logic_connect = false;
        std::list<CItem*>::iterator i = listaItems->begin();
        while ( i != listaItems->end() ){
        CItem *temp = *i;
@@ -54,7 +59,7 @@ void WorkPlace::delete_item(int _id)
        CItem *temp = *i;
                if ( temp->get_id() == _id ){
                        delete_line(_id);
-                       listaItems->erase(i);
+                       lista_logic_Items->erase(i);
                        delete temp;
                        break;
                }
@@ -79,8 +84,18 @@ void WorkPlace::delete_line(int _id)
 {
        std::list<t_line>::iterator i = lista_lineas.begin();
        while ( i != lista_lineas.end() ){
-               if ( ((*i).logic->get_id() == _id) || ((*i).store->get_id() == _id) )
+               if ( (*i).store->get_id() == _id ) {
                        lista_lineas.erase(i);
+                       i = lista_lineas.begin();
+               }
                i++;
        }
+       i = lista_lineas.begin();
+       while ( i != lista_lineas.end() ){
+               if ( (*i).logic->get_id() == _id ) {
+                       lista_lineas.erase(i);
+                       i = lista_lineas.begin();
+               }
+               i++;
+       }       
 }