]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Model/src/simulator.cpp
* Los colores ya estan completamente arreglados
[z.facultad/75.42/plaqui.git] / Model / src / simulator.cpp
index 9e84e8a257559f093b83e56fbd43000bcd2ae77f..f5c011452c1c1a8e66854b8baee9b3a3255dfbcc 100644 (file)
@@ -158,8 +158,10 @@ void Simulator::simulate()
                (*i1)->update();
 
        std::list<PlantItem *>::iterator i2;
-       for(i2=items.begin(); i2!=items.end(); i2++) 
+       for(i2=items.begin(); i2!=items.end(); i2++) {
                (*i2)->update();
+               (*i2)->update_color();
+       }
        
        for(i2=items.begin(); i2!=items.end(); i2++) 
                (*i2)->simulate();
@@ -312,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);
                        }
                }
@@ -512,15 +514,11 @@ void Simulator::do_connections(xmlNodePtr nodo)
                                // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar
                                to_connect = find((char *)XML_GET_CONTENT(conector3->children));
                                // y lo conecto
-                               if (!current_item->connect(to_connect, IConector::IN)) {
-                                       std::cout << s << " Error al conectar " << std::endl;
-                               }
+                               current_item->connect(to_connect, IConector::IN);
                        } else if (xmlStrcmp(conector3->name, BAD_CAST"salida") == 0) {
                                // Era a salida, es casi lo mismo que arriba 
                                to_connect = find((char *)XML_GET_CONTENT(conector3->children));
-                               if (!current_item->connect(to_connect, IConector::OUT)) {
-                                       std::cout << s << " Error al conectar " << std::endl;
-                               }
+                               current_item->connect(to_connect, IConector::OUT);
                        }
                }
                nodo = nodo->next;
@@ -547,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)
@@ -559,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);
 }