diff options
Diffstat (limited to 'draw.cpp')
-rw-r--r-- | draw.cpp | 46 |
1 files changed, 21 insertions, 25 deletions
@@ -1,6 +1,5 @@ #include "draw.h" #include "edit.h" -#include "level.h" #include "geometry.h" #include <math.h> #include <gtk/gtk.h> @@ -142,9 +141,9 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { drawGrid(cr, &rect); - for(i = 0; i < getLevel()->nRooms; i++) { - if(&getLevel()->rooms[i] != getActiveRoom()) { - polygon2path(cr, &getLevel()->rooms[i].polygon, &rect, TRUE); + for(Level::iterator room = getLevel()->begin(); room != getLevel()->end(); room++) { + if(&*room != getActiveRoom()) { + polygon2path(cr, &*room, &rect, TRUE); } } @@ -155,7 +154,7 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { cairo_stroke(cr); if(getEditMode() == EDIT_MODE_SELECTED) { - polygon2path(cr, &getActiveRoom()->polygon, &rect, TRUE); + polygon2path(cr, getActiveRoom(), &rect, TRUE); cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.2); cairo_fill_preserve(cr); @@ -182,22 +181,22 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { if(getHoveredRoom() != NULL && getHoveredRoom() != getActiveRoom() && (getEditMode() == EDIT_MODE_VIEW || getEditMode() == EDIT_MODE_SELECTED)) { - polygon2path(cr, &getHoveredRoom()->polygon, &rect, TRUE); + polygon2path(cr, getHoveredRoom(), &rect, TRUE); cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); cairo_stroke(cr); } else if(getEditMode() == EDIT_MODE_ADD) { - polygon2path(cr, &getActiveRoom()->polygon, NULL, FALSE); + polygon2path(cr, getActiveRoom(), NULL, FALSE); - if(isPolygonOk(&getActiveRoom()->polygon)) + if(isPolygonOk(getActiveRoom())) cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.2); else cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.2); cairo_fill_preserve(cr); - if(!getActiveRoom()->polygon.empty() && getHoveredVertex()) { + if(!getActiveRoom()->empty() && getHoveredVertex()) { vertexOk = isVertexOk(getHoveredVertex()); if(vertexOk) @@ -210,10 +209,10 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); cairo_stroke(cr); - if(!getActiveRoom()->polygon.empty() && getHoveredVertex() && !vertexOk) { + if(!getActiveRoom()->empty() && getHoveredVertex() && !vertexOk) { cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.7); - cairo_move_to(cr, getActiveRoom()->polygon.back().getX(), getActiveRoom()->polygon.back().getY()); + cairo_move_to(cr, getActiveRoom()->back().getX(), getActiveRoom()->back().getY()); cairo_line_to(cr, getHoveredVertex()->getX(), getHoveredVertex()->getY()); cairo_stroke(cr); @@ -246,16 +245,14 @@ void viewToImage(Vertex *v) { } double getImageWidth() { - const LEVEL *level = getLevel(); double min = 0.0, max = 0.0; - int i; - if(level) { - for(i = 0; i < level->nRooms; i++) { - for(Polygon::iterator it = level->rooms[i].polygon.begin(); it != level->rooms[i].polygon.end(); it++) { - min = MIN(min, it->getX()); - max = MAX(max, it->getX()); + if(getLevel()) { + for(Level::iterator room = getLevel()->begin(); room != getLevel()->end(); room++) { + for(Room::iterator v = room->begin(); v != room->end(); v++) { + min = MIN(min, v->getX()); + max = MAX(max, v->getX()); } } } @@ -264,15 +261,14 @@ double getImageWidth() { } double getImageHeight() { - const LEVEL *level = getLevel(); double min = 0.0, max = 0.0; - int i; - if(level) { - for(i = 0; i < level->nRooms; i++) { - for(Polygon::iterator it = level->rooms[i].polygon.begin(); it != level->rooms[i].polygon.end(); it++) { - min = MIN(min, it->getY()); - max = MAX(max, it->getY()); + + if(getLevel()) { + for(Level::iterator room = getLevel()->begin(); room != getLevel()->end(); room++) { + for(Room::iterator v = room->begin(); v != room->end(); v++) { + min = MIN(min, v->getY()); + max = MAX(max, v->getY()); } } } |