#include <iostream>
#include <sstream>
#include <string>
+#include "item_codo.h"
+#include "item_conduct.h"
+#include "item_exclusa.h"
+#include "item_tank.h"
+#include "item_pump.h"
+#include "item_union.h"
Principal::Principal(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg):Gtk::Window(co),refXml(rg)
{
dlg->show();*/
}
+bool Principal::on_item_clicked(GdkEventButton *e, ViewItem *i)
+{
+ txt_view->get_buffer()->insert_at_cursor("Item : ");
+ txt_view->get_buffer()->insert_at_cursor(i->get_name());
+ txt_view->get_buffer()->insert_at_cursor("\n");
+}
+
void Principal::on_conexion_ok()
{
txt_view->get_buffer()->insert_at_cursor("El server dice que ta' todo ok!\n");
xmlDocPtr document;
document = xmlParseFile("test.xml");
if (document == NULL) {
- printf("Error al parsear test.xml\n");
return;
}
items = nodo->children;
while (items != NULL) {
if (items->type == XML_ELEMENT_NODE) {
- if (strcmp((char *)items->name, "bomba")==0) {
+ if (xmlStrcmp(items->name, BAD_CAST"bomba")==0) {
loadBomba(items);
- } else if (strcmp((char *)items->name, "codo")==0) {
+ } else if (xmlStrcmp(items->name, BAD_CAST"codo")==0) {
loadCodo(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"tubo")==0) {
+ loadConduct(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"exclusa")==0) {
+ loadExclusa(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"tanque")==0) {
+ loadTank(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"empalme")==0) {
+ loadUnion(items);
}
+
+
+
}
items = items->next;
}
}
// listo, ya recolecte todos los datos, ahora creo el objeto!
- Bomba *b = Gtk::manage( new Bomba(name, orientacion) );
+ ViewPump *b = Gtk::manage( new ViewPump(name, orientacion) );
+ b->signal_button_press_event().connect(SigC::bind( SigC::slot(*this, &Principal::on_item_clicked), b) );
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
}
void Principal::loadCodo(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ 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;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ ViewItem *b = Gtk::manage( new ViewCodo(name, orientacion) );
+ b->signal_button_press_event().connect(SigC::bind( SigC::slot(*this, &Principal::on_item_clicked), b) );
+ b->set_position(x,y);
+ work_place->put(*b, x, y);
+ b->show();
+ // los agrego al hash
+ //mapItems.insert(name, b);
+}
+
+void Principal::loadConduct(xmlNodePtr nodo)
{
Glib::ustring name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
int orientacion=0, x, y;
}
// listo, ya recolecte todos los datos, ahora creo el objeto!
- Codo *b = Gtk::manage( new Codo(name, orientacion) );
+ ViewConduct *b = Gtk::manage( new ViewConduct(name, orientacion) );
+ b->signal_button_press_event().connect(SigC::bind( SigC::slot(*this, &Principal::on_item_clicked), b) );
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
}
+void Principal::loadExclusa(xmlNodePtr nodo)
+{
+ Glib::ustring name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ 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;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ ViewExclusa *b = Gtk::manage( new ViewExclusa(name, orientacion) );
+ b->signal_button_press_event().connect(SigC::bind( SigC::slot(*this, &Principal::on_item_clicked), b) );
+ b->set_position(x,y);
+ work_place->put(*b, x, y);
+ b->show();
+}
+
+void Principal::loadTank(xmlNodePtr nodo)
+{
+ Glib::ustring name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ 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;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ ViewTank *b = Gtk::manage( new ViewTank(name, orientacion) );
+ b->signal_button_press_event().connect(SigC::bind( SigC::slot(*this, &Principal::on_item_clicked), b) );
+ b->set_position(x,y);
+ work_place->put(*b, x, y);
+ b->show();
+}
+
+void Principal::loadUnion(xmlNodePtr nodo)
+{
+ Glib::ustring name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ 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;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ ViewUnion *b = Gtk::manage( new ViewUnion(name, orientacion) );
+ b->signal_button_release_event().connect(SigC::bind( SigC::slot(*this, &Principal::on_item_clicked), b) );
+ b->set_position(x,y);
+ work_place->put(*b, x, y);
+ b->show();
+}