diff options
Diffstat (limited to 'draw.cpp')
-rw-r--r-- | draw.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -85,7 +85,7 @@ static void polygon2path(cairo_t *cr, const POLYGON *polygon, const RECTANGLE *r cairo_new_sub_path(cr); for(i = 0; i < polygon2.nVertices; i++) { - cairo_line_to(cr, polygon2.vertices[i].x, polygon2.vertices[i].y); + cairo_line_to(cr, polygon2.vertices[i].getX(), polygon2.vertices[i].getY()); } if(close) @@ -97,7 +97,7 @@ static void polygon2path(cairo_t *cr, const POLYGON *polygon, const RECTANGLE *r gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { cairo_t *cr; - VERTEX v1 = {-1, -1}, v2 = {widget->allocation.width+1, widget->allocation.height+1}; + Vertex v1(-1, -1), v2(widget->allocation.width+1, widget->allocation.height+1); RECTANGLE rect; gboolean vertexOk; static GdkPixmap *pixmap = NULL; @@ -112,10 +112,10 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { viewToImage(&v1); viewToImage(&v2); - rect.x = v1.x; - rect.y = v1.y; - rect.width = v2.x-v1.x; - rect.height = v2.y-v1.y; + rect.x = v1.getX(); + rect.y = v1.getY(); + rect.width = v2.getX()-v1.getX(); + rect.height = v2.getY()-v1.getY(); if(pixmap == NULL || fabs(lastImageWidth - getImageWidth()) >= 0.000001 || fabs(lastImageHeight - getImageHeight()) >= 0.000001 || lastWidth != widget->allocation.width || lastHeight != widget->allocation.height || lastEditMode != getEditMode() || repaint) @@ -205,7 +205,7 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { vertexOk = isVertexOk(getHoveredVertex()); if(vertexOk) - cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y); + cairo_line_to(cr, getHoveredVertex()->getX(), getHoveredVertex()->getY()); } cairo_set_line_width(cr, 2.0/scale); @@ -218,8 +218,8 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.7); i = getActiveRoom()->polygon.nVertices - 1; - cairo_move_to(cr, getActiveRoom()->polygon.vertices[i].x, getActiveRoom()->polygon.vertices[i].y); - cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y); + cairo_move_to(cr, getActiveRoom()->polygon.vertices[i].getX(), getActiveRoom()->polygon.vertices[i].getY()); + cairo_line_to(cr, getHoveredVertex()->getX(), getHoveredVertex()->getY()); cairo_stroke(cr); } @@ -240,14 +240,14 @@ void setScale(double s) { repaint = TRUE; } -void imageToView(VERTEX *v) { - v->x = v->x*scale+getImageWidth()/2-xTranslate; - v->y = v->y*scale+getImageHeight()/2-yTranslate; +void imageToView(Vertex *v) { + v->setX(v->getX()*scale+getImageWidth()/2-xTranslate); + v->setY(v->getY()*scale+getImageHeight()/2-yTranslate); } -void viewToImage(VERTEX *v) { - v->x = (v->x-getImageWidth()/2+xTranslate)/scale; - v->y = (v->y-getImageHeight()/2+yTranslate)/scale; +void viewToImage(Vertex *v) { + v->setX((v->getX()-getImageWidth()/2+xTranslate)/scale); + v->setY((v->getY()-getImageHeight()/2+yTranslate)/scale); } double getImageWidth() { @@ -258,8 +258,8 @@ double getImageWidth() { if(level) { for(i = 0; i < level->nRooms; i++) { for(j = 0; j < level->rooms[i].polygon.nVertices; j++) { - min = MIN(min, level->rooms[i].polygon.vertices[j].x); - max = MAX(max, level->rooms[i].polygon.vertices[j].x); + min = MIN(min, level->rooms[i].polygon.vertices[j].getX()); + max = MAX(max, level->rooms[i].polygon.vertices[j].getX()); } } } @@ -275,8 +275,8 @@ double getImageHeight() { if(level) { for(i = 0; i < level->nRooms; i++) { for(j = 0; j < level->rooms[i].polygon.nVertices; j++) { - min = MIN(min, level->rooms[i].polygon.vertices[j].y); - max = MAX(max, level->rooms[i].polygon.vertices[j].y); + min = MIN(min, level->rooms[i].polygon.vertices[j].getY()); + max = MAX(max, level->rooms[i].polygon.vertices[j].getY()); } } } |