]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
* Los colores ya estan completamente arreglados
authorRicardo Markiewicz <gazer.arg@gmail.com>
Sun, 30 Nov 2003 22:54:56 +0000 (22:54 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Sun, 30 Nov 2003 22:54:56 +0000 (22:54 +0000)
 * El cliente ya visualiza correctamente todos los items

Client/include/item_drain.h
Client/include/item_tank.h
Client/src/item_codo.cpp
Client/src/item_drain.cpp
Client/src/item_tank.cpp
Model/src/drainage.cpp
Model/src/plantitem.cpp
Model/src/simulator.cpp
Model/src/tank.cpp
Model/src/union.cpp

index b501cf95521a001995bd3698e96dd22e5a40eb76..21e110e0d11a0fb92666627607e465cff7796ddf 100644 (file)
@@ -8,6 +8,7 @@ class ViewDrain:public ViewItem {
 public:
        ViewDrain(Glib::ustring _name, int orientacion);
        virtual ~ViewDrain();
 public:
        ViewDrain(Glib::ustring _name, int orientacion);
        virtual ~ViewDrain();
+       bool on_image_expose_event(GdkEventExpose *e);
 };
 
 #endif
 };
 
 #endif
index 1cb080601153e8e6aff9195b2a79b3c5c970d476..1b9aee959fc33227dc2a85663925ed3aebf76410 100644 (file)
@@ -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(); 
        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
 };
 
 #endif
index 73dee4259e571ae12bdbf562f5f52d418cc08e0c..3dc290e84c664b7b886c001ce060fc41e3db199d 100644 (file)
@@ -28,7 +28,6 @@ ViewCodo::~ViewCodo()
 bool ViewCodo::on_image_expose_event(GdkEventExpose *e)
 {
        Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
 bool ViewCodo::on_image_expose_event(GdkEventExpose *e)
 {
        Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
-       Gdk::Color blanco = Gdk::Color("white");
        colormap->alloc_color(color);
        gc->set_foreground(color);
        gc->set_background(color);
        colormap->alloc_color(color);
        gc->set_foreground(color);
        gc->set_background(color);
index 0a03dd5efc73f28d47f4555a75cd46e6e8554598..80136ba8a5856a84359f36a951912f07ec9545cd 100644 (file)
@@ -25,3 +25,18 @@ ViewDrain::~ViewDrain()
 {
 }
 
 {
 }
 
+bool ViewDrain::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> 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;
+}
index 28cd57644c5900dde19819e74e1bbf0860b04621..daeb4e7ce9eb585c165b0a24fcb922ee3515c22b 100644 (file)
@@ -44,3 +44,18 @@ std::string ViewTank::get_extra()
        return s;
 }
 
        return s;
 }
 
+bool ViewTank::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> 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;
+}
index 6d7953483a88a825361b12137c5f637a785685be..85fec867fdc062154761dea2fa09c399bb97ded3 100644 (file)
@@ -32,7 +32,6 @@ void Drainage::simulate()
 #endif
        updated = false;
        color_updated = false;
 #endif
        updated = false;
        color_updated = false;
-       actual_flow = 0;
 }
 
 void Drainage::recieve_msg(int msg, IConector *who, void *data)
 }
 
 void Drainage::recieve_msg(int msg, IConector *who, void *data)
index 50d8e9884c34571e9a786acf194828a6b7936fda..75697223e2ee61a4eb2efe4d48f5f4df4fb7f7f5 100644 (file)
@@ -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);
                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);
                        }
                        update_color();
                        who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color);
@@ -50,8 +51,8 @@ void PlantItem::update_color()
 {
        if (color_updated) return;
 
 {
        if (color_updated) return;
 
-       send_msg(IConector::IN, MSG_QUERY_COLOR);
        color_updated = true;
        color_updated = true;
+       send_msg(IConector::IN, MSG_QUERY_COLOR);
 }
 
 void PlantItem::get_state_as_xml(std::stringstream &out)
 }
 
 void PlantItem::get_state_as_xml(std::stringstream &out)
index 66148f296928aba5295d06ea1136ff8f7a57042f..f5c011452c1c1a8e66854b8baee9b3a3255dfbcc 100644 (file)
@@ -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) );
                                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);
                        }
                }
                                color = loadRGB(nodo->children);
                        }
                }
index e526716a69c1be84fd1a66b190fbead931076d7d..a557c0b5cf83b8094bf7951867ede32ae4e8bd44 100644 (file)
@@ -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;
                        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);
                        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) {
                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:
                        }
                break;
                case MSG_RESPONSE_COLOR:
+               {
                        RGB c = *((RGB *)data);
                        PlantItem *ic = static_cast<PlantItem *>(*(in_list.begin()));
                        int r,g,b;
                        RGB c = *((RGB *)data);
                        PlantItem *ic = static_cast<PlantItem *>(*(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));
                        g %= 256;
                        b %= 256;
                        set_color(RGB(r,g,b));
+                       color_updated = true;
+               }
+               break;
+               default:
+                       Control::recieve_msg(msg, who, data);
        }
 }
 
        }
 }
 
index 450b6e630211cb341e3d6ea8cdfa74d1dbb124ec..0d2c18c85e8fc8798113c3fee616fe5fd41827ff 100644 (file)
@@ -35,11 +35,16 @@ void Union::recieve_msg(int msg, IConector *who, void *data)
                        float m_data =  *((float *)data)*2;
                        float tmp;
 
                        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;
                                who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &tmp);
                                break;
-                       }
+                       }*/
                        updated = true;
                        if (m_data == 0) {
                                in_on_zero++;
                        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;
                                }
                                        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);
                        }
                                tmp = (in_on_zero==0)?actual_flow/2.0f:actual_flow;
                                who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &tmp);
                        }