MODO DE USO
-accionar el boton logica
-click en una compuerta
-click en la entrada o salida de un item
esto es:
exclusa entrada: al medio y arriba (en el pingorcho)
salida: al medio y abajo
bomba entrada: (en el conector) la mitad superior
salida: mitad inferior
tanque entrada conector superior
salida conector inferior
todo esto es aproximado
igual se van a dar cuenta
ojo que las primeras lineas las tira en cualquier lado (no se por que)
pero cuando rota el item se acomodan
-Se cuelga bastante, asi que tengan cuidado
intenten eliminar lo menos posible
chauuu
14 files changed:
*/
virtual ConnectorType get_connector_type(int _a, int _b);
*/
virtual ConnectorType get_connector_type(int _a, int _b);
- /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
+ /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la entrada.
- virtual void get_logic_connect_position(int& _a, int& _b);
+ virtual void get_in_logic_connect_position(int& _a, int& _b);
+
+ /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la salida.
+ */
+ virtual void get_out_logic_connect_position(int& _a, int& _b);
+
+ /**Actualiza la posicion de los conectores logicos ante un movimiento.
+ */
+ virtual void update_logic_position();
+
+ /**Detecta si el click fue en el area de entrada o salida logica, devuelve UNDEF si no fue ninguna de las dos
+ */
+ ConnectorType detect_click_position(int _a, int _b);
+ /**Coordenadas de las entrada y salida logica.
+ */
+ int in_x, in_y, out_x, out_y;
/**Atributos que definen su comportamiento
*/
double capacidad, contenido_inicial;
/**Atributos que definen su comportamiento
*/
double capacidad, contenido_inicial;
*/
virtual ConnectorType get_connector_type(int _a, int _b);
*/
virtual ConnectorType get_connector_type(int _a, int _b);
- /**Los valores _a y _b se setean en el punto donde se deben conectar los cables logicos
+ /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la entrada.
- virtual void get_logic_connect_position(int& _a, int& _b);
-
+ virtual void get_in_logic_connect_position(int& _a, int& _b);
+
+ /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos a la salida.
+ */
+ virtual void get_out_logic_connect_position(int& _a, int& _b);
+
+ /**Actualiza la posicion de los conectores logicos ante un movimiento.
+ */
+ virtual void update_logic_position();
+
+ /**Detecta si el click fue en el area de entrada o salida logica, devuelve UNDEF si no fue ninguna de las dos
+ */
+ ConnectorType detect_click_position(int _a, int _b);
+
/**Funciones para obtener y setear sus propiedades
*/
void set_estado(bool _state);
bool get_estado();
/**Funciones para obtener y setear sus propiedades
*/
void set_estado(bool _state);
bool get_estado();
+ protected:
+ /**Coordenadas de las entrada y salida logica.
+ */
+ int in_x, in_y, out_x, out_y;
/**Imagenes en sus 2 posiciones
*/
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
/**Imagenes en sus 2 posiciones
*/
Glib::RefPtr<Gdk::Pixbuf> imageN; // 0
///TODO: hacer abstractas estas funciones... en item no hacen nada....
virtual void set_default_connector();
virtual ConnectorType get_connector_type( int _a, int _b );
///TODO: hacer abstractas estas funciones... en item no hacen nada....
virtual void set_default_connector();
virtual ConnectorType get_connector_type( int _a, int _b );
- virtual void get_logic_connect_position(int& _a, int& _b);
+
+ virtual void get_in_logic_connect_position(int& _a, int& _b);
+ virtual void get_out_logic_connect_position(int& _a, int& _b);
+ virtual void update_logic_position();
///Puntero al area de trabajo de la ventana principal
WorkPlace *workplace;
///Puntero al area de trabajo de la ventana principal
WorkPlace *workplace;
///Indica si puede realizarse la conexion logica con una compuerta
static bool logic_connect;
///Indica si puede realizarse la conexion logica con una compuerta
static bool logic_connect;
+
+ ///Almacena el ID de la compuerta logica seleccionada
+ static int gate_id;
/**Vector de connectores donde se mantiene la siguiente referencia:
* indice 0 = "arriba/izquierda" para la exclusa, el tubo, el codo, el empalme y el tanque.
/**Vector de connectores donde se mantiene la siguiente referencia:
* indice 0 = "arriba/izquierda" para la exclusa, el tubo, el codo, el empalme y el tanque.
///Devuelve el tipo de conector que posee en las coordenadas (_a,_b) segun su orientacion
virtual ConnectorType get_connector_type(int _a, int _b);
///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
///Devuelve el tipo de conector que posee en las coordenadas (_a,_b) segun su orientacion
virtual ConnectorType get_connector_type(int _a, int _b);
///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
- virtual void get_logic_connect_position(int& _a, int& _b);
+ virtual void get_in_logic_connect_position(int& _a, int& _b);
+ ///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
+ virtual void get_out_logic_connect_position(int& _a, int& _b);
+ ///Actualiza la posicion de los conectores logicos ante un movimiento.
+ virtual void update_logic_position();
+ ///Detecta si el click fue en el area de entrada o salida logica, devuelve UNDEF si no fue ninguna de las dos
+ ConnectorType detect_click_position(int _a, int _b);
+ ///Coordenadas de las entrada y salida logica.
+ int in_x, in_y, out_x, out_y;
///Indica la maxima capacidad de entrega de la bomba
double entrega;
/// Indica el color del liquido que entrega
///Indica la maxima capacidad de entrega de la bomba
double entrega;
/// Indica el color del liquido que entrega
void delete_item(int _id);
void delete_line(int _id);
CItem *get_logic_item(int _id);
void delete_item(int _id);
void delete_line(int _id);
CItem *get_logic_item(int _id);
+ void update_logic_position();
std::list<CItem *> *listaItems, *lista_logic_Items;
std::list<CItem *> *listaItems, *lista_logic_Items;
- std::list<t_line> lista_lineas;
+ /** Listas de lineas que van de una compuerta a un item y de un item a una compuerta
+ */
+ std::list<t_line> lista_lineas_in, lista_lineas_out;
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
if (CItem::logic_connect)
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
if (CItem::logic_connect)
combo_entry->set_text(name);
WorkPlace::pointed = ID;
}
combo_entry->set_text(name);
WorkPlace::pointed = ID;
}
menu_popup.popup(event->button, event->time);
return true; //It has been handled.
}
menu_popup.popup(event->button, event->time);
return true; //It has been handled.
}
+ workplace->queue_draw();
return true;
}
void And::on_menu_popup_rotar()
return true;
}
void And::on_menu_popup_rotar()
Cistern::Cistern(int orientacion)
{
Cistern::Cistern(int orientacion)
{
+ in_x = x;
+ in_y = y+16;
+ out_x = x + 48;
+ out_y = y + 64;
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");
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");
combo_entry->set_text(name);
WorkPlace::pointed = ID;
if (CItem::logic_connect) {
combo_entry->set_text(name);
WorkPlace::pointed = ID;
if (CItem::logic_connect) {
- tmp_line.logic = workplace->get_logic_item(CItem::quien);
- tmp_line.store = this;
- workplace->lista_lineas.push_back(tmp_line);
- workplace->on_expose_event(&e);
+ if ( detect_click_position(event->x, event->y) == IN ){
+ tmp_line.logic = workplace->get_logic_item(CItem::gate_id);
+ tmp_line.store = this;
+ workplace->lista_lineas_in.push_back(tmp_line);
+ workplace->queue_draw();
+ } else {
+ tmp_line.logic = workplace->get_logic_item(CItem::gate_id);
+ tmp_line.store = this;
+ workplace->lista_lineas_out.push_back(tmp_line);
+ workplace->queue_draw();
+ }
switch (imgActual) {
case 1:
image = imageO;
switch (imgActual) {
case 1:
image = imageO;
+ in_x = x + image->get_width();
+ in_y = y + 16;
+ out_x = x+16;
+ out_y = y + image->get_height();
break;
default:
imgActual = 0;
image = imageE;
break;
default:
imgActual = 0;
image = imageE;
+ in_x = x;
+ in_y = y+16;
+ out_x = x + image->get_width() -16;
+ out_y = y + image->get_height();
}
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);
}
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);
cistern_pty_wnd->txt_cistern_name->set_text( name );
cistern_pty_wnd->show();
}
cistern_pty_wnd->txt_cistern_name->set_text( name );
cistern_pty_wnd->show();
}
- workplace->on_expose_event(&e);
+ workplace->queue_draw();
connect_vec[1].type = OUT;
}
connect_vec[1].type = OUT;
}
-void Cistern::get_logic_connect_position(int& _a, int& _b)
+void Cistern::get_in_logic_connect_position(int& _a, int& _b)
+ _a = in_x;
+ _b = in_y;
+}
+
+void Cistern::get_out_logic_connect_position(int& _a, int& _b)
+{
+ _a = out_x;
+ _b = out_y;
+}
+
+ConnectorType Cistern::detect_click_position(int _a, int _b)
+{
+ //VER DONDE CAEN LOS CLICKS!!!!!!!!!!!!!! SI ES CON RESPECTO AL WORKPLACE O AL ITEM!!!
- case 0:
- _a = x;
- _b = y + 10;
+ case 0:
+ if ( (_a<=32) &&(_a>=0)&&(_b<=32)&&(_b>=0) )
+ return IN;
+ if ( (_a<=image->get_width())&&(_a>=image->get_width()-32)&&(_b<=image->get_height())&&(_b>=image->get_height()-32) )
+ return OUT;
- case 1:
- _a = x +image->get_width();
- _b = y + 10;
+ case 1:
+ if ( (_a<=image->get_width()) &&(_a>=image->get_width()-32)&&(_b<=32)&&(_b>=0) )
+ return IN;
+ if ( (_a<=32)&&(_a>=0)&&(_b<=image->get_height())&&(_b>=image->get_height()-32) )
+ return OUT;
+ }
+ return UNDEF;
+}
+
+void Cistern::update_logic_position()
+{
+ switch (imgActual) {
+ case 1:
+ in_x = x + image->get_width();
+ in_y = y + 16;
+ out_x = x+16;
+ out_y = y + image->get_height();
+ break;
+ case 0:
+ in_x = x;
+ in_y = y+16;
+ out_x = x + image->get_width() -16;
+ out_y = y + image->get_height();
{
GdkEventExpose e;
context->set_icon(item->get_image(), 5, 5);
{
GdkEventExpose e;
context->set_icon(item->get_image(), 5, 5);
- workplace->on_expose_event(&e);
+ workplace->update_logic_position();
+ workplace->queue_draw();
}
void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
}
void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
} else if (strcmp((const char *)selection_data->data, "or_e.png")==0) {
a = new Or(); a->is_logic = true;
} else if (strcmp((const char *)selection_data->data, "not_e.png")==0) {
} else if (strcmp((const char *)selection_data->data, "or_e.png")==0) {
a = new Or(); a->is_logic = true;
} else if (strcmp((const char *)selection_data->data, "not_e.png")==0) {
- a = new Not(); a->is_logic = true;
+ a = new Not(); a->is_logic = true;
Exclusa::Exclusa(int orientacion)
{
Exclusa::Exclusa(int orientacion)
{
+ in_x = x + 48;
+ in_y = y;
+ out_x = in_x;
+ out_y = y + 32;
imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_h.png");
imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_s.png");
null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_h.png");
imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/exclusa_s.png");
null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
bool Exclusa::on_button_press_event(GdkEventButton *event)
{
bool Exclusa::on_button_press_event(GdkEventButton *event)
{
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
WorkPlace::pointed = ID;
if (CItem::logic_connect) {
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
WorkPlace::pointed = ID;
if (CItem::logic_connect) {
- tmp_line.logic = workplace->get_logic_item(CItem::quien);
- tmp_line.store = this;
- workplace->lista_lineas.push_back(tmp_line);
- workplace->on_expose_event(&e);
- }
+ if ( detect_click_position(event->x, event->y) == IN) {
+ tmp_line.logic = workplace->get_logic_item(CItem::gate_id);
+ tmp_line.store = this;
+ workplace->lista_lineas_in.push_back(tmp_line);
+ workplace->queue_draw();
+ } else {
+ tmp_line.logic = workplace->get_logic_item(CItem::gate_id);
+ tmp_line.store = this;
+ workplace->lista_lineas_out.push_back(tmp_line);
+ workplace->queue_draw();
+ }
+ }
}
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
}
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
switch (imgActual) {
case 1:
image = imageS;
switch (imgActual) {
case 1:
image = imageS;
+ in_x = x + image->get_width();
+ in_y = y + image->get_height()/2;
+ out_x = x;
+ out_y = in_y;
break;
default:
imgActual = 0;
image = imageN;
break;
default:
imgActual = 0;
image = imageN;
+ in_x = x + image->get_width()/2;
+ in_y = y;
+ out_x = in_x;
+ out_y = y +image->get_height();
}
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);
}
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 (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
exclusa_pty_wnd->show();
}
if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
exclusa_pty_wnd->show();
}
- workplace->on_expose_event(&e);
+ workplace->queue_draw();
+
+void Exclusa::set_default_connector()
+{
+ connect_vec[0].type = UNDEF;
+ connect_vec[1].type = UNDEF;
+}
-void Exclusa::get_logic_connect_position(int& _a, int& _b)
+void Exclusa::get_in_logic_connect_position(int& _a, int& _b)
+{
+ _a = in_x;
+ _b = in_y;
+}
+
+void Exclusa::get_out_logic_connect_position(int& _a, int& _b)
+{
+ _a = out_x;
+ _b = out_y;
+}
+
+ConnectorType Exclusa::detect_click_position(int _a, int _b)
- case 0:
- _a = x + image->get_width()/2;
- _b = y;
+ case 0:
+ if ( (_a <= image->get_width()/2+10)&&(_a>=image->get_width()/2-10)&&(_b<=16)&&(_b >= 0) )
+ return IN;
+ if ( (_a <= image->get_width()/2+10)&&(_a>=image->get_width()/2-10)&&(_b<=32)&&(_b > 16) )
+ return OUT;
- case 1:
- _a = x + image->get_width();
- _b = y + image->get_height()/2;
- }
+ case 1:
+ if ( (_a <=32)&&(_a> 16)&&(_b<=image->get_height()/2+10)&&(_b >= image->get_height()/2-10) )
+ return IN;
+ if ( (_a <= 16)&&(_a>=0)&&(_b<=image->get_height()/2+10)&&(_b >= image->get_height()/2-10) )
+ return OUT;
+ }
+ return UNDEF;
-
-void Exclusa::set_default_connector()
+
+void Exclusa::update_logic_position()
- connect_vec[0].type = UNDEF;
- connect_vec[1].type = UNDEF;
+ switch (imgActual) {
+ case 1:
+ in_x = x + image->get_width();
+ in_y = y + image->get_height()/2;
+ out_x = x;
+ out_y = in_y;
+ break;
+ case 0:
+ in_x = x + image->get_width()/2;
+ in_y = y;
+ out_x = in_x;
+ out_y = y +image->get_height();
+ }
#include "item.h"
bool CItem::logic_connect = false;
#include "item.h"
bool CItem::logic_connect = false;
+int CItem::gate_id = -1;
CItem::CItem(const char *filename):Gtk::DrawingArea()
CItem::CItem(const char *filename):Gtk::DrawingArea()
-void CItem::get_logic_connect_position(int& _a, int& _b)
+void CItem::get_in_logic_connect_position(int& _a, int& _b)
+
+void CItem::get_out_logic_connect_position(int& _a, int& _b)
+{
+ _a = x;
+ _b = y;
+}
+
+void CItem::update_logic_position()
+{
+}
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
if (CItem::logic_connect)
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
if (CItem::logic_connect)
combo_entry->set_text(name);
WorkPlace::pointed = ID;
}
combo_entry->set_text(name);
WorkPlace::pointed = ID;
}
menu_popup.popup(event->button, event->time);
return true; //It has been handled.
}
menu_popup.popup(event->button, event->time);
return true; //It has been handled.
}
+ workplace->queue_draw();
return true;
}
void Not::on_menu_popup_rotar()
return true;
}
void Not::on_menu_popup_rotar()
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
if (CItem::logic_connect)
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
if (CItem::logic_connect)
combo_entry->set_text(name);
WorkPlace::pointed = ID;
}
combo_entry->set_text(name);
WorkPlace::pointed = ID;
}
menu_popup.popup(event->button, event->time);
return true; //It has been handled.
}
menu_popup.popup(event->button, event->time);
return true; //It has been handled.
}
+ workplace->queue_draw();
Pump::Pump(int orientacion)
{
Pump::Pump(int orientacion)
{
+ in_x = x + 48;
+ in_y = y;
+ out_x = in_x;
+ out_y = y + 32;
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");
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");
bool Pump::on_button_press_event(GdkEventButton *event)
{
bool Pump::on_button_press_event(GdkEventButton *event)
{
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
WorkPlace::pointed = ID;
if (CItem::logic_connect) {
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
WorkPlace::pointed = ID;
if (CItem::logic_connect) {
- tmp_line.logic = workplace->get_logic_item(CItem::quien);
- tmp_line.store = this;
- workplace->lista_lineas.push_back(tmp_line);
- workplace->on_expose_event(&e);
+ if ( detect_click_position(event->x, event->y) == IN) {
+ tmp_line.logic = workplace->get_logic_item(CItem::gate_id);
+ tmp_line.store = this;
+ workplace->lista_lineas_in.push_back(tmp_line);
+ workplace->queue_draw();
+ } else {
+ tmp_line.logic = workplace->get_logic_item(CItem::gate_id);
+ tmp_line.store = this;
+ workplace->lista_lineas_out.push_back(tmp_line);
+ workplace->queue_draw();
+ }
switch (imgActual) {
case 1:
image = imageO;
switch (imgActual) {
case 1:
image = imageO;
+ in_x = x + 16;
+ in_y = y;
+ out_x = in_x;
+ out_y = y + 32;
break;
default:
imgActual = 0;
image = imageE;
break;
default:
imgActual = 0;
image = imageE;
+ in_x = x + image->get_width()-16;
+ in_y = y;
+ out_x = in_x;
+ out_y = y + 32;
}
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);
}
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);
pump_pty_wnd->txt_pump_name->set_text( name );
pump_pty_wnd->show();
}
pump_pty_wnd->txt_pump_name->set_text( name );
pump_pty_wnd->show();
}
- workplace->on_expose_event(&e);
+ workplace->queue_draw();
connect_vec[0].type = OUT;
}
connect_vec[0].type = OUT;
}
-void Pump::get_logic_connect_position(int& _a, int& _b)
+void Pump::get_in_logic_connect_position(int& _a, int& _b)
- switch(imgActual) {
- case 0:
- _a = x + image->get_width() - 10;
- _b = y;
+ _a = in_x;
+ _b = in_y;
+}
+
+void Pump::get_out_logic_connect_position(int& _a, int& _b)
+{
+ _a = out_x;
+ _b = out_y;
+}
+
+ConnectorType Pump::detect_click_position(int _a, int _b)
+{
+ switch (imgActual) {
+ case 0:
+ if ( (_a <=image->get_width())&&(_a>=image->get_width()-32)&&(_b<=16)&&(_b >= 0) )
+ return IN;
+ if ( (_a <= image->get_width())&&(_a>=image->get_width()-32)&&(_b<=32)&&(_b > 16) )
+ return OUT;
- case 1:
- _a = x + 10;
- _b = y;
+ case 1:
+ if ( (_a <= 32)&&(_a>=0)&&(_b<=16)&&(_b >= 0) )
+ return IN;
+ if ( (_a <= 32)&&(_a>=0)&&(_b<=32)&&(_b > 16) )
+ return OUT;
+ }
+ return UNDEF;
+}
+
+void Pump::update_logic_position()
+{
+ switch (imgActual) {
+ case 1:
+ in_x = x + 16;
+ in_y = y;
+ out_x = in_x;
+ out_y = y + 32;
+ break;
+ case 0:
+ in_x = x + image->get_width()-16;
+ in_y = y;
+ out_x = in_x;
+ out_y = y + 32;
gc->set_rgb_bg_color(color);
get_style()->set_black(color);
int w, z;
gc->set_rgb_bg_color(color);
get_style()->set_black(color);
int w, z;
- std::list<t_line>::iterator i = lista_lineas.begin();
- while ( i != lista_lineas.end() ) {
+ std::list<t_line>::iterator i = lista_lineas_in.begin();
+ while ( i != lista_lineas_in.end() ) {
- temp.store->get_logic_connect_position(w,z);
+ temp.store->get_in_logic_connect_position(w,z);
get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
i++;
}
get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
i++;
}
+ i = lista_lineas_out.begin();
+ while ( i != lista_lineas_out.end() ) {
+ t_line temp = *i;
+ temp.store->get_out_logic_connect_position(w,z);
+ get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
+ i++;
+ }
+
void WorkPlace::delete_line(int _id)
{
void WorkPlace::delete_line(int _id)
{
- std::list<t_line>::iterator i = lista_lineas.begin();
- while ( i != lista_lineas.end() ){
+ std::list<t_line>::iterator i = lista_lineas_in.begin();
+ while ( i != lista_lineas_in.end() ){
if ( (*i).store->get_id() == _id ) {
if ( (*i).store->get_id() == _id ) {
- lista_lineas.erase(i);
- i = lista_lineas.begin();
+ lista_lineas_in.erase(i);
+ i = lista_lineas_in.begin();
- i = lista_lineas.begin();
- while ( i != lista_lineas.end() ){
+ i = lista_lineas_in.begin();
+ while ( i != lista_lineas_in.end() ){
if ( (*i).logic->get_id() == _id ) {
if ( (*i).logic->get_id() == _id ) {
- lista_lineas.erase(i);
- i = lista_lineas.begin();
+ lista_lineas_in.erase(i);
+ i = lista_lineas_in.begin();
+
+void WorkPlace::update_logic_position()
+{
+ std::list<CItem*>::iterator i = listaItems->begin();
+ while ( i != listaItems->end() ){
+ (*i)->update_logic_position();
+ i++;
+ }
+}