From 85e58bd658d3b572ed598e0460965d7827f4e901 Mon Sep 17 00:00:00 2001 From: neoraider Date: Tue, 15 Apr 2008 01:04:02 +0000 Subject: zoomedit: * Connected TopView to RenderArea --- src/Data/Room.cpp | 62 ++++++++++++++++++++++++++++++++++++++------------- src/Data/Room.h | 12 ++++++++++ src/Data/Triangle.cpp | 2 +- 3 files changed, 60 insertions(+), 16 deletions(-) (limited to 'src/Data') 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(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(*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(*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 triangles; xmlpp::Element *roomNode; + std::list 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& 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 #include namespace ZoomEdit { -- cgit v1.2.3