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) {
} 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;
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");
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) {
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;
p->set_name(name);
p->set_capacidad(capacidad);
p->set_contenido_inicial(liquido);
-
+ p->set_liquid_color(color);
return p;
}
t_line tmp_line;
tmp_line.logic_id = logic_id;
//workplace->get_logic_item(logic_id)->set_out_connected(true);
- tmp_line.store_id = workplace->get_item_id(otro);
- std::cout << otro << " " << tmp_line.logic_id << " " << tmp_line.store_id << std::endl;
- workplace->lista_lineas_in.push_back(tmp_line);
+ if (workplace->get_item_id(otro) != -1) {
+ tmp_line.store_id = workplace->get_item_id(otro);
+ std::cout << otro << " se conecta a una compuerta" << std::endl;
+ workplace->lista_lineas_in.push_back(tmp_line);
+ } else {
+ /* Como no era un item, debe ser una compuerta */
+ tmp_line.store_id = workplace->get_logic_id(otro);
+ workplace->lista_lineas_logic.push_back(tmp_line);
+ }
} else if (xmlStrcmp(nodo->name, BAD_CAST"entrada")==0) {
otro = (char *)XML_GET_CONTENT(nodo->children);
t_line tmp_line;
tmp_line.logic_id = logic_id;
- tmp_line.store_id = workplace->get_item_id(otro);
- workplace->lista_lineas_out.push_back(tmp_line);
- std::cout << otro << " " << tmp_line.logic_id << " " << tmp_line.store_id << std::endl;
+ if (workplace->get_item_id(otro) != -1) {
+ tmp_line.store_id = workplace->get_item_id(otro);
+ /* Tengo que ver si es un tanque, para setearlo correctamente */
+ if (dynamic_cast<Cistern *>(workplace->get_item(workplace->get_item_id(otro)))) {
+ std::string donde = (char *)xmlGetProp(nodo, BAD_CAST"id");
+ tmp_line.cistern_out1 = true;
+ if (donde == "inferior") {
+ tmp_line.cistern_out1 = false;
+ }
+ }
+ workplace->lista_lineas_out.push_back(tmp_line);
+ std::cout << otro << " se conecta a una compuerta" << std::endl;
+ } else {
+ /* Como no era un item, debe ser una compuerta */
+ tmp_line.store_id = workplace->get_logic_id(otro);
+ workplace->lista_lineas_logic.push_back(tmp_line);
+ }
}
}
nodo = nodo->next;