]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Mas cosas bonitas en el cliente
authorRicardo Markiewicz <gazer.arg@gmail.com>
Sun, 30 Nov 2003 20:26:39 +0000 (20:26 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Sun, 30 Nov 2003 20:26:39 +0000 (20:26 +0000)
Client/include/item_pump.h
Client/src/item_codo.cpp
Client/src/item_conduct.cpp
Client/src/item_exclusa.cpp
Client/src/item_pump.cpp
Client/src/item_union.cpp
Client/src/principal.cpp
Model/include/rgb.h
Model/include/union.h
Model/src/union.cpp

index f426f2773abe6abfd6643c7236bfaee3427357a3..674788ef6c81c094859335c68cc60d777707161a 100644 (file)
@@ -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
index ce0f2b5ce4dfde7e1b2f27297c1cb42c0f1ab1bf..e0a1a1caba1d5d182b647107d71f8b722b18e0fd 100644 (file)
@@ -29,39 +29,36 @@ bool ViewCodo::on_image_expose_event(GdkEventExpose *e)
 {
        Glib::RefPtr<Gdk::Colormap> 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;
 }
 
index f348945e40d1ad76a7bbafcf743eb66963ec774d..8f070a21d0590c4ed357ee45adef9715e2126086 100644 (file)
@@ -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;
 }
 
+
index d318ac4cc610a4ec79d62df66f0f8f432ac1a7a7..d09ad8a1f5bb44eb1859127cd9febfe2384d764e 100644 (file)
@@ -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;
 }
 
index abb1b0c5c55ce50216363775091005c79e07955e..536a884d16f937724e6a567cdc36c2590586ea36 100644 (file)
@@ -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<Gdk::Colormap> 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;
+}
index 08bad4ed80fa04d59b7e7e85b47eca2826fb9ab5..4bfd2ff73b2106cbbbfa83fb2dbe42ebfd82edb5 100644 (file)
@@ -29,28 +29,32 @@ ViewUnion::~ViewUnion()
 bool ViewUnion::on_image_expose_event(GdkEventExpose *e)
 {
        Glib::RefPtr<Gdk::Colormap> 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;
 }
 
+
index 845de818211325b867fd2eee0897d16dc0babf04..870c06a96d2de14b4867034c1732647c57915445 100644 (file)
@@ -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<gushort>(65535 * (r / 255.0f));
+       g = static_cast<gushort>(65535 * (g / 255.0f));
+       b = static_cast<gushort>(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;
index 0feedc26e74ba09f822e66dac5318680a0105aeb..7eebfb15e3e5c5220a71bc43157332c53e16dac2 100644 (file)
@@ -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; }
index 5069c80f956cc6d6a2b36bc423257d9031b6fcca..db6be6ab78df022fb05abe914a53c85b771f2cab 100644 (file)
@@ -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; }
index 7fe666b6930726011701c6dc9cf2cf4a55cfdd4d..65b1e7b43e412562b5af376e3b3f43727c4f5911 100644 (file)
@@ -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<PlantItem *>(who)->get_actual_flow();
+                               entrada1 = static_cast<PlantItem *>(who);
+                               flow1 = entrada1->get_actual_flow();
                                in_colors++;
-                       } else {
+                       } else if ((in_colors == 1) && (entrada1 != who)) {
                                color2  = *((RGB *)data);
                                flow2 = static_cast<PlantItem *>(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;