x_path.c 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* This file contains the internal paint_path() and paint_paths() methods,
  16. which the public method endpath() is a wrapper around. */
  17. /* This file also contains the internal path_is_flushable() method, which
  18. is invoked after any path segment is added to the segment list, provided
  19. (0) the segment list has become greater than or equal to the
  20. `max_unfilled_path_length' Plotter parameter, (1) the path isn't to be
  21. filled. In most Plotters, this operation simply returns true. */
  22. /* This file also contains the internal maybe_prepaint_segments() method.
  23. It is called immediately after any segment is added to a path. Some
  24. Plotters, at least under some circumstances, treat endpath() as a no-op.
  25. Instead, they plot the segments of a path in real time. */
  26. /**********************************************************************/
  27. /* This version of paint_path() is for XDrawablePlotters (and XPlotters).
  28. By construction, for such Plotters our path buffer always contains
  29. either a segment list, or an ellipse object. If it's a segment list, it
  30. contains either (1) a sequence of line segments, or (2) a single
  31. circular or elliptic arc segment. Those are all sorts of path that X11
  32. can handle. (For an ellipse or circular/elliptic arc segment to have
  33. been added to the path buffer, the map from user to device coordinates
  34. must preserve axes.) */
  35. /* If the line style is "solid" and the path has zero width, it's actually
  36. drawn in real time, before endpath() and paint_path() are called; see
  37. the maybe_prepaint_segments() method further below in this file. So if the
  38. path doesn't need to be filled, we don't do anything in paint_path().
  39. If it does, we fill it, and then redraw it. */
  40. /* Note that when filling a polyline, we look at
  41. _plotter->drawstate->path->primitive to determine which X11 rendering
  42. algorithm to use. Our default algorithm is "Complex" (i.e. generic),
  43. but when drawing polygonal approximations to ellipse and rectangle
  44. primitives, which we know must be convex, we specify "Convex" instead,
  45. to speed up rendering. */
  46. #include "sys-defines.h"
  47. #include "extern.h"
  48. /* number of XPoint structs we can store on the stack, for speed, without
  49. invoking malloc */
  50. #define MAX_NUM_POINTS_ON_STACK 128
  51. #define DIST(p1, p2) sqrt( ((p1).x - (p2).x) * ((p1).x - (p2).x) \
  52. + ((p1).y - (p2).y) * ((p1).y - (p2).y))
  53. void
  54. _pl_x_paint_path (S___(Plotter *_plotter))
  55. {
  56. if (_plotter->drawstate->pen_type == 0
  57. && _plotter->drawstate->fill_type == 0)
  58. /* nothing to draw */
  59. return;
  60. switch ((int)_plotter->drawstate->path->type)
  61. {
  62. case (int)PATH_SEGMENT_LIST:
  63. {
  64. bool closed; /* not currently used */
  65. int is_a_rectangle;
  66. int i, polyline_len;
  67. plPoint p0, p1, pc;
  68. XPoint *xarray, local_xarray[MAX_NUM_POINTS_ON_STACK];
  69. bool heap_storage;
  70. double xu_last, yu_last;
  71. bool identical_user_coordinates;
  72. /* sanity checks */
  73. if (_plotter->drawstate->path->num_segments == 0)/* nothing to do */
  74. break;
  75. if (_plotter->drawstate->path->num_segments == 1) /*shouldn't happen */
  76. break;
  77. if (_plotter->drawstate->path->num_segments == 2
  78. && _plotter->drawstate->path->segments[1].type == S_ARC)
  79. /* segment buffer contains a single circular arc, not a polyline */
  80. {
  81. p0 = _plotter->drawstate->path->segments[0].p;
  82. p1 = _plotter->drawstate->path->segments[1].p;
  83. pc = _plotter->drawstate->path->segments[1].pc;
  84. /* use native X rendering to draw the (transformed) circular
  85. arc */
  86. _pl_x_draw_elliptic_arc (R___(_plotter) p0, p1, pc);
  87. break;
  88. }
  89. if (_plotter->drawstate->path->num_segments == 2
  90. && _plotter->drawstate->path->segments[1].type == S_ELLARC)
  91. /* segment buffer contains a single elliptic arc, not a polyline */
  92. {
  93. p0 = _plotter->drawstate->path->segments[0].p;
  94. p1 = _plotter->drawstate->path->segments[1].p;
  95. pc = _plotter->drawstate->path->segments[1].pc;
  96. /* use native X rendering to draw the (transformed) elliptic
  97. arc */
  98. _pl_x_draw_elliptic_arc_2 (R___(_plotter) p0, p1, pc);
  99. break;
  100. }
  101. /* neither of above applied, so segment buffer contains a polyline,
  102. not an arc */
  103. if ((_plotter->drawstate->path->num_segments >= 3)/*check for closure*/
  104. && (_plotter->drawstate->path->segments[_plotter->drawstate->path->num_segments - 1].p.x == _plotter->drawstate->path->segments[0].p.x)
  105. && (_plotter->drawstate->path->segments[_plotter->drawstate->path->num_segments - 1].p.y == _plotter->drawstate->path->segments[0].p.y))
  106. closed = true;
  107. else
  108. closed = false; /* 2-point ones should be open */
  109. /* Check whether we `pre-drew' the polyline, i.e., drew every line
  110. segment in real time. (See the maybe_prepaint_segments() method
  111. further below, which is invoked to do that.) Our convention: we
  112. pre-draw only if pen width is zero, and line style is "solid".
  113. Also, we don't do it if we're drawing a polygonalized built-in
  114. object (i.e. a rectangle or ellipse).
  115. If we pre-drew, we don't do anything here unless there's filling
  116. to be done. If so, we'll fill the polyline and re-edge it. */
  117. if ((_plotter->drawstate->pen_type != 0 /* pen is present */
  118. && _plotter->drawstate->line_type == PL_L_SOLID
  119. && !_plotter->drawstate->dash_array_in_effect /* really solid */
  120. && _plotter->drawstate->points_are_connected /* really, really */
  121. && _plotter->drawstate->quantized_device_line_width == 0
  122. && !_plotter->drawstate->path->primitive) /* not builtin object */
  123. /* we pre-drew */
  124. &&
  125. _plotter->drawstate->fill_type == 0)
  126. /* there's no filling to be done, so we're out of here */
  127. break;
  128. /* At this point we know that we didn't pre-draw, or we did, but
  129. the polyline was drawn unfilled and it'll need to be re-drawn as
  130. filled. */
  131. /* prepare an array of XPoint structures (X11 uses short ints for
  132. these) */
  133. if (_plotter->drawstate->path->num_segments
  134. <= MAX_NUM_POINTS_ON_STACK)
  135. /* store XPoints on stack, for speed */
  136. {
  137. xarray = local_xarray;
  138. heap_storage = false;
  139. }
  140. else
  141. /* store XPoints in heap */
  142. {
  143. xarray = (XPoint *)_pl_xmalloc (_plotter->drawstate->path->num_segments * sizeof(XPoint));
  144. heap_storage = true;
  145. }
  146. /* convert vertices to device coordinates, removing runs; also keep
  147. track of whether or not all points in user space are the same */
  148. polyline_len = 0;
  149. xu_last = 0.0;
  150. yu_last = 0.0;
  151. identical_user_coordinates = true;
  152. for (i = 0; i < _plotter->drawstate->path->num_segments; i++)
  153. {
  154. plPathSegment datapoint;
  155. double xu, yu, xd, yd;
  156. int device_x, device_y;
  157. datapoint = _plotter->drawstate->path->segments[i];
  158. xu = datapoint.p.x;
  159. yu = datapoint.p.y;
  160. xd = XD(xu, yu);
  161. yd = YD(xu, yu);
  162. device_x = IROUND(xd);
  163. device_y = IROUND(yd);
  164. if (X_OOB_INT(device_x) || X_OOB_INT(device_y))
  165. /* point position can't be represented using X11's 2-byte
  166. ints, so truncate the polyline right here */
  167. {
  168. _plotter->warning (R___(_plotter)
  169. "truncating a polyline that extends too far for X11");
  170. break;
  171. }
  172. if (i > 0 && (xu != xu_last || yu != yu_last))
  173. /* in user space, not all points are the same */
  174. identical_user_coordinates = false;
  175. if ((polyline_len == 0)
  176. || (device_x != xarray[polyline_len-1].x)
  177. || (device_y != xarray[polyline_len-1].y))
  178. /* add point, in integer X coordinates, to the array */
  179. {
  180. xarray[polyline_len].x = device_x;
  181. xarray[polyline_len].y = device_y;
  182. polyline_len++;
  183. if (polyline_len >= _plotter->x_max_polyline_len)
  184. /* polyline is getting too long for the X server to
  185. handle (we determined the maximum X request size when
  186. openpl() was invoked), so truncate it right here */
  187. {
  188. _plotter->warning (R___(_plotter)
  189. "truncating a polyline that's too long for the X display");
  190. break;
  191. }
  192. }
  193. xu_last = xu;
  194. yu_last = yu;
  195. }
  196. /* Is this path a rectangle in device space? We check this because
  197. by calling XFillRectangle (and XDrawRectangle too, if the edging
  198. is solid), we can save a bit of time, or at least network
  199. bandwidth. */
  200. /* N.B. This checks only for rectangles traced counterclockwise
  201. from the lower left corner. Should improve this. */
  202. #define IS_A_RECTANGLE(len,q) \
  203. ((len) == 5 && (q)[0].x == (q)[4].x && (q)[0].y == (q)[4].y && \
  204. (q)[0].x == (q)[3].x && (q)[1].x == (q)[2].x && \
  205. (q)[0].y == (q)[1].y && (q)[2].y == (q)[3].y && \
  206. (q)[0].x < (q)[1].x && (q)[0].y > (q)[2].y) /* note flipped-y convention */
  207. is_a_rectangle = IS_A_RECTANGLE(polyline_len, xarray);
  208. /* N.B. If a rectangle, upper left corner = q[3], and also, width
  209. = q[1].x - q[0].x and height = q[0].y - q[2].y (note flipped-y
  210. convention). */
  211. /* compute the square size, and offset of upper left vertex from
  212. center of square, that we'll use when handling the notorious
  213. special case: all user-space points in the polyline get mapped
  214. to a single integer X pixel */
  215. /* FIRST TASK: fill the polygon (if necessary). */
  216. if (_plotter->drawstate->fill_type)
  217. /* not transparent, so fill the path */
  218. {
  219. int x_polygon_type
  220. = (_plotter->drawstate->path->primitive ? Convex : Complex);
  221. /* update GC used for filling */
  222. _pl_x_set_attributes (R___(_plotter) X_GC_FOR_FILLING);
  223. /* select fill color as foreground color in GC used for filling */
  224. _pl_x_set_fill_color (S___(_plotter));
  225. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  226. {
  227. if (_plotter->drawstate->path->num_segments > 1
  228. && polyline_len == 1)
  229. /* special case: all user-space points in the polyline
  230. were mapped to a single integer X pixel */
  231. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
  232. _plotter->drawstate->x_gc_fill,
  233. (int)(xarray[0].x), (int)(xarray[0].y));
  234. else
  235. /* general case */
  236. {
  237. if (is_a_rectangle)
  238. /* call XFillRectangle, for speed */
  239. XFillRectangle (_plotter->x_dpy, _plotter->x_drawable3,
  240. _plotter->drawstate->x_gc_fill,
  241. (int)(xarray[3].x), (int)(xarray[3].y),
  242. (unsigned int)(xarray[1].x - xarray[0].x),
  243. /* flipped y */
  244. (unsigned int)(xarray[0].y - xarray[2].y));
  245. else
  246. /* not a rectangle, call XFillPolygon */
  247. XFillPolygon (_plotter->x_dpy, _plotter->x_drawable3,
  248. _plotter->drawstate->x_gc_fill,
  249. xarray, polyline_len,
  250. x_polygon_type, CoordModeOrigin);
  251. }
  252. }
  253. else /* not double buffering, no `x_drawable3' */
  254. {
  255. if (_plotter->drawstate->path->num_segments > 1
  256. && polyline_len == 1)
  257. /* special case: all user-space points in the polyline
  258. were mapped to a single integer X pixel. */
  259. {
  260. if (_plotter->x_drawable1)
  261. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
  262. _plotter->drawstate->x_gc_fill,
  263. (int)(xarray[0].x), (int)(xarray[0].y));
  264. if (_plotter->x_drawable2)
  265. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
  266. _plotter->drawstate->x_gc_fill,
  267. (int)(xarray[0].x), (int)(xarray[0].y));
  268. }
  269. else
  270. /* general case */
  271. {
  272. if (is_a_rectangle)
  273. /* call XFillRectangle, for speed */
  274. {
  275. if (_plotter->x_drawable1)
  276. XFillRectangle (_plotter->x_dpy, _plotter->x_drawable1,
  277. _plotter->drawstate->x_gc_fill,
  278. (int)(xarray[3].x), (int)(xarray[3].y),
  279. (unsigned int)(xarray[1].x - xarray[0].x),
  280. /* flipped y */
  281. (unsigned int)(xarray[0].y - xarray[2].y));
  282. if (_plotter->x_drawable2)
  283. XFillRectangle (_plotter->x_dpy, _plotter->x_drawable2,
  284. _plotter->drawstate->x_gc_fill,
  285. (int)(xarray[3].x), (int)(xarray[3].y),
  286. (unsigned int)(xarray[1].x - xarray[0].x),
  287. /* flipped y */
  288. (unsigned int)(xarray[0].y - xarray[2].y));
  289. }
  290. else
  291. /* not a rectangle, call XFillPolygon */
  292. {
  293. if (_plotter->x_drawable1)
  294. XFillPolygon (_plotter->x_dpy, _plotter->x_drawable1,
  295. _plotter->drawstate->x_gc_fill,
  296. xarray, polyline_len,
  297. x_polygon_type, CoordModeOrigin);
  298. if (_plotter->x_drawable2)
  299. XFillPolygon (_plotter->x_dpy, _plotter->x_drawable2,
  300. _plotter->drawstate->x_gc_fill,
  301. xarray, polyline_len,
  302. x_polygon_type, CoordModeOrigin);
  303. }
  304. }
  305. }
  306. }
  307. /* SECOND TASK: edge the polygon (if necessary). */
  308. if (_plotter->drawstate->pen_type)
  309. /* pen is present, so edge the path */
  310. {
  311. int xloc = 0, yloc = 0;
  312. unsigned int sp_size = 1;
  313. /* update GC used for drawing */
  314. _pl_x_set_attributes (R___(_plotter) X_GC_FOR_DRAWING);
  315. /* select pen color as foreground color in GC used for drawing */
  316. _pl_x_set_pen_color (S___(_plotter));
  317. /* Check first for the special case: all points in the polyline
  318. were mapped to a single integer X pixel. If (1) they
  319. weren't all the same to begin with, or (2) they were all the
  320. same to begin with and the cap mode is "round", then draw as
  321. a filled circle of diameter equal to the line width;
  322. otherwise draw nothing. (If the circle would have diameter
  323. 1 or less, we draw a point instead.) */
  324. if (_plotter->drawstate->path->num_segments > 1
  325. && polyline_len == 1)
  326. /* this is the special case, so compute quantities needed for
  327. drawing the filled circle */
  328. {
  329. int sp_offset;
  330. sp_size = (unsigned int)_plotter->drawstate->quantized_device_line_width;
  331. if (sp_size == 0)
  332. sp_size = 1;
  333. sp_offset = (_plotter->drawstate->quantized_device_line_width + 1) / 2;
  334. xloc = xarray[0].x - sp_offset;
  335. yloc = xarray[0].y - sp_offset;
  336. }
  337. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  338. /* double buffering, have a `x_drawable3' to draw into */
  339. {
  340. if (_plotter->drawstate->path->num_segments > 1
  341. && polyline_len == 1)
  342. /* special case */
  343. {
  344. if (identical_user_coordinates == false
  345. || _plotter->drawstate->cap_type == PL_CAP_ROUND)
  346. {
  347. if (sp_size == 1)
  348. /* subcase: just draw a point */
  349. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
  350. _plotter->drawstate->x_gc_fg,
  351. (int)(xarray[0].x), (int)(xarray[0].y));
  352. else
  353. /* draw filled circle */
  354. XFillArc(_plotter->x_dpy, _plotter->x_drawable3,
  355. _plotter->drawstate->x_gc_fg,
  356. xloc, yloc, sp_size, sp_size,
  357. 0, 64 * 360);
  358. }
  359. }
  360. else
  361. /* general case */
  362. /* NOTE: this code is what libplot uses to draw nearly all
  363. polylines, in the case when double buffering is used */
  364. {
  365. if (is_a_rectangle
  366. && _plotter->drawstate->dash_array_in_effect == false
  367. && _plotter->drawstate->line_type == PL_L_SOLID)
  368. /* call XDrawRectangle, for speed */
  369. XDrawRectangle (_plotter->x_dpy, _plotter->x_drawable3,
  370. _plotter->drawstate->x_gc_fg,
  371. (int)(xarray[3].x), (int)(xarray[3].y),
  372. (unsigned int)(xarray[1].x - xarray[0].x),
  373. /* flipped y */
  374. (unsigned int)(xarray[0].y - xarray[2].y));
  375. else
  376. /* can't call XDrawRectangle */
  377. XDrawLines (_plotter->x_dpy, _plotter->x_drawable3,
  378. _plotter->drawstate->x_gc_fg,
  379. xarray, polyline_len,
  380. CoordModeOrigin);
  381. }
  382. }
  383. else
  384. /* not double buffering, have no `x_drawable3' */
  385. {
  386. if (_plotter->drawstate->path->num_segments > 1
  387. && polyline_len == 1)
  388. /* special case */
  389. {
  390. if (identical_user_coordinates == false
  391. || _plotter->drawstate->cap_type == PL_CAP_ROUND)
  392. {
  393. if (sp_size == 1)
  394. /* subcase: just draw a point */
  395. {
  396. if (_plotter->x_drawable1)
  397. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
  398. _plotter->drawstate->x_gc_fg,
  399. (int)(xarray[0].x), (int)(xarray[0].y));
  400. if (_plotter->x_drawable2)
  401. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
  402. _plotter->drawstate->x_gc_fg,
  403. (int)(xarray[0].x), (int)(xarray[0].y));
  404. }
  405. else
  406. /* draw filled circle */
  407. {
  408. if (_plotter->x_drawable1)
  409. XFillArc(_plotter->x_dpy, _plotter->x_drawable1,
  410. _plotter->drawstate->x_gc_fg,
  411. xloc, yloc, sp_size, sp_size,
  412. 0, 64 * 360);
  413. if (_plotter->x_drawable2)
  414. XFillArc(_plotter->x_dpy, _plotter->x_drawable2,
  415. _plotter->drawstate->x_gc_fg,
  416. xloc, yloc, sp_size, sp_size,
  417. 0, 64 * 360);
  418. }
  419. }
  420. }
  421. else
  422. /* general case */
  423. /* NOTE: this code is what libplot uses to draw nearly all
  424. polylines; at least, if double buffering is not used */
  425. {
  426. if (is_a_rectangle
  427. && _plotter->drawstate->dash_array_in_effect == false
  428. && _plotter->drawstate->line_type == PL_L_SOLID)
  429. /* call XDrawRectangle, for speed */
  430. {
  431. if (_plotter->x_drawable1)
  432. XDrawRectangle (_plotter->x_dpy, _plotter->x_drawable1,
  433. _plotter->drawstate->x_gc_fg,
  434. (int)(xarray[3].x), (int)(xarray[3].y),
  435. (unsigned int)(xarray[1].x - xarray[0].x),
  436. /* flipped y */
  437. (unsigned int)(xarray[0].y - xarray[2].y));
  438. if (_plotter->x_drawable2)
  439. XDrawRectangle (_plotter->x_dpy, _plotter->x_drawable2,
  440. _plotter->drawstate->x_gc_fg,
  441. (int)(xarray[3].x), (int)(xarray[3].y),
  442. (unsigned int)(xarray[1].x - xarray[0].x),
  443. /* flipped y */
  444. (unsigned int)(xarray[0].y - xarray[2].y));
  445. }
  446. else
  447. /* can't use XDrawRectangle() */
  448. {
  449. if (_plotter->x_drawable1)
  450. XDrawLines (_plotter->x_dpy, _plotter->x_drawable1,
  451. _plotter->drawstate->x_gc_fg,
  452. xarray, polyline_len,
  453. CoordModeOrigin);
  454. if (_plotter->x_drawable2)
  455. XDrawLines (_plotter->x_dpy, _plotter->x_drawable2,
  456. _plotter->drawstate->x_gc_fg,
  457. xarray, polyline_len,
  458. CoordModeOrigin);
  459. }
  460. }
  461. }
  462. }
  463. /* reset buffer used for array of XPoint structs */
  464. if (_plotter->drawstate->path->num_segments > 0)
  465. {
  466. if (heap_storage)
  467. free (xarray); /* free malloc'd array of XPoints */
  468. }
  469. }
  470. break;
  471. case (int)PATH_ELLIPSE:
  472. {
  473. int ninetymult;
  474. int x_orientation, y_orientation;
  475. int xorigin, yorigin;
  476. unsigned int squaresize_x, squaresize_y;
  477. plPoint pc;
  478. double rx, ry, angle;
  479. pc = _plotter->drawstate->path->pc;
  480. rx = _plotter->drawstate->path->rx;
  481. ry = _plotter->drawstate->path->ry;
  482. angle = _plotter->drawstate->path->angle;
  483. /* if angle is multiple of 90 degrees, modify to permit use of
  484. X11 arc rendering */
  485. ninetymult = IROUND(angle / 90.0);
  486. if (angle == (double) (90 * ninetymult))
  487. {
  488. angle = 0.0;
  489. if (ninetymult % 2)
  490. {
  491. double temp;
  492. temp = rx;
  493. rx = ry;
  494. ry = temp;
  495. }
  496. }
  497. rx = (rx < 0.0 ? -rx : rx); /* avoid obscure libxmi problems */
  498. ry = (ry < 0.0 ? -ry : ry);
  499. /* axes flipped? (by default y-axis is, due to libxmi's flipped-y
  500. convention) */
  501. x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
  502. y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
  503. /* location of `origin' (upper left corner of bounding rect. for
  504. ellipse) and width and height; X11's flipped-y convention
  505. affects these values */
  506. xorigin = IROUND(XD(pc.x - x_orientation * rx,
  507. pc.y - y_orientation * ry));
  508. yorigin = IROUND(YD(pc.x - x_orientation * rx,
  509. pc.y - y_orientation * ry));
  510. squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * rx, 0.0));
  511. squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * ry));
  512. /* Because this ellipse object was added to the path buffer, we
  513. already know that (1) the user->device frame map preserves
  514. coordinate axes, (2) effectively, angle == 0. These are
  515. necessary for the libxmi scan-conversion module to do the
  516. drawing. */
  517. /* draw ellipse (elliptic arc aligned with the coordinate axes, arc
  518. range = 64*360 64'ths of a degree) */
  519. _pl_x_draw_elliptic_arc_internal (R___(_plotter)
  520. xorigin, yorigin,
  521. squaresize_x, squaresize_y,
  522. 0, 64 * 360);
  523. }
  524. break;
  525. default: /* shouldn't happen */
  526. break;
  527. }
  528. /* maybe flush X output buffer and handle X events (a no-op for
  529. XDrawablePlotters, which is overridden for XPlotters) */
  530. _maybe_handle_x_events (S___(_plotter));
  531. }
  532. /* Use native X rendering to draw what would be a circular arc in the user
  533. frame on an X display. If this is called, the map from user to device
  534. coordinates is assumed to preserve coordinate axes (it may be
  535. anisotropic [x and y directions scaled differently], and it may include
  536. a reflection through either or both axes). So it will be a circular or
  537. elliptic arc in the device frame, of the sort that X11 supports. */
  538. void
  539. _pl_x_draw_elliptic_arc (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
  540. {
  541. double radius;
  542. double theta0, theta1;
  543. int startangle, anglerange;
  544. int x_orientation, y_orientation;
  545. int xorigin, yorigin;
  546. unsigned int squaresize_x, squaresize_y;
  547. /* axes flipped? (by default y-axis is, due to X's flipped-y convention) */
  548. x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
  549. y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
  550. /* radius of circular arc in user frame is distance to p0, and also to p1 */
  551. radius = DIST(pc, p0);
  552. /* location of `origin' (upper left corner of bounding rect. on display)
  553. and width and height; X's flipped-y convention affects these values */
  554. xorigin = IROUND(XD(pc.x - x_orientation * radius,
  555. pc.y - y_orientation * radius));
  556. yorigin = IROUND(YD(pc.x - x_orientation * radius,
  557. pc.y - y_orientation * radius));
  558. squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * radius, 0.0));
  559. squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * radius));
  560. theta0 = _xatan2 (-y_orientation * (p0.y - pc.y),
  561. x_orientation * (p0.x - pc.x)) / M_PI;
  562. theta1 = _xatan2 (-y_orientation * (p1.y - pc.y),
  563. x_orientation * (p1.x - pc.x)) / M_PI;
  564. if (theta1 < theta0)
  565. theta1 += 2.0; /* adjust so that difference > 0 */
  566. if (theta0 < 0.0)
  567. {
  568. theta0 += 2.0; /* adjust so that startangle > 0 */
  569. theta1 += 2.0;
  570. }
  571. if (theta1 - theta0 > 1.0) /* swap if angle appear to be > 180 degrees */
  572. {
  573. double tmp;
  574. tmp = theta0;
  575. theta0 = theta1;
  576. theta1 = tmp;
  577. theta1 += 2.0; /* adjust so that difference > 0 */
  578. }
  579. if (theta0 >= 2.0 && theta1 >= 2.0)
  580. /* avoid obscure X bug */
  581. {
  582. theta0 -= 2.0;
  583. theta1 -= 2.0;
  584. }
  585. startangle = IROUND(64 * theta0 * 180.0); /* in 64'ths of a degree */
  586. anglerange = IROUND(64 * (theta1 - theta0) * 180.0); /* likewise */
  587. _pl_x_draw_elliptic_arc_internal (R___(_plotter)
  588. xorigin, yorigin,
  589. squaresize_x, squaresize_y,
  590. startangle, anglerange);
  591. }
  592. /* Use native X rendering to draw what would be a quarter-ellipse in the
  593. user frame on an X display. If this is called, the map from user to
  594. device coordinates is assumed to preserve coordinate axes (it may be
  595. anisotropic [x and y directions scaled differently], and it may include
  596. a reflection through either or both axes). So it will be a
  597. quarter-ellipse in the device frame, of the sort that the X11 drawing
  598. protocol supports. */
  599. void
  600. _pl_x_draw_elliptic_arc_2 (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
  601. {
  602. double rx, ry;
  603. double x0, y0, x1, y1, xc, yc;
  604. int startangle, endangle, anglerange;
  605. int x_orientation, y_orientation;
  606. int xorigin, yorigin;
  607. unsigned int squaresize_x, squaresize_y;
  608. /* axes flipped? (by default y-axis is, due to X's flipped-y convention) */
  609. x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
  610. y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
  611. xc = pc.x, yc = pc.y;
  612. x0 = p0.x, y0 = p0.y;
  613. x1 = p1.x, y1 = p1.y;
  614. if (y0 == yc && x1 == xc)
  615. /* initial pt. on x-axis, final pt. on y-axis */
  616. {
  617. /* semi-axes in user frame */
  618. rx = (x0 > xc) ? x0 - xc : xc - x0;
  619. ry = (y1 > yc) ? y1 - yc : yc - y1;
  620. /* starting and ending angles; note flipped-y convention */
  621. startangle = ((x0 > xc ? 1 : -1) * x_orientation == 1) ? 0 : 180;
  622. endangle = ((y1 > yc ? 1 : -1) * y_orientation == -1) ? 90 : 270;
  623. }
  624. else
  625. /* initial pt. on y-axis, final pt. on x-axis */
  626. {
  627. /* semi-axes in user frame */
  628. rx = (x1 > xc) ? x1 - xc : xc - x1;
  629. ry = (y0 > yc) ? y0 - yc : yc - y0;
  630. /* starting and ending angles; note flipped-y convention */
  631. startangle = ((y0 > yc ? 1 : -1) * y_orientation == -1) ? 90 : 270;
  632. endangle = ((x1 > xc ? 1 : -1) * x_orientation == 1) ? 0 : 180;
  633. }
  634. if (endangle < startangle)
  635. endangle += 360;
  636. anglerange = endangle - startangle; /* always 90 or 270 */
  637. /* our convention: a quarter-ellipse can only be 90 degrees
  638. of an X ellipse, not 270 degrees, so interchange points */
  639. if (anglerange == 270)
  640. {
  641. int tmp;
  642. tmp = startangle;
  643. startangle = endangle;
  644. endangle = tmp;
  645. anglerange = 90;
  646. }
  647. if (startangle >= 360)
  648. /* avoid obscure X bug */
  649. startangle -= 360; /* endangle no longer relevant */
  650. /* location of `origin' (upper left corner of bounding rect. on display)
  651. and width and height; X's flipped-y convention affects these values */
  652. xorigin = IROUND(XD(xc - x_orientation * rx,
  653. yc - y_orientation * ry));
  654. yorigin = IROUND(YD(xc - x_orientation * rx,
  655. yc - y_orientation * ry));
  656. squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * rx, 0.0));
  657. squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * ry));
  658. /* reexpress in 64'ths of a degree (X11 convention) */
  659. startangle *= 64;
  660. anglerange *= 64;
  661. _pl_x_draw_elliptic_arc_internal (R___(_plotter)
  662. xorigin, yorigin,
  663. squaresize_x, squaresize_y,
  664. startangle, anglerange);
  665. }
  666. /* Use native X rendering to draw an elliptic arc on an X display. Takes
  667. account of the possible presence of more than one drawable, and the
  668. possible need for filling.
  669. The cases squaresize_{x,y} <= 1 are handled specially, since XFillArc()
  670. and XDrawArc() don't support them in the way we wish. More accurately,
  671. they don't support squaresize_{x,y} = 0 (documented), and don't support
  672. squaresize_{x,y} = 1 in the way we'd like (undocumented). */
  673. void
  674. _pl_x_draw_elliptic_arc_internal (R___(Plotter *_plotter) int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange)
  675. {
  676. if (X_OOB_INT(xorigin) || X_OOB_INT(yorigin) || X_OOB_UNSIGNED(squaresize_x)
  677. || X_OOB_UNSIGNED(squaresize_y))
  678. /* dimensions can't be represented using X11's 2-byte ints, so punt */
  679. {
  680. _plotter->warning (R___(_plotter)
  681. "not drawing an arc that extends too far for X11");
  682. return;
  683. }
  684. if (_plotter->drawstate->fill_type)
  685. /* not transparent, so fill the arc */
  686. {
  687. /* update GC used for filling */
  688. _pl_x_set_attributes (R___(_plotter) X_GC_FOR_FILLING);
  689. /* select fill color as foreground color in GC used for filling */
  690. _pl_x_set_fill_color (S___(_plotter));
  691. if (squaresize_x <= 1 || squaresize_y <= 1)
  692. /* a special case, which XFillArc() doesn't handle in the way we'd
  693. like; just paint a single pixel, irrespective of angle range */
  694. {
  695. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  696. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
  697. _plotter->drawstate->x_gc_fill,
  698. xorigin, yorigin);
  699. else
  700. {
  701. if (_plotter->x_drawable1)
  702. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
  703. _plotter->drawstate->x_gc_fill,
  704. xorigin, yorigin);
  705. if (_plotter->x_drawable2)
  706. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
  707. _plotter->drawstate->x_gc_fill,
  708. xorigin, yorigin);
  709. }
  710. }
  711. else
  712. /* default case, almost always used */
  713. {
  714. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  715. XFillArc(_plotter->x_dpy, _plotter->x_drawable3,
  716. _plotter->drawstate->x_gc_fill,
  717. xorigin, yorigin, squaresize_x, squaresize_y,
  718. startangle, anglerange);
  719. else
  720. {
  721. if (_plotter->x_drawable1)
  722. XFillArc(_plotter->x_dpy, _plotter->x_drawable1,
  723. _plotter->drawstate->x_gc_fill,
  724. xorigin, yorigin, squaresize_x, squaresize_y,
  725. startangle, anglerange);
  726. if (_plotter->x_drawable2)
  727. XFillArc(_plotter->x_dpy, _plotter->x_drawable2,
  728. _plotter->drawstate->x_gc_fill,
  729. xorigin, yorigin, squaresize_x, squaresize_y,
  730. startangle, anglerange);
  731. }
  732. }
  733. }
  734. if (_plotter->drawstate->pen_type)
  735. /* pen is present, so edge the arc */
  736. {
  737. unsigned int sp_size = 0; /* keep compiler happy */
  738. /* update GC used for drawing */
  739. _pl_x_set_attributes (R___(_plotter) X_GC_FOR_DRAWING);
  740. /* select pen color as foreground color in GC used for drawing */
  741. _pl_x_set_pen_color (S___(_plotter));
  742. if (squaresize_x <= 1 || squaresize_y <= 1)
  743. /* Won't call XDrawArc in the usual way, because it performs poorly
  744. when one of these two is zero, at least. Irrespective of angle
  745. range, will fill a disk of diameter equal to line width */
  746. {
  747. int sp_offset;
  748. sp_size
  749. = (unsigned int)_plotter->drawstate->quantized_device_line_width;
  750. sp_offset
  751. = (int)(_plotter->drawstate->quantized_device_line_width + 1) / 2;
  752. if (sp_size == 0)
  753. sp_size = 1;
  754. xorigin -= sp_offset;
  755. yorigin -= sp_offset;
  756. }
  757. if (squaresize_x <= 1 || squaresize_y <= 1)
  758. /* special case */
  759. {
  760. if (sp_size == 1)
  761. /* special subcase: line width is small too, so just paint a
  762. single pixel rather than filling abovementioned disk */
  763. {
  764. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  765. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
  766. _plotter->drawstate->x_gc_fg,
  767. xorigin, yorigin);
  768. else
  769. {
  770. if (_plotter->x_drawable1)
  771. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
  772. _plotter->drawstate->x_gc_fg,
  773. xorigin, yorigin);
  774. if (_plotter->x_drawable2)
  775. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
  776. _plotter->drawstate->x_gc_fg,
  777. xorigin, yorigin);
  778. }
  779. }
  780. else
  781. /* normal version of special case: fill a disk of diameter
  782. equal to line width */
  783. {
  784. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  785. XFillArc(_plotter->x_dpy, _plotter->x_drawable3,
  786. _plotter->drawstate->x_gc_fg,
  787. xorigin, yorigin, sp_size, sp_size,
  788. 0, 64 * 360);
  789. else
  790. {
  791. if (_plotter->x_drawable1)
  792. XFillArc(_plotter->x_dpy, _plotter->x_drawable1,
  793. _plotter->drawstate->x_gc_fg,
  794. xorigin, yorigin, sp_size, sp_size,
  795. 0, 64 * 360);
  796. if (_plotter->x_drawable2)
  797. XFillArc(_plotter->x_dpy, _plotter->x_drawable2,
  798. _plotter->drawstate->x_gc_fg,
  799. xorigin, yorigin, sp_size, sp_size,
  800. 0, 64 * 360);
  801. }
  802. }
  803. }
  804. else
  805. /* default case, which is what is almost always used */
  806. {
  807. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  808. XDrawArc(_plotter->x_dpy, _plotter->x_drawable3,
  809. _plotter->drawstate->x_gc_fg,
  810. xorigin, yorigin, squaresize_x, squaresize_y,
  811. startangle, anglerange);
  812. else
  813. {
  814. if (_plotter->x_drawable1)
  815. XDrawArc(_plotter->x_dpy, _plotter->x_drawable1,
  816. _plotter->drawstate->x_gc_fg,
  817. xorigin, yorigin, squaresize_x, squaresize_y,
  818. startangle, anglerange);
  819. if (_plotter->x_drawable2)
  820. XDrawArc(_plotter->x_dpy, _plotter->x_drawable2,
  821. _plotter->drawstate->x_gc_fg,
  822. xorigin, yorigin, squaresize_x, squaresize_y,
  823. startangle, anglerange);
  824. }
  825. }
  826. }
  827. }
  828. /**********************************************************************/
  829. /* This version of the internal method path_is_flushable() is for XDrawable
  830. and X Plotters, which will under some circumstances `pre-draw', i.e.,
  831. draw line segments in real time. (This requires a zero line width and a
  832. "solid" line style.). In that case, this returns false; otherwise it
  833. will return true. */
  834. bool
  835. _pl_x_path_is_flushable (S___(Plotter *_plotter))
  836. {
  837. if (_plotter->drawstate->pen_type != 0 /* pen is present */
  838. && _plotter->drawstate->line_type == PL_L_SOLID
  839. && !_plotter->drawstate->dash_array_in_effect /* really solid */
  840. && _plotter->drawstate->points_are_connected /* really, really */
  841. && _plotter->drawstate->quantized_device_line_width == 0
  842. && !_plotter->drawstate->path->primitive) /* not a builtin */
  843. /* we're pre-drawing rather than drawing when endpath() is finally
  844. invoked, so flushing out a partially drawn path by invoking
  845. endpath() early would be absurd */
  846. return false;
  847. else
  848. /* endpath() will be invoked */
  849. return true;
  850. }
  851. /**********************************************************************/
  852. /* This version of the internal method maybe_prepaint_segments() is for
  853. XDrawable and X Plotters. It will draw line segments in real time if
  854. the line width is zero, the line style is "solid", and there's no
  855. filling to be done. Also, it requires that the polyline being drawn be
  856. unfilled, and not be one one of the polygonalized convex closed
  857. primitives (box/circle/ellipse).
  858. This hack makes it possible, after doing `graph -TX' (which has a
  859. default line width of zero), to type in points manually, and see the
  860. corresponding polyline drawn in real time. The `-x' and `-y' options
  861. must of course be specified too, to set the axis limits in advance. */
  862. void
  863. _pl_x_maybe_prepaint_segments (R___(Plotter *_plotter) int prev_num_segments)
  864. {
  865. int i;
  866. bool something_drawn = false;
  867. /* sanity check */
  868. if (_plotter->drawstate->path->num_segments < 2)
  869. return;
  870. if (_plotter->drawstate->path->num_segments == prev_num_segments)
  871. /* nothing to paint */
  872. return;
  873. /* Our criteria for pre-drawing line segments: zero-width solid line, and
  874. we're not drawing this line segment as part of a polygonalized
  875. built-in object (i.e. a rectangles or ellipse). If the criteria
  876. aren't met, we wait until endpath() is invoked, or in general until
  877. the path is flushed out, before painting it.
  878. If we pre-draw, we don't also draw when endpath() is invoked. One
  879. exception: if the polyline is to be filled. In that case, at endpath
  880. time, we'll fill it and re-edge it. */
  881. if (!(_plotter->drawstate->pen_type != 0 /* pen is present */
  882. && _plotter->drawstate->line_type == PL_L_SOLID
  883. && !_plotter->drawstate->dash_array_in_effect /* really solid */
  884. && _plotter->drawstate->points_are_connected /* really, really */
  885. && _plotter->drawstate->quantized_device_line_width == 0
  886. && !_plotter->drawstate->path->primitive)) /* not a built-in object */
  887. /* we're not pre-drawing */
  888. return;
  889. /* An X/XDrawable Plotter's segment list, at painting time, will only
  890. contain a polyline (i.e. a sequence of line segments) or a single
  891. circular or elliptic arc. That's because X/XDrawable Plotters can't
  892. handle `mixed paths'.
  893. Since they can't handle mixed paths, any single arc that's placed in a
  894. previously empty segment list will need to be replaced by a polygonal
  895. approximation, when and if additional segments need to be added. The
  896. maybe_replace_arc() function, which is invoked in the base Plotter
  897. code in several places, takes care of that.
  898. Because of this replacement procedure, maybe_prepaint_segments() may
  899. be invoked on a segment list that consists of a single moveto-arc or
  900. moveto-ellarc pair. We don't prepaint such things. Of course if the
  901. arc is subsequently replaced by a polygonal approximation, then we'll
  902. prepaint the polygonal approximation, at that time. */
  903. if (prev_num_segments == 0 &&
  904. _plotter->drawstate->path->num_segments == 2
  905. && _plotter->drawstate->path->segments[0].type == S_MOVETO
  906. && (_plotter->drawstate->path->segments[1].type == S_ARC
  907. || _plotter->drawstate->path->segments[1].type == S_ELLARC))
  908. return;
  909. if (prev_num_segments == 0)
  910. /* first segment of path; this must be a `moveto' */
  911. {
  912. /* update GC used for drawing */
  913. _pl_x_set_attributes (R___(_plotter) X_GC_FOR_DRAWING);
  914. /* select pen color as foreground color in GC used for drawing */
  915. _pl_x_set_pen_color (S___(_plotter));
  916. }
  917. /* Iterate over all segments to be painted. Because X/XDrawable Plotters
  918. can't handle `mixed paths', this function ends up being called only on
  919. sequences of line segments. */
  920. for (i = IMAX(1, prev_num_segments);
  921. i < _plotter->drawstate->path->num_segments;
  922. i++)
  923. {
  924. /* use same variables for points #1 and #2, since reusing them works
  925. around an obscure bug in gcc 2.7.2.3 that rears its head if -O2 is
  926. used */
  927. double xu, yu, xd, yd;
  928. double x, y;
  929. int x1, y1, x2, y2;
  930. /* starting and ending points for zero-width line segment: (xu,yu)
  931. and (x,y) respectively */
  932. xu = _plotter->drawstate->path->segments[i-1].p.x;
  933. yu = _plotter->drawstate->path->segments[i-1].p.y;
  934. x = _plotter->drawstate->path->segments[i].p.x;
  935. y = _plotter->drawstate->path->segments[i].p.y;
  936. /* convert to integer X11 coordinates */
  937. xd = XD(xu, yu);
  938. yd = YD(xu, yu);
  939. x1 = IROUND(xd);
  940. y1 = IROUND(yd);
  941. xd = XD(x,y);
  942. yd = YD(x,y);
  943. x2 = IROUND(xd);
  944. y2 = IROUND(yd);
  945. if (x1 != x2 || y1 != y2)
  946. /* line segment has nonzero length, so draw it */
  947. {
  948. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  949. /* double buffering, have a `x_drawable3' to draw into */
  950. XDrawLine (_plotter->x_dpy, _plotter->x_drawable3,
  951. _plotter->drawstate->x_gc_fg, x1, y1, x2, y2);
  952. else
  953. {
  954. if (_plotter->x_drawable1)
  955. XDrawLine (_plotter->x_dpy, _plotter->x_drawable1,
  956. _plotter->drawstate->x_gc_fg, x1, y1, x2, y2);
  957. if (_plotter->x_drawable2)
  958. XDrawLine (_plotter->x_dpy, _plotter->x_drawable2,
  959. _plotter->drawstate->x_gc_fg, x1, y1, x2, y2);
  960. }
  961. something_drawn = true;
  962. }
  963. else
  964. /* line segment in terms of integer device coordinates has zero
  965. length; but if it has nonzero length in user coordinates, draw
  966. it as a single pixel unless cap type is "butt" */
  967. if (!(_plotter->drawstate->cap_type == PL_CAP_BUTT
  968. && xu == x && yu == y))
  969. {
  970. if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
  971. /* double buffering, have a `x_drawable3' to draw into */
  972. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
  973. _plotter->drawstate->x_gc_fg,
  974. x1, y1);
  975. else
  976. /* not double buffering */
  977. {
  978. if (_plotter->x_drawable1)
  979. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
  980. _plotter->drawstate->x_gc_fg,
  981. x1, y1);
  982. if (_plotter->x_drawable2)
  983. XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
  984. _plotter->drawstate->x_gc_fg,
  985. x1, y1);
  986. }
  987. something_drawn = true;
  988. }
  989. }
  990. if (something_drawn)
  991. /* maybe flush X output buffer and handle X events (a no-op for
  992. XDrawablePlotters, which is overridden for XPlotters) */
  993. _maybe_handle_x_events (S___(_plotter));
  994. }
  995. bool
  996. _pl_x_paint_paths (S___(Plotter *_plotter))
  997. {
  998. return false;
  999. }