]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
ya no me acuerdo ni que cambie, pero va tomando forma esto, si el circuito que se...
authorNicolás Dimov <ndimov@gmail.com>
Tue, 11 Nov 2003 03:58:20 +0000 (03:58 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Tue, 11 Nov 2003 03:58:20 +0000 (03:58 +0000)
13 files changed:
Constructor/cistern.cpp
Constructor/cistern.h
Constructor/conduct.cpp
Constructor/conduct.h
Constructor/constructor.cpp
Constructor/constructor.glade
Constructor/constructor.h
Constructor/item.cpp
Constructor/item.h
Constructor/splitter.cpp
Constructor/splitter.h
Constructor/union.cpp
Constructor/union.h

index 41073c197557879a5016400e42856549849ab9ff..fe0e5dd1a5ccb42ebaaa79b5f7df5679f49fc83d 100644 (file)
@@ -112,3 +112,17 @@ void Cistern::save(FILE *archivo)
        dato += "\t</tanque>\n";
        fprintf(archivo,dato.c_str());  
 }
+
+bool Cistern::check_connection()
+{
+       switch (get_img_actual()) {
+               case 0:
+                       if ( is_other_occupied_area( get_position_x()+get_image()->get_width()+10 , get_position_y()+get_image()->get_height() -10) )
+                               return true;                            
+                       break;
+               case 1:
+                       if ( is_other_occupied_area( get_position_x() -10, get_position_y()+get_image()->get_height()-10) )
+                               return true;
+       }
+       return false;
+}
index 7b552d28220e88c7ded310c9c9edb36f00141f5a..1bb290c4706e149d4148078181c50cdfae81ffb1 100644 (file)
@@ -18,9 +18,9 @@ class Cistern : public CItem {
                void set_contenido_inicial(double _ini);
                double get_contenido_inicial();
                virtual void save(FILE *archivo);
+               virtual bool check_connection();
        protected:
                double capacidad, contenido_inicial;
-               int imgActual;  
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageO; // 1
                Glib::RefPtr<Gdk::Pixbuf> null; 
index 1daf3560cf3a6fedecd91cdd5e550ea9566c0ca6..2a582fb9f82fc8c432276bbc97063a4aa284c74c 100644 (file)
@@ -85,3 +85,19 @@ void Conduct::save(FILE *archivo)
        dato += "\t</tubo>\n";
        fprintf(archivo,dato.c_str());  
 }
+
+bool Conduct::check_connection()
+{
+       switch (get_img_actual()) {
+                       case 0:
+                               if ( is_other_occupied_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+10) && 
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()/2, get_position_y() - 10) )
+                                       return true;                            
+                               break;
+                       case 1:
+                               if ( is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()/2) && 
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+get_image()->get_height()/2) )
+                               return true;
+       }
+       return false;
+}
index 84007ed51d584b843b5b559c3b24c1f9052a6d06..4937caf285b95cc17007a74f6f988bbca20b3a6b 100644 (file)
@@ -11,9 +11,8 @@ class Conduct : public CItem {
                virtual void on_menu_popup_rotar();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
+               virtual bool check_connection();
        private:
-               int imgActual;  
-       
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
                Glib::RefPtr<Gdk::Pixbuf> null; 
index e8180b0d3109e8907a663590d6f68a3422da3275..98fbb786ffc7f754ad4df8b81172109cc9f8732c 100644 (file)
@@ -1,4 +1,3 @@
-//constructor.cpp
 #include "constructor.h"
 
 Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade):Gtk::Window(cobject)
@@ -22,6 +21,9 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        refGlade->get_widget("chk_btn_logica",chk_btn_logica);
        refGlade->get_widget("file_selection",file_selection);
        refGlade->get_widget("combo_entry",combo_entry);
+       refGlade->get_widget("btn_check",btn_check);
+       refGlade->get_widget("dlg_connect", dlg_connect);
+       refGlade->get_widget("btn_dlg_close", btn_dlg_close);
        
        refGlade->get_widget_derived("workplace", workplace);  //fixed
        
@@ -40,6 +42,8 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        btn_y->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_y_drag_get));
        btn_codo->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_codo_drag_get));
        btn_tanque->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_tanque_drag_get));
+       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));
        chk_btn_logica->signal_clicked().connect(SigC::slot(*this, &Constructor::on_chk_btn_clicked));
        
        main_menu_quit->signal_activate().connect(SigC::slot(*this, &Constructor::on_main_menu_quit));
@@ -141,6 +145,11 @@ void Constructor::on_btn_file_cancel_clicked()
        file_selection->hide();
 }
 
+void Constructor::on_btn_dlg_connect_clicked()
+{
+       dlg_connect->hide();
+}
+
 void Constructor::on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
 {
        context->set_icon(ico_canio, 5, 5); 
@@ -231,6 +240,8 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                                a->workplace= workplace;
                                //Apunto a la lista.
                                a->combo_entry = combo_entry;
+                               //Apunto a la listaItems.
+                               a->listaItems = &listaItems;
                                //Seteo la posicion del item
                                a->set_position(i*32,j*32);
                                // Seteo la lista de tipos de drags 
@@ -255,3 +266,16 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
                context->drag_finish(false, false, time);
        }
 }
+
+void Constructor::on_btn_check_clicked()
+{
+       std::list<CItem *>::iterator i = listaItems.begin();
+       while ( i != listaItems.end() ) {
+               CItem *temp = *i;
+               if ( !temp->check_connection() ) {
+                       dlg_connect->show();
+                       break;
+               }
+       i++;
+       }
+}
index db62ae0de9fcb2e4a0fda14fbe8b4cca24010769..01b07435913f4f5f4038fda5590839b85804471f 100644 (file)
          <property name="spacing">0</property>
 
          <child>
-           <widget class="GtkLabel" id="label17">
-             <property name="width_request">125</property>
+           <widget class="GtkButton" id="btn_check">
              <property name="visible">True</property>
-             <property name="label" translatable="yes">Buscar Item</property>
-             <property name="use_underline">False</property>
-             <property name="use_markup">False</property>
-             <property name="justify">GTK_JUSTIFY_LEFT</property>
-             <property name="wrap">False</property>
-             <property name="selectable">False</property>
-             <property name="xalign">0.5</property>
-             <property name="yalign">0.5</property>
-             <property name="xpad">0</property>
-             <property name="ypad">0</property>
+             <property name="can_focus">True</property>
+             <property name="label" translatable="yes">Verificar Conexionado</property>
+             <property name="use_underline">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
            </widget>
            <packing>
              <property name="padding">0</property>
   </child>
 </widget>
 
+<widget class="GtkDialog" id="dlg_connect">
+  <property name="title" translatable="yes">Error</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_CENTER</property>
+  <property name="modal">True</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox3">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="buttonarea">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
+
+         <child>
+           <widget class="GtkButton" id="btn_dlg_close">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-ok</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-5</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkLabel" id="label21">
+         <property name="visible">True</property>
+         <property name="label" translatable="yes">Los elementos no estan conectados
+                correctamente</property>
+         <property name="use_underline">False</property>
+         <property name="use_markup">False</property>
+         <property name="justify">GTK_JUSTIFY_FILL</property>
+         <property name="wrap">False</property>
+         <property name="selectable">False</property>
+         <property name="xalign">0.5</property>
+         <property name="yalign">0.5</property>
+         <property name="xpad">0</property>
+         <property name="ypad">0</property>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index f9b5bf316b36a116ea2dae01caef6b9163daae50..d2c9d6faef4b398d27ab7c5afb418a8da34bd93c 100644 (file)
@@ -29,16 +29,17 @@ class Constructor : public Gtk::Window {
        protected: 
        int id;
                // / defino los elementos de la ventana.
-       Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_file_ok, *btn_file_cancel;
+       Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_file_ok, *btn_file_cancel, *btn_check, *btn_dlg_close;
        Gtk::ImageMenuItem *main_menu_quit, *edit_menu_del, *main_menu_save;
        Gtk::CheckButton *chk_btn_logica;
        Gtk::FileSelection *file_selection;
        Gtk::Entry *combo_entry;
-       WorkPlace *workplace;
+       Gtk::Dialog *dlg_connect;
        Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo, ico_tanque;
-       std::list<Gtk::TargetEntry> listTargets;
        Glib::RefPtr<Gdk::Pixbuf> ico_last;
+       std::list<Gtk::TargetEntry> listTargets;
        std::list<CItem *> listaItems;
+       WorkPlace *workplace;
        bool logica;
        bool can_drop(CItem *, int , int);
        // /señales de control para los elementos de la ventana.
@@ -53,6 +54,8 @@ class Constructor : public Gtk::Window {
        virtual void on_chk_btn_clicked();
        virtual void on_btn_file_ok_clicked();
        virtual void on_btn_file_cancel_clicked();
+       virtual void on_btn_check_clicked();
+       virtual void on_btn_dlg_connect_clicked();
                
        // señales para cambiar el icono.
        virtual void on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
index 79515ff4990ab1d3bded0be364dac10eecfef20b..31d955dbebb8ea4faabfccc8aae3f8635fe2d8e4 100644 (file)
@@ -126,9 +126,26 @@ int CItem::get_conector_out()
        return conector_out;
 }
 
+int CItem::get_img_actual()
+{
+       return imgActual;
+}
+
 bool CItem::is_occupied_area(int _a, int _b)
 {      
        if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) )  
                        return true;
                else return false;
 }
+
+bool CItem::is_other_occupied_area(int _a, int _b)
+{
+       std::list<CItem *>::iterator i = listaItems->begin();
+       while ( i != listaItems->end() ){
+               CItem *temp = *i;
+               if ( temp->is_occupied_area(_a,_b) )
+                       return true;
+               i++;
+       }
+       return false;
+}
index 3c78eaf2e0903e4b10873fcf4e7112a4fec16903..facb96d12b4be43b88125447a53fb380f9c43236 100644 (file)
@@ -24,12 +24,12 @@ public:
        virtual void on_menu_popup_eliminar();
        virtual void on_menu_popup_conectar();
        Glib::RefPtr<Gdk::Pixbuf> get_image() { return image; }
-       virtual void save(FILE *archivo) = 0;
        int get_position_x();
        int get_position_y();
        int get_id();
        int get_conector_in();
        int get_conector_out();
+       int get_img_actual();
        double get_caudal();
        void set_position(int _x, int _y);
        void set_id(int _id);
@@ -38,10 +38,15 @@ public:
        void set_conector_in(int _in);
        void set_conector_out(int _out);
        bool is_occupied_area(int _a, int _b);
+       bool is_other_occupied_area(int _a, int _b);
+       virtual void save(FILE *archivo) = 0;
+       virtual bool check_connection()=0;
        Glib::ustring get_name();
        WorkPlace *workplace;
        Gtk::Entry *combo_entry;
+       std::list<CItem *> *listaItems;
 protected:
+       int imgActual;
        int ID, conector_in, conector_out; 
        Glib::ustring name;
        double caudal_max;
index 71241baee52341add60b00f37a984476390c1eb7..5e61abd60397e88b97e506e76c74d995cf3788fd 100644 (file)
@@ -90,3 +90,29 @@ void Splitter::save(FILE *archivo)
        dato += "\t</codo>\n";
        fprintf(archivo,dato.c_str());  
 }
+
+bool Splitter::check_connection()
+{
+       switch (get_img_actual()) {
+                       case 0:
+                               if ( is_other_occupied_area( get_position_x()-10, get_position_y()+10) && 
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()-10, +get_position_y()+get_image()->get_height() + 10) )
+                                       return true;                            
+                               break;  
+                       case 1:
+                               if ( is_other_occupied_area( get_position_x()+get_image()->get_width() - 10, get_position_y() -10) && 
+                                        is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()-10) )
+                                       return true;
+                               break;
+                       case 2:
+                               if ( is_other_occupied_area( get_position_x() + 10, get_position_y() -10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+get_image()->get_height()-10) )
+                                       return true;
+                               break;
+                       case 3:
+                               if ( is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y() +10) &&
+                                        is_other_occupied_area( get_position_x() + 10, get_position_y()+get_image()->get_height() + 10) )
+                                       return true;
+       }
+       return false;
+}
index b8f55d451af9e77568f3d060cc79d28838738009..206aa24db139cf5e98eaf721ff584b2277b9adba 100644 (file)
@@ -11,9 +11,8 @@ class Splitter : public CItem {
                virtual void on_menu_popup_rotar();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
+               virtual bool check_connection();
        private:
-               int imgActual;  
-       
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 2
index 82a51409f12e7f795266dfd4e434f5bef6da7aba..3de8b900fc3eee1d20a5f41059a2e606bd74392c 100644 (file)
@@ -91,3 +91,33 @@ void Union::save(FILE *archivo)
        dato += "\t</union>\n";
        fprintf(archivo,dato.c_str());  
 }
+
+bool Union::check_connection()
+{
+       switch (get_img_actual()) {
+                       case 0:
+                               if ( is_other_occupied_area( get_position_x() - 10, get_position_y() +10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+10) )
+                                       return true;                            
+                               break;
+                       case 1:
+                               if ( is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()/2) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()-10, get_position_y()-10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()-10, get_position_y()+get_image()->get_height()+10) )
+                                       return true;                            
+                               break;
+                       case 2:
+                               if ( is_other_occupied_area( get_position_x()-10, get_position_y()+get_image()->get_height()-10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()/2, get_position_y()-10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+get_image()->get_height()-10) )
+                                       return true;
+                               break;
+                       case 3:
+                               if ( is_other_occupied_area( get_position_x()+10, get_position_y()-10) &&
+                                        is_other_occupied_area( get_position_x()+get_image()->get_width()+10, get_position_y()+get_image()->get_height()/2) &&
+                                        is_other_occupied_area( get_position_x()+10, get_position_y()+get_image()->get_height()+10) )
+                                       return true;
+       }
+       return false;   
+}
index aa435b694873541a88c2f1998a46389c3b3490d4..2376c79fa9de7ba6c57ac9698ee430a8a4dabb63 100644 (file)
@@ -12,9 +12,8 @@ class Union : public CItem {
                virtual void on_menu_popup_rotar();
                virtual void on_menu_popup_propiedades();
                virtual void save(FILE *archivo);
+               virtual bool check_connection();
        private:
-               int imgActual;  
-       
                Glib::RefPtr<Gdk::Pixbuf> imageN; // 0 
                Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
                Glib::RefPtr<Gdk::Pixbuf> imageE; // 2