]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
para que lo vean
authorNicolás Dimov <ndimov@gmail.com>
Tue, 18 Nov 2003 02:44:49 +0000 (02:44 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Tue, 18 Nov 2003 02:44:49 +0000 (02:44 +0000)
Constructor/cistern.cpp
Constructor/constructor.cpp
Constructor/constructor.h
Constructor/item.cpp
Constructor/item.h
Constructor/or.cpp
Constructor/or.h
Constructor/workplace.cpp
Constructor/workplace.h

index 433f03075005ab5d09b7dd30163bc8e43f384b89..5f2a4fa0ebce4c816a6adbc774393a0221e1d299 100644 (file)
@@ -30,8 +30,21 @@ Cistern::~Cistern()
 
 bool Cistern::on_button_press_event(GdkEventButton *event)
 {
 
 bool Cistern::on_button_press_event(GdkEventButton *event)
 {
-       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+       GdkEventExpose e;
+       CItem *logic_item;
+       t_line tmp_line;
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                combo_entry->set_text(name);
+               if (CItem::logic_connect) {
+                       std::cout<<workplace<<std::endl;
+                       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)){
                image = null; 
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
                image = null; 
index 241abdb3f2d6f1627e74da12df3fec259901fe96..67e1a0855b99814b5d4ac2fefa722e74a0079eaf 100644 (file)
@@ -94,6 +94,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        workplace->drag_dest_set(listTargets);
        workplace->signal_drag_data_received().connect( SigC::slot(*this, &Constructor::on_item_drop_drag_received) );  
        workplace->listaItems = &listaItems;    
        workplace->drag_dest_set(listTargets);
        workplace->signal_drag_data_received().connect( SigC::slot(*this, &Constructor::on_item_drop_drag_received) );  
        workplace->listaItems = &listaItems;    
+       workplace->listaItems = &lista_logic_Items;     
        logica = false;
 }
 
        logica = false;
 }
 
@@ -271,7 +272,9 @@ void Constructor::on_not_drag_begin(const Glib::RefPtr<Gdk::DragContext>& contex
 
 void Constructor::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, CItem *item)
 {
 
 void Constructor::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, CItem *item)
 {
+       GdkEventExpose e;
        context->set_icon(item->get_image(), 5, 5);
        context->set_icon(item->get_image(), 5, 5);
+       workplace->on_expose_event(&e);
 }
 
 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)
@@ -318,29 +321,30 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                if ((selection_data->length >= 0) && (selection_data->format == 8))     {
                        CItem *a;
                        if (strcmp((const char *)selection_data->data, "codo_o.png")==0) 
                if ((selection_data->length >= 0) && (selection_data->format == 8))     {
                        CItem *a;
                        if (strcmp((const char *)selection_data->data, "codo_o.png")==0) 
-                               a = new Splitter();
-                                       else    if (strcmp((const char *)selection_data->data, "canio_n.png")==0) 
-                                               a = new Conduct();
-                                                       else if (strcmp((const char *)selection_data->data, "y_n.png")==0) 
-                                                               a = new Union();
-                                                                       else if (strcmp((const char *)selection_data->data, "tanque_e.png")==0) 
-                                                                               a = new Cistern();
-                                                                                       else if (strcmp((const char *)selection_data->data, "bomba_e.png")==0) 
-                                                                                               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, "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();  
+                       a = new Splitter();
+                       else    if (strcmp((const char *)selection_data->data, "canio_n.png")==0) 
+                       a = new Conduct();
+                       else if (strcmp((const char *)selection_data->data, "y_n.png")==0) 
+                       a = new Union();
+                       else if (strcmp((const char *)selection_data->data, "tanque_e.png")==0) 
+                       a = new Cistern();
+                       else if (strcmp((const char *)selection_data->data, "bomba_e.png")==0) 
+                       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, "drain_n.png")==0) 
+                       a = new Drain();
+                       else if (strcmp((const char *)selection_data->data, "and_e.png")==0){ 
+                       a = new And(); a->is_logic = true;
+                       } 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;
+                                       }
                
                        char char_id[10];
                        sprintf(char_id,"%d",id);
                
                        char char_id[10];
                        sprintf(char_id,"%d",id);
-                       a->set_id(++id);                
+                       a->set_id(id++);                
                        a->set_name( a->get_name()+char_id );
                        if ( can_drop(a, i*32, j*32) ) {
                                workplace->put(*a, i*32, j*32);
                        a->set_name( a->get_name()+char_id );
                        if ( can_drop(a, i*32, j*32) ) {
                                workplace->put(*a, i*32, j*32);
@@ -350,6 +354,8 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                                a->combo_entry = combo_entry;
                                //Apunto a la listaItems.
                                a->listaItems = &listaItems;
                                a->combo_entry = combo_entry;
                                //Apunto a la listaItems.
                                a->listaItems = &listaItems;
+                               //Apunto a la lista de items logicos
+                               a->lista_logic_Items = &lista_logic_Items;
                                //Seteo la posicion del item
                                a->set_position(i*32,j*32);
                                // Seteo la lista de tipos de drags 
                                //Seteo la posicion del item
                                a->set_position(i*32,j*32);
                                // Seteo la lista de tipos de drags 
@@ -364,7 +370,10 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                                // raro se vea el widget tal cual.
                                a->signal_drag_begin().connect(SigC::bind( SigC::slot(*this, &Constructor::on_item_drag_begin), a));
                                a->show();      
                                // raro se vea el widget tal cual.
                                a->signal_drag_begin().connect(SigC::bind( SigC::slot(*this, &Constructor::on_item_drag_begin), a));
                                a->show();      
-                               listaItems.push_back(a);
+                               if (! a->is_logic )
+                                       listaItems.push_back(a);
+                               else 
+                                       lista_logic_Items.push_back(a);
                        } else {
                                        id--;
                                        delete a;
                        } else {
                                        id--;
                                        delete a;
index 64f8a06de5f81665af89df9e3def106f5f047d15..b406ce5c376bb0bf5fab829fa56438d64da675a7 100644 (file)
@@ -45,7 +45,7 @@ class Constructor : public Gtk::Window {
        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;
        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;
+       std::list<CItem *> listaItems, lista_logic_Items;
        WorkPlace *workplace;
        bool logica;
        bool can_drop(CItem *, int , int);
        WorkPlace *workplace;
        bool logica;
        bool can_drop(CItem *, int , int);
index cd53614c6eb486539519bc0374fecf076217eb47..77eefda2ec7478d92461a98c936a57ebb2a3d507 100644 (file)
@@ -1,5 +1,8 @@
 #include "item.h"
 #include "item.h"
-#include "workplace.h"
+
+bool CItem::   logic_connect = false;
+int CItem::quien = -1;
+
 
 CItem::CItem(const char *filename):Gtk::DrawingArea()
 {
 
 CItem::CItem(const char *filename):Gtk::DrawingArea()
 {
@@ -15,6 +18,7 @@ CItem::CItem()
        caudal_max = 0.0;
        is_union = true;
        is_connected = false;
        caudal_max = 0.0;
        is_union = true;
        is_connected = false;
+       is_logic =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);
index 87ddb0190000cb8ef538ca3d7af7b5c20d56b96a..34f9ecd770831ea1008528f713178399a95c21cb 100644 (file)
@@ -10,6 +10,7 @@
 #include <libglademm.h>
 #include <gtkmm/entry.h>
 #include "itemptywnd.h"
 #include <libglademm.h>
 #include <gtkmm/entry.h>
 #include "itemptywnd.h"
+#include "workplace.h"
 
 ///Tipo de estado en el que pueden estar los conectores de un item
 typedef enum { UNDEF, IN, OUT } ConnectorType;
 
 ///Tipo de estado en el que pueden estar los conectores de un item
 typedef enum { UNDEF, IN, OUT } ConnectorType;
@@ -29,7 +30,7 @@ class Connector {
                }
 };
 
                }
 };
 
-class WorkPlace;
+//class WorkPlace;
        
 class CItem:public Gtk::DrawingArea {
 public:
        
 class CItem:public Gtk::DrawingArea {
 public:
@@ -103,12 +104,22 @@ public:
        ///Puntero a la lista de items
        std::list<CItem *> *listaItems;
        
        ///Puntero a la lista de items
        std::list<CItem *> *listaItems;
        
+       ///Puntero a la lista de Items logicos
+       std::list<CItem *> *lista_logic_Items;
+       
        ///TODO poner esto en Union y crear una ventana nueva de propiedades
        bool is_union;
        
        ///indica si el item ya esta conectado con sus conectores bien definidos
        bool is_connected;
        
        ///TODO poner esto en Union y crear una ventana nueva de propiedades
        bool is_union;
        
        ///indica si el item ya esta conectado con sus conectores bien definidos
        bool is_connected;
        
+       ///Indica si es una compuerta logica
+       bool is_logic;
+       
+       ///Indica si puede realizarse la conexion logica con una compuerta
+       static bool logic_connect;
+       static int quien;
+       
        /**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.
         *                                      "derecha" para la bomba.
        /**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.
         *                                      "derecha" para la bomba.
@@ -123,22 +134,31 @@ public:
 protected:
        ///Indica el numero que le corresponde a la imagen actual del item.
        int imgActual;
 protected:
        ///Indica el numero que le corresponde a la imagen actual del item.
        int imgActual;
+
        ///Numero "unico" que identifica al item.
        int ID;
        ///Numero "unico" que identifica al item.
        int ID;
+
        ///Nombre del item
        Glib::ustring name;
        ///Nombre del item
        Glib::ustring name;
+       
        ///Caudal maximo que puede contener un item.
        double caudal_max;
        ///Caudal maximo que puede contener un item.
        double caudal_max;
+       
        ///Menu flotante del item
        Gtk::Menu menu_popup;
        ///Menu flotante del item
        Gtk::Menu menu_popup;
+       
        ///Lista de opciones del menu flotante
        Gtk::Menu::MenuList menulist;
        ///Lista de opciones del menu flotante
        Gtk::Menu::MenuList menulist;
+       
        ///Imagenes del menu flotante
        Gtk::Image menu_image_delete, menu_image_rotar, menu_image_propiedades, menu_image_linea;
        ///Imagenes del menu flotante
        Gtk::Image menu_image_delete, menu_image_rotar, menu_image_propiedades, menu_image_linea;
+       
        ///Puntero a la imagen del item
        Glib::RefPtr<Gdk::Pixbuf> image;
        ///Puntero a la imagen del item
        Glib::RefPtr<Gdk::Pixbuf> image;
+       
        ///Puntero a la ventana de propiedades del item
        ItemPtyWnd *property_wnd;
        ///Puntero a la ventana de propiedades del item
        ItemPtyWnd *property_wnd;
+       
        ///Posicion del item en el area de trabajo
        int x, y;
 };
        ///Posicion del item en el area de trabajo
        int x, y;
 };
index b4801881aedf08cc48a82a9ab4bd358cec548ff9..0c0631b29ef780b885514e9c40f75b61566381b2 100644 (file)
@@ -20,8 +20,10 @@ Or::~Or()
 
 bool Or::on_button_press_event(GdkEventButton *event)
 {
 
 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)) {
+               std::cout<<ID<<std::endl;
                combo_entry->set_text(name);
                combo_entry->set_text(name);
+       }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
@@ -50,6 +52,7 @@ bool Or::on_button_press_event(GdkEventButton *event)
        }
        return true;
 }
        }
        return true;
 }
+
 void Or::on_menu_popup_rotar()
 {
        GdkEventButton event; 
 void Or::on_menu_popup_rotar()
 {
        GdkEventButton event; 
@@ -58,7 +61,11 @@ void Or::on_menu_popup_rotar()
        Or::on_button_press_event(&event);
 }
 
        Or::on_button_press_event(&event);
 }
 
-
+void Or::on_menu_popup_conectar()
+{
+       CItem::logic_connect = true;
+       CItem::quien = ID;      
+}
 
 void Or::save(FILE *archivo)
 {
 
 void Or::save(FILE *archivo)
 {
index 9da1cd2a0f429bfe34f17f8b74ddac626f2a6be9..10b9234d3ba2ef70c1883f2cc34141ec5623be17 100644 (file)
@@ -9,8 +9,10 @@ class Or : public CItem {
                virtual ~Or();
                virtual bool on_button_press_event(GdkEventButton *event);
                virtual void on_menu_popup_rotar();
                virtual ~Or();
                virtual bool on_button_press_event(GdkEventButton *event);
                virtual void on_menu_popup_rotar();
+               virtual void on_menu_popup_conectar();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
                virtual void save(FILE *archivo);
                virtual bool check_connection();
+               std::list<int> connected_items;
        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 1e7ceab5d8affd4ede09abed62db8831bc71063d..e1fa47d64ed092466304479d334f6b9f5f7d5215 100644 (file)
@@ -1,9 +1,8 @@
 #include "workplace.h"
 #include "workplace.h"
+#include "item.h"
 
 WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
 {
 
 WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
 {
-       refGlade->get_widget_derived("viewport",viewport);
-       viewport->workplace = this;
 }
 
 WorkPlace::~WorkPlace()
 }
 
 WorkPlace::~WorkPlace()
@@ -22,12 +21,12 @@ 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);
                }
                
-/*     std::list<t_line>::iterator i = lista_lineas.begin();
+       std::list<t_line>::iterator i = lista_lineas.begin();
        while ( i != lista_lineas.end() ) {
                t_line temp = *i;
        while ( i != lista_lineas.end() ) {
                t_line temp = *i;
-               get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);
+               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());
                i++;
                i++;
-       }*/
+       }
        return true;
 }
 
        return true;
 }
 
@@ -44,3 +43,15 @@ void WorkPlace::delete_item(int _id)
                i++;
        }
 }
                i++;
        }
 }
+
+CItem* WorkPlace::get_logic_item(int _id)
+{
+       std::list<CItem *>::iterator i = lista_logic_Items->begin();
+       while ( i != lista_logic_Items->end() ){
+               CItem *temp = *i;
+               if ( temp->get_id() == _id )
+                       return temp;
+               i++;
+       }
+       return NULL;
+}
index c3e290135690ea438ef3c167d1dec9a6b74c5be0..896e908f68d577e213ec53f516f3d85423428071 100644 (file)
@@ -5,11 +5,12 @@
 #include <gdkmm/gc.h>
 #include <gtkmm.h>
 #include <libglademm.h>
 #include <gdkmm/gc.h>
 #include <gtkmm.h>
 #include <libglademm.h>
-#include "activezone.h"
-#include "item.h"
 
 class CItem;
 
 class CItem;
-class ActiveZone;
+
+typedef struct {
+       CItem *logic, *store;
+}t_line;
 
 class WorkPlace:public Gtk::Fixed {
        public:
 
 class WorkPlace:public Gtk::Fixed {
        public:
@@ -17,9 +18,9 @@ class WorkPlace:public Gtk::Fixed {
                virtual ~WorkPlace();
                virtual bool on_expose_event(GdkEventExpose *event);
                void delete_item(int _id);      
                virtual ~WorkPlace();
                virtual bool on_expose_event(GdkEventExpose *event);
                void delete_item(int _id);      
-               std::list<CItem *> *listaItems;
+               CItem *get_logic_item(int _id);
+               std::list<CItem *> *listaItems, *lista_logic_Items;
                std::list<t_line> lista_lineas;
                std::list<t_line> lista_lineas;
-               ActiveZone *viewport;
 };
 
 #endif
 };
 
 #endif