From fc545e363e5352e2a672b0fa6a39facf6dc7d36b Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 1 Dec 2003 01:59:19 +0000 Subject: [PATCH 1/1] * Se agrega carga de colores desde el XML * Se arregla el bug de las conexiones en la exclusa solamente --- Constructor/include/cisternptywnd.h | 4 +++- Constructor/include/constructor.h | 1 + Constructor/include/pumpptywnd.h | 4 +++- Constructor/src/cisternptywnd.cpp | 9 +++++++++ Constructor/src/constructor.cpp | 29 +++++++++++++++++++++++++++-- Constructor/src/exclusa.cpp | 4 ++-- Constructor/src/item.cpp | 1 + Constructor/src/pump.cpp | 1 + Constructor/src/pumpptywnd.cpp | 9 +++++++++ 9 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Constructor/include/cisternptywnd.h b/Constructor/include/cisternptywnd.h index d8762dc..b8c91f8 100644 --- a/Constructor/include/cisternptywnd.h +++ b/Constructor/include/cisternptywnd.h @@ -14,7 +14,9 @@ class CisternPtyWnd : public PropertyWnd { ///Destructor. virtual ~CisternPtyWnd(); - + + virtual void show(); + ///Puntero al Tanque que se le modificaran sus propiedades. Cistern *cistern; diff --git a/Constructor/include/constructor.h b/Constructor/include/constructor.h index 0746191..c81f5b0 100644 --- a/Constructor/include/constructor.h +++ b/Constructor/include/constructor.h @@ -115,5 +115,6 @@ class Constructor : public Gtk::Window { And *loadAnd(xmlNodePtr nodo); Not *loadNot(xmlNodePtr nodo); Or *loadOr(xmlNodePtr nodo); + Gdk::Color loadColor(xmlNodePtr nodo); }; #endif diff --git a/Constructor/include/pumpptywnd.h b/Constructor/include/pumpptywnd.h index 877dff0..e35a717 100644 --- a/Constructor/include/pumpptywnd.h +++ b/Constructor/include/pumpptywnd.h @@ -14,7 +14,9 @@ class PumpPtyWnd : public PropertyWnd{ ///Destructor. virtual ~PumpPtyWnd(); - + + virtual void show(); + ///Puntero al item al cual se le modifcan las propiedades. Pump *pump; diff --git a/Constructor/src/cisternptywnd.cpp b/Constructor/src/cisternptywnd.cpp index f12867c..31a0152 100644 --- a/Constructor/src/cisternptywnd.cpp +++ b/Constructor/src/cisternptywnd.cpp @@ -17,6 +17,15 @@ CisternPtyWnd::CisternPtyWnd(BaseObjectType* cobject, const Glib::RefPtrsignal_clicked().connect(SigC::slot(*this,&CisternPtyWnd::on_btn_select_color_clicked)); dlg_select_color_cancel->signal_clicked().connect(SigC::slot(*this,&CisternPtyWnd::on_dlg_select_color_cancel_clicked)); dlg_select_color_ok->signal_clicked().connect(SigC::slot(*this,&CisternPtyWnd::on_dlg_select_color_ok_clicked)); + cistern = NULL; +} + +void CisternPtyWnd::show() +{ + if (cistern != NULL) { + color_preview->modify_bg( Gtk::STATE_NORMAL , cistern->get_liquid_color() ); + } + PropertyWnd::show(); } CisternPtyWnd::~CisternPtyWnd() diff --git a/Constructor/src/constructor.cpp b/Constructor/src/constructor.cpp index 8a36809..e352f4a 100644 --- a/Constructor/src/constructor.cpp +++ b/Constructor/src/constructor.cpp @@ -769,6 +769,7 @@ Pump *Constructor::loadBomba(xmlNodePtr nodo) std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id"); int orientacion=0, x, y; float flujo; + Gdk::Color color; nodo = nodo->children; while (nodo != NULL) { @@ -782,7 +783,7 @@ Pump *Constructor::loadBomba(xmlNodePtr nodo) } else if (xmlStrcmp(nodo->name, BAD_CAST"entrega") == 0) { flujo = atof( (char *)XML_GET_CONTENT(nodo->children) ); } else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) { - // FIXME ! + color = loadColor(nodo->children); } } nodo = nodo->next; @@ -793,10 +794,31 @@ Pump *Constructor::loadBomba(xmlNodePtr nodo) p->set_entrega(flujo); p->set_id( atoi(id.c_str()) ); p->set_name(name); + p->set_liquid_color(color); return p; } +Gdk::Color Constructor::loadColor(xmlNodePtr nodo) +{ + gushort r,g,b; + while (nodo != NULL) { + if (nodo->type == XML_ELEMENT_NODE) { + if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0) + r = atoi( (char *)XML_GET_CONTENT(nodo->children) ); + if (xmlStrcmp(nodo->name, BAD_CAST"verde")==0) + g = atoi( (char *)XML_GET_CONTENT(nodo->children) ); + if (xmlStrcmp(nodo->name, BAD_CAST"azul")==0) + b = atoi( (char *)XML_GET_CONTENT(nodo->children) ); + } + nodo = nodo->next; + } + Gdk::Color c; + c.set_rgb(r,g,b); + std::cout << r << " " << g << " " << b << std::endl; + return c; +} + Conduct *Constructor::loadConduct(xmlNodePtr nodo) { std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre"); @@ -868,6 +890,7 @@ Cistern *Constructor::loadTank(xmlNodePtr nodo) std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id"); int orientacion=0, x, y; float liquido,capacidad; + Gdk::Color color; nodo = nodo->children; while (nodo != NULL) { @@ -882,6 +905,8 @@ Cistern *Constructor::loadTank(xmlNodePtr nodo) capacidad = atof ((char *)XML_GET_CONTENT(nodo->children) ); } else if (xmlStrcmp(nodo->name, BAD_CAST"inicial") == 0) { liquido = atof ((char *)XML_GET_CONTENT(nodo->children) ); + } else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) { + color = loadColor(nodo->children); } } nodo = nodo->next; @@ -893,7 +918,7 @@ Cistern *Constructor::loadTank(xmlNodePtr nodo) p->set_name(name); p->set_capacidad(capacidad); p->set_contenido_inicial(liquido); - + p->set_liquid_color(color); return p; } diff --git a/Constructor/src/exclusa.cpp b/Constructor/src/exclusa.cpp index 5eb4ead..eb296d6 100644 --- a/Constructor/src/exclusa.cpp +++ b/Constructor/src/exclusa.cpp @@ -205,7 +205,7 @@ ConnectorType Exclusa::get_connector_type(int _a, int _b) CItem *_item; switch (imgActual) { case 1: - if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ){ //arriba + if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > y ) ){ //arriba if ( is_connected ) return connect_vec[0].type; connect_vec[1].type = is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5, &_item); //pregunto que hay abajo switch ( connect_vec[1].type ) { @@ -244,7 +244,7 @@ ConnectorType Exclusa::get_connector_type(int _a, int _b) } break; case 0: - if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )){ //izquierda + if ((_a <= x+10 )&&(_a > x) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )){ //izquierda if ( is_connected ) return connect_vec[0].type; connect_vec[1].type = is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16, &_item);//pregunto por la derecha switch ( connect_vec[1].type ) { diff --git a/Constructor/src/item.cpp b/Constructor/src/item.cpp index 0bbf005..cbba331 100644 --- a/Constructor/src/item.cpp +++ b/Constructor/src/item.cpp @@ -113,6 +113,7 @@ Glib::ustring CItem::get_name() Glib::ustring CItem::get_other_name(int _id) { std::list::iterator i = listaItems->begin(); + std::cout << name << " " << _id << std::endl; while ( i != listaItems->end() ) { if ( (*i)->get_id() == _id ) return (*i)->get_name(); diff --git a/Constructor/src/pump.cpp b/Constructor/src/pump.cpp index fb827d3..2d7f2a8 100644 --- a/Constructor/src/pump.cpp +++ b/Constructor/src/pump.cpp @@ -198,6 +198,7 @@ bool Pump::check_connection() temp = is_other_connection_area( get_position_x() -5, get_position_y() +16, &_item); } if (is_connected = ( temp == IN) ) { + std::cout << "PUMP " << _item->get_id() << std::endl; connect_vec[0].id_dest = _item->get_id(); return is_connected; } diff --git a/Constructor/src/pumpptywnd.cpp b/Constructor/src/pumpptywnd.cpp index 0889599..b265271 100644 --- a/Constructor/src/pumpptywnd.cpp +++ b/Constructor/src/pumpptywnd.cpp @@ -16,12 +16,21 @@ PumpPtyWnd::PumpPtyWnd(BaseObjectType* cobject, const Glib::RefPtrsignal_clicked().connect(SigC::slot(*this,&PumpPtyWnd::on_btn_select_color_clicked)); dlg_select_color_cancel->signal_clicked().connect(SigC::slot(*this,&PumpPtyWnd::on_dlg_select_color_cancel_clicked)); dlg_select_color_ok->signal_clicked().connect(SigC::slot(*this,&PumpPtyWnd::on_dlg_select_color_ok_clicked)); + pump = NULL; } PumpPtyWnd::~PumpPtyWnd() { } +void PumpPtyWnd::show() +{ + if (pump != NULL) { + color_preview->modify_bg( Gtk::STATE_NORMAL , pump->get_liquid_color() ); + } + PropertyWnd::show(); +} + void PumpPtyWnd::on_btn_accept_clicked() { PumpPtyWnd::on_btn_apply_clicked(); -- 2.43.0