X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/c0e0cf58ce033421d125afb813636f102456592c..ed2cb04e907c90998221e00fcac1ded840ce693c:/Model/src/simulator.cpp diff --git a/Model/src/simulator.cpp b/Model/src/simulator.cpp index 3aeacd6..2fe6f6e 100644 --- a/Model/src/simulator.cpp +++ b/Model/src/simulator.cpp @@ -78,6 +78,7 @@ void Simulator::add_conduct(const std::string &name, float flujo) { Conduct *p = new Conduct(name); // FIXME no va!! + std::cout << flujo << std::endl; p->set_max_flow(flujo); conduct_lst.push_back(p); items.push_back(p); @@ -200,8 +201,7 @@ void Simulator::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 = RGB(); + color = loadRGB(nodo->children); } } nodo = nodo->next; @@ -269,7 +269,7 @@ void Simulator::loadTank(xmlNodePtr nodo) std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre"); int orientacion=0, x, y; float capacidad, inicial; - RGB color; // TODO + RGB color; nodo = nodo->children; while (nodo != NULL) { @@ -284,6 +284,8 @@ 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) { + color = loadRGB(nodo->children); } } nodo = nodo->next; @@ -442,3 +444,20 @@ std::string Simulator::get_state_as_xml() return out.str();; } +RGB Simulator::loadRGB(xmlNodePtr nodo) +{ + unsigned 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; + } + return RGB(r,g,b); +} +