]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Se corrige el bug en la union (del modelo) que probablemente era el error
authorRicardo Markiewicz <gazer.arg@gmail.com>
Sun, 30 Nov 2003 22:03:25 +0000 (22:03 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Sun, 30 Nov 2003 22:03:25 +0000 (22:03 +0000)
 de visualizacion del color en la union. Queda algo en el tanque que ahora
 vere.

Client/src/item_codo.cpp
Client/src/item_exclusa.cpp
Client/src/item_pump.cpp
Client/src/item_union.cpp
Client/src/principal.cpp
Model/src/main.cpp
Model/src/simulator.cpp
Model/src/union.cpp

index e0a1a1caba1d5d182b647107d71f8b722b18e0fd..73dee4259e571ae12bdbf562f5f52d418cc08e0c 100644 (file)
@@ -27,7 +27,7 @@ ViewCodo::~ViewCodo()
 
 bool ViewCodo::on_image_expose_event(GdkEventExpose *e)
 {
-       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
        Gdk::Color blanco = Gdk::Color("white");
        colormap->alloc_color(color);
        gc->set_foreground(color);
index d09ad8a1f5bb44eb1859127cd9febfe2384d764e..4a3e7b40b43db32073cef67222bf0ff61086cd90 100644 (file)
@@ -37,7 +37,7 @@ ViewExclusa::~ViewExclusa()
 
 bool ViewExclusa::on_image_expose_event(GdkEventExpose *e)
 {
-       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
        colormap->alloc_color(color);
        gc->set_foreground(color);
        gc->set_background(color);
index 536a884d16f937724e6a567cdc36c2590586ea36..70201be0f740240e2ca9fa2562f2601ee8a037f1 100644 (file)
@@ -37,8 +37,11 @@ ViewPump::~ViewPump()
 
 bool ViewPump::on_image_expose_event(GdkEventExpose *e)
 {
-       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
-       colormap->alloc_color(color);
+       Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
+       if (!colormap->alloc_color(color, true, true)) {
+               std::cout << name << ": Error alocando color!" << std::endl;
+       }
+       
        gc->set_foreground(color);
        gc->set_background(color);
        gc->set_line_attributes(6, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER);
index 4bfd2ff73b2106cbbbfa83fb2dbe42ebfd82edb5..eee974e2aa8110c4f4c4ec5c8a114725d09901e1 100644 (file)
@@ -28,10 +28,16 @@ ViewUnion::~ViewUnion()
 
 bool ViewUnion::on_image_expose_event(GdkEventExpose *e)
 {
-       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
-       colormap->alloc_color(color);
+       Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
+       if (!colormap->alloc_color(color, false, false)) {
+               std::cout << "ERROR ALOCANDO COLOR!" << std::endl;
+       }
        gc->set_foreground(color);
        gc->set_background(color);
+       
+       if (name == "union6") {
+               std::cout << color.get_red() << " " << color.get_green() << " " << color.get_blue() << std::endl;
+       }
        int w,h;
        w = image.get_width();
        h = image.get_height();
index 870c06a96d2de14b4867034c1732647c57915445..c73f2c81088ed7b9e484bc102521a18ce2636390 100644 (file)
@@ -816,6 +816,7 @@ Gdk::Color Principal::get_rgb_from_xml(xmlNodePtr nodo)
        b = static_cast<gushort>(65535 * (b / 255.0f));
        Gdk::Color c;
        c.set_rgb(r,g,b);
+
        return c;
 }
 
index 7c7f1e327f6eb700614cb34f325c2613a0819c9e..8671daa9780011119fd8efbcc3d5ba9a3c68b54e 100644 (file)
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
                }
                i++;
                sim->simulate();
-               //std::cout << sim->get_state_as_xml() << std::endl << std::endl;
+               std::cout << sim->get_state_as_xml() << std::endl << std::endl;
        }
 
        delete sim;
index 981b546feb2f4fa32dfe18cac5a3fb609525473c..66148f296928aba5295d06ea1136ff8f7a57042f 100644 (file)
@@ -545,7 +545,7 @@ std::string Simulator::get_state_as_xml()
 
 RGB Simulator::loadRGB(xmlNodePtr nodo)
 {
-       unsigned r,g,b;
+       unsigned long r,g,b;
        while (nodo != NULL) {
                if (nodo->type == XML_ELEMENT_NODE) {
                        if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0)
@@ -557,6 +557,10 @@ RGB Simulator::loadRGB(xmlNodePtr nodo)
                }
                nodo = nodo->next;
        }
+       r = static_cast<unsigned long>(255 * (r / 65535.0f));
+       g = static_cast<unsigned long>(255 * (g / 65535.0f));
+       b = static_cast<unsigned long>(255 * (b / 65535.0f));
+
        return RGB(r,g,b);
 }
 
index 65b1e7b43e412562b5af376e3b3f43727c4f5911..450b6e630211cb341e3d6ea8cdfa74d1dbb124ec 100644 (file)
@@ -109,12 +109,9 @@ void Union::recieve_msg(int msg, IConector *who, void *data)
                                if (flow2 == 0) n--;
                                float suma = flow1+flow2;
                                if (n != 0) {
-                                       r = (int)(color1.r()*flow1/suma + color2.r()*flow2/suma)/n;
-                                       g = (int)(color1.g()*flow1/suma + color2.g()*flow2/suma)/n;
-                                       b = (int)(color1.b()*flow1/suma + color2.b()*flow2/suma)/n;
-                                       r %= 256;
-                                       g %= 256;
-                                       b %= 256;
+                                       r = (int)(color1.r()*flow1/suma + color2.r()*flow2/suma);
+                                       g = (int)(color1.g()*flow1/suma + color2.g()*flow2/suma);
+                                       b = (int)(color1.b()*flow1/suma + color2.b()*flow2/suma);
                                        set_color(RGB(r,g,b));
                                } else {
                                        set_color(RGB(0,0,0));