12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130 |
- #include "sys-defines.h"
- #include "extern.h"
- #define MAX_NUM_POINTS_ON_STACK 128
- #define DIST(p1, p2) sqrt( ((p1).x - (p2).x) * ((p1).x - (p2).x) \
- + ((p1).y - (p2).y) * ((p1).y - (p2).y))
- void
- _pl_x_paint_path (S___(Plotter *_plotter))
- {
- if (_plotter->drawstate->pen_type == 0
- && _plotter->drawstate->fill_type == 0)
-
- return;
- switch ((int)_plotter->drawstate->path->type)
- {
- case (int)PATH_SEGMENT_LIST:
- {
- bool closed;
- int is_a_rectangle;
- int i, polyline_len;
- plPoint p0, p1, pc;
- XPoint *xarray, local_xarray[MAX_NUM_POINTS_ON_STACK];
- bool heap_storage;
- double xu_last, yu_last;
- bool identical_user_coordinates;
-
-
- if (_plotter->drawstate->path->num_segments == 0)
- break;
- if (_plotter->drawstate->path->num_segments == 1)
- break;
- if (_plotter->drawstate->path->num_segments == 2
- && _plotter->drawstate->path->segments[1].type == S_ARC)
-
- {
- p0 = _plotter->drawstate->path->segments[0].p;
- p1 = _plotter->drawstate->path->segments[1].p;
- pc = _plotter->drawstate->path->segments[1].pc;
-
-
- _pl_x_draw_elliptic_arc (R___(_plotter) p0, p1, pc);
- break;
- }
- if (_plotter->drawstate->path->num_segments == 2
- && _plotter->drawstate->path->segments[1].type == S_ELLARC)
-
- {
- p0 = _plotter->drawstate->path->segments[0].p;
- p1 = _plotter->drawstate->path->segments[1].p;
- pc = _plotter->drawstate->path->segments[1].pc;
-
-
- _pl_x_draw_elliptic_arc_2 (R___(_plotter) p0, p1, pc);
-
- break;
- }
-
- if ((_plotter->drawstate->path->num_segments >= 3)
- && (_plotter->drawstate->path->segments[_plotter->drawstate->path->num_segments - 1].p.x == _plotter->drawstate->path->segments[0].p.x)
- && (_plotter->drawstate->path->segments[_plotter->drawstate->path->num_segments - 1].p.y == _plotter->drawstate->path->segments[0].p.y))
- closed = true;
- else
- closed = false;
-
-
- if ((_plotter->drawstate->pen_type != 0
- && _plotter->drawstate->line_type == PL_L_SOLID
- && !_plotter->drawstate->dash_array_in_effect
- && _plotter->drawstate->points_are_connected
- && _plotter->drawstate->quantized_device_line_width == 0
- && !_plotter->drawstate->path->primitive)
-
- &&
- _plotter->drawstate->fill_type == 0)
-
- break;
-
-
- if (_plotter->drawstate->path->num_segments
- <= MAX_NUM_POINTS_ON_STACK)
-
- {
- xarray = local_xarray;
- heap_storage = false;
- }
- else
-
- {
- xarray = (XPoint *)_pl_xmalloc (_plotter->drawstate->path->num_segments * sizeof(XPoint));
- heap_storage = true;
- }
-
-
-
- polyline_len = 0;
- xu_last = 0.0;
- yu_last = 0.0;
- identical_user_coordinates = true;
- for (i = 0; i < _plotter->drawstate->path->num_segments; i++)
- {
- plPathSegment datapoint;
- double xu, yu, xd, yd;
- int device_x, device_y;
-
- datapoint = _plotter->drawstate->path->segments[i];
- xu = datapoint.p.x;
- yu = datapoint.p.y;
- xd = XD(xu, yu);
- yd = YD(xu, yu);
- device_x = IROUND(xd);
- device_y = IROUND(yd);
-
- if (X_OOB_INT(device_x) || X_OOB_INT(device_y))
-
- {
- _plotter->warning (R___(_plotter)
- "truncating a polyline that extends too far for X11");
- break;
- }
-
- if (i > 0 && (xu != xu_last || yu != yu_last))
-
- identical_user_coordinates = false;
-
- if ((polyline_len == 0)
- || (device_x != xarray[polyline_len-1].x)
- || (device_y != xarray[polyline_len-1].y))
-
- {
- xarray[polyline_len].x = device_x;
- xarray[polyline_len].y = device_y;
- polyline_len++;
-
- if (polyline_len >= _plotter->x_max_polyline_len)
-
- {
- _plotter->warning (R___(_plotter)
- "truncating a polyline that's too long for the X display");
- break;
- }
- }
-
- xu_last = xu;
- yu_last = yu;
- }
-
-
-
- #define IS_A_RECTANGLE(len,q) \
- ((len) == 5 && (q)[0].x == (q)[4].x && (q)[0].y == (q)[4].y && \
- (q)[0].x == (q)[3].x && (q)[1].x == (q)[2].x && \
- (q)[0].y == (q)[1].y && (q)[2].y == (q)[3].y && \
- (q)[0].x < (q)[1].x && (q)[0].y > (q)[2].y)
- is_a_rectangle = IS_A_RECTANGLE(polyline_len, xarray);
-
-
-
-
-
- if (_plotter->drawstate->fill_type)
-
- {
- int x_polygon_type
- = (_plotter->drawstate->path->primitive ? Convex : Complex);
-
-
- _pl_x_set_attributes (R___(_plotter) X_GC_FOR_FILLING);
-
-
- _pl_x_set_fill_color (S___(_plotter));
-
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
- {
- if (_plotter->drawstate->path->num_segments > 1
- && polyline_len == 1)
-
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fill,
- (int)(xarray[0].x), (int)(xarray[0].y));
- else
-
- {
- if (is_a_rectangle)
-
- XFillRectangle (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fill,
- (int)(xarray[3].x), (int)(xarray[3].y),
- (unsigned int)(xarray[1].x - xarray[0].x),
-
- (unsigned int)(xarray[0].y - xarray[2].y));
- else
-
- XFillPolygon (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fill,
- xarray, polyline_len,
- x_polygon_type, CoordModeOrigin);
- }
- }
- else
- {
- if (_plotter->drawstate->path->num_segments > 1
- && polyline_len == 1)
-
- {
- if (_plotter->x_drawable1)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fill,
- (int)(xarray[0].x), (int)(xarray[0].y));
- if (_plotter->x_drawable2)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fill,
- (int)(xarray[0].x), (int)(xarray[0].y));
- }
- else
-
- {
- if (is_a_rectangle)
-
- {
- if (_plotter->x_drawable1)
- XFillRectangle (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fill,
- (int)(xarray[3].x), (int)(xarray[3].y),
- (unsigned int)(xarray[1].x - xarray[0].x),
-
- (unsigned int)(xarray[0].y - xarray[2].y));
- if (_plotter->x_drawable2)
- XFillRectangle (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fill,
- (int)(xarray[3].x), (int)(xarray[3].y),
- (unsigned int)(xarray[1].x - xarray[0].x),
-
- (unsigned int)(xarray[0].y - xarray[2].y));
- }
- else
-
- {
- if (_plotter->x_drawable1)
- XFillPolygon (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fill,
- xarray, polyline_len,
- x_polygon_type, CoordModeOrigin);
- if (_plotter->x_drawable2)
- XFillPolygon (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fill,
- xarray, polyline_len,
- x_polygon_type, CoordModeOrigin);
- }
- }
- }
- }
-
-
-
- if (_plotter->drawstate->pen_type)
-
- {
- int xloc = 0, yloc = 0;
- unsigned int sp_size = 1;
-
- _pl_x_set_attributes (R___(_plotter) X_GC_FOR_DRAWING);
-
-
- _pl_x_set_pen_color (S___(_plotter));
-
-
-
- if (_plotter->drawstate->path->num_segments > 1
- && polyline_len == 1)
-
- {
- int sp_offset;
- sp_size = (unsigned int)_plotter->drawstate->quantized_device_line_width;
- if (sp_size == 0)
- sp_size = 1;
- sp_offset = (_plotter->drawstate->quantized_device_line_width + 1) / 2;
- xloc = xarray[0].x - sp_offset;
- yloc = xarray[0].y - sp_offset;
- }
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
-
- {
- if (_plotter->drawstate->path->num_segments > 1
- && polyline_len == 1)
-
- {
- if (identical_user_coordinates == false
- || _plotter->drawstate->cap_type == PL_CAP_ROUND)
- {
- if (sp_size == 1)
-
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- (int)(xarray[0].x), (int)(xarray[0].y));
- else
-
- XFillArc(_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- xloc, yloc, sp_size, sp_size,
- 0, 64 * 360);
- }
- }
- else
-
-
- {
- if (is_a_rectangle
- && _plotter->drawstate->dash_array_in_effect == false
- && _plotter->drawstate->line_type == PL_L_SOLID)
-
- XDrawRectangle (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- (int)(xarray[3].x), (int)(xarray[3].y),
- (unsigned int)(xarray[1].x - xarray[0].x),
-
- (unsigned int)(xarray[0].y - xarray[2].y));
- else
-
- XDrawLines (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- xarray, polyline_len,
- CoordModeOrigin);
- }
- }
- else
-
- {
- if (_plotter->drawstate->path->num_segments > 1
- && polyline_len == 1)
-
- {
- if (identical_user_coordinates == false
- || _plotter->drawstate->cap_type == PL_CAP_ROUND)
- {
- if (sp_size == 1)
-
- {
- if (_plotter->x_drawable1)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- (int)(xarray[0].x), (int)(xarray[0].y));
- if (_plotter->x_drawable2)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- (int)(xarray[0].x), (int)(xarray[0].y));
- }
- else
-
- {
- if (_plotter->x_drawable1)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- xloc, yloc, sp_size, sp_size,
- 0, 64 * 360);
- if (_plotter->x_drawable2)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- xloc, yloc, sp_size, sp_size,
- 0, 64 * 360);
- }
- }
- }
- else
-
-
- {
- if (is_a_rectangle
- && _plotter->drawstate->dash_array_in_effect == false
- && _plotter->drawstate->line_type == PL_L_SOLID)
-
- {
- if (_plotter->x_drawable1)
- XDrawRectangle (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- (int)(xarray[3].x), (int)(xarray[3].y),
- (unsigned int)(xarray[1].x - xarray[0].x),
-
- (unsigned int)(xarray[0].y - xarray[2].y));
- if (_plotter->x_drawable2)
- XDrawRectangle (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- (int)(xarray[3].x), (int)(xarray[3].y),
- (unsigned int)(xarray[1].x - xarray[0].x),
-
- (unsigned int)(xarray[0].y - xarray[2].y));
- }
- else
-
- {
- if (_plotter->x_drawable1)
- XDrawLines (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- xarray, polyline_len,
- CoordModeOrigin);
- if (_plotter->x_drawable2)
- XDrawLines (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- xarray, polyline_len,
- CoordModeOrigin);
- }
- }
- }
- }
-
-
- if (_plotter->drawstate->path->num_segments > 0)
- {
- if (heap_storage)
- free (xarray);
- }
- }
- break;
-
- case (int)PATH_ELLIPSE:
- {
- int ninetymult;
- int x_orientation, y_orientation;
- int xorigin, yorigin;
- unsigned int squaresize_x, squaresize_y;
- plPoint pc;
- double rx, ry, angle;
- pc = _plotter->drawstate->path->pc;
- rx = _plotter->drawstate->path->rx;
- ry = _plotter->drawstate->path->ry;
- angle = _plotter->drawstate->path->angle;
-
- ninetymult = IROUND(angle / 90.0);
- if (angle == (double) (90 * ninetymult))
- {
- angle = 0.0;
- if (ninetymult % 2)
- {
- double temp;
-
- temp = rx;
- rx = ry;
- ry = temp;
- }
- }
-
- rx = (rx < 0.0 ? -rx : rx);
- ry = (ry < 0.0 ? -ry : ry);
-
-
- x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
- y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
-
-
- xorigin = IROUND(XD(pc.x - x_orientation * rx,
- pc.y - y_orientation * ry));
- yorigin = IROUND(YD(pc.x - x_orientation * rx,
- pc.y - y_orientation * ry));
- squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * rx, 0.0));
- squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * ry));
-
-
- _pl_x_draw_elliptic_arc_internal (R___(_plotter)
- xorigin, yorigin,
- squaresize_x, squaresize_y,
- 0, 64 * 360);
- }
- break;
- default:
- break;
- }
-
- _maybe_handle_x_events (S___(_plotter));
- }
-
- void
- _pl_x_draw_elliptic_arc (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
- {
- double radius;
- double theta0, theta1;
- int startangle, anglerange;
- int x_orientation, y_orientation;
- int xorigin, yorigin;
- unsigned int squaresize_x, squaresize_y;
-
- x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
- y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
-
- radius = DIST(pc, p0);
-
- xorigin = IROUND(XD(pc.x - x_orientation * radius,
- pc.y - y_orientation * radius));
- yorigin = IROUND(YD(pc.x - x_orientation * radius,
- pc.y - y_orientation * radius));
- squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * radius, 0.0));
- squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * radius));
- theta0 = _xatan2 (-y_orientation * (p0.y - pc.y),
- x_orientation * (p0.x - pc.x)) / M_PI;
- theta1 = _xatan2 (-y_orientation * (p1.y - pc.y),
- x_orientation * (p1.x - pc.x)) / M_PI;
- if (theta1 < theta0)
- theta1 += 2.0;
- if (theta0 < 0.0)
- {
- theta0 += 2.0;
- theta1 += 2.0;
- }
- if (theta1 - theta0 > 1.0)
- {
- double tmp;
-
- tmp = theta0;
- theta0 = theta1;
- theta1 = tmp;
- theta1 += 2.0;
- }
- if (theta0 >= 2.0 && theta1 >= 2.0)
-
- {
- theta0 -= 2.0;
- theta1 -= 2.0;
- }
- startangle = IROUND(64 * theta0 * 180.0);
- anglerange = IROUND(64 * (theta1 - theta0) * 180.0);
- _pl_x_draw_elliptic_arc_internal (R___(_plotter)
- xorigin, yorigin,
- squaresize_x, squaresize_y,
- startangle, anglerange);
- }
- void
- _pl_x_draw_elliptic_arc_2 (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
- {
- double rx, ry;
- double x0, y0, x1, y1, xc, yc;
- int startangle, endangle, anglerange;
- int x_orientation, y_orientation;
- int xorigin, yorigin;
- unsigned int squaresize_x, squaresize_y;
-
- x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
- y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
- xc = pc.x, yc = pc.y;
- x0 = p0.x, y0 = p0.y;
- x1 = p1.x, y1 = p1.y;
- if (y0 == yc && x1 == xc)
-
- {
-
- rx = (x0 > xc) ? x0 - xc : xc - x0;
- ry = (y1 > yc) ? y1 - yc : yc - y1;
-
- startangle = ((x0 > xc ? 1 : -1) * x_orientation == 1) ? 0 : 180;
- endangle = ((y1 > yc ? 1 : -1) * y_orientation == -1) ? 90 : 270;
- }
- else
-
- {
-
- rx = (x1 > xc) ? x1 - xc : xc - x1;
- ry = (y0 > yc) ? y0 - yc : yc - y0;
-
- startangle = ((y0 > yc ? 1 : -1) * y_orientation == -1) ? 90 : 270;
- endangle = ((x1 > xc ? 1 : -1) * x_orientation == 1) ? 0 : 180;
- }
- if (endangle < startangle)
- endangle += 360;
- anglerange = endangle - startangle;
-
- if (anglerange == 270)
- {
- int tmp;
- tmp = startangle;
- startangle = endangle;
- endangle = tmp;
- anglerange = 90;
- }
-
- if (startangle >= 360)
-
- startangle -= 360;
-
- xorigin = IROUND(XD(xc - x_orientation * rx,
- yc - y_orientation * ry));
- yorigin = IROUND(YD(xc - x_orientation * rx,
- yc - y_orientation * ry));
- squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * rx, 0.0));
- squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * ry));
-
-
- startangle *= 64;
- anglerange *= 64;
- _pl_x_draw_elliptic_arc_internal (R___(_plotter)
- xorigin, yorigin,
- squaresize_x, squaresize_y,
- startangle, anglerange);
- }
- void
- _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)
- {
- if (X_OOB_INT(xorigin) || X_OOB_INT(yorigin) || X_OOB_UNSIGNED(squaresize_x)
- || X_OOB_UNSIGNED(squaresize_y))
-
- {
- _plotter->warning (R___(_plotter)
- "not drawing an arc that extends too far for X11");
- return;
- }
- if (_plotter->drawstate->fill_type)
-
- {
-
- _pl_x_set_attributes (R___(_plotter) X_GC_FOR_FILLING);
-
- _pl_x_set_fill_color (S___(_plotter));
- if (squaresize_x <= 1 || squaresize_y <= 1)
-
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fill,
- xorigin, yorigin);
- else
- {
- if (_plotter->x_drawable1)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fill,
- xorigin, yorigin);
- if (_plotter->x_drawable2)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fill,
- xorigin, yorigin);
- }
- }
- else
-
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fill,
- xorigin, yorigin, squaresize_x, squaresize_y,
- startangle, anglerange);
- else
- {
- if (_plotter->x_drawable1)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fill,
- xorigin, yorigin, squaresize_x, squaresize_y,
- startangle, anglerange);
- if (_plotter->x_drawable2)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fill,
- xorigin, yorigin, squaresize_x, squaresize_y,
- startangle, anglerange);
- }
- }
- }
-
- if (_plotter->drawstate->pen_type)
-
- {
- unsigned int sp_size = 0;
-
- _pl_x_set_attributes (R___(_plotter) X_GC_FOR_DRAWING);
-
-
- _pl_x_set_pen_color (S___(_plotter));
-
- if (squaresize_x <= 1 || squaresize_y <= 1)
-
- {
- int sp_offset;
- sp_size
- = (unsigned int)_plotter->drawstate->quantized_device_line_width;
- sp_offset
- = (int)(_plotter->drawstate->quantized_device_line_width + 1) / 2;
-
- if (sp_size == 0)
- sp_size = 1;
- xorigin -= sp_offset;
- yorigin -= sp_offset;
- }
- if (squaresize_x <= 1 || squaresize_y <= 1)
-
- {
- if (sp_size == 1)
-
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin);
- else
- {
- if (_plotter->x_drawable1)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin);
- if (_plotter->x_drawable2)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin);
- }
- }
- else
-
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin, sp_size, sp_size,
- 0, 64 * 360);
- else
- {
- if (_plotter->x_drawable1)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin, sp_size, sp_size,
- 0, 64 * 360);
- if (_plotter->x_drawable2)
- XFillArc(_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin, sp_size, sp_size,
- 0, 64 * 360);
- }
- }
- }
- else
-
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
- XDrawArc(_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin, squaresize_x, squaresize_y,
- startangle, anglerange);
- else
- {
- if (_plotter->x_drawable1)
- XDrawArc(_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin, squaresize_x, squaresize_y,
- startangle, anglerange);
- if (_plotter->x_drawable2)
- XDrawArc(_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- xorigin, yorigin, squaresize_x, squaresize_y,
- startangle, anglerange);
- }
- }
- }
- }
- bool
- _pl_x_path_is_flushable (S___(Plotter *_plotter))
- {
- if (_plotter->drawstate->pen_type != 0
- && _plotter->drawstate->line_type == PL_L_SOLID
- && !_plotter->drawstate->dash_array_in_effect
- && _plotter->drawstate->points_are_connected
- && _plotter->drawstate->quantized_device_line_width == 0
- && !_plotter->drawstate->path->primitive)
-
- return false;
- else
-
- return true;
- }
- void
- _pl_x_maybe_prepaint_segments (R___(Plotter *_plotter) int prev_num_segments)
- {
- int i;
- bool something_drawn = false;
-
- if (_plotter->drawstate->path->num_segments < 2)
- return;
- if (_plotter->drawstate->path->num_segments == prev_num_segments)
-
- return;
-
- if (!(_plotter->drawstate->pen_type != 0
- && _plotter->drawstate->line_type == PL_L_SOLID
- && !_plotter->drawstate->dash_array_in_effect
- && _plotter->drawstate->points_are_connected
- && _plotter->drawstate->quantized_device_line_width == 0
- && !_plotter->drawstate->path->primitive))
-
- return;
-
- if (prev_num_segments == 0 &&
- _plotter->drawstate->path->num_segments == 2
- && _plotter->drawstate->path->segments[0].type == S_MOVETO
- && (_plotter->drawstate->path->segments[1].type == S_ARC
- || _plotter->drawstate->path->segments[1].type == S_ELLARC))
- return;
- if (prev_num_segments == 0)
-
- {
-
- _pl_x_set_attributes (R___(_plotter) X_GC_FOR_DRAWING);
-
-
- _pl_x_set_pen_color (S___(_plotter));
- }
-
-
- for (i = IMAX(1, prev_num_segments);
- i < _plotter->drawstate->path->num_segments;
- i++)
- {
-
- double xu, yu, xd, yd;
- double x, y;
- int x1, y1, x2, y2;
-
- xu = _plotter->drawstate->path->segments[i-1].p.x;
- yu = _plotter->drawstate->path->segments[i-1].p.y;
- x = _plotter->drawstate->path->segments[i].p.x;
- y = _plotter->drawstate->path->segments[i].p.y;
-
-
- xd = XD(xu, yu);
- yd = YD(xu, yu);
- x1 = IROUND(xd);
- y1 = IROUND(yd);
- xd = XD(x,y);
- yd = YD(x,y);
- x2 = IROUND(xd);
- y2 = IROUND(yd);
-
- if (x1 != x2 || y1 != y2)
-
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
-
- XDrawLine (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg, x1, y1, x2, y2);
- else
- {
- if (_plotter->x_drawable1)
- XDrawLine (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg, x1, y1, x2, y2);
- if (_plotter->x_drawable2)
- XDrawLine (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg, x1, y1, x2, y2);
- }
-
- something_drawn = true;
- }
- else
-
- if (!(_plotter->drawstate->cap_type == PL_CAP_BUTT
- && xu == x && yu == y))
- {
- if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
-
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3,
- _plotter->drawstate->x_gc_fg,
- x1, y1);
- else
-
- {
- if (_plotter->x_drawable1)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1,
- _plotter->drawstate->x_gc_fg,
- x1, y1);
- if (_plotter->x_drawable2)
- XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2,
- _plotter->drawstate->x_gc_fg,
- x1, y1);
- }
- something_drawn = true;
- }
- }
-
- if (something_drawn)
-
- _maybe_handle_x_events (S___(_plotter));
- }
- bool
- _pl_x_paint_paths (S___(Plotter *_plotter))
- {
- return false;
- }
|