summaryrefslogtreecommitdiffstats
path: root/src/View
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2008-04-15 22:43:02 +0200
committerneoraider <devnull@localhost>2008-04-15 22:43:02 +0200
commitcfd608527e167877d623bf5b9682b5c4b6130df9 (patch)
treed1f72729554e0f647d8028f006fa656f9af085c0 /src/View
parentbb09e9e703caceab0c5c5774509fb7167ead8d49 (diff)
downloadzoomedit-cfd608527e167877d623bf5b9682b5c4b6130df9.tar
zoomedit-cfd608527e167877d623bf5b9682b5c4b6130df9.zip
zoomedit:
* Calculate model dimensions
Diffstat (limited to 'src/View')
-rw-r--r--src/View/TopView.cpp42
-rw-r--r--src/View/TopView.h3
-rw-r--r--src/View/View.h1
3 files changed, 45 insertions, 1 deletions
diff --git a/src/View/TopView.cpp b/src/View/TopView.cpp
index 8ca047f..08074c9 100644
--- a/src/View/TopView.cpp
+++ b/src/View/TopView.cpp
@@ -154,5 +154,47 @@ void TopView::render(Gui::RenderArea *renderArea) {
renderRoom(*room);
}
+void TopView::getBounds(float *minX, float *maxX, float *minY, float *maxY) {
+ if(!level)
+ return;
+
+ if(minX)
+ *minX = 0;
+ if(maxX)
+ *maxX = 0;
+ if(minY)
+ *minY = 0;
+ if(maxY)
+ *maxY = 0;
+
+ const std::list<Data::Room*> &rooms = level->getRooms();
+
+ for(std::list<Data::Room*>::const_iterator room = rooms.begin(); room != rooms.end(); ++room) {
+ const std::list<Data::Triangle*> &triangles = (*room)->getFloorTriangles();
+
+ for(std::list<Data::Triangle*>::const_iterator t = triangles.begin(); t != triangles.end(); ++t) {
+ const Data::Vertex &v1 = (*t)->getVertex(0), &v2 = (*t)->getVertex(1), &v3 = (*t)->getVertex(2);
+
+ if(minX)
+ *minX = std::min(std::min(*minX, v1.getX()), std::min(v2.getX(), v3.getX()));
+ if(maxX)
+ *maxX = std::max(std::max(*maxX, v1.getX()), std::max(v2.getX(), v3.getX()));
+ if(minY)
+ *minY = std::min(std::min(*minY, v1.getZ()), std::min(v2.getZ(), v3.getZ()));
+ if(maxY)
+ *maxY = std::max(std::max(*maxY, v1.getZ()), std::max(v2.getZ(), v3.getZ()));
+ }
+ }
+
+ if(minX)
+ *minX -= 5;
+ if(maxX)
+ *maxX += 5;
+ if(minY)
+ *minY -= 5;
+ if(maxY)
+ *maxY += 5;
+}
+
}
}
diff --git a/src/View/TopView.h b/src/View/TopView.h
index bbb9394..0996ad3 100644
--- a/src/View/TopView.h
+++ b/src/View/TopView.h
@@ -48,7 +48,6 @@ class TopView : public View {
bool edgeLess(const Edge &e1, const Edge &e2);
void drawGrid(Gui::RenderArea *renderArea);
-
void renderRoom(Data::Room *room);
public:
@@ -58,6 +57,8 @@ class TopView : public View {
void setLevel(Data::Level *level0) {level = level0;}
virtual void render(Gui::RenderArea *renderArea);
+
+ virtual void getBounds(float *minX, float *maxX, float *minY, float *maxY);
};
}
diff --git a/src/View/View.h b/src/View/View.h
index cdf27aa..bb52032 100644
--- a/src/View/View.h
+++ b/src/View/View.h
@@ -33,6 +33,7 @@ class View {
virtual ~View() {}
virtual void render(Gui::RenderArea *renderArea) = 0;
+ virtual void getBounds(float *minX, float *maxX, float *minY, float *maxY) = 0;
};
}