From: Emden R. Gansner Date: Sat, 13 Feb 2016 18:55:33 +0000 (-0500) Subject: Add cylinder (database) shape; fix some missing entries in files X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca9d461eaf709fba9db88a49e9bc813dd38e18a2;p=graphviz Add cylinder (database) shape; fix some missing entries in files and repository. --- diff --git a/doc/info/Makefile.am b/doc/info/Makefile.am index 725e00922..b1733fff4 100644 --- a/doc/info/Makefile.am +++ b/doc/info/Makefile.am @@ -18,12 +18,12 @@ html_DATA = attrs.html colors.html command.html \ aa_ornormal.gif aa_rbox.gif aa_rcrow.gif aa_rdiamond.gif aa_rinv.gif \ aa_rnormal.gif aa_rtee.gif aa_rvee.gif aa_tee.gif aa_vee.gif back.gif \ both.gif box.gif box3d.gif circle.gif colorlist.gif component.gif underline.gif \ - constraint.gif diamond.gif doublecircle.gif doubleoctagon.gif egg.gif \ + constraint.gif cylinder.gif diamond.gif doublecircle.gif doubleoctagon.gif egg.gif \ ellipse.gif fill.gif folder.gif forward.gif hexagon.gif house.gif \ g_lin0.png g_lin270.png g_lin45.png g_rad0.png g_rad270.png g_rad45.png \ g_lin180.png g_lin360.png g_lin90.png g_rad180.png g_rad360.png g_rad90.png \ html1.gif html2.gif html3.gif html4.gif invhouse.gif invtrapezium.gif \ - invtriangle.gif mrecord.gif nohead.gif none.gif note.gif octagon.gif \ + invtriangle.gif mrecord.gif nohead.gif none.gif plain.gif note.gif octagon.gif \ oval.gif parallelogram.gif pentagon.gif plaintext.gif point.gif polygon.gif \ record.gif record2.gif rect.gif rectangle.gif round.gif septagon.gif tab.gif \ trapezium.gif triangle.gif tripleoctagon.gif sdlshapes.jpg sdlshapes.png \ diff --git a/doc/info/cylinder.gif b/doc/info/cylinder.gif new file mode 100644 index 000000000..9344b3823 Binary files /dev/null and b/doc/info/cylinder.gif differ diff --git a/doc/info/plain.gif b/doc/info/plain.gif new file mode 100644 index 000000000..5162660e6 Binary files /dev/null and b/doc/info/plain.gif differ diff --git a/doc/info/shapes.html b/doc/info/shapes.html index 011aebcd3..d8b966a61 100644 --- a/doc/info/shapes.html +++ b/doc/info/shapes.html @@ -130,81 +130,83 @@ The possible polygon-based shapes are displayed below. + - underline + cylinder note tab - folder + - + folder box3d component promoter - cds + - + cds terminator utr primersite - restrictionsite + - + restrictionsite fivepoverhang threepoverhang noverhang - assembly + - + assembly signature insulator ribosite - rnastab + - + rnastab proteasesite proteinstab rpromoter - rarrow + + rarrow larrow lpromoter diff --git a/doc/infosrc/Makefile.old b/doc/infosrc/Makefile.old index 744c65f5b..72391669d 100644 --- a/doc/infosrc/Makefile.old +++ b/doc/infosrc/Makefile.old @@ -50,11 +50,11 @@ SGIF = Mcircle.gif Mdiamond.gif Msquare.gif box.gif \ circle.gif diamond.gif doublecircle.gif \ doubleoctagon.gif egg.gif ellipse.gif hexagon.gif house.gif \ invhouse.gif invtrapezium.gif invtriangle.gif none.gif underline.gif \ - octagon.gif oval.gif parallelogram.gif plaintext.gif \ - point.gif polygon.gif trapezium.gif triangle.gif \ - tripleoctagon.gif pentagon.gif septagon.gif rect.gif \ - rectangle.gif square.gif star.gif tab.gif folder.gif box3d.gif component.gif \ - promoter.gif cds.gif terminator.gif utr.gif \ + octagon.gif oval.gif parallelogram.gif plaintext.gif note.gif \ + point.gif polygon.gif trapezium.gif triangle.gif cylinder.gif \ + tripleoctagon.gif pentagon.gif septagon.gif rect.gif plain.gif \ + rectangle.gif square.gif star.gif tab.gif folder.gif box3d.gif \ + component.gif promoter.gif cds.gif terminator.gif utr.gif \ primersite.gif restrictionsite.gif fivepoverhang.gif \ threepoverhang.gif noverhang.gif assembly.gif signature.gif \ insulator.gif ribosite.gif rnastab.gif proteasesite.gif \ diff --git a/doc/infosrc/shapelist b/doc/infosrc/shapelist index 26294c242..d4444d699 100644 --- a/doc/infosrc/shapelist +++ b/doc/infosrc/shapelist @@ -31,6 +31,7 @@ square star none underline +cylinder note tab folder diff --git a/lib/common/const.h b/lib/common/const.h index 1c4c47355..2c3763462 100644 --- a/lib/common/const.h +++ b/lib/common/const.h @@ -247,6 +247,7 @@ #define RARROW (23 << 24) #define LARROW (24 << 24) #define LPROMOTER (25 << 24) +#define CYLINDER (26 << 24) /* fill types */ #define FILL 1 diff --git a/lib/common/shapes.c b/lib/common/shapes.c index c2ebbe4d0..c0fcd58b0 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -70,6 +70,15 @@ static poly_desc_t star_gen = { star_vertices, }; +static pointf cylinder_size (pointf); +static void cylinder_vertices (pointf*, pointf*); +static void cylinder_draw(GVJ_t * job, pointf * AF, int sides, int style, int filled); +/* static boolean cylinder_inside(inside_t * inside_context, pointf p); */ +static poly_desc_t cylinder_gen = { + cylinder_size, + cylinder_vertices, +}; + /* polygon descriptions. "polygon" with 0 sides takes all user control */ /* regul perip sides orien disto skew */ @@ -98,6 +107,7 @@ 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 }; static polygon_t p_underline = { FALSE, 1, 4, 0., 0., 0., UNDERLINE }; +static polygon_t p_cylinder = { FALSE, 1, 19, 0., 0., 0., CYLINDER, (pointf*)&cylinder_gen }; /* redundant and undocumented builtin polygons */ static polygon_t p_doublecircle = { TRUE, 2, 1, 0., 0., 0. }; @@ -211,6 +221,14 @@ static shape_functions star_fns = { poly_path, poly_gencode }; +static shape_functions cylinder_fns = { + poly_init, + poly_free, + poly_port, + poly_inside, + poly_path, + poly_gencode +}; static shape_desc Shapes[] = { /* first entry is default for no such shape */ {"box", &poly_fns, &p_box}, @@ -237,6 +255,7 @@ static shape_desc Shapes[] = { /* first entry is default for no such shape */ {"folder", &poly_fns, &p_folder}, {"box3d", &poly_fns, &p_box3d}, {"component", &poly_fns, &p_component}, + {"cylinder", &cylinder_fns, &p_cylinder}, {"rect", &poly_fns, &p_box}, {"rectangle", &poly_fns, &p_box}, {"square", &poly_fns, &p_square}, @@ -508,6 +527,10 @@ void round_corners(GVJ_t * job, pointf * AF, int sides, int style, int filled) mode = shape; else mode = ROUNDED; + if (mode == CYLINDER) { + cylinder_draw (job, AF, sides, style, filled); + return; + } B = N_NEW(4 * sides + 4, pointf); i = 0; /* rbconst is distance offset from a corner of the polygon. @@ -3981,6 +4004,89 @@ static boolean star_inside(inside_t * inside_context, pointf p) return TRUE; } +static pointf cylinder_size (pointf sz) +{ + sz.y *= 1.375; + return sz; +} + +static void cylinder_vertices (pointf* vertices, pointf* bb) +{ + double x = bb->x/2; + double y = bb->y/2; + double yr = bb->y/11; + + vertices[0].x = x; + vertices[0].y = y-yr; + vertices[1].x = x; + vertices[1].y = y-(1-0.551784)*yr; + vertices[2].x = 0.551784*x; + vertices[2].y = y; + vertices[3].x = 0; + vertices[3].y = y; + vertices[4].x = -0.551784*x; + vertices[4].y = y; + vertices[5].x = -x; + vertices[5].y = vertices[1].y; + vertices[6].x = -x; + vertices[6].y = y-yr; + vertices[7] = vertices[6]; + vertices[8].x = -x; + vertices[8].y = yr-y; + vertices[9] = vertices[8]; + vertices[10].x = -x; + vertices[10].y = -vertices[1].y; + vertices[11].x = vertices[4].x; + vertices[11].y = -vertices[4].y; + vertices[12].x = vertices[3].x; + vertices[12].y = -vertices[3].y; + vertices[13].x = vertices[2].x; + vertices[13].y = -vertices[2].y; + vertices[14].x = vertices[1].x; + vertices[14].y = -vertices[1].y; + vertices[15].x = vertices[0].x; + vertices[15].y = -vertices[0].y; + vertices[16] = vertices[15]; + vertices[18] = vertices[17] = vertices[0]; +} + +static void cylinder_draw(GVJ_t * job, pointf * AF, int sides, int style, int filled) +{ + pointf vertices[7]; + double y0 = AF[0].y; + double y02 = y0+y0; + + vertices[0] = AF[0]; + vertices[1].x = AF[1].x; + vertices[1].y = y02 - AF[1].y; + vertices[2].x = AF[2].x; + vertices[2].y = y02 - AF[2].y; + vertices[3].x = AF[3].x; + vertices[3].y = y02 - AF[3].y; + vertices[4].x = AF[4].x; + vertices[4].y = y02 - AF[4].y; + vertices[5].x = AF[5].x; + vertices[5].y = y02 - AF[5].y; + vertices[6] = AF[6]; + + gvrender_beziercurve(job, AF, sides, FALSE, FALSE, filled); + gvrender_beziercurve(job, vertices, 7, FALSE, FALSE, FALSE); +} + +#if 0 +/* cylinder_inside: + * At present, we use just the polygonal outline provided by vertices. + * This cold be made more precise by using a finer-grained polyline path + * to the spline top and bottom. Another approach might be to approximate + * the top and bottom by ellipses. Then the test would involve a check if + * the point is in the rectangle or one of the two ellipses. + */ +static boolean cylinder_inside(inside_t * inside_context, pointf p) +{ + return TRUE; +} +#endif + static char *side_port[] = { "s", "e", "n", "w" }; static point cvtPt(pointf p, int rankdir)