From 387114b416140947a736c1ec7917f5c0c6aa3813 Mon Sep 17 00:00:00 2001 From: ellson Date: Sun, 2 Mar 2008 15:22:47 +0000 Subject: [PATCH] Add "folder" shape. - patch provided by: Pander --- lib/common/const.h | 5 +++-- lib/common/shapes.c | 54 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/lib/common/const.h b/lib/common/const.h index b20f1ca59..926d092a8 100644 --- a/lib/common/const.h +++ b/lib/common/const.h @@ -209,8 +209,9 @@ #define INVISIBLE (1 << 4) #define DOGEAR (1 << 5) #define TAB (1 << 6) -#define BOX3D (1 << 7) -#define COMPONENT (1 << 8) +#define FOLDER (1 << 7) +#define BOX3D (1 << 8) +#define COMPONENT (1 << 9) /* label types */ #define LT_NONE (0 << 1) diff --git a/lib/common/shapes.c b/lib/common/shapes.c index c95506ce4..5d88a8be8 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -81,6 +81,7 @@ static polygon_t p_septagon = { FALSE, 1, 7, 0., 0., 0. }; static polygon_t p_octagon = { FALSE, 1, 8, 0., 0., 0. }; static polygon_t p_note = { FALSE, 1, 4, 0., 0., 0., DOGEAR }; static polygon_t p_tab = { FALSE, 1, 4, 0., 0., 0., TAB }; +static polygon_t p_folder = { FALSE, 1, 4, 0., 0., 0., FOLDER }; static polygon_t p_box3d = { FALSE, 1, 4, 0., 0., 0., BOX3D }; static polygon_t p_component = { FALSE, 1, 4, 0., 0., 0., COMPONENT }; @@ -101,7 +102,7 @@ static polygon_t p_Mcircle = /* True if style requires processing through node_round_corners. */ #define SPECIAL_CORNERS(style) \ - ((style) & (ROUNDED | DIAGONALS | DOGEAR | TAB | BOX3D | COMPONENT)) + ((style) & (ROUNDED | DIAGONALS | DOGEAR | TAB | FOLDER | BOX3D | COMPONENT)) /* * every shape has these functions: @@ -182,6 +183,7 @@ static shape_desc Shapes[] = { /* first entry is default for no such shape */ {"octagon", &poly_fns, &p_octagon}, {"note", &poly_fns, &p_note}, {"tab", &poly_fns, &p_tab}, + {"folder", &poly_fns, &p_folder}, {"box3d", &poly_fns, &p_box3d}, {"component", &poly_fns, &p_component}, {"rect", &poly_fns, &p_box}, @@ -379,8 +381,8 @@ void round_corners(GVJ_t * job, char* fillc, char* penc, pointf * AF, if (style & DIAGONALS) mode = DIAGONALS; - else if (style & (DOGEAR | TAB | BOX3D | COMPONENT)) - mode = style & (DOGEAR | TAB | BOX3D | COMPONENT); + else if (style & (DOGEAR | TAB | FOLDER | BOX3D | COMPONENT)) + mode = style & (DOGEAR | TAB | FOLDER | BOX3D | COMPONENT); else mode = ROUNDED; B = N_NEW(4 * sides + 4, pointf); @@ -480,6 +482,19 @@ void round_corners(GVJ_t * job, char* fillc, char* penc, pointf * AF, gvrender_polyline(job, C, 2); break; case TAB: + /* + * Adjust the perimeter for the protrusions. + * + * D[3] +--+ D[2] + * | | B[1] + * B[3] + +----------+--+ AF[0]=B[0]=D[0] + * | B[2]=D[1] | + * B[4] + | + * | | + * B[5] + | + * +----------------+ + * + */ gvrender_set_pencolor(job, penc); if (style & FILLED) gvrender_set_fillcolor(job, fillc); /* emit fill color */ @@ -501,6 +516,39 @@ void round_corners(GVJ_t * job, char* fillc, char* penc, pointf * AF, C[0] = B[3]; C[1] = B[2]; gvrender_polyline(job, C, 2); + break; + case FOLDER: + /* + * Adjust the perimeter for the protrusions. + * + * D[2] +----+ D[1] + * B[3]= / \ + * D[4] +--+----+ + + AF[0]=B[0]=D[0] + * | B[2] D[3] B[1]| + * B[4] + | + * | | + * B[5] + | + * +----------------+ + * + */ + gvrender_set_pencolor(job, penc); + if (style & FILLED) + gvrender_set_fillcolor(job, fillc); /* emit fill color */ + /* Add the folder edges. */ + D = N_NEW(sides + 3, pointf); + D[0] = AF[0]; + D[1].x = AF[0].x - (AF[0].x - B[1].x) / 4; + D[1].y = AF[0].y + (B[3].y - B[4].y) / 3; + D[2].x = AF[0].x - 2 * (AF[0].x - B[1].x); + D[2].y = D[1].y; + D[3].x = AF[0].x - 2.25 * (AF[0].x - B[1].x); + D[3].y = B[3].y; + D[4].x = B[3].x; + D[4].y = B[3].y; + for (seg = 4; seg < sides + 3; seg++) + D[seg] = AF[seg - 3]; + gvrender_polygon(job, D, sides + 3, style & FILLED); + free(D); break; case BOX3D: assert(sides == 4); -- 2.40.0