]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
-Las compuertas pueden tener n entradas pero solo 1 salida
authorNicolás Dimov <ndimov@gmail.com>
Wed, 26 Nov 2003 19:24:26 +0000 (19:24 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Wed, 26 Nov 2003 19:24:26 +0000 (19:24 +0000)
-La Not puede tener 1 y 1
-Para conectar hay que atinarle a la zona de conexion de las compuetas, cosa que
habria que dibujarlas como en los otros items.
-Una vez hecho un click en una compueta se puede tirar un cable, pero para tirar
otro cable desde la misma compuerta hay que volver a seleccionarla
-Se salvan correctamente estos cambios en el xml
-Puse que pordefecto los tubos y codos tengan capacidad 10, el tanque 100 y la bomba
entrega 10. para no tener que setearlo cada vez que se agrega un item.
-TODO: dibujar los conectores en las compueetas.

14 files changed:
Constructor/dialogs/constructor.glade
Constructor/include/and.h
Constructor/include/item.h
Constructor/include/not.h
Constructor/include/or.h
Constructor/include/workplace.h
Constructor/src/and.cpp
Constructor/src/cistern.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 1dd2fd1a1af00ebc6f2f0b9179940794f7965457..43279fa79b7c8772509eff49c3c1958db4f855fc 100644 (file)
          <property name="fill">True</property>
        </packing>
       </child>
+
+      <child>
+       <widget class="GtkStatusbar" id="statusbar1">
+         <property name="visible">True</property>
+         <property name="has_resize_grip">True</property>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
     </widget>
   </child>
 </widget>
              <property name="update_policy">GTK_UPDATE_ALWAYS</property>
              <property name="snap_to_ticks">False</property>
              <property name="wrap">False</property>
-             <property name="adjustment">0 0 100 0.1 10 10</property>
+             <property name="adjustment">0 0 10000 0.1 10 10</property>
            </widget>
            <packing>
              <property name="left_attach">1</property>
              <property name="update_policy">GTK_UPDATE_ALWAYS</property>
              <property name="snap_to_ticks">False</property>
              <property name="wrap">False</property>
-             <property name="adjustment">0 0 100 0.1 10 10</property>
+             <property name="adjustment">0 0 10000 0.1 10 10</property>
            </widget>
            <packing>
              <property name="left_attach">1</property>
              <property name="update_policy">GTK_UPDATE_ALWAYS</property>
              <property name="snap_to_ticks">False</property>
              <property name="wrap">False</property>
-             <property name="adjustment">0 0 100 0.1 10 10</property>
+             <property name="adjustment">0 0 10000 0.1 10 10</property>
            </widget>
            <packing>
              <property name="left_attach">1</property>
              <property name="update_policy">GTK_UPDATE_ALWAYS</property>
              <property name="snap_to_ticks">False</property>
              <property name="wrap">False</property>
-             <property name="adjustment">0 0 100 0.1 10 10</property>
+             <property name="adjustment">0 0 10000 0.1 10 10</property>
            </widget>
            <packing>
              <property name="left_attach">1</property>
index b872eca13ebe05036cda85637b7115d374e8ccf5..754a5343b34983df1539272cc3506f58c3ab781c 100644 (file)
@@ -15,8 +15,10 @@ class And : public CItem {
                virtual void update_logic_position();
                virtual void get_in_logic_connect_position(int& _a, int& _b);
                virtual void get_out_logic_connect_position(int& _a, int& _b);  
+               virtual void set_out_connected(bool _o);
        private:
                int in_x, in_y, out_x, out_y;
+               bool out_connected;
                std::vector<t_logic_connector> vec_connector;   
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index d0ed6139e46b89f667851e060876b8fef5e5e604..bae7d225077db2fd304cda3abc389a43fbfdcf5a 100644 (file)
@@ -119,6 +119,13 @@ public:
        */
        virtual void update_logic_position();
        
+       /**Funciones para no permitir mas de una conexion a la salida de las compuertas.
+         *En el caso de la compuerta NOT, tampoco puede tener mas de una conexion 
+         *a la entrada.          
+       */
+       virtual void set_out_connected(bool _o);
+       virtual void set_in_connected(bool _o);
+       
        /**Dibuja los conectores logicos del Item, AZUL == ENTRADA, ROJO == SALIDA.
        */
        virtual void draw_connectors();
index 783cd901465d32bd90349a79d49e9efd1f955955..77c086e244156784d1d0092d33e98715ab6c9c68 100644 (file)
@@ -15,9 +15,11 @@ class Not : public CItem {
                virtual void update_logic_position();
                virtual void get_in_logic_connect_position(int& _a, int& _b);
                virtual void get_out_logic_connect_position(int& _a, int& _b);  
+               virtual void set_out_connected(bool _o);
+               virtual void set_in_connected(bool _o);
        private:
                int in_x, in_y, out_x, out_y;
-               int cant_connections;
+               bool in_connected, out_connected;
                std::vector<t_logic_connector> vec_connector;
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index c1844f197abe250d69a61ae3731215af45fa7481..d9506231e76a3964e2a9728f484c9d9a08d96162 100644 (file)
@@ -15,8 +15,10 @@ class Or : public CItem {
                virtual void update_logic_position();
                virtual void get_in_logic_connect_position(int& _a, int& _b);
                virtual void get_out_logic_connect_position(int& _a, int& _b);  
+               virtual void set_out_connected(bool _o);
        private:
                int in_x, in_y, out_x, out_y;
+               bool out_connected;
                std::vector<t_logic_connector> vec_connector;
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
index fe827174459313d65e8addc4ee954e049a96981e..cb3156197c553a6d96e910c129d2ec7eefa2c352 100644 (file)
@@ -37,10 +37,10 @@ class WorkPlace:public Gtk::Fixed {
                ///Borra las lineas que esten conectadas con el item de ID == _id.
                void delete_line(int _id);      
        
-               ///Devuelve un puntero al item  de transporte _id.
+               ///Devuelve un puntero al item logico cuyo ID es _id.   
                CItem *get_logic_item(int _id);
        
-               ///Devuelve un puntero al item logico cuyo ID es _id.
+               ///Devuelve un puntero al item  de transporte _id.              
                CItem *get_item(int _id);
        
                ///Actualiza las posiciones de los conectores logicos.
@@ -50,8 +50,8 @@ class WorkPlace:public Gtk::Fixed {
                std::list<CItem *> *listaItems, *lista_logic_Items;
                
                /** Listas de lineas que van de una compuerta a la entrada de un item y de la salida de un item a una compuerta
-                         lista_lineas_in =  compuerta --> (entrada) item
-                         lista_lineas_out= compuerta --> (salida) item
+                         lista_lineas_in = (salida) compuerta --> (entrada) item
+                         lista_lineas_out= (entrada) compuerta --> (salida) item
                */
                std::list<t_line> lista_lineas_in, lista_lineas_out;
                
index 2862eaaf2b90db7ad121e0904cdb0325130bf8aa..ccaf8973c3bb0a99d9f26a83b7e6391d7cf81e61 100644 (file)
@@ -2,6 +2,7 @@
 
 And::And()
 {
+       out_connected = false;
        in_x = x;
        in_y = y+16;
        out_x = x+32;
@@ -26,9 +27,15 @@ bool And::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if ( CItem::logic_connect ) {
-                       CItem::gate_id = ID;
-                       WorkPlace::pointed = ID;
-               }
+                       if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected) {
+                               CItem::gate_id = ID;
+                               WorkPlace::pointed = ID;
+                       }
+                       if ( detect_click_position((int)event->x, (int)event->y ) == IN ) {
+                               CItem::gate_id = ID;
+                               WorkPlace::pointed = ID;
+                       }
+               }                       
                list_pointed->push_back(name);
                combo_entry->set_popdown_strings(*list_pointed);
                combo_entry->get_entry()->set_text (name);
@@ -141,8 +148,7 @@ bool And::check_connection()
                }
                i++;
        }
-       //FIXME   la and tiene n entradas  y una salida!!!!!!!!!!!!!!!
-       return true;// (cant_in == cant_out );
+       return true;
 }
 
 ConnectorType And::detect_click_position(int _a, int _b)
@@ -215,3 +221,8 @@ void And::get_out_logic_connect_position(int& _a, int& _b)
        _a =out_x;
        _b =out_y;
 }
+
+void And::set_out_connected(bool _o)
+{
+       out_connected = _o;
+}
index f58df18b44a432e056ae9a6c7e6154bebc693fd9..aebd35d5796fa4c2b0b08924de333885ccf6f1b1 100644 (file)
@@ -7,6 +7,7 @@ Cistern::Cistern(int orientacion)
        in_y = y+16;
        out_x = x + 48;
        out_y = y + 64;
+       capacidad = 100;
        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");
@@ -51,15 +52,19 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                if (CItem::logic_connect && CItem::gate_id != -1) {
                        if ( detect_click_position((int)event->x, (int)event->y) == IN ){
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               workplace->get_logic_item(CItem::gate_id)->set_out_connected(true);
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
                        } else if (detect_click_position((int)event->x, (int)event->y) == OUT) { 
+//                             if (dynamic_cast<Not *>(get_item(temp.logic_id))) 
+       //                              get_logic_item(temp.logic_id)->set_in_connected(true);
                                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);
                                workplace->queue_draw();
                        }
+                       CItem::gate_id = -1;
                }
        }
        
index 680ce43b797dcf2bb4e461ae413c7b76bcc4c6ad..71475d6f5570741ffaa40ff5bdd522736fbc7ae6 100644 (file)
@@ -48,6 +48,7 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
                if (CItem::logic_connect && CItem::gate_id != -1) {
                        if ( detect_click_position((int)event->x, (int)event->y) == IN) {
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               workplace->get_logic_item(CItem::gate_id)->set_out_connected(true);
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();        
@@ -57,6 +58,7 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
+                       CItem::gate_id = -1;
                }
        }
        
index f4604b009f0e3cf24badb5d6fd4145943c5ee54c..d3624db421aae00c19f2ebdbe741790a62b6b508 100644 (file)
@@ -17,7 +17,7 @@ CItem::CItem()
        Glib::RefPtr<Gnome::Glade::Xml> ref;
        ref = Gnome::Glade::Xml::create(PACKAGE_DATA_DIR"/plaqui-constructor/dialogs/constructor.glade", "item_pty_wnd");
        ref->get_widget_derived("item_pty_wnd",property_wnd);
-       caudal_max = 0.0;
+       caudal_max = 10.0;
        is_union = true;
        is_connected = false;
        is_logic =false;
@@ -147,6 +147,14 @@ void CItem::set_name(Glib::ustring _name)
        name = _name;
 }
 
+void CItem::set_out_connected(bool _o)
+{
+}
+
+void CItem::set_in_connected(bool _o)
+{
+}
+
 bool CItem::is_occupied_area(int _a, int _b)
 {      
        if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) )  
@@ -207,4 +215,3 @@ void CItem::draw_connectors()
                queue_draw();
        }
 }
-
index 0a7c8c707748c459b4db250da5a9ad85644b156c..562ee4d90fde5ef91b18e4204c3c873761481b29 100644 (file)
@@ -2,6 +2,7 @@
 
 Not::Not()
 {
+       in_connected = out_connected = false;
        in_x = x;
        in_y = y+16;
        out_x = x+32;
@@ -27,8 +28,14 @@ bool Not::on_button_press_event(GdkEventButton *event)
 
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if ( CItem::logic_connect ) {
-                       CItem::gate_id = ID;
-                       WorkPlace::pointed = ID;
+                       if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected )  {
+                               CItem::gate_id = ID;
+                               WorkPlace::pointed = ID;
+                       }
+                       if ( detect_click_position((int)event->x, (int)event->y ) == IN && !in_connected) {
+                               CItem::gate_id = ID;
+                               WorkPlace::pointed = ID;
+                       }
                }
                list_pointed->push_back(name);
                combo_entry->set_popdown_strings(*list_pointed);
@@ -217,3 +224,13 @@ void Not::get_out_logic_connect_position(int& _a, int& _b)
        _a =out_x;
        _b =out_y;
 }
+
+void Not::set_out_connected(bool _o)
+{
+       out_connected = _o;
+}
+
+void Not::set_in_connected(bool _o)
+{
+       in_connected = _o;
+}
index d7e8a780ac4b48d0906ea10091677fc426abb9cd..5c63e70e83dcf0bda62cae601b331c89435f5d14 100644 (file)
@@ -2,6 +2,7 @@
 
 Or::Or()
 {
+       out_connected = false;
        in_x = x;
        in_y = y+16;
        out_x = x+32;
@@ -26,9 +27,14 @@ bool Or::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                if ( CItem::logic_connect ) {
-                       CItem::gate_id = ID;
-                       WorkPlace::pointed = ID;
-                       workplace->queue_draw();
+                       if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected) {
+                               CItem::gate_id = ID;
+                               WorkPlace::pointed = ID;
+                       } 
+                       if ( detect_click_position((int)event->x, (int)event->y ) == IN ) {
+                               CItem::gate_id = ID;
+                               WorkPlace::pointed = ID;
+                       }
                }
                list_pointed->push_back(name);
                combo_entry->set_popdown_strings(*list_pointed);
@@ -217,3 +223,8 @@ void Or::get_out_logic_connect_position(int& _a, int& _b)
        _a =out_x;
        _b =out_y;
 }
+
+void Or::set_out_connected(bool _o)
+{
+       out_connected = _o;
+}
index 48435cc44eba955a9104873a6ba14b59af23dcc3..46bac68ca7f0694d761fc14b8db3f0f8e8f1b377 100644 (file)
@@ -7,6 +7,7 @@ Pump::Pump(int orientacion)
        in_y = y;
        out_x = in_x;
        out_y = y + 32;
+       entrega = 10.0;
        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");
@@ -48,6 +49,7 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                if (CItem::logic_connect && CItem::gate_id != -1) {
                        if ( detect_click_position((int)event->x, (int)event->y) == IN) {
                                tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               workplace->get_logic_item(CItem::gate_id)->set_out_connected(true);
                                tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
@@ -57,6 +59,7 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
+                       CItem::gate_id = -1;
                }
        }
        
index 37b0aa49ca018b23b892ac64ad138fb536756ee9..2b04130487e1e58665709e74b767cb5b044b93b0 100644 (file)
@@ -2,13 +2,13 @@
 #include "item.h"
 #include "pump.h"
 #include "exclusa.h"
+#include "not.h"
 
 int WorkPlace::pointed = -1;
 
 WorkPlace::WorkPlace(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
 {
        gc = Gdk::GC::create(get_window());
-       std::cout << "Aca" << std::endl;
        Glib::RefPtr<Gdk::Colormap> colormap = gc->get_colormap();
        color_in = Gdk::Color("red");
        color_out = Gdk::Color("blue");
@@ -26,7 +26,6 @@ void WorkPlace::on_realize()
 {
        Gtk::Fixed::on_realize();
        gc = Gdk::GC::create(get_window());
-       std::cout << "Aca" << std::endl;
        Glib::RefPtr<Gdk::Colormap> colormap = gc->get_colormap();
        color_in = Gdk::Color("red");
        color_out = Gdk::Color("blue");
@@ -87,6 +86,7 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
                                        y_offset = -15;
                        }
                        get_logic_item(temp.logic_id)->get_out_logic_connect_position(a, b);
+                       get_logic_item(temp.logic_id)->set_out_connected(true);
                        get_item(temp.store_id)->get_in_logic_connect_position(w,z);
                        draw_line(a+x_offset, b+y_offset, w+item_x_offset, z+item_y_offset, color_in);
                        get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset);
@@ -115,6 +115,8 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
                                        y_offset = 15;
                        }
                        get_item(temp.store_id)->get_out_logic_connect_position(w,z);
+                       if (dynamic_cast<Not *>(get_logic_item(temp.logic_id))) 
+                               get_logic_item(temp.logic_id)->set_in_connected(true);
                        get_logic_item(temp.logic_id)->get_in_logic_connect_position(a, b);
                        draw_line(w+item_y_offset, z+item_y_offset, a+x_offset, b+y_offset,color_out);
                        get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset);
@@ -127,7 +129,6 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
 void WorkPlace::delete_item(int _id)
 {
        delete_line(_id);
-       CItem::logic_connect = false;
        std::list<CItem*>::iterator i = listaItems->begin();
        while ( i != listaItems->end() ){
        CItem *temp = *i;
@@ -190,6 +191,7 @@ void WorkPlace::delete_line(int _id)
        while ( i != lista_lineas_in.end() ){
                if ( get_logic_item((*i).logic_id) != NULL)
                        if ( get_logic_item((*i).logic_id)->get_id() == _id) {
+                               get_logic_item((*i).logic_id)->set_out_connected(false);        
                                lista_lineas_in.erase(i);
                                i = lista_lineas_in.begin();
                        }
@@ -210,6 +212,8 @@ void WorkPlace::delete_line(int _id)
        while ( j != lista_lineas_out.end() ){
                if ( get_logic_item((*j).logic_id) != NULL )
                        if ( get_logic_item((*j).logic_id)->get_id() == _id ) {
+                               if (dynamic_cast<Not *>(get_logic_item((*i).logic_id))) 
+                                       get_logic_item((*j).logic_id)->set_in_connected(false);
                                lista_lineas_out.erase(j);
                                j = lista_lineas_out.begin();
                        }
@@ -238,4 +242,3 @@ void WorkPlace::draw_line(int x1, int y1, int x2, int y2, Gdk::Color &color)
        get_window()->draw_line (gc, x1, y1, x1, y2);
        get_window()->draw_line (gc, x1, y2, x2, y2);
 }
-