From: Ricardo Markiewicz Date: Sun, 30 Nov 2003 22:54:56 +0000 (+0000) Subject: * Los colores ya estan completamente arreglados X-Git-Tag: svn_import~144 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/dfabbe2822ffdfb241105cff491b4331096e4af3?hp=c45e0693cd6b07a5123955102de53d96143f7fd8 * Los colores ya estan completamente arreglados * El cliente ya visualiza correctamente todos los items --- diff --git a/Client/include/item_drain.h b/Client/include/item_drain.h index b501cf9..21e110e 100644 --- a/Client/include/item_drain.h +++ b/Client/include/item_drain.h @@ -8,6 +8,7 @@ class ViewDrain:public ViewItem { public: ViewDrain(Glib::ustring _name, int orientacion); virtual ~ViewDrain(); + bool on_image_expose_event(GdkEventExpose *e); }; #endif diff --git a/Client/include/item_tank.h b/Client/include/item_tank.h index 1cb0806..1b9aee9 100644 --- a/Client/include/item_tank.h +++ b/Client/include/item_tank.h @@ -12,6 +12,7 @@ public: virtual std::string get_cap_flow() { return "Capacidad :"; } virtual std::string get_cap_extra() { return "Liquido :"; } virtual std::string get_extra(); + bool on_image_expose_event(GdkEventExpose *e); }; #endif diff --git a/Client/src/item_codo.cpp b/Client/src/item_codo.cpp index 73dee42..3dc290e 100644 --- a/Client/src/item_codo.cpp +++ b/Client/src/item_codo.cpp @@ -28,7 +28,6 @@ ViewCodo::~ViewCodo() bool ViewCodo::on_image_expose_event(GdkEventExpose *e) { Glib::RefPtr colormap = Gtk::Widget::get_default_colormap(); - Gdk::Color blanco = Gdk::Color("white"); colormap->alloc_color(color); gc->set_foreground(color); gc->set_background(color); diff --git a/Client/src/item_drain.cpp b/Client/src/item_drain.cpp index 0a03dd5..80136ba 100644 --- a/Client/src/item_drain.cpp +++ b/Client/src/item_drain.cpp @@ -25,3 +25,18 @@ ViewDrain::~ViewDrain() { } +bool ViewDrain::on_image_expose_event(GdkEventExpose *e) +{ + Glib::RefPtr colormap = Gtk::Widget::get_default_colormap(); + colormap->alloc_color(color); + gc->set_foreground(color); + gc->set_background(color); + gc->set_line_attributes(6, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); + int w,h; + w = image.get_width(); + h = image.get_height(); + // TODO : hacer que dibuje arcos en el sentido del codo! + if (actual_flow == 0) return true; + image.get_window()->draw_arc(gc, 1, 8, 8, 16, 16, 0, 360*64); + return true; +} diff --git a/Client/src/item_tank.cpp b/Client/src/item_tank.cpp index 28cd576..daeb4e7 100644 --- a/Client/src/item_tank.cpp +++ b/Client/src/item_tank.cpp @@ -44,3 +44,18 @@ std::string ViewTank::get_extra() return s; } +bool ViewTank::on_image_expose_event(GdkEventExpose *e) +{ + Glib::RefPtr colormap = Gtk::Widget::get_default_colormap(); + colormap->alloc_color(color); + gc->set_foreground(color); + gc->set_background(color); + gc->set_line_attributes(6, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); + int w,h; + w = image.get_width(); + h = image.get_height(); + // TODO : hacer que dibuje arcos en el sentido del codo! + if (actual_flow == 0) return true; + image.get_window()->draw_arc(gc, 1, w/2-7, h/2-7, 14, 14, 0, 360*64); + return true; +} diff --git a/Model/src/drainage.cpp b/Model/src/drainage.cpp index 6d79534..85fec86 100644 --- a/Model/src/drainage.cpp +++ b/Model/src/drainage.cpp @@ -32,7 +32,6 @@ void Drainage::simulate() #endif updated = false; color_updated = false; - actual_flow = 0; } void Drainage::recieve_msg(int msg, IConector *who, void *data) diff --git a/Model/src/plantitem.cpp b/Model/src/plantitem.cpp index 50d8e98..7569722 100644 --- a/Model/src/plantitem.cpp +++ b/Model/src/plantitem.cpp @@ -31,6 +31,7 @@ void PlantItem::recieve_msg(int msg, IConector *who, void *data) case MSG_QUERY_COLOR: if (color_updated) { who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color); + return; } update_color(); who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color); @@ -50,8 +51,8 @@ void PlantItem::update_color() { if (color_updated) return; - send_msg(IConector::IN, MSG_QUERY_COLOR); color_updated = true; + send_msg(IConector::IN, MSG_QUERY_COLOR); } void PlantItem::get_state_as_xml(std::stringstream &out) diff --git a/Model/src/simulator.cpp b/Model/src/simulator.cpp index 66148f2..f5c0114 100644 --- a/Model/src/simulator.cpp +++ b/Model/src/simulator.cpp @@ -314,7 +314,7 @@ void Simulator::loadTank(xmlNodePtr nodo) capacidad = atoi( (char *)XML_GET_CONTENT(nodo->children) ); } else if (xmlStrcmp(nodo->name, BAD_CAST"inicial") == 0) { inicial = atof( (char *)XML_GET_CONTENT(nodo->children) ); - } else if (xmlStrcmp(nodo->name, BAD_CAST"") == 0) { + } else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) { color = loadRGB(nodo->children); } } diff --git a/Model/src/tank.cpp b/Model/src/tank.cpp index e526716..a557c0b 100644 --- a/Model/src/tank.cpp +++ b/Model/src/tank.cpp @@ -68,10 +68,10 @@ void Tank::recieve_msg(int msg, IConector *who, void *data) if (*((float *)data) < actual_in_flow) actual_in_flow = *((float *)data); actual_out_flow = litros; + updated = true; send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &actual_out_flow); who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &actual_in_flow); - updated = true; break; case MSG_RESPONSE_MAX_FLOW: if (pos == OUT) { @@ -80,6 +80,7 @@ void Tank::recieve_msg(int msg, IConector *who, void *data) } break; case MSG_RESPONSE_COLOR: + { RGB c = *((RGB *)data); PlantItem *ic = static_cast(*(in_list.begin())); int r,g,b; @@ -92,6 +93,11 @@ void Tank::recieve_msg(int msg, IConector *who, void *data) g %= 256; b %= 256; set_color(RGB(r,g,b)); + color_updated = true; + } + break; + default: + Control::recieve_msg(msg, who, data); } } diff --git a/Model/src/union.cpp b/Model/src/union.cpp index 450b6e6..0d2c18c 100644 --- a/Model/src/union.cpp +++ b/Model/src/union.cpp @@ -35,11 +35,16 @@ void Union::recieve_msg(int msg, IConector *who, void *data) float m_data = *((float *)data)*2; float tmp; - if (updated) { - float tmp = actual_flow/2.0f; +/* if (updated) { + if (m_data == 0) { + tmp = 0; + actual_flow /= 2.0f; + } else { + tmp = actual_flow/2.0f; + } who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &tmp); break; - } + }*/ updated = true; if (m_data == 0) { in_on_zero++; @@ -67,7 +72,8 @@ void Union::recieve_msg(int msg, IConector *who, void *data) case 2: actual_flow = 0; } - send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &actual_flow); + if (!updated) + send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &actual_flow); tmp = (in_on_zero==0)?actual_flow/2.0f:actual_flow; who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &tmp); }