+ }
+ std::cout<<"check_connection logic"<<std::endl;
+ std::list<CItem *>::iterator j = lista_logic_Items.begin();
+ while ( j != lista_logic_Items.end() ) {
+ if ( !(*j)->check_connection() ) {
+ name = (*j)->get_name();
+ return false;
+ }
+ j++;
+ }
+ return true;
+}
+
+
+//Los siguientes metodos son utilizados para levantar cada item desde el XML
+
+Not *Constructor::loadNot(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;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Not *p = new Not(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+
+ return p;
+}
+
+Or *Constructor::loadOr(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;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Or *p = new Or(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+
+ return p;
+}
+
+And *Constructor::loadAnd(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 flujo;
+ xmlNodePtr inicial = nodo;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ And *p = new And(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+ return p;
+}
+
+Pump *Constructor::loadBomba(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 flujo;
+ Gdk::Color color;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } 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) {
+ color = loadColor(nodo->children);
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Pump *p = new Pump(orientacion);
+ p->set_position(x,y);
+ 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 flujo;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"caudal") == 0) {
+ flujo = atof( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Conduct *p = new Conduct(orientacion);
+ p->set_position(x,y);
+ p->set_caudal(flujo);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+
+ return p;
+}
+
+Exclusa *Constructor::loadExclusa(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id");
+ std::string estado;
+ int orientacion=0, x, y;
+ float flujo;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"estado") == 0) {
+ estado = (char *)XML_GET_CONTENT(nodo->children);
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Exclusa *p = new Exclusa(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+ p->set_estado( estado == "1" );
+
+ return p;
+}
+
+Cistern *Constructor::loadTank(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) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"capacidad") == 0) {
+ 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;
+ }
+
+ Cistern *p = new Cistern(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+ p->set_capacidad(capacidad);
+ p->set_contenido_inicial(liquido);
+ p->set_liquid_color(color);
+ return p;
+}
+
+Union *Constructor::loadUnion(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id");
+ std::string tipo;
+ int orientacion=0, x, y;
+ float caudal;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"caudal") == 0) {
+ caudal = atof ((char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"tipo") == 0) {
+ tipo = (char *)XML_GET_CONTENT(nodo->children);
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Union *p = new Union(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+ p->set_caudal(caudal);
+ p->is_union = (tipo == "union");
+
+ return p;
+}
+
+Drain *Constructor::loadDrain(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;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Drain *p = new Drain(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+
+ return p;
+}
+
+Splitter *Constructor::loadCodo(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 caudal;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"caudal") == 0) {
+ caudal = atof( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ Splitter *p = new Splitter(orientacion);
+ p->set_position(x,y);
+ p->set_id( atoi(id.c_str()) );
+ p->set_name(name);
+ p->set_caudal(caudal);
+
+ return p;
+}
+
+void Constructor::create_lines(xmlNodePtr nodo)
+{
+ std::string name;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"and")==0) {
+ name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ std::cout << name << std::endl;
+ create_line(nodo->children, workplace->get_logic_id(name));
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"not")==0) {
+ name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ std::cout << name << std::endl;
+ create_line(nodo->children, workplace->get_logic_id(name));
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"or")==0) {
+ name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ std::cout << name << std::endl;
+ create_line(nodo->children, workplace->get_logic_id(name));
+ }
+ }
+ nodo = nodo->next;
+ }
+}
+
+//Levanta las lineas desde el archvo XML
+void Constructor::create_line(xmlNodePtr nodo, int logic_id)
+{
+ std::string otro;
+ std::cout << "Buscando lineas ..." << std::endl;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"salida")==0) {
+ otro = (char *)XML_GET_CONTENT(nodo->children);
+ 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);
+ } 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;
+ }
+ }
+ nodo = nodo->next;