// CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bool And::check_connection()
{
- switch (get_img_actual()) {
+ /*switch (get_img_actual()) {
case 0:
if ( is_other_connection_area( get_position_x()-5, get_position_y()+16) &&
is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5) )
return true;
- break;
case 1:
if ( is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5) &&
is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16) )
return true;
- break;
case 2:
if ( is_other_connection_area( get_position_x() + 16, get_position_y() -5) &&
is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16) )
return true;
- break;
case 3:
if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16) &&
is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
return true;
}
- return false;
+ return false;*/
+ return true;
}
+/*
bool And::is_connection_area(int _a, int _b)
{
switch (imgActual) {
}
return false;
}
+*/
virtual void on_menu_popup_rotar();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+// virtual bool is_connection_area(int _a, int _b);
private:
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
cistern_pty_wnd->cistern = this;
cistern_pty_wnd->set_title("Propiedades del Tanque");
name = "tanque";
+
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = IN;
+ connect_vec.push_back(temp); // entrada arriba
+ temp.type = OUT;
+ connect_vec.push_back(temp); // salida abajo
}
Cistern::~Cistern()
bool Cistern::check_connection()
{
+ ConnectorType temp0, temp1;
switch (get_img_actual()) {
case 0:
- if ( is_other_connection_area( get_position_x()+get_image()->get_width() + 5 , get_position_y()+get_image()->get_height() -16) &&
- is_other_connection_area( get_position_x() + 16, get_position_y() - 5) )
- return true;
+ temp0 = is_other_connection_area( get_position_x()+get_image()->get_width() + 5 , get_position_y()+get_image()->get_height() -16);
+ temp1 = is_other_connection_area( get_position_x() + 16, get_position_y() - 5);
+ break;
case 1:
- if ( is_other_connection_area( get_position_x() -5, get_position_y()+get_image()->get_height()-16) &&
- is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() - 5) )
- return true;
+ temp0 = is_other_connection_area( get_position_x() -5, get_position_y()+get_image()->get_height()-16);
+ temp1 = is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() - 5);
}
- return false;
+ if (temp0 == OUT && temp1 == IN)
+ return (is_connected = true);
+ return is_connected;
}
-bool Cistern::is_connection_area(int _a, int _b)
+ConnectorType Cistern::get_connector_type(int _a, int _b)
+{
+ switch (imgActual) {
+ case 0: if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) )
+ return connect_vec[0].type;
+ if ( (_a <= x+image->get_width()-1)&&(_a >=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) )
+ return connect_vec[1].type;
+ break;
+ case 1: if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+10)&&(_b > y) )
+ return connect_vec[0].type;
+ if ( (_a <= x +10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) )
+ return connect_vec[1].type;
+ }
+ return UNDEF;
+}
+
+/*
+ConnectorType Cistern::is_connection_area(int _a, int _b)
{
switch (imgActual) {
- case 0: if ( ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) ) ||
- ( (_a <= x+image->get_width()-1)&&(_a >=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) ) )
- return true;
- case 1: if ( ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+10)&&(_b > y) ) ||
- ( (_a <= x +10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) ) )
- return true;
+ case 0:
+ if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) )
+ return connect_vec[0].type;
+ if ( (_a <= x+image->get_width()-1)&&(_a >=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) )
+ return connect_vec[1].type;
+ break;
+ case 1:
+ if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+10)&&(_b > y) )
+ return connect_vec[0].type;
+ if ( (_a <= x +10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b >=y+image->get_height()-22) )
+ return connect_vec[1].type;
+ break;
}
- return false;
+ return UNDEF;
}
+*/
Gdk::Color get_liquid_color();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+// virtual ConnectorType is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
protected:
double capacidad, contenido_inicial;
Glib::RefPtr<Gdk::Pixbuf> imageE; // 0
refGlade->get_widget("spin_inicial", spin_inicial);
refGlade->get_widget("txt_cistern_name", txt_cistern_name);
refGlade->get_widget("btn_select_color", btn_select_color);
+ refGlade->get_widget("color_preview",color_preview);
+
Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "color_select_dlg");
ref->get_widget("color_select_dlg",color_select_dlg);
ref->get_widget("dlg_select_color_cancel",dlg_select_color_cancel);
void CisternPtyWnd::on_dlg_select_color_ok_clicked()
{
cistern->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
+ color_preview->modify_bg( Gtk::STATE_NORMAL , cistern->get_liquid_color() );
color_select_dlg->hide();
}
Gtk::Button *btn_select_color, *dlg_select_color_ok, *dlg_select_color_cancel;
Gtk::Entry *txt_cistern_name;
Gtk::ColorSelectionDialog *color_select_dlg;
+ Gtk::DrawingArea *color_preview;
virtual void on_btn_accept_clicked();
virtual void on_btn_apply_clicked();
virtual void on_btn_select_color_clicked();
set_size_request(image->get_width(), image->get_height());
property_wnd->set_title("Propiedades del Tubo");
name="tubo";
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = UNDEF;
+ connect_vec.push_back(temp);
+ connect_vec.push_back(temp);
}
Conduct::~Conduct()
{
switch (get_img_actual()) {
case 0:
- if ( is_other_connection_area( get_position_x()+16, get_position_y()-5) &&
- is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5) )
- return true;
+ connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5);
+ connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5);
+ break;
case 1:
- if ( is_other_connection_area( get_position_x()-5, get_position_y()+16) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) )
- return true;
+ connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16);
+ connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
}
- return false;
+ if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
+ return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
+ else return false;
}
+ConnectorType Conduct::get_connector_type(int _a, int _b)
+{
+ if ( ! is_connected ) {
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
+ return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5); //pregunto que hay abajo
+ if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 ))//abajo
+ return is_other_connection_area( get_position_x()+16, get_position_y()-5);//pregunto que hay arriba.
+ break;
+ case 1:
+ if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
+ return is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16);//pregunto por la derecha
+ if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
+ return is_other_connection_area(get_position_x()-5, get_position_y()+16); //pregunto por la izquierda.
+ }
+ } else {
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
+ return connect_vec[0].type;
+ if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo
+ return connect_vec[1].type;
+ break;
+ case 1:
+ if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
+ return connect_vec[0].type;
+ if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
+ return connect_vec[1].type;
+ }
+ }
+ return UNDEF;
+}
+/*si no estoy conectado pregunto por el del otro lado, y ahi puedo setear los dos
+ *si ya estoy devuelvo.
+*/
+/*
bool Conduct::is_connection_area(int _a, int _b)
{
switch (imgActual){
}
return false;
}
+*/
virtual void on_menu_popup_propiedades();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+// virtual bool is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
private:
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
ico_codo = Gdk::Pixbuf::create_from_file("codo_o.png");
ico_tanque = Gdk::Pixbuf::create_from_file("tanque_e.png");
ico_exclusa = Gdk::Pixbuf::create_from_file("exclusa_h.png");
+ ico_drain = Gdk::Pixbuf::create_from_file("drain_n.png");
ico_bomba = Gdk::Pixbuf::create_from_file("bomba_e.png");
ico_and = Gdk::Pixbuf::create_from_file("and_e.png");
ico_or = Gdk::Pixbuf::create_from_file("or_e.png");
refGlade->get_widget("btn_tanque",btn_tanque);
refGlade->get_widget("btn_bomba", btn_bomba);
refGlade->get_widget("btn_exclusa", btn_exclusa);
+ refGlade->get_widget("btn_drain", btn_drain);
refGlade->get_widget("btn_and", btn_and);
refGlade->get_widget("btn_or", btn_or);
refGlade->get_widget("btn_not", btn_not);
btn_codo->drag_source_set(listTargets);
btn_tanque->drag_source_set(listTargets);
btn_bomba->drag_source_set(listTargets);
+ btn_drain->drag_source_set(listTargets);
btn_exclusa->drag_source_set(listTargets);
btn_and->drag_source_set(listTargets);
btn_or->drag_source_set(listTargets);
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_drain->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_drain_drag_get));
btn_and->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_and_drag_get));
btn_or->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_or_drag_get));
btn_not->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_not_drag_get));
btn_tanque->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_tanque_drag_begin));
btn_bomba->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_bomba_drag_begin));
btn_exclusa->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_exclusa_drag_begin));
+ btn_drain->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_drain_drag_begin));
btn_and->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_and_drag_begin));
btn_or->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_or_drag_begin));
btn_not->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_not_drag_begin));
gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"exclusa_h.png",15);
}
+void Constructor::on_btn_drain_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
+{
+ gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"drain_n.png",11);
+}
+
void Constructor::on_btn_and_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
{
gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"and_e.png",9);
std::list<CItem *>::iterator i = listaItems.begin();
std::string file_name = file_selection->get_filename();
if ( (archivo = fopen( file_name.c_str(), "w+")) != NULL ){
+ fprintf(archivo, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n");
fprintf (archivo,"<planta>\n");
while ( i != listaItems.end() ){
CItem *temp = *i;
context->set_icon(ico_exclusa, 5, 5);
}
+void Constructor::on_drain_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ context->set_icon(ico_drain, 5, 5);
+}
+
void Constructor::on_and_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
{
context->set_icon(ico_and, 5, 5);
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, "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();
+ 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();
char char_id[10];
- sprintf(char_id," %d",id);
+ sprintf(char_id,"%d",id);
a->set_id(++id);
a->set_name( a->get_name()+char_id );
if ( can_drop(a, i*32, j*32) ) {
<glade-interface>
<widget class="GtkWindow" id="wnd_constructor">
- <property name="width_request">640</property>
- <property name="height_request">573</property>
+ <property name="width_request">738</property>
+ <property name="height_request">689</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Constuctor</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
</child>
</widget>
</child>
+
+ <child>
+ <widget class="GtkButton" id="btn_drain">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment8">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox10">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image17">
+ <property name="visible">True</property>
+ <property name="pixbuf">drain_n.png</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">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
</widget>
<widget class="GtkDialog" id="cistern_pty_wnd">
- <property name="width_request">272</property>
+ <property name="width_request">304</property>
<property name="height_request">182</property>
<property name="title" translatable="yes">Propiedades del Tanque</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="y_options"></property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkDrawingArea" id="color_preview">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
</child>
<child>
- <widget class="GtkLabel" id="lbl_property">
+ <widget class="GtkLabel" id="lb_max_fluid">
<property name="visible">True</property>
<property name="label" translatable="yes">Flujo Máximo</property>
<property name="use_underline">False</property>
<property name="y_options"></property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkDrawingArea" id="color_preview">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">10</property>
#include "cistern.h"
#include "exclusa.h"
#include "pump.h"
+#include "drain.h"
#include "and.h"
#include "or.h"
#include "not.h"
protected:
int id;
// / defino los elementos de la ventana.
- Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_bomba, *btn_exclusa, *btn_file_ok, *btn_file_cancel, *btn_check, *btn_dlg_close,
+ Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_bomba, *btn_exclusa, *btn_drain, *btn_file_ok, *btn_file_cancel, *btn_check, *btn_dlg_close,
*btn_and, *btn_or, *btn_not;
Gtk::ImageMenuItem *main_menu_quit, *edit_menu_del, *main_menu_save;
Gtk::CheckButton *chk_btn_logica;
Gtk::Entry *combo_entry;
Gtk::Dialog *dlg_connect;
Gtk::Label *dlg_label;
- Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo, ico_tanque, ico_bomba, ico_exclusa, ico_and, ico_or, ico_not;
+ 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;
virtual void on_btn_tanque_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_bomba_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_exclusa_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
+ virtual void on_btn_drain_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_and_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_or_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_not_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_tanque_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
virtual void on_bomba_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
virtual void on_exclusa_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
+ virtual void on_drain_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
virtual void on_and_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
virtual void on_or_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
virtual void on_not_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
--- /dev/null
+#include "drain.h"
+
+Drain::Drain()
+{
+ imageE = Gdk::Pixbuf::create_from_file("drain_e.png");
+ imageO = Gdk::Pixbuf::create_from_file("drain_o.png");
+ imageN = Gdk::Pixbuf::create_from_file("drain_n.png");
+ imageS = Gdk::Pixbuf::create_from_file("drain_s.png");
+ null = Gdk::Pixbuf::create_from_file("null.png");
+ imgActual = 0;
+ image = imageN;
+ set_size_request(image->get_width(), image->get_height());
+ property_wnd->item = this;
+ property_wnd->lb_max_fluid->property_visible() = false;
+ property_wnd->spin_caudal->property_visible() = false;
+ property_wnd->set_title("Propiedades del Drenaje");
+ name = "drenaje";
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = IN;
+ connect_vec.push_back(temp);
+}
+
+Drain::~Drain()
+{
+}
+
+bool Drain::on_button_press_event(GdkEventButton *event)
+{
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ combo_entry->set_text(name);
+
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
+ image = null;
+ 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);
+ imgActual++;
+ switch (imgActual) {
+ case 1:
+ image = imageE;
+ break;
+ case 2:
+ image = imageS;
+ break;
+ case 3:
+ image = imageO;
+ break;
+ default:
+ imgActual = 0;
+ image = imageN;
+ }
+ 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)){
+ menu_popup.popup(event->button, event->time);
+ return true; //It has been handled.
+ }
+
+ if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
+ property_wnd->txt_item_name->set_text( name );
+ property_wnd->show();
+ }
+ return true;
+}
+
+void Drain::on_menu_popup_rotar()
+{
+ GdkEventButton event;
+ event.type = GDK_BUTTON_PRESS;
+ event.button = 2;
+ Drain::on_button_press_event(&event);
+}
+
+void Drain::on_menu_popup_propiedades()
+{
+ GdkEventButton event;
+ event.type = GDK_2BUTTON_PRESS;
+ event.button = 1;
+ Drain::on_button_press_event(&event);
+}
+
+void Drain::save(FILE *archivo)
+{
+ char c_id[50], c_x[50], c_y[50], c_img[50];
+ sprintf(c_x,"\t\t<x>%d</x>\n",x);
+ sprintf(c_y,"\t\t<y>%d</y>\n",y);
+ sprintf(c_id,"%d",ID);
+ sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
+ Glib::ustring dato;
+ dato = "\t<drenaje nombre=\""+name+"\" id=\"";
+ dato += c_id;
+ dato += "\">\n";
+ dato += c_img;
+ dato += c_x;
+ dato += c_y;
+ dato += "\t</drenaje>\n";
+ fprintf(archivo,dato.c_str());
+}
+
+bool Drain::check_connection()
+{
+ ConnectorType temp;
+ switch (get_img_actual()) {
+ case 0:
+ temp = is_other_connection_area( get_position_x()+16 , get_position_y() -5);
+ break;
+ case 1:
+ temp = is_other_connection_area( get_position_x()+image->get_width() + 5, get_position_y()+16);
+ break;
+ case 2:
+ temp = is_other_connection_area( get_position_x()+16, get_position_y()+image->get_height()+5);
+ break;
+ case 3:
+ temp = is_other_connection_area( get_position_x()-5, get_position_y()+16);
+ }
+ return ( is_connected = (temp == OUT) );
+}
+
+ConnectorType Drain::get_connector_type(int _a, int _b)
+{
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+10)&&(_b > y) )
+ return connect_vec[0].type;
+ break;
+ case 1:
+ if ( (_a <= x+image->get_width() -1)&&(_a>=x+image->get_width()-10)&&(_b<=y+22)&&(_b >= y+10) )
+ return connect_vec[0].type;
+ break;
+ case 2:
+ if ( (_a <= x +22)&&(_a >= x+10)&&(_b<=y+image->get_height() -1)&&(_b >=y+image->get_height()-10) )
+ return connect_vec[0].type;
+ break;
+ case 3:
+ if ( (_a <= x+10)&&(_a >x)&&(_b<=y+22)&&(_b >=y+10) )
+ return connect_vec[0].type;
+ }
+ return UNDEF;
+}
--- /dev/null
+#ifndef _DRAIN_H_
+#define _DRAIN_H_
+
+#include <iostream>
+#include "item.h"
+
+
+class Drain : public CItem {
+ public:
+ Drain();
+ virtual ~Drain();
+ virtual bool on_button_press_event(GdkEventButton *event);
+ virtual void on_menu_popup_rotar();
+ virtual void on_menu_popup_propiedades();
+ double get_contenido_inicial();
+ double get_capacidad();
+ virtual void save(FILE *archivo);
+ virtual bool check_connection();
+ //virtual ConnectorType is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
+ protected:
+ Glib::RefPtr<Gdk::Pixbuf> imageE; // 0
+ Glib::RefPtr<Gdk::Pixbuf> imageO; // 1
+ Glib::RefPtr<Gdk::Pixbuf> imageN; // 1
+ Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
+ Glib::RefPtr<Gdk::Pixbuf> null;
+};
+#endif
{
switch (get_img_actual()) {
case 0:
- if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) &&
- is_other_connection_area( get_position_x()-5, get_position_y() + 16) )
- return true;
- break;
+ connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5);
+ connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5);
+ break;
case 1:
- if ( is_other_connection_area( get_position_x()+16, get_position_y()-5 ) &&
- is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5) )
- return true;
+ connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16);
+ connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
}
- return false;
+ if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
+ return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
+ else return false;
}
-bool Exclusa::is_connection_area(int _a, int _b)
+ConnectorType Exclusa::get_connector_type(int _a, int _b)
+{
+ if ( ! is_connected ) {
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
+ return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5); //pregunto que hay abajo
+ if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 ))//abajo
+ return is_other_connection_area( get_position_x()+16, get_position_y()-5);//pregunto que hay arriba.
+ break;
+ case 1:
+ if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
+ return is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16);//pregunto por la derecha
+ if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
+ return is_other_connection_area(get_position_x()-5, get_position_y()+16); //pregunto por la izquierda.
+ }
+ } else {
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
+ return connect_vec[0].type;
+ if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo
+ return connect_vec[1].type;
+ break;
+ case 1:
+ if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
+ return connect_vec[0].type;
+ if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
+ return connect_vec[1].type;
+ }
+ }
+ return UNDEF;
+}
+/*si no estoy conectado pregunto por el del otro lado, y ahi puedo setear los dos
+ *si ya estoy devuelvo.
+*/
+/*bool Exclusa::is_connection_area(int _a, int _b)
{
switch (imgActual){
case 0:
}
return false;
}
+*/
virtual void on_menu_popup_propiedades();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+// virtual ConnectorType is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
void set_estado(bool _state);
bool get_estado();
private:
ref->get_widget_derived("item_pty_wnd",property_wnd);
caudal_max = 0.0;
is_union = true;
+ is_connected = 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);
{
}
-void CItem::set_position(int _x, int _y)
-{
- this->x = _x;
- this->y = _y;
-}
-
-void CItem::set_id(int _id)
-{
- ID = _id;
-}
-
-void CItem::set_caudal(double _caudal)
-{
- caudal_max = _caudal;
-}
-
-void CItem::set_name(Glib::ustring _name)
-{
- name = _name;
-}
-
-void CItem::set_conector_in(int _in)
-{
- conector_in = _in;
-}
-
-void CItem::set_conector_out(int _out)
-{
- conector_out = _out;
-}
-
int CItem::get_position_x()
{
return x;
return name;
}
-int CItem::get_conector_in()
+int CItem::get_img_actual()
{
- return conector_in;
+ return imgActual;
}
-int CItem::get_conector_out()
+void CItem::set_position(int _x, int _y)
{
- return conector_out;
+ this->x = _x;
+ this->y = _y;
}
-int CItem::get_img_actual()
+void CItem::set_id(int _id)
{
- return imgActual;
+ ID = _id;
+}
+
+void CItem::set_caudal(double _caudal)
+{
+ caudal_max = _caudal;
+}
+
+void CItem::set_name(Glib::ustring _name)
+{
+ name = _name;
}
bool CItem::is_occupied_area(int _a, int _b)
else return false;
}
-bool CItem::is_other_connection_area(int _a, int _b)
+ConnectorType CItem::is_other_connection_area(int _a, int _b)
{
+ ConnectorType temp2;
std::list<CItem *>::iterator i = listaItems->begin();
- while ( i != listaItems->end() ){
+ while ( i != listaItems->end() ) {
CItem *temp = *i;
- if ( temp->is_connection_area(_a,_b) )
- return true;
- i++;
+ if (temp != this) {
+ if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF )
+ return temp2;
+ i++;
+ }
}
- return false;
+ return UNDEF;
+}
+ConnectorType CItem::get_connector_type( int _a, int _b )
+{
+ return UNDEF;
}
#include <gtkmm/entry.h>
#include "itemptywnd.h"
+typedef enum { NONE, RIGHT, LEFT, MIDDLE } ConnectorSide;
+typedef enum { UNDEF, IN, OUT } ConnectorType;
+
+class Connector {
+ public:
+ int id_dest;
+ ConnectorType type;
+ Connector& operator= (Connector & c) {
+ id_dest = c.id_dest;
+ type = c.type;
+ return *this;
+ }
+};
+
class WorkPlace;
class CItem:public Gtk::DrawingArea {
int get_position_x();
int get_position_y();
int get_id();
- int get_conector_in();
- int get_conector_out();
int get_img_actual();
Glib::ustring get_name();
double get_caudal();
void set_id(int _id);
void set_caudal(double _caudal);
void set_name(Glib::ustring _name);
- void set_conector_in(int _in);
- void set_conector_out(int _out);
bool is_occupied_area(int _a, int _b);
- bool is_other_connection_area(int _a, int _b);
+ ConnectorType is_other_connection_area(int _a, int _b);
virtual void save(FILE *archivo) = 0;
virtual bool check_connection()=0;
- virtual bool is_connection_area(int _a, int _b)=0;
+// virtual ConnectorType is_connection_area(int _a, int _b)=0;
+ virtual ConnectorType get_connector_type( int _a, int _b );
WorkPlace *workplace;
Gtk::Entry *combo_entry;
std::list<CItem *> *listaItems;
bool is_union;
+ bool is_connected;
+ // Hay que ocultarlo --- problemas con el get y el set!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // 0 = izquierda/arriba , 1 = derecha/abajo , 2 = medio. tomando como referencia la imagen inicial de cada item cuando corresponda
+ std::vector<Connector> connect_vec;
protected:
int imgActual;
- int ID, conector_in, conector_out;
+ int ID;
Glib::ustring name;
double caudal_max;
Gtk::Menu menu_popup;
refGlade->get_widget("rd_btn_division", rd_btn_division);
refGlade->get_widget("rd_btn_union", rd_btn_union);
refGlade->get_widget("lb_type", lb_type);
-
+ refGlade->get_widget("lb_max_fluid", lb_max_fluid);
rd_btn_division->signal_clicked().connect(SigC::slot(*this,&ItemPtyWnd::on_rd_btn_division_clicked));
rd_btn_union->signal_clicked().connect(SigC::slot(*this,&ItemPtyWnd::on_rd_btn_union_clicked));
}
void ItemPtyWnd::on_rd_btn_union_clicked()
{
+ item->connect_vec[0].type = IN;
+ item->connect_vec[1].type = IN;
+ item->connect_vec[2].type = OUT;
item->is_union = true;
}
void ItemPtyWnd::on_rd_btn_division_clicked()
{
+ item->connect_vec[0].type = OUT;
+ item->connect_vec[1].type = OUT;
+ item->connect_vec[2].type = IN;
item->is_union = false;
}
virtual ~ItemPtyWnd();
Gtk::SpinButton *spin_caudal;
Gtk::RadioButton *rd_btn_union, *rd_btn_division;
- Gtk::Label *lb_type;
+ Gtk::Label *lb_type, *lb_max_fluid;
Gtk::Entry *txt_item_name;
protected:
virtual void on_btn_cancel_clicked();
// CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bool Not::check_connection()
{
- switch (get_img_actual()) {
+/* switch (get_img_actual()) {
case 0:
if ( is_other_connection_area( get_position_x()-5, get_position_y()+16) &&
is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5) )
is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
return true;
}
- return false;
+ return false;*/
+ return true;
}
+/*
bool Not::is_connection_area(int _a, int _b)
{
- switch (imgActual) {
+ /*switch (imgActual) {
case 0: if ( ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) ||
( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) )
return true;
return true;
}
return false;
+ return true;
}
+*/
virtual void on_menu_popup_rotar();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+ //virtual bool is_connection_area(int _a, int _b);
private:
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
// CAMBIAR TODO ESTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bool Or::check_connection()
{
- switch (get_img_actual()) {
+ /*switch (get_img_actual()) {
case 0:
if ( is_other_connection_area( get_position_x()-5, get_position_y()+16) &&
is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5) )
is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
return true;
}
- return false;
+ return false;*/
+ return true;
}
+/*
bool Or::is_connection_area(int _a, int _b)
{
- switch (imgActual) {
+ /*switch (imgActual) {
case 0: if ( ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) ||
( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) )
return true;
}
return false;
}
+*/
virtual void on_menu_popup_rotar();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+ //virtual ConnectorType is_connection_area(int _a, int _b);
private:
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
#include <gtkmm/spinbutton.h>
#include <gtkmm/entry.h>
#include <gtkmm/colorselection.h>
+#include <gtkmm/drawingarea.h>
#include <gdkmm.h>
#include <libglademm.h>
ref->get_widget_derived("pump_pty_wnd",pump_pty_wnd);
pump_pty_wnd->pump = this;
name = "bomba";
+
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = OUT;
+ connect_vec.push_back(temp);
}
Pump::~Pump()
bool Pump::check_connection()
{
+ ConnectorType temp;
switch (get_img_actual()) {
case 0:
- if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16) )
- return true;
+ temp = is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16);
break;
case 1:
- if ( is_other_connection_area( get_position_x() -5, get_position_y() +16) )
- return true;
+ temp = is_other_connection_area( get_position_x() -5, get_position_y() +16);
}
- return false;
+ return (is_connected = ( temp == IN) );
}
+ConnectorType Pump::get_connector_type(int _a, int _b)
+{
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+22)&&(_b > y) ) //derecha.
+ return connect_vec[0].type;
+ break;
+ case 1:
+ if ( (_a <= x+10)&&(_a > x)&&(_b<=y+22)&&(_b > y) ) //izquierda
+ return connect_vec[0].type;
+ }
+ return UNDEF;
+}
+/*
bool Pump::is_connection_area(int _a, int _b)
{
switch (imgActual) {
}
return false;
}
+*/
Gdk::Color get_liquid_color();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
protected:
double entrega;
Glib::RefPtr<Gdk::Pixbuf> imageE; // 0
refGlade->get_widget("btn_select_color",btn_select_color);
refGlade->get_widget("spin_fluid",spin_fluid);
refGlade->get_widget("txt_pump_name",txt_pump_name);
+ refGlade->get_widget("color_preview",color_preview);
Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "color_select_dlg");
ref->get_widget("color_select_dlg",color_select_dlg);
}
void PumpPtyWnd::on_dlg_select_color_ok_clicked()
-{
+{
pump->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
+ color_preview->modify_bg( Gtk::STATE_NORMAL , pump->get_liquid_color() );
color_select_dlg->hide();
}
Gtk::Entry *txt_pump_name;
Gtk::Button *btn_select_color, *dlg_select_color_cancel, *dlg_select_color_ok;
Gtk::ColorSelectionDialog *color_select_dlg;
+ Gtk::DrawingArea *color_preview;
virtual void on_btn_accept_clicked();
virtual void on_btn_apply_clicked();
virtual void on_btn_select_color_clicked();
set_size_request(image->get_width(), image->get_height());
property_wnd->set_title("Propiedades del Codo");
name = "codo";
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = UNDEF;
+ connect_vec.push_back(temp);
+ connect_vec.push_back(temp);
}
Splitter::~Splitter()
{
switch (get_img_actual()) {
case 0:
- if ( is_other_connection_area( get_position_x()-5, get_position_y()+16) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5) )
- return true;
+ connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16); //arriba-izquierda h
+ connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5);//abajo-derecha v
break;
case 1:
- if ( is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5) &&
- is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16) )
- return true;
+ connect_vec[0].type = is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5);//arriba-derecha v
+ connect_vec[1].type = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16);//abajo-izquierda h
break;
case 2:
- if ( is_other_connection_area( get_position_x() + 16, get_position_y() -5) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16) )
- return true;
+ connect_vec[1].type = is_other_connection_area( get_position_x() + 16, get_position_y() - 5);//arriba-izquierda v
+ connect_vec[0].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height() - 16); //abajo-derecha h
break;
case 3:
- if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16) &&
- is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5) )
- return true;
+ connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16);//arriba-derecha h
+ connect_vec[0].type = is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5); //abajo-izquierda v
}
- return false;
+ if (connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF)
+ return ( is_connected = (connect_vec[0].type == connect_vec[1].type) );
+ else return false;
}
+ConnectorType Splitter::get_connector_type(int _a, int _b)
+{
+ if ( ! is_connected ) {
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) // arriba - izquierda h
+ return is_other_connection_area (get_position_x()+get_image()->get_width()-16, +get_position_y()+get_image()->get_height() + 5);
+ if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) )//abajo-derecha v
+ return is_other_connection_area( get_position_x()-5, get_position_y()+16);
+ break;
+ case 1:
+ if ( (_a <= x+image->get_width()-10)&&(_a >= x+image->get_width()-22) && (_b <=y+10)&&(_b > y) ) //arriba-derecha v
+ return is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16);
+ if ( (_a <= x+10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-izquierda h
+ return is_other_connection_area( get_position_x()+get_image()->get_width() - 16, get_position_y() -5);
+ break;
+ case 2:
+ if ( (_a <= x+22)&&(_a >= x+10) && (_b <=y+10)&&(_b > y) ) //arriba-izquierda v
+ return is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height() - 16);
+ if ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-derecha h
+ return is_other_connection_area( get_position_x() + 16, get_position_y() - 5);
+ break;
+ case 3:
+ if ( (_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <=y+22)&&(_b>=y+10) ) //arriba-derecha h
+ return is_other_connection_area( get_position_x() + 16, get_position_y()+get_image()->get_height() + 5);
+ if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) // abajo-izquierda v
+ return is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y() +16);
+ }
+ } else {
+ switch (imgActual) {
+ case 0:
+ if ( (_a <= x+10)&&(_a > x) && (_b <=y+22)&&(_b>=y+10) ) // arriba - izquierda h
+ return connect_vec[0].type;
+ if ( (_a <= x+image->get_width()-10)&&(_a>=x+image->get_width()-22)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) )//abajo-derecha v
+ return connect_vec[1].type;
+ break;
+ case 1:
+ if ( (_a <= x+image->get_width()-10)&&(_a >= x+image->get_width()-22) && (_b <=y+10)&&(_b > y) ) //arriba-derecha v
+ return connect_vec[0].type;
+ if ( (_a <= x+10)&&(_a > x)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-izquierda h
+ return connect_vec[1].type;
+ break;
+ case 2:
+ if ( (_a <= x+22)&&(_a >= x+10) && (_b <=y+10)&&(_b > y) ) //arriba-izquierda v
+ return connect_vec[1].type;
+ if ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+image->get_height()-10)&&(_b>=y+image->get_height()-22) ) // abajo-derecha h
+ return connect_vec[0].type;
+ break;
+ case 3:
+ if ( (_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <=y+22)&&(_b>=y+10) ) //arriba-derecha h
+ return connect_vec[1].type;
+ if ( (_a <= x+22)&&(_a>=x+10)&&(_b<=y+image->get_height()-1)&&(_b>=y+image->get_height()-10) ) // abajo-izquierda v
+ return connect_vec[0].type;
+ }
+ }
+ return UNDEF;
+}
+
+/*
bool Splitter::is_connection_area(int _a, int _b)
{
switch (imgActual) {
}
return false;
}
+*/
virtual void on_menu_popup_propiedades();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+// virtual ConnectorType is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
private:
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
property_wnd->rd_btn_union->property_visible() = true;
property_wnd->lb_type->property_visible() = true;
name = "union";
+ Connector temp;
+ temp.id_dest = -1;
+ temp.type = IN;
+ connect_vec.push_back(temp); //izquierda
+ connect_vec.push_back(temp); //derecha
+ temp.type = OUT;
+ connect_vec.push_back(temp); //medio
}
Union::~Union()
bool Union::check_connection()
{
+ ConnectorType temp0, temp1, temp2;
switch (get_img_actual()) {
case 0:
- if ( is_other_connection_area( get_position_x() - 5, get_position_y() +16) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+5) )
- return true;
+ temp0 = is_other_connection_area( get_position_x() - 5, get_position_y() +16);
+ temp1 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
+ temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()+get_image()->get_height()+5);
break;
case 1:
- if ( is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()/2) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()-5) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()+get_image()->get_height()+5) )
- return true;
+ temp2 = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()/2);
+ temp0 = is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()-5);
+ temp1 = is_other_connection_area( get_position_x()+get_image()->get_width()-16, get_position_y()+get_image()->get_height()+5);
break;
case 2:
- if ( is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()-5) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16) )
- return true;
+ temp1 = is_other_connection_area( get_position_x()-5, get_position_y()+get_image()->get_height()-16);
+ temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()/2, get_position_y()-5);
+ temp0 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()-16);
break;
case 3:
- if ( is_other_connection_area( get_position_x()+16, get_position_y()-5) &&
- is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()/2) &&
- is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5) )
- return true;
+ temp1 = is_other_connection_area( get_position_x()+16, get_position_y()-5);
+ temp2 = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+get_image()->get_height()/2);
+ temp0 = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5);
}
- return false;
+ if ( is_union ) {
+ if ( temp0 == OUT && temp1 == OUT && temp2 == IN )
+ return (is_connected = true);
+ } else {
+ if ( temp0 == IN && temp1 == IN && temp2 == OUT )
+ return (is_connected = true);
+ }
+ return false;
+}
+
+ConnectorType Union::get_connector_type(int _a, int _b)
+{
+ switch ( imgActual) {
+ case 0: if ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10))
+ return connect_vec[0].type;
+ if ((_a <= x+image->get_width()-1) && (_a >= x+image->get_width()-10)&&(_b <= y+22) && (_b >= y+10))
+ return connect_vec[1].type;
+ if ((_a <= x+image->get_width()/2 + 5)&&( _a>= x+image->get_width()/2 - 5) && (_b<=y+image->get_height()-1)&&(_b >= y+image->get_height()-10))
+ return connect_vec[2].type;
+ break;
+ case 1: if ((_a <= x+image->get_width()-10) && (_a >= x+image->get_width() -22) && (_b<= y + 10) && (_b > y ))
+ return connect_vec[0].type;
+ if ((_a <= x +10) && (_a > x )&&(_b <= y+image->get_height()/2+5 ) && (_b >= y+image->get_height()/2-5))
+ return connect_vec[2].type;
+ if ((_a <= x+image->get_width() - 10)&&( _a>= x+image->get_width()-22) && (_b<=y+image->get_height()-1)&&(_b >= y+image->get_height()-10))
+ return connect_vec[1].type;
+ break;
+ case 2: if ((_a <= x+10) && (_a > x) && (_b<= y+image->get_height()-10) && (_b >= y+image->get_height()-22))
+ return connect_vec[1].type;
+ if ((_a <= x+image->get_width()-1) && (_a >= x+image->get_width()-10)&&(_b <= y+image->get_height()-10) && (_b >= y+image->get_height()-22))
+ return connect_vec[0].type;
+ if ((_a <= x+image->get_width()/2 + 5)&&( _a>= x+image->get_width()/2 - 5) && (_b<=y+10)&&(_b > y))
+ return connect_vec[2].type;
+ break;
+ case 3: if ((_a <= x+22) && (_a >= x+10) && (_b<= y + 10) && (_b > y ))
+ return connect_vec[1].type;
+ if ((_a <= x+22) && (_a >= x+10 )&&(_b <= y+image->get_height()-1 ) && (_b >= y+image->get_height()-10))
+ return connect_vec[0].type;
+ if ((_a <= x+image->get_width() -1)&&( _a>= x+image->get_width()-10) && (_b<=y+image->get_height()/2+5)&&(_b >= y+image->get_height()/2-5))
+ return connect_vec[2].type;
+ }
+ return UNDEF;
}
-bool Union::is_connection_area(int _a, int _b)
+/*
+ConnectorType Union::is_connection_area(int _a, int _b)
{
switch ( imgActual) {
- case 0: if ( ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10)) ||
+ case 0: if ( ((_a <= x+10) && (_a > x+1) && (_b<= y + 22) && (_b >= y+10))
+ retur
((_a <= x+image->get_width()-1) && (_a >= x+image->get_width()-10)&&(_b <= y+22) && (_b >= y+10)) ||
((_a <= x+image->get_width()/2 + 5)&&( _a>= x+image->get_width()/2 - 5) && (_b<=y+image->get_height()-1)&&(_b >= y+image->get_height()-10)) )
return true;
return true;
}
return false;
-}
+}*/
virtual void on_menu_popup_propiedades();
virtual void save(FILE *archivo);
virtual bool check_connection();
- virtual bool is_connection_area(int _a, int _b);
+ //virtual ConnectorType is_connection_area(int _a, int _b);
+ virtual ConnectorType get_connector_type(int _a, int _b);
private:
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
Glib::RefPtr<Gdk::Pixbuf> imageS; // 1