X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/cc77948bedbd851e009ad3b8a421dea93c3ceeff..fc545e363e5352e2a672b0fa6a39facf6dc7d36b:/Constructor/src/constructor.cpp diff --git a/Constructor/src/constructor.cpp b/Constructor/src/constructor.cpp index 8a36809..e352f4a 100644 --- a/Constructor/src/constructor.cpp +++ b/Constructor/src/constructor.cpp @@ -769,6 +769,7 @@ Pump *Constructor::loadBomba(xmlNodePtr nodo) std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id"); int orientacion=0, x, y; float flujo; + Gdk::Color color; nodo = nodo->children; while (nodo != NULL) { @@ -782,7 +783,7 @@ Pump *Constructor::loadBomba(xmlNodePtr nodo) } else if (xmlStrcmp(nodo->name, BAD_CAST"entrega") == 0) { flujo = atof( (char *)XML_GET_CONTENT(nodo->children) ); } else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) { - // FIXME ! + color = loadColor(nodo->children); } } nodo = nodo->next; @@ -793,10 +794,31 @@ Pump *Constructor::loadBomba(xmlNodePtr nodo) p->set_entrega(flujo); p->set_id( atoi(id.c_str()) ); p->set_name(name); + p->set_liquid_color(color); return p; } +Gdk::Color Constructor::loadColor(xmlNodePtr nodo) +{ + gushort r,g,b; + while (nodo != NULL) { + if (nodo->type == XML_ELEMENT_NODE) { + if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0) + r = atoi( (char *)XML_GET_CONTENT(nodo->children) ); + if (xmlStrcmp(nodo->name, BAD_CAST"verde")==0) + g = atoi( (char *)XML_GET_CONTENT(nodo->children) ); + if (xmlStrcmp(nodo->name, BAD_CAST"azul")==0) + b = atoi( (char *)XML_GET_CONTENT(nodo->children) ); + } + nodo = nodo->next; + } + Gdk::Color c; + c.set_rgb(r,g,b); + std::cout << r << " " << g << " " << b << std::endl; + return c; +} + Conduct *Constructor::loadConduct(xmlNodePtr nodo) { std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre"); @@ -868,6 +890,7 @@ Cistern *Constructor::loadTank(xmlNodePtr nodo) std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id"); int orientacion=0, x, y; float liquido,capacidad; + Gdk::Color color; nodo = nodo->children; while (nodo != NULL) { @@ -882,6 +905,8 @@ Cistern *Constructor::loadTank(xmlNodePtr nodo) capacidad = atof ((char *)XML_GET_CONTENT(nodo->children) ); } else if (xmlStrcmp(nodo->name, BAD_CAST"inicial") == 0) { liquido = atof ((char *)XML_GET_CONTENT(nodo->children) ); + } else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) { + color = loadColor(nodo->children); } } nodo = nodo->next; @@ -893,7 +918,7 @@ Cistern *Constructor::loadTank(xmlNodePtr nodo) p->set_name(name); p->set_capacidad(capacidad); p->set_contenido_inicial(liquido); - + p->set_liquid_color(color); return p; }