summaryrefslogtreecommitdiffstats
path: root/src/Data
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Room.cpp62
-rw-r--r--src/Data/Room.h12
-rw-r--r--src/Data/Triangle.cpp2
3 files changed, 60 insertions, 16 deletions
diff --git a/src/Data/Room.cpp b/src/Data/Room.cpp
index acc79be..b1d7473 100644
--- a/src/Data/Room.cpp
+++ b/src/Data/Room.cpp
@@ -23,8 +23,36 @@
namespace ZoomEdit {
namespace Data {
+void Room::populateTriangle(xmlpp::Element *tNode) {
+ xmlpp::Element *node = tNode->add_child("vertex");
+ node->set_attribute("x", "0.0");
+ node->set_attribute("y", "0.0");
+ node->set_attribute("z", "0.0");
+
+ node = tNode->add_child("vertex");
+ node->set_attribute("x", "0.0");
+ node->set_attribute("y", "0.0");
+ node->set_attribute("z", "0.0");
+
+ node = tNode->add_child("vertex");
+ node->set_attribute("x", "0.0");
+ node->set_attribute("y", "0.0");
+ node->set_attribute("z", "0.0");
+}
+
Room::Room(xmlpp::Element *node) : roomNode(node) {
- xmlpp::Node::NodeList triangleList = node->get_children("triangle");
+ floorNode = dynamic_cast<xmlpp::Element*>(node->get_children("floor").front());
+
+ xmlpp::Node::NodeList triangleList = floorNode->get_children("triangle");
+
+ for(xmlpp::Node::NodeList::iterator t = triangleList.begin(); t != triangleList.end(); ++t) {
+ xmlpp::Element *tNode = dynamic_cast<xmlpp::Element*>(*t);
+
+ if(tNode)
+ floor.push_back(new Triangle(tNode));
+ }
+
+ triangleList = node->get_children("triangle");
for(xmlpp::Node::NodeList::iterator t = triangleList.begin(); t != triangleList.end(); ++t) {
xmlpp::Element *tNode = dynamic_cast<xmlpp::Element*>(*t);
@@ -44,20 +72,7 @@ Room::~Room() {
Triangle* Room::addTriangle() {
xmlpp::Element *tNode = roomNode->add_child("triangle");
- xmlpp::Element *node = tNode->add_child("vertex");
- node->set_attribute("x", "0.0");
- node->set_attribute("y", "0.0");
- node->set_attribute("z", "0.0");
-
- node = tNode->add_child("vertex");
- node->set_attribute("x", "0.0");
- node->set_attribute("y", "0.0");
- node->set_attribute("z", "0.0");
-
- node = tNode->add_child("vertex");
- node->set_attribute("x", "0.0");
- node->set_attribute("y", "0.0");
- node->set_attribute("z", "0.0");
+ populateTriangle(tNode);
Triangle *t = new Triangle(tNode);
triangles.push_back(t);
@@ -71,5 +86,22 @@ void Room::removeTriangle(Triangle *t) {
delete t;
}
+Triangle* Room::addFloorTriangle() {
+ xmlpp::Element *tNode = floorNode->add_child("triangle");
+
+ populateTriangle(tNode);
+
+ Triangle *t = new Triangle(tNode);
+ floor.push_back(t);
+
+ return t;
+}
+
+void Room::removeFloorTriangle(Triangle *t) {
+ floorNode->remove_child(t->getNode());
+ floor.remove(t);
+ delete t;
+}
+
}
}
diff --git a/src/Data/Room.h b/src/Data/Room.h
index e290e36..b23923b 100644
--- a/src/Data/Room.h
+++ b/src/Data/Room.h
@@ -33,8 +33,13 @@ class Room {
std::list<Triangle*> triangles;
xmlpp::Element *roomNode;
+ std::list<Triangle*> floor;
+ xmlpp::Element *floorNode;
+
Glib::ustring id;
+ void populateTriangle(xmlpp::Element *tNode);
+
// Prevent shallow copy
Room(const Room &o);
Room& operator=(const Room &o);
@@ -50,6 +55,13 @@ class Room {
Triangle* addTriangle();
void removeTriangle(Triangle *t);
+ const std::list<Triangle*>& getFloorTriangles() const {
+ return floor;
+ }
+
+ Triangle* addFloorTriangle();
+ void removeFloorTriangle(Triangle *t);
+
const Glib::ustring& getId() const {
return id;
}
diff --git a/src/Data/Triangle.cpp b/src/Data/Triangle.cpp
index 096081b..b3f76a7 100644
--- a/src/Data/Triangle.cpp
+++ b/src/Data/Triangle.cpp
@@ -18,7 +18,7 @@
*/
#include "Triangle.h"
-#include "../Util/Xml.h"
+#include <Util/Xml.h>
#include <cstdlib>
namespace ZoomEdit {