From e7bc59fe98396b7c67024911b03bf1e08728df3e Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Sun, 30 Nov 2003 20:26:39 +0000 Subject: [PATCH] Mas cosas bonitas en el cliente --- Client/include/item_pump.h | 1 + Client/src/item_codo.cpp | 27 ++++++++++++--------------- Client/src/item_conduct.cpp | 11 +++++------ Client/src/item_exclusa.cpp | 6 ++++-- Client/src/item_pump.cpp | 20 ++++++++++++++++++++ Client/src/item_union.cpp | 36 ++++++++++++++++++++---------------- Client/src/principal.cpp | 10 +++++----- Model/include/rgb.h | 4 ++++ Model/include/union.h | 1 + Model/src/union.cpp | 9 +++++++-- 10 files changed, 79 insertions(+), 46 deletions(-) diff --git a/Client/include/item_pump.h b/Client/include/item_pump.h index f426f27..674788e 100644 --- a/Client/include/item_pump.h +++ b/Client/include/item_pump.h @@ -10,6 +10,7 @@ public: virtual ~ViewPump(); virtual std::string get_cap_extra() { return "Estado"; } virtual std::string get_extra() { return (open)?"Encendida":"Apagada"; } + bool on_image_expose_event(GdkEventExpose *e); }; #endif diff --git a/Client/src/item_codo.cpp b/Client/src/item_codo.cpp index ce0f2b5..e0a1a1c 100644 --- a/Client/src/item_codo.cpp +++ b/Client/src/item_codo.cpp @@ -29,39 +29,36 @@ bool ViewCodo::on_image_expose_event(GdkEventExpose *e) { Glib::RefPtr colormap = image.get_colormap(); Gdk::Color blanco = Gdk::Color("white"); - colormap->alloc_color(blanco); colormap->alloc_color(color); - gc->set_foreground(blanco); - gc->set_background(blanco); + 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; switch (m_or) { case 0: image.get_window()->draw_arc(gc, 0, -16, 16, w, h, 0, 90*64); - gc->set_line_attributes(4, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); - gc->set_foreground(color); - image.get_window()->draw_arc(gc, 0, -16, 16, w, h, 0, 90*64); + image.get_window()->draw_line(gc, 0, 16, 16, 16); + image.get_window()->draw_line(gc, 64-16, 64-16, 64-16, 64); break; case 1: image.get_window()->draw_arc(gc, 0, -16, -16, w, h, 0*64, -90*64); - gc->set_line_attributes(4, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); - gc->set_foreground(color); - image.get_window()->draw_arc(gc, 0, -16, -16, w, h, 0*64, -90*64); + image.get_window()->draw_line(gc, 64-16, 0, 64-16, 16); + image.get_window()->draw_line(gc, 0, 64-16, 16, 64-16); break; case 2: image.get_window()->draw_arc(gc, 0, 16, -16, w, h, -90*64, -90*64); - gc->set_line_attributes(4, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); - gc->set_foreground(color); - image.get_window()->draw_arc(gc, 0, 16, -16, w, h, -90*64, -90*64); + image.get_window()->draw_line(gc, 16, 0, 16, 16); + image.get_window()->draw_line(gc, 64-16, 64-16, 64, 64-16); break; case 3: image.get_window()->draw_arc(gc, 0, 16, 16, w, h, 90*64, 90*64); - gc->set_line_attributes(4, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); - gc->set_foreground(color); - image.get_window()->draw_arc(gc, 0, 16, 16, w, h, 90*64, 90*64); + image.get_window()->draw_line(gc, 16, 64-16, 16, 64); + image.get_window()->draw_line(gc, 64-16, 16, 64, 16); } + return true; } diff --git a/Client/src/item_conduct.cpp b/Client/src/item_conduct.cpp index f348945..8f070a2 100644 --- a/Client/src/item_conduct.cpp +++ b/Client/src/item_conduct.cpp @@ -30,16 +30,15 @@ bool ViewConduct::on_image_expose_event(GdkEventExpose *e) int w,h; w = image.get_width(); h = image.get_height(); + if (actual_flow == 0) return true; switch (m_or) { case 0: // Vertical - image.get_window()->draw_rectangle(gc, 1, w/2-2, 0, 4, h-1); - gc->set_foreground(blanco); - image.get_window()->draw_rectangle(gc, 0, w/2-3, 0, 6, h-1); + image.get_window()->draw_rectangle(gc, 1, w/2-3, 0, 6, h); break; case 1: // Horizontal - image.get_window()->draw_rectangle(gc, 1, 0, h/2-2, w-1, 4); - gc->set_foreground(blanco); - image.get_window()->draw_rectangle(gc, 0, 0, h/2-3, w-1, 6); + image.get_window()->draw_rectangle(gc, 1, 0, h/2-3, w, 6); } + return true; } + diff --git a/Client/src/item_exclusa.cpp b/Client/src/item_exclusa.cpp index d318ac4..d09ad8a 100644 --- a/Client/src/item_exclusa.cpp +++ b/Client/src/item_exclusa.cpp @@ -44,12 +44,14 @@ bool ViewExclusa::on_image_expose_event(GdkEventExpose *e) int w,h; w = image.get_width(); h = image.get_height(); + if (actual_flow == 0) return true; switch (m_or) { case 1: // Vertical - image.get_window()->draw_rectangle(gc, 1, w/2-2, 0, 4, h); + image.get_window()->draw_rectangle(gc, 1, w/2-3, 0, 6, h); break; case 0: // Horizontal - image.get_window()->draw_rectangle(gc, 1, 0, h/2-2, w, 4); + image.get_window()->draw_rectangle(gc, 1, 0, h/2-3, w, 6); } + return true; } diff --git a/Client/src/item_pump.cpp b/Client/src/item_pump.cpp index abb1b0c..536a884 100644 --- a/Client/src/item_pump.cpp +++ b/Client/src/item_pump.cpp @@ -26,6 +26,7 @@ ViewPump::ViewPump(Glib::ustring _name, int orientacion):ViewItem(_name) item_offset_x = 0; item_offset_y = -15; } + m_or = orientacion; image.show(); set_size_request(); } @@ -34,3 +35,22 @@ ViewPump::~ViewPump() { } +bool ViewPump::on_image_expose_event(GdkEventExpose *e) +{ + Glib::RefPtr colormap = image.get_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); + if (actual_flow == 0) return true; + switch (m_or) { + case 0: + image.get_window()->draw_arc(gc, 1, 8, 8, 16, 16, 0, 360*64); + image.get_window()->draw_line(gc, 16, 16, 96, 16); + break; + case 1: + image.get_window()->draw_arc(gc, 1, 72, 8, 16, 16, 0, 360*64); + image.get_window()->draw_line(gc, 80, 16, 0, 16); + } + return true; +} diff --git a/Client/src/item_union.cpp b/Client/src/item_union.cpp index 08bad4e..4bfd2ff 100644 --- a/Client/src/item_union.cpp +++ b/Client/src/item_union.cpp @@ -29,28 +29,32 @@ ViewUnion::~ViewUnion() bool ViewUnion::on_image_expose_event(GdkEventExpose *e) { Glib::RefPtr colormap = image.get_colormap(); - Gdk::Color blanco = Gdk::Color("white"); colormap->alloc_color(color); - colormap->alloc_color(blanco); gc->set_foreground(color); gc->set_background(color); int w,h; w = image.get_width(); h = image.get_height(); - switch (m_or) { - case 0: - image.get_window()->draw_rectangle(gc, 1, w/2-2, h/2, 4, h/2); - gc->set_foreground(blanco); - image.get_window()->draw_rectangle(gc, 0, w/2-3, h/2-1, 6, h/2); - break; - case 1: - image.get_window()->draw_rectangle(gc, 1, 0, h/2-2, w/2, 4); - break; - case 2: - image.get_window()->draw_rectangle(gc, 1, w/2-2, 0, 4, h/2); - break; - case 3: - image.get_window()->draw_rectangle(gc, 1, w/2, h/2-2, w/2, 4); + if (actual_flow > 0) { + switch (m_or) { + case 0: + image.get_window()->draw_rectangle(gc, 1, w/2-3, 16, 6, h-16); + image.get_window()->draw_rectangle(gc, 1, 0, 13, w, 6); + break; + case 1: + image.get_window()->draw_rectangle(gc, 1, 0, h/2-3, w/2, 6); + image.get_window()->draw_rectangle(gc, 1, 51, 0, 6, h); + break; + case 2: + image.get_window()->draw_rectangle(gc, 1, w/2-3, 0, 6, h/2); + image.get_window()->draw_rectangle(gc, 1, 0, 51, w, 6); + break; + case 3: + image.get_window()->draw_rectangle(gc, 1, w/2, h/2-3, w/2, 6); + image.get_window()->draw_rectangle(gc, 1, 16, 0, 6, h); + } } + return true; } + diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index 845de81..870c06a 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -799,7 +799,7 @@ void Principal::read_status_xml(const std::string &frame) Gdk::Color Principal::get_rgb_from_xml(xmlNodePtr nodo) { - unsigned r,g,b; + gushort r,g,b; while (nodo != NULL) { if (nodo->type == XML_ELEMENT_NODE) { if (xmlStrcmp(nodo->name, BAD_CAST"r")==0) @@ -811,14 +811,14 @@ Gdk::Color Principal::get_rgb_from_xml(xmlNodePtr nodo) } nodo = nodo->next; } - r = 65535 * r / 255; - g = 65535 * g / 255; - b = 65535 * b / 255; + r = static_cast(65535 * (r / 255.0f)); + g = static_cast(65535 * (g / 255.0f)); + b = static_cast(65535 * (b / 255.0f)); Gdk::Color c; c.set_rgb(r,g,b); - return c; } + float Principal::get_float_from_xml(xmlNodePtr nodo) { float tmp = -1; diff --git a/Model/include/rgb.h b/Model/include/rgb.h index 0feedc2..7eebfb1 100644 --- a/Model/include/rgb.h +++ b/Model/include/rgb.h @@ -23,6 +23,10 @@ public: return (*this); } + bool operator == (const RGB &c) { + return ((r()==c.r()) && (g() == c.g()) && (b() == c.b())); + } + color r() const { return my_r; } color g() const { return my_g; } color b() const { return my_b; } diff --git a/Model/include/union.h b/Model/include/union.h index 5069c80..db6be6a 100644 --- a/Model/include/union.h +++ b/Model/include/union.h @@ -31,6 +31,7 @@ protected: int in_colors; RGB color1, color2; float flow1, flow2; + PlantItem *entrada1; private: Union(const Union &):Transport("null") {} Union &operator = (const Union &) { return *this; } diff --git a/Model/src/union.cpp b/Model/src/union.cpp index 7fe666b..65b1e7b 100644 --- a/Model/src/union.cpp +++ b/Model/src/union.cpp @@ -91,11 +91,16 @@ void Union::recieve_msg(int msg, IConector *who, void *data) case MSG_RESPONSE_COLOR: if (in_colors == 0) { color1 = *((RGB *)data); - flow1 = static_cast(who)->get_actual_flow(); + entrada1 = static_cast(who); + flow1 = entrada1->get_actual_flow(); in_colors++; - } else { + } else if ((in_colors == 1) && (entrada1 != who)) { color2 = *((RGB *)data); flow2 = static_cast(who)->get_actual_flow(); + in_colors++; + if (color1 == color2) { + std::cout << "TODO MAL" << std::endl << std::endl; + } /* Ya tengo mis 2 colores, los sumo */ int r,g,b; -- 2.43.0