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;
+}
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;
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;
+}
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;
-//constructor.cpp
#include "constructor.h"
Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade):Gtk::Window(cobject)
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
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));
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);
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
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++;
+ }
+}
<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>
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.
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);
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;
+}
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);
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;
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;
+}
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
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;
+}
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