static void _do_bezier (WpgImportRenderer *ren, WPGPoint *pts, int iNum) { int num_points = (iNum + 2) / 3; int i; int ofs = ren->Box.Height; BezPoint *bps; g_return_if_fail (num_points > 1); bps = g_alloca (num_points * sizeof(BezPoint)); bps[0].type = BEZ_MOVE_TO; bps[0].p1.x = pts[0].x / WPU_PER_DCM; bps[0].p1.y = (ofs - pts[0].y) / WPU_PER_DCM; for (i = 1; i < num_points; ++i) { bps[i].type = BEZ_CURVE_TO; /* although declared as unsigned (WORD) these values have to be treaded * as signed, because they can move in both directions. */ bps[i].p1.x = (gint16)pts[i*3-2].x / WPU_PER_DCM; bps[i].p1.y = (ofs - (gint16)pts[i*3-2].y) / WPU_PER_DCM; bps[i].p2.x = (gint16)pts[i*3-1].x / WPU_PER_DCM; bps[i].p2.y = (ofs - (gint16)pts[i*3-1].y) / WPU_PER_DCM; bps[i].p3.x = (gint16)pts[i*3 ].x / WPU_PER_DCM; bps[i].p3.y = (ofs - (gint16)pts[i*3 ].y) / WPU_PER_DCM; } /* XXX: should we fold this calls into one? What's closing a WPG PolyCurve? */ if (ren->LineAttr.Type != WPG_LA_NONE) DIA_RENDERER_GET_CLASS(ren)->draw_bezier (DIA_RENDERER(ren), bps, num_points, &ren->stroke); if (ren->FillAttr.Type != WPG_FA_HOLLOW) DIA_RENDERER_GET_CLASS(ren)->draw_beziergon (DIA_RENDERER(ren), bps, num_points, &ren->fill, NULL); }
static void _do_ellipse (WpgImportRenderer *ren, WPGEllipse* pEll) { int h = ren->Box.Height; Point center; center.x = pEll->x / WPU_PER_DCM; center.y = (h - pEll->y) / WPU_PER_DCM; if (fabs(pEll->EndAngle - pEll->StartAngle) < 360) { /* WPG arcs are counter-clockwise so ensure that end is bigger than start */ real arcEnd = pEll->EndAngle; if (arcEnd < pEll->StartAngle) arcEnd += 360; if (ren->LineAttr.Type != WPG_LA_NONE) DIA_RENDERER_GET_CLASS(ren)->draw_arc (DIA_RENDERER(ren), ¢er, 2 * pEll->rx / WPU_PER_DCM, 2 * pEll->ry / WPU_PER_DCM, pEll->StartAngle, arcEnd, &ren->stroke); if (ren->FillAttr.Type != WPG_FA_HOLLOW) DIA_RENDERER_GET_CLASS(ren)->fill_arc (DIA_RENDERER(ren), ¢er, 2 * pEll->rx / WPU_PER_DCM, 2 * pEll->ry / WPU_PER_DCM, pEll->StartAngle, arcEnd, &ren->fill); } else { DIA_RENDERER_GET_CLASS(ren)->draw_ellipse (DIA_RENDERER(ren), ¢er, 2 * pEll->rx / WPU_PER_DCM, 2 * pEll->ry / WPU_PER_DCM, (ren->FillAttr.Type != WPG_FA_HOLLOW) ? &ren->fill : NULL, (ren->LineAttr.Type != WPG_LA_NONE) ? &ren->stroke : NULL); } }
void handle_draw(Handle *handle, DDisplay *ddisp) { gboolean some_selected; int x,y; DiaRenderer *renderer = ddisp->renderer; DiaInteractiveRendererInterface *irenderer = DIA_GET_INTERACTIVE_RENDERER_INTERFACE (ddisp->renderer); const Color *color; ddisplay_transform_coords(ddisp, handle->pos.x, handle->pos.y, &x, &y); /* change handle color to reflect different behaviour for multiple selected */ /* this code relies on the fact that only selected objects get their handles drawn */ some_selected = g_list_length (ddisp->diagram->data->selected) > 1; if (handle->connected_to != NULL) { color = &handle_color_connected[handle->type + (some_selected ? NUM_HANDLE_TYPES : 0)]; } else { color = &handle_color[handle->type + (some_selected ? NUM_HANDLE_TYPES : 0)]; } DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, 0.0); DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID); DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); DIA_RENDERER_GET_CLASS(renderer)->set_fillstyle(renderer, FILLSTYLE_SOLID); irenderer->fill_pixel_rect(renderer, x - HANDLE_SIZE/2 + 1, y - HANDLE_SIZE/2 + 1, HANDLE_SIZE-2, HANDLE_SIZE-2, /* it does not change the color, but does not reflect taht in the signature */ (Color *)color); irenderer->draw_pixel_rect(renderer, x - HANDLE_SIZE/2, y - HANDLE_SIZE/2, HANDLE_SIZE-1, HANDLE_SIZE-1, &color_black); if (handle->connect_type != HANDLE_NONCONNECTABLE) { irenderer->draw_pixel_line (renderer, x - HANDLE_SIZE/2, y - HANDLE_SIZE/2, x + HANDLE_SIZE/2, y + HANDLE_SIZE/2, &color_black); irenderer->draw_pixel_line (renderer, x - HANDLE_SIZE/2, y + HANDLE_SIZE/2, x + HANDLE_SIZE/2, y - HANDLE_SIZE/2, &color_black); } }
void pagebreak_draw(DDisplay *ddisp, Rectangle *update) { DiaRenderer *renderer = ddisp->renderer; DiaInteractiveRendererInterface *irenderer; int width = dia_renderer_get_width_pixels(ddisp->renderer); int height = dia_renderer_get_height_pixels(ddisp->renderer); irenderer = DIA_GET_INTERACTIVE_RENDERER_INTERFACE (renderer); if (prefs.pagebreak.visible) { Diagram *dia = ddisp->diagram; real origx = 0, origy = 0, pos; real pwidth = dia->data->paper.width; real pheight = dia->data->paper.height; int x,y; DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, 0.0); if (prefs.pagebreak.solid) DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID, 0.0); else DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_DOTTED, ddisplay_untransform_length(ddisp, 31)); if (dia->data->paper.fitto) { origx = dia->data->extents.left; origy = dia->data->extents.top; } /* vertical lines ... */ pos = origx + ceil((update->left - origx) / pwidth) * pwidth; while (pos <= update->right) { ddisplay_transform_coords(ddisp, pos,0,&x,&y); irenderer->draw_pixel_line(renderer, x, 0, x, height, &dia->pagebreak_color); pos += pwidth; } /* Horizontal lines: */ pos = origy + ceil((update->top - origy) / pheight) * pheight; while (pos <= update->bottom) { ddisplay_transform_coords(ddisp, 0,pos,&x,&y); irenderer->draw_pixel_line(renderer, 0, y, width, y, &dia->pagebreak_color); pos += pheight; } } }
static void grid_draw_horizontal_lines(DDisplay *ddisp, Rectangle *update, real length) { int x, y; real pos; int height, width; guint major_lines = ddisp->diagram->grid.major_lines; DiaRenderer *renderer = ddisp->renderer; DiaInteractiveRendererInterface *irenderer; int major_count = 0; irenderer = DIA_GET_INTERACTIVE_RENDERER_INTERFACE (renderer); pos = ceil( update->top / length ) * length; ddisplay_transform_coords(ddisp, update->left, pos, &x, &y); ddisplay_transform_coords(ddisp, update->right, update->bottom, &width, &height); /* Explanatory note from Lawrence Withers ([email protected]): Think about it in terms of the maths and the modulo arithmetic; we have a number P such that P < 0, and we want to find a number Q such that Q >= 0, but (P % major_count) == (Q % major_count). To do this, we say Q = P - (P * major_count), which is guaranteed to give a correct answer if major_count > 0 (since the addition of anf multiple of major_count won't alter the modulo). */ if (major_lines) { major_count = ROUND (pos/length); if(major_count < 0) major_count -= major_lines * major_count; major_count %= major_lines; } while (y < height) { if (major_lines) { if (major_count == 0) DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID, 0.0); else DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_DOTTED, ddisplay_untransform_length(ddisp, 31)); major_count = (major_count+1)%major_lines; } irenderer->draw_pixel_line(renderer, x, y, width, y, &ddisp->diagram->grid.colour); pos += length; ddisplay_transform_coords(ddisp, update->left, pos, &x, &y); } }
static void bus_draw(Bus *bus, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Point *endpoints; int i; assert(bus != NULL); assert(renderer != NULL); endpoints = &bus->real_ends[0]; renderer_ops->set_linewidth(renderer, LINE_WIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); renderer_ops->set_linecaps(renderer, LINECAPS_BUTT); renderer_ops->draw_line(renderer, &endpoints[0], &endpoints[1], &bus->line_color); for (i=0;i<bus->num_handles;i++) { renderer_ops->draw_line(renderer, &bus->parallel_points[i], &bus->handles[i]->pos, &bus->line_color); } }
static void beziergon_draw(Beziergon *beziergon, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); BezierShape *bez = &beziergon->bezier; BezPoint *points; int n; points = &bez->bezier.points[0]; n = bez->bezier.num_points; renderer_ops->set_linewidth(renderer, beziergon->line_width); renderer_ops->set_linestyle(renderer, beziergon->line_style); renderer_ops->set_dashlength(renderer, beziergon->dashlength); renderer_ops->set_linejoin(renderer, beziergon->line_join); renderer_ops->set_linecaps(renderer, LINECAPS_BUTT); if (beziergon->show_background) renderer_ops->fill_bezier(renderer, points, n, &beziergon->inner_color); renderer_ops->draw_bezier(renderer, points, n, &beziergon->line_color); /* these lines should only be displayed when object is selected. * Unfortunately the draw function is not aware of the selected * state. This is a compromise until I fix this properly. */ if (renderer->is_interactive && dia_object_is_selected((DiaObject*)beziergon)) { bezier_draw_control_lines (beziergon->bezier.bezier.num_points, beziergon->bezier.bezier.points, renderer); } }
static void aadlpackage_draw_borders(Aadlbox *aadlbox, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real x, y, w, h; Point points[9]; assert(aadlbox != NULL); assert(renderer != NULL); elem = &aadlbox->element; x = elem->corner.x; y = elem->corner.y; w = elem->width; h = elem->height; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, AADLBOX_BORDERWIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID, 0.0); points[0].x = x; points[0].y = y; points[1].x = x + 0.03 * w ; points[1].y = y; points[2].x = x + 0.08 * w ; points[2].y = y - AADL_PORT_MAX_OUT; points[3].x = x + 0.40 * w ; points[3].y = y - AADL_PORT_MAX_OUT; points[4].x = x + 0.45 * w ; points[4].y = y; points[5].x = x + w - 0.05 * w; points[5].y = y; points[6].x = x + w; points[6].y = y + 0.05 * h; points[7].x = x + w; points[7].y = y + h; points[8].x = x ; points[8].y = y + h; renderer_ops->draw_polygon(renderer, points, 9, &aadlbox->fill_color, &aadlbox->line_color); }
static void newgroup_draw(NewGroup *group, DiaRenderer *renderer) { Point lr_corner; Element *elem; DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); assert(group != NULL); assert(renderer != NULL); elem = &group->element; lr_corner.x = elem->corner.x + elem->width; lr_corner.y = elem->corner.y + elem->height; renderer_ops->set_linewidth(renderer, 0.01); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); renderer_ops->draw_rect(renderer, &elem->corner, &lr_corner, &color_black); }
/*! The default object renderer. * @param obj An object to render. * @param renderer The renderer to render on. * @param active_layer The layer containing the object. * @param data The diagram containing the layer. * \ingroup DiagramStructure */ static void normal_render(DiaObject *obj, DiaRenderer *renderer, int active_layer, gpointer data) { DIA_RENDERER_GET_CLASS(renderer)->draw_object(renderer, obj, NULL); }
static void zigzagline_draw(Zigzagline *zigzagline, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); OrthConn *orth = &zigzagline->orth; Point *points; int n; points = &orth->points[0]; n = orth->numpoints; renderer_ops->set_linewidth(renderer, zigzagline->line_width); renderer_ops->set_linestyle(renderer, zigzagline->line_style); renderer_ops->set_dashlength(renderer, zigzagline->dashlength); renderer_ops->set_linejoin(renderer, zigzagline->line_join); renderer_ops->set_linecaps(renderer, zigzagline->line_caps); renderer_ops->draw_rounded_polyline_with_arrows(renderer, points, n, zigzagline->line_width, &zigzagline->line_color, &zigzagline->start_arrow, &zigzagline->end_arrow, zigzagline->corner_radius); }
static void polyline_draw(Polyline *polyline, DiaRenderer *renderer) { Point gap_endpoints[2]; DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); PolyConn *poly = &polyline->poly; Point *points; int n; points = &poly->points[0]; n = poly->numpoints; renderer_ops->set_linewidth(renderer, polyline->line_width); renderer_ops->set_linestyle(renderer, polyline->line_style, polyline->dashlength); renderer_ops->set_linejoin(renderer, polyline->line_join); renderer_ops->set_linecaps(renderer, polyline->line_caps); polyline_calculate_gap_endpoints(polyline, gap_endpoints); polyline_exchange_gap_points(polyline, gap_endpoints); renderer_ops->draw_rounded_polyline_with_arrows(renderer, points, n, polyline->line_width, &polyline->line_color, &polyline->start_arrow, &polyline->end_arrow, polyline->corner_radius); polyline_exchange_gap_points(polyline, gap_endpoints); }
// specialized draw_rounded_polyline() for renderers with an own concept of Arrow void dia::Renderer::draw_rounded_polyline_with_arrows (Point *points, int num_points, real line_width, Color *color, Arrow *start_arrow, Arrow *end_arrow, real radius) { assert (self); DIA_RENDERER_GET_CLASS(self)->draw_rounded_polyline_with_arrows (self, points, num_points, line_width, color, start_arrow, end_arrow, radius); }
static void line_draw(Line *line, DiaRenderer *renderer) { Point gap_endpoints[2]; DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); assert(line != NULL); assert(renderer != NULL); renderer_ops->set_linewidth(renderer, line->line_width); renderer_ops->set_linestyle(renderer, line->line_style, line->dashlength); renderer_ops->set_linecaps(renderer, line->line_caps); if (line->absolute_start_gap || line->absolute_end_gap ) { line_adjust_for_absolute_gap(line, gap_endpoints); renderer_ops->draw_line_with_arrows(renderer, &gap_endpoints[0], &gap_endpoints[1], line->line_width, &line->line_color, &line->start_arrow, &line->end_arrow); } else { renderer_ops->draw_line_with_arrows(renderer, &line->connection.endpoints[0], &line->connection.endpoints[1], line->line_width, &line->line_color, &line->start_arrow, &line->end_arrow); } }
static void draw_dot(DiaRenderer *renderer, Point *end, Point *vect, Color *col) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Point vv,vp,vt,pt; real vlen; vv = *end; point_sub(&vv,vect); vlen = distance_point_point(vect,end); if (vlen < 1E-7) return; point_scale(&vv,1/vlen); vp.y = vv.x; vp.x = -vv.y; pt = *end; vt = vp; point_scale(&vt,ARROW_DOT_WOFFSET); point_add(&pt,&vt); vt = vv; point_scale(&vt,-ARROW_DOT_LOFFSET); point_add(&pt,&vt); renderer_ops->set_fillstyle(renderer,FILLSTYLE_SOLID); renderer_ops->fill_ellipse(renderer,&pt, ARROW_DOT_RADIUS,ARROW_DOT_RADIUS, col); }
static void state_draw(State *state, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real x, y, w, h; Point p1, p2; assert(state != NULL); assert(renderer != NULL); elem = &state->element; x = elem->corner.x; y = elem->corner.y; w = elem->width; h = elem->height; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, STATE_LINEWIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); p1.x = x; p1.y = y; p2.x = x + w; p2.y = y + h; renderer_ops->fill_rounded_rect(renderer, &p1, &p2, &state->fill_color, 1.0); renderer_ops->draw_rounded_rect(renderer, &p1, &p2, &state->line_color, 1.0); text_draw(state->text, renderer); }
static void aadlsubprogram_draw_borders(Aadlbox *aadlbox, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real x, y, w, h; Point center; assert(aadlbox != NULL); assert(renderer != NULL); elem = &aadlbox->element; x = elem->corner.x; y = elem->corner.y; w = elem->width; h = elem->height; center.x = x + 0.5*w; center.y = y + 0.5*h; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, AADLBOX_BORDERWIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); renderer_ops->fill_ellipse(renderer, ¢er, w, h, &aadlbox->fill_color); renderer_ops->draw_ellipse(renderer, ¢er, w, h, &aadlbox->line_color); }
static void branch_draw(Branch *branch, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real w, h; Point points[4]; assert(branch != NULL); assert(renderer != NULL); elem = &branch->element; w = elem->width/2; h = elem->height/2; points[0].x = elem->corner.x, points[0].y = elem->corner.y + h; points[1].x = elem->corner.x + w, points[1].y = elem->corner.y; points[2].x = elem->corner.x + 2*w, points[2].y = elem->corner.y + h; points[3].x = elem->corner.x + w, points[3].y = elem->corner.y + 2*h; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, BRANCH_BORDERWIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); renderer_ops->fill_polygon(renderer, points, 4, &branch->fill_color); renderer_ops->draw_polygon(renderer, points, 4, &branch->line_color); }
void grid_draw(DDisplay *ddisp, Rectangle *update) { Grid *grid = &ddisp->grid; DiaRenderer *renderer = ddisp->renderer; if (grid->visible) { /* distance between visible grid lines */ real width_x = ddisp->diagram->grid.width_x; real width_y = ddisp->diagram->grid.width_y; real width_w = ddisp->diagram->grid.width_w; if (ddisp->diagram->grid.dynamic) { calculate_dynamic_grid(ddisp, &width_x, &width_y); } else { width_x = ddisp->diagram->grid.width_x * ddisp->diagram->grid.visible_x; width_y = ddisp->diagram->grid.width_y * ddisp->diagram->grid.visible_y; } DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, 0.0); if (ddisp->diagram->grid.hex) { grid_draw_hex(ddisp, update, width_w); } else { if (ddisplay_transform_length(ddisp, width_y) >= 2.0 && ddisplay_transform_length(ddisp, width_x) >= 2.0) { /* Vertical lines: */ grid_draw_vertical_lines(ddisp, update, width_x); /* Horizontal lines: */ grid_draw_horizontal_lines(ddisp, update, width_y); } } } }
static void image_draw(EImage *image, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Point ul_corner, lr_corner; Element *elem; assert(image != NULL); assert(renderer != NULL); elem = &image->element; lr_corner.x = elem->corner.x + elem->width + image->border_width/2; lr_corner.y = elem->corner.y + elem->height + image->border_width/2; ul_corner.x = elem->corner.x - image->border_width/2; ul_corner.y = elem->corner.y - image->border_width/2; if (image->draw_border) { renderer_ops->set_linewidth(renderer, image->border_width); renderer_ops->set_linestyle(renderer, image->line_style); renderer_ops->set_dashlength(renderer, image->dashlength); renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); renderer_ops->draw_rect(renderer, &ul_corner, &lr_corner, &image->border_color); } /* Draw the image */ if (image->image) { if (image->keep_orig_aspect) { real aspect; real width,height; Point corner; aspect = (real)dia_image_width(image->image) / (real)dia_image_height(image->image); width = elem->height * aspect; if (width < elem->width) { height = elem->height; } else { width = elem->width; height = elem->width * (1.0/aspect); } corner.x = elem->corner.x + elem->width / 2.0 - width / 2.0; corner.y = elem->corner.y + elem->height / 2.0 - height / 2.0; renderer_ops->draw_image(renderer,&corner,width,height,image->image); } else { renderer_ops->draw_image(renderer, &elem->corner, elem->width, elem->height, image->image); } } else { DiaImage *broken = dia_image_get_broken(); renderer_ops->draw_image(renderer, &elem->corner, elem->width, elem->height, broken); dia_image_unref(broken); } }
static void constraint_draw(Constraint *constraint, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Point *endpoints; Arrow arrow; assert(constraint != NULL); assert(renderer != NULL); endpoints = &constraint->connection.endpoints[0]; renderer_ops->set_linewidth(renderer, constraint->line_width); renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED, CONSTRAINT_DASHLEN); renderer_ops->set_linecaps(renderer, LINECAPS_BUTT); arrow.type = ARROW_LINES; arrow.length = CONSTRAINT_ARROWLEN; arrow.width = CONSTRAINT_ARROWWIDTH; renderer_ops->draw_line_with_arrows(renderer, &endpoints[0], &endpoints[1], constraint->line_width, &constraint->line_color, NULL, &arrow); renderer_ops->set_font(renderer, constraint->font, constraint->font_height); renderer_ops->draw_string(renderer, constraint->brtext, &constraint->text_pos, ALIGN_LEFT, &constraint->text_color); }
static void grid_object_draw(Grid_Object *grid_object, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; Point lr_corner; g_assert(grid_object != NULL); g_assert(renderer != NULL); elem = &grid_object->element; lr_corner.x = elem->corner.x + elem->width; lr_corner.y = elem->corner.y + elem->height; renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); /* draw background */ if (grid_object->show_background) renderer_ops->fill_rect(renderer,&elem->corner, &lr_corner, &grid_object->inner_color); /* draw gridlines */ renderer_ops->set_linewidth(renderer, grid_object->gridline_width); grid_object_draw_gridlines(grid_object, renderer, &lr_corner); /* draw outline */ renderer_ops->set_linewidth(renderer, grid_object->border_line_width); renderer_ops->draw_rect(renderer,&elem->corner, &lr_corner, &grid_object->border_color); }
// specialized draw_line() for renderers with an own concept of Arrow void dia::Renderer::draw_arc_with_arrows (Point *start, Point *end, Point *midpoint, real line_width, Color *color, Arrow *start_arrow, Arrow *end_arrow) { assert (self); DIA_RENDERER_GET_CLASS(self)->draw_arc_with_arrows (self, start, end, midpoint, line_width, color, start_arrow, end_arrow); }
static void aadldata_draw_borders(Aadlbox *aadlbox, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real x, y, w, h; Point points[2]; assert(aadlbox != NULL); assert(renderer != NULL); elem = &aadlbox->element; x = elem->corner.x; y = elem->corner.y; w = elem->width; h = elem->height; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, AADLBOX_BORDERWIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID, 0.0); points[0].x = x; points[0].y = y; points[1].x = x + w; points[1].y = y + h; renderer_ops->draw_rect(renderer, points, points + 1, &aadlbox->fill_color, &aadlbox->line_color); }
// specialized draw_bezier() for renderers with an own concept of Arrow void dia::Renderer::draw_bezier_with_arrows (BezPoint *points, int num_points, real line_width, Color *color, Arrow *start_arrow, Arrow *end_arrow) { assert (self); DIA_RENDERER_GET_CLASS(self)->draw_bezier_with_arrows (self, points, num_points, line_width, color, start_arrow, end_arrow); }
/** draw is here */ static void req_draw(Requirement *req, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real x, y, w, h; Point c; assert(req != NULL); assert(renderer != NULL); elem = &req->element; x = elem->corner.x; y = elem->corner.y; w = elem->width; h = elem->height; c.x = x + w/2.0; c.y = y + h/2.0; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, REQ_LINEWIDTH); renderer_ops->set_dashlength(renderer, REQ_DASHLEN); renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED); renderer_ops->fill_ellipse(renderer, &c, w, h, &color_white); renderer_ops->draw_ellipse(renderer, &c, w, h, &color_black); text_draw(req->text, renderer); }
static void ellipse_draw(Ellipse *ellipse, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; Point center; assert(ellipse != NULL); assert(renderer != NULL); elem = &ellipse->element; center.x = elem->corner.x + elem->width/2; center.y = elem->corner.y + elem->height/2; if (ellipse->show_background) { renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->fill_ellipse(renderer, ¢er, elem->width, elem->height, &ellipse->inner_color); } renderer_ops->set_linewidth(renderer, ellipse->border_width); renderer_ops->set_linestyle(renderer, ellipse->line_style); renderer_ops->set_dashlength(renderer, ellipse->dashlength); renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); renderer_ops->draw_ellipse(renderer, ¢er, elem->width, elem->height, &ellipse->border_color); text_draw(ellipse->text, renderer); }
/* drawing stuff */ static void goal_draw(Goal *goal, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Point p1,p2; BezPoint bpl[5]; Element *elem; /* some asserts */ assert(goal != NULL); assert(renderer != NULL); elem = &goal->element; renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID, 0.0); renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); renderer_ops->set_linewidth(renderer, GOAL_LINE_WIDTH); if (goal->type==GOAL) { /* goal */ p1.x=elem->corner.x; p1.y= elem->corner.y; p2.x=p1.x+elem->width; p2.y=p1.y+elem->height; renderer_ops->draw_rounded_rect (renderer,&p1,&p2, &GOAL_BG_COLOR, &GOAL_FG_COLOR, elem->height/2.0); } else { /* softgoal */ compute_cloud(goal,bpl); renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->draw_beziergon(renderer,bpl,5,&GOAL_BG_COLOR,&GOAL_FG_COLOR); } /* drawing text */ text_draw(goal->text, renderer); }
static void chronoref_draw(Chronoref *chronoref, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; Point lr_corner; real t; Point p1,p2,p3; assert(renderer != NULL); elem = &chronoref->element; renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); lr_corner.x = elem->corner.x + elem->width; lr_corner.y = elem->corner.y + elem->height; p1.y = p2.y = elem->corner.y; renderer_ops->set_font(renderer, chronoref->font, chronoref->font_size); p3.y = p2.y + chronoref->majgrad_height + dia_font_ascent("1",chronoref->font, chronoref->font_size); renderer_ops->set_linewidth(renderer, chronoref->light_lwidth); if (chronoref->time_lstep > 0.0) { p2.y = p1.y + chronoref->mingrad_height; for (t = chronoref->firstmaj, p1.x = chronoref->firstmin_x; p1.x <= lr_corner.x; t += chronoref->time_lstep, p1.x += chronoref->mingrad) { p2.x = p1.x; renderer_ops->draw_line(renderer,&p1,&p2,&chronoref->color); } } renderer_ops->set_linewidth(renderer, chronoref->main_lwidth); if (chronoref->time_step > 0.0) { p2.y = p1.y + chronoref->majgrad_height; for (t = chronoref->firstmaj, p1.x = chronoref->firstmaj_x; p1.x <= lr_corner.x; t += chronoref->time_step, p1.x += chronoref->majgrad) { char time[10]; p3.x = p2.x = p1.x; renderer_ops->draw_line(renderer,&p1,&p2,&chronoref->color); g_snprintf(time,sizeof(time),"%.*f",chronoref->spec,t); renderer_ops->draw_string(renderer,time,&p3,ALIGN_CENTER, &chronoref->font_color); } } p1.x = elem->corner.x; p2.x = lr_corner.x; p1.y = p2.y = elem->corner.y; renderer_ops->draw_line(renderer,&p1,&p2,&chronoref->color); }
void aadlbox_draw_inclined_box(Aadlbox *aadlbox, DiaRenderer *renderer, LineStyle linestyle) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); Element *elem; real x, y, w, h; Point points[4]; assert(aadlbox != NULL); assert(renderer != NULL); elem = &aadlbox->element; x = elem->corner.x; y = elem->corner.y; w = elem->width; h = elem->height; points[0].x = x + w * AADLBOX_INCLINE_FACTOR; points[1].x = x + w; points[0].y = points[1].y = y; points[3].x = x; points[2].x = x + w - w * AADLBOX_INCLINE_FACTOR; points[3].y = points[2].y = y + h; renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); renderer_ops->set_linewidth(renderer, AADLBOX_BORDERWIDTH); renderer_ops->set_linestyle(renderer, linestyle); renderer_ops->set_dashlength(renderer, AADLBOX_DASH_LENGTH); renderer_ops->fill_polygon(renderer, points, 4, &aadlbox->fill_color); renderer_ops->draw_polygon(renderer, points, 4, &aadlbox->line_color); }