From ca9d461eaf709fba9db88a49e9bc813dd38e18a2 Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Sat, 13 Feb 2016 13:55:33 -0500 Subject: [PATCH] Add cylinder (database) shape; fix some missing entries in files and repository. --- doc/info/Makefile.am | 4 +- doc/info/cylinder.gif | Bin 0 -> 991 bytes doc/info/plain.gif | Bin 0 -> 554 bytes doc/info/shapes.html | 26 +++++----- doc/infosrc/Makefile.old | 10 ++-- doc/infosrc/shapelist | 1 + lib/common/const.h | 1 + lib/common/shapes.c | 106 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 129 insertions(+), 19 deletions(-) create mode 100644 doc/info/cylinder.gif create mode 100644 doc/info/plain.gif 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 0000000000000000000000000000000000000000..9344b3823513c509acf92201dd5fd52985927645 GIT binary patch literal 991 zcmV<510eiINk%w1VN(D*0M!5h1Ofzvf`mjuM8v|xBqAiFqNHSEWaQ%H6cQAal9W_Z zR5UU)w6e5xa&*+v)b#fB3>M5(oSvLqUR*prJiNZVe13e~-rWEH z{r~^~A^8LW002G!EC2ui08;=v000L5z>jc9EE2Acw^?e=#L+w1Twh^$={k&P2^|Is0t+`U0Evo=jE#;UC?qQ)8WsUK zEDje@dqgf1DK#PlAc~P25-KJQ0Wc{UB^7WZv?DSOxVW{nEG!iT83_>`HG?861Q3c4 zGb$Y=JxQGx5gW<~3o$h?B|Epd;Njxq%3^)M>A|$0K3N(05MKvHV3Ly;U{Qds_ zG77ZN0RROHdP8Uc=2*Bcp3IJLV003e^ z4jwpmfSg%Q28$FeV%$ii!$AJYElvR7Vi7_G1!Vvrkk}BzK!*shSPY;!PR0%f1yY1) zkVAx_QUy1dNHM|zjGuafj@yBQhXn;XD4=Nc0>KRu6jp2y!I!TB6@X*(6(L~53<@_6 zAyotd!vab*B2<_Y?yO0a57AV>0V6<%1{MrxP%&7A5HoVNML~683^EI_bFH$g5fzh zQ-KmjL}7&wU5Md78vbs$9E9e1$RUUgidasECPqhMiX$?}B5o_b$PbD#S{GxDD!Pbc zj=Ckd<2c~;0Kx_d{1{RT7;IqD2Lp(Z(FPWzz(I;K&=7$J6x?IMCOr~yKngjm#1aW2 zh{19*_<6sG3kY!=NvE3FjKPHQa~*JjJC8{Bs5?YH2D NEAF`De%nA006Tsfm@ohU literal 0 HcmV?d00001 diff --git a/doc/info/plain.gif b/doc/info/plain.gif new file mode 100644 index 0000000000000000000000000000000000000000..5162660e62d2382110bd8295f9d732f9027a1732 GIT binary patch literal 554 zcmV+_0@eLTNk%w1VK4w60M!5h1Ofzvf`r7v#6&_wqg$|) zwgN$0jFkWzWd-mh6A|d;#9c%Ic61}bh0|pmDnoX7LKX%KHAFfQLIe&t2q6YdCJhi2 z1rh)+7(#n5<+l%I2iysLJtp3 zB_Km8AQzr@LL@V~4=07GLID6ILN_hU&O-+y(}Xx0G&Ly)+r-}BIO60(7!W1tw;zEQ z@Nih*hGSm1aZH*G5deSzKO4E;#q0L%AhTLRXnYtV0>C3U0~84G&_IC#I01w#0ANFi z1Q-`-thgXUfshCz06h3o0K`a%4K+Xv(15A~3jqfJlptXO27myalqe)%Q%O}EQL`w_ s^Muw_u1ZX>q7Vb@5(P8T1~SXGt=qS7<7TNqx31m0c=PJrTQ>**J8K-*q5uE@ literal 0 HcmV?d00001 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) -- 2.50.1