47 #define round(x) ceil((double)(x))
66 rotate_point(GdkPoint point,
double angle) {
73 sint = sin(DEG2RAD(-angle));
74 cost = cos(DEG2RAD(-angle));
76 returned.x = lround(cost * point.x - sint * point.y);
77 returned.y = lround(sint * point.x + cost * point.y);
86 gerbv_gdk_draw_prim1(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
87 const int exposure_idx = 0;
88 const int diameter_idx = 1;
89 const int x_offset_idx = 2;
90 const int y_offset_idx = 3;
91 const gint full_circle = 23360;
92 GdkGC* local_gc = gdk_gc_new(pixmap);
93 gint dia = round(fabs(s->parameter[diameter_idx] * scale));
94 gint real_x = x - dia / 2;
95 gint real_y = y - dia / 2;
98 gdk_gc_copy(local_gc, gc);
100 real_x += (int)(s->parameter[x_offset_idx] * (
double)scale);
101 real_y -= (int)(s->parameter[y_offset_idx] * (
double)scale);
104 if (s->parameter[exposure_idx] == 0.0) {
106 gdk_gc_set_foreground(local_gc, &color);
109 gdk_gc_set_line_attributes(
111 GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
117 gdk_draw_arc(pixmap, local_gc, 1, real_x, real_y, dia, dia, 0, full_circle);
119 gdk_gc_unref(local_gc);
130 gerbv_gdk_draw_prim4(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
131 const int exposure_idx = 0;
132 const int nuf_points_idx = 1;
133 const int first_x_idx = 2;
134 const int first_y_idx = 3;
135 const int rotext_idx = 4;
136 GdkGC* local_gc = gdk_gc_new(pixmap);
137 int nuf_points, point;
143 nuf_points = (int)s->parameter[nuf_points_idx] + 1;
144 points = g_new(GdkPoint, nuf_points);
150 rotation = s->parameter[(nuf_points - 1) * 2 + rotext_idx];
151 for (point = 0; point < nuf_points; point++) {
152 points[point].x = (int)round(scale * s->parameter[point * 2 + first_x_idx]);
153 points[point].y = -(int)round(scale * s->parameter[point * 2 + first_y_idx]);
155 points[point] = rotate_point(points[point], rotation);
156 points[point].x += x;
157 points[point].y += y;
160 gdk_gc_copy(local_gc, gc);
163 if (s->parameter[exposure_idx] == 0.0) {
165 gdk_gc_set_foreground(local_gc, &color);
168 gdk_gc_set_line_attributes(
170 GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
172 gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_points);
176 gdk_gc_unref(local_gc);
185 gerbv_gdk_draw_prim5(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
186 const int exposure_idx = 0;
187 const int nuf_vertices_idx = 1;
188 const int center_x_idx = 2;
189 const int center_y_idx = 3;
190 const int diameter_idx = 4;
191 const int rotation_idx = 5;
193 double vertex, tick, rotation, radius;
195 GdkGC* local_gc = gdk_gc_new(pixmap);
198 nuf_vertices = (int)s->parameter[nuf_vertices_idx];
199 points = g_new(GdkPoint, nuf_vertices);
205 gdk_gc_copy(local_gc, gc);
208 if (s->parameter[exposure_idx] == 0.0) {
210 gdk_gc_set_foreground(local_gc, &color);
213 tick = 2 * M_PI / (double)nuf_vertices;
214 rotation = DEG2RAD(-s->parameter[rotation_idx]);
215 radius = s->parameter[diameter_idx] / 2.0;
216 for (i = 0; i < nuf_vertices; i++) {
217 vertex = tick * (double)i + rotation;
218 points[i].x = (int)round(scale * (radius * cos(vertex) + s->parameter[center_x_idx])) + x;
219 points[i].y = (int)round(scale * (radius * sin(vertex) - s->parameter[center_y_idx])) + y;
222 gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_vertices);
224 gdk_gc_unref(local_gc);
237 gerbv_gdk_draw_prim6(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
238 const int outside_dia_idx = 2;
239 const int ci_thickness_idx = 3;
240 const int gap_idx = 4;
241 const int nuf_circles_idx = 5;
242 const int ch_thickness_idx = 6;
243 const int ch_length_idx = 7;
244 const int rotation_idx = 8;
245 GdkGC* local_gc = gdk_gc_new(pixmap);
247 double real_dia_diff;
249 GdkPoint crosshair[4];
252 gdk_gc_copy(local_gc, gc);
253 gdk_gc_set_line_attributes(
254 local_gc, (
int)round(scale * s->parameter[ci_thickness_idx]), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
257 real_dia = s->parameter[outside_dia_idx] - s->parameter[ci_thickness_idx] / 2.0;
258 real_dia_diff = 2 * (s->parameter[gap_idx] + s->parameter[ci_thickness_idx]);
260 for (circle = 0; circle != (int)s->parameter[nuf_circles_idx]; circle++) {
264 const gint full_circle = 23360;
265 gint dia = (real_dia - real_dia_diff * circle) * scale;
267 gdk_draw_arc(pixmap, local_gc, 0, x - dia / 2, y - dia / 2, dia, dia, 0, full_circle);
274 memset(crosshair, 0,
sizeof(GdkPoint) * 4);
275 crosshair[0].x = (int)((s->parameter[ch_length_idx] / 2.0) * scale);
277 crosshair[1].x = -crosshair[0].x;
280 crosshair[2].y = crosshair[0].x;
282 crosshair[3].y = -crosshair[0].x;
284 gdk_gc_set_line_attributes(
285 local_gc, (
int)round(scale * s->parameter[ch_thickness_idx]), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
288 for (point = 0; point < 4; point++) {
289 crosshair[point] = rotate_point(crosshair[point], s->parameter[rotation_idx]);
290 crosshair[point].x += x;
291 crosshair[point].y += y;
293 gdk_draw_line(pixmap, local_gc, crosshair[0].x, crosshair[0].y, crosshair[1].x, crosshair[1].y);
294 gdk_draw_line(pixmap, local_gc, crosshair[2].x, crosshair[2].y, crosshair[3].x, crosshair[3].y);
296 gdk_gc_unref(local_gc);
302 gerbv_gdk_draw_prim7(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
303 const int outside_dia_idx = 2;
304 const int inside_dia_idx = 3;
305 const int ch_thickness_idx = 4;
306 const int rotation_idx = 5;
307 const gint full_circle = 23360;
310 GdkGC* local_gc = gdk_gc_new(pixmap);
312 double ci_thickness = (s->parameter[outside_dia_idx] - s->parameter[inside_dia_idx]) / 2.0;
314 gdk_gc_copy(local_gc, gc);
315 gdk_gc_set_line_attributes(
316 local_gc, (
int)round(scale * ci_thickness), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
322 diameter = (s->parameter[inside_dia_idx] + ci_thickness) * scale;
323 gdk_draw_arc(pixmap, local_gc, 0, x - diameter / 2, y - diameter / 2, diameter, diameter, 0, full_circle);
332 for (i = 0; i < 4; i++) {
333 point[i].x = round((s->parameter[outside_dia_idx] / 2.0) * scale) + 2;
335 point[i] = rotate_point(point[i], s->parameter[rotation_idx] + 90 * i);
340 gdk_gc_set_line_attributes(
341 local_gc, (
int)round(scale * s->parameter[ch_thickness_idx]), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
345 gdk_gc_get_values(local_gc, &gc_val);
346 if (gc_val.foreground.pixel == 1)
347 gc_val.foreground.pixel = 0;
349 gc_val.foreground.pixel = 1;
350 gdk_gc_set_foreground(local_gc, &(gc_val.foreground));
353 gdk_draw_line(pixmap, local_gc, point[0].x, point[0].y, point[2].x, point[2].y);
354 gdk_draw_line(pixmap, local_gc, point[1].x, point[1].y, point[3].x, point[3].y);
356 gdk_gc_unref(local_gc);
365 gerbv_gdk_draw_prim20(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
366 const int exposure_idx = 0;
367 const int linewidth_idx = 1;
368 const int start_x_idx = 2;
369 const int start_y_idx = 3;
370 const int end_x_idx = 4;
371 const int end_y_idx = 5;
372 const int rotation_idx = 6;
373 const int nuf_points = 2;
374 GdkGC* local_gc = gdk_gc_new(pixmap);
375 GdkPoint points[nuf_points];
379 gdk_gc_copy(local_gc, gc);
382 if (s->parameter[exposure_idx] == 0.0) {
384 gdk_gc_set_foreground(local_gc, &color);
387 gdk_gc_set_line_attributes(
388 local_gc, (
int)round(scale * s->parameter[linewidth_idx]), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER
391 points[0].x = (s->parameter[start_x_idx] * scale);
392 points[0].y = (s->parameter[start_y_idx] * scale);
393 points[1].x = (s->parameter[end_x_idx] * scale);
394 points[1].y = (s->parameter[end_y_idx] * scale);
396 for (i = 0; i < nuf_points; i++) {
397 points[i] = rotate_point(points[i], -s->parameter[rotation_idx]);
398 points[i].x = x + points[i].x;
399 points[i].y = y - points[i].y;
402 gdk_draw_line(pixmap, local_gc, points[0].x, points[0].y, points[1].x, points[1].y);
404 gdk_gc_unref(local_gc);
410 gerbv_gdk_draw_prim21(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
411 const int exposure_idx = 0;
412 const int width_idx = 1;
413 const int height_idx = 2;
414 const int exp_x_idx = 3;
415 const int exp_y_idx = 4;
416 const int rotation_idx = 5;
417 const int nuf_points = 4;
418 GdkPoint points[nuf_points];
420 GdkGC* local_gc = gdk_gc_new(pixmap);
421 int half_width, half_height;
424 half_width = (int)round(s->parameter[width_idx] * scale / 2.0);
425 half_height = (int)round(s->parameter[height_idx] * scale / 2.0);
427 points[0].x = half_width;
428 points[0].y = half_height;
430 points[1].x = half_width;
431 points[1].y = -half_height;
433 points[2].x = -half_width;
434 points[2].y = -half_height;
436 points[3].x = -half_width;
437 points[3].y = half_height;
439 for (i = 0; i < nuf_points; i++) {
440 points[i].x += (int)(s->parameter[exp_x_idx] * scale);
441 points[i].y -= (int)(s->parameter[exp_y_idx] * scale);
442 points[i] = rotate_point(points[i], s->parameter[rotation_idx]);
447 gdk_gc_copy(local_gc, gc);
450 if (s->parameter[exposure_idx] == 0.0) {
452 gdk_gc_set_foreground(local_gc, &color);
455 gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_points);
457 gdk_gc_unref(local_gc);
466 gerbv_gdk_draw_prim22(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
467 const int exposure_idx = 0;
468 const int width_idx = 1;
469 const int height_idx = 2;
470 const int x_lower_left_idx = 3;
471 const int y_lower_left_idx = 4;
472 const int rotation_idx = 5;
473 const int nuf_points = 4;
474 GdkPoint points[nuf_points];
475 GdkGC* local_gc = gdk_gc_new(pixmap);
479 points[0].x = (int)round(s->parameter[x_lower_left_idx] * scale);
480 points[0].y = (int)round(s->parameter[y_lower_left_idx] * scale);
482 points[1].x = (int)round((s->parameter[x_lower_left_idx] + s->parameter[width_idx]) * scale);
483 points[1].y = (int)round(s->parameter[y_lower_left_idx] * scale);
485 points[2].x = (int)round((s->parameter[x_lower_left_idx] + s->parameter[width_idx]) * scale);
486 points[2].y = (int)round((s->parameter[y_lower_left_idx] + s->parameter[height_idx]) * scale);
488 points[3].x = (int)round(s->parameter[x_lower_left_idx] * scale);
489 points[3].y = (int)round((s->parameter[y_lower_left_idx] + s->parameter[height_idx]) * scale);
491 for (i = 0; i < nuf_points; i++) {
492 points[i] = rotate_point(points[i], -s->parameter[rotation_idx]);
493 points[i].x = x + points[i].x;
494 points[i].y = y - points[i].y;
497 gdk_gc_copy(local_gc, gc);
500 if (s->parameter[exposure_idx] == 0.0) {
502 gdk_gc_set_foreground(local_gc, &color);
505 gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_points);
507 gdk_gc_unref(local_gc);
513 static void (*dgk_draw_amacro_funcs[])(GdkPixmap*, GdkGC*, gerbv_simplified_amacro_t*, double, gint, gint) = {
521 gerbv_gdk_draw_amacro(GdkPixmap* pixmap, GdkGC* gc, gerbv_simplified_amacro_t* s,
double scale, gint x, gint y) {
522 dprintf(
"%s(): drawing simplified aperture macros:\n", __func__);
526 dgk_draw_amacro_funcs[s->type](pixmap, gc, s, scale, x, y);
529 GERB_FATAL_ERROR(_(
"Unknown simplified aperture macro type %d"), s->type);
540 gerbv_gdk_draw_circle(GdkPixmap* pixmap, GdkGC* gc, gint filled, gint x, gint y, gint dia) {
541 static const gint full_circle = 23360;
542 gint real_x = x - dia / 2;
543 gint real_y = y - dia / 2;
545 gdk_draw_arc(pixmap, gc, filled, real_x, real_y, dia, dia, 0, full_circle);
554 gerbv_gdk_draw_rectangle(
555 GdkPixmap* pixmap, GdkGC* gc,
int filled, gint x, gint y, gint x_side, gint y_side,
double angle_deg
560 points[0].x = -(x_side >> 1);
561 points[0].y = -(y_side >> 1);
562 points[1].x = x_side >> 1;
563 points[1].y = points[0].y;
564 points[2].x = points[1].x;
565 points[2].y = y_side >> 1;
566 points[3].x = points[0].x;
567 points[3].y = points[2].y;
569 for (i = 0; i < 4; i++) {
570 points[i] = rotate_point(points[i], angle_deg);
575 gdk_draw_polygon(pixmap, gc, filled, points, 4);
585 GdkPixmap* pixmap, GdkGC* gc,
int filled, gint x, gint y, gint x_axis, gint y_axis,
double angle_deg
589 GdkGC* local_gc = gdk_gc_new(pixmap);
591 gdk_gc_copy(local_gc, gc);
593 if (x_axis > y_axis) {
597 points[0].x = -(x_axis >> 1) + (y_axis >> 1);
599 points[1].x = (x_axis >> 1) - (y_axis >> 1);
606 points[0].y = -(y_axis >> 1) + (x_axis >> 1);
608 points[1].y = (y_axis >> 1) - (x_axis >> 1);
611 points[0] = rotate_point(points[0], angle_deg);
614 points[1] = rotate_point(points[1], angle_deg);
618 gdk_gc_set_line_attributes(local_gc, width, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER);
619 gdk_draw_line(pixmap, local_gc, points[0].x, points[0].y, points[1].x, points[1].y);
621 gdk_gc_unref(local_gc);
633 GdkPixmap* pixmap, GdkGC* gc,
int x,
int y, gdouble width, gdouble height,
double angle1,
double angle2
635 gint real_x = round(x - width / 2);
636 gint real_y = round(y - height / 2);
639 pixmap, gc, FALSE, real_x, real_y, width, height, round(64 * fmod(angle1, 360)), round(64 * (angle2 - angle1))
644 draw_gdk_render_polygon_object(
646 cairo_matrix_t* scaleMatrix, GdkGC* gc, GdkGC* pgc, GdkPixmap** pixmap
649 gint x2, y2, cp_x = 0, cp_y = 0, cir_width = 0;
650 GdkPoint* points = NULL;
651 unsigned int pointArraySize, curr_point_idx;
653 gdouble angleDiff, tempX, tempY;
660 for (currentNet = oldNet->
next; currentNet != NULL; currentNet = currentNet->
next) {
661 tempX = currentNet->
stop_x + sr_x;
662 tempY = currentNet->
stop_y + sr_y;
663 cairo_matrix_transform_point(fullMatrix, &tempX, &tempY);
664 x2 = (int)round(tempX);
665 y2 = (int)round(tempY);
671 tempX = currentNet->
cirseg->width;
672 tempY = currentNet->
cirseg->height;
673 cairo_matrix_transform_point(scaleMatrix, &tempX, &tempY);
677 cir_width = (int)round(tempX);
679 tempX = currentNet->
cirseg->cp_x + sr_x;
680 tempY = currentNet->
cirseg->cp_y + sr_y;
681 cairo_matrix_transform_point(fullMatrix, &tempX, &tempY);
682 cp_x = (int)round(tempX);
683 cp_y = (int)round(tempY);
691 if (pointArraySize < (curr_point_idx + 1)) {
692 pointArraySize = curr_point_idx + 1;
693 points = (GdkPoint*)g_realloc(points, pointArraySize *
sizeof(GdkPoint));
695 points[curr_point_idx].x = x2;
696 points[curr_point_idx].y = y2;
703 angleDiff = currentNet->
cirseg->angle2 - currentNet->
cirseg->angle1;
704 steps = (int)abs(angleDiff);
705 if (pointArraySize < (curr_point_idx + steps)) {
706 pointArraySize = curr_point_idx + steps;
707 points = (GdkPoint*)g_realloc(points, pointArraySize *
sizeof(GdkPoint));
709 for (i = 0; i < steps; i++) {
710 points[curr_point_idx].x =
711 cp_x + cir_width / 2.0 * cos(DEG2RAD(currentNet->
cirseg->angle1 + (angleDiff * i) / steps));
712 points[curr_point_idx].y =
713 cp_y - cir_width / 2.0 * sin(DEG2RAD(currentNet->
cirseg->angle1 + (angleDiff * i) / steps));
718 gdk_gc_copy(pgc, gc);
719 gdk_gc_set_line_attributes(pgc, 1, GDK_LINE_SOLID, GDK_CAP_PROJECTING, GDK_JOIN_MITER);
720 gdk_draw_polygon(*pixmap, pgc, 1, points, curr_point_idx);
724 default: GERB_COMPILE_WARNING(_(
"Skipped interpolation type %d"), currentNet->
interpolation);
break;
731 draw_gdk_apply_netstate_transformation(
732 cairo_matrix_t* fullMatrix, cairo_matrix_t* scaleMatrix,
gerbv_netstate_t* state
735 cairo_matrix_scale(fullMatrix, state->
scaleA, state->
scaleB);
736 cairo_matrix_scale(scaleMatrix, state->
scaleA, state->
scaleB);
738 cairo_matrix_translate(fullMatrix, state->
offsetA, state->
offsetB);
741 case GERBV_MIRROR_STATE_FLIPA:
742 cairo_matrix_scale(fullMatrix, -1, 1);
743 cairo_matrix_scale(scaleMatrix, -1, 1);
745 case GERBV_MIRROR_STATE_FLIPB:
746 cairo_matrix_scale(fullMatrix, 1, -1);
747 cairo_matrix_scale(scaleMatrix, -1, 1);
749 case GERBV_MIRROR_STATE_FLIPAB:
750 cairo_matrix_scale(fullMatrix, -1, -1);
751 cairo_matrix_scale(scaleMatrix, -1, 1);
756 if (state->
axisSelect == GERBV_AXIS_SELECT_SWAPAB) {
759 cairo_matrix_rotate(fullMatrix, M_PI + M_PI_2);
760 cairo_matrix_scale(fullMatrix, 1, -1);
765 draw_gdk_cross(GdkPixmap* pixmap, GdkGC* gc, gint xc, gint yc, gint r) {
766 gdk_gc_set_line_attributes(gc, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
767 gdk_draw_line(pixmap, gc, xc - r, yc, xc + r, yc);
768 gdk_draw_line(pixmap, gc, xc, yc - r, xc, yc + r);
775 draw_gdk_image_to_pixmap(
776 GdkPixmap** pixmap,
gerbv_image_t* image,
double scale,
double trans_x,
double trans_y,
enum draw_mode drawMode,
779 const int hole_cross_inc_px = 8;
780 GdkGC* gc = gdk_gc_new(*pixmap);
781 GdkGC* pgc = gdk_gc_new(*pixmap);
782 GdkGCValues gc_values;
787 glong xlong1, ylong1, xlong2, ylong2;
789 double cir_width = 0, cir_height = 0;
790 int cp_x = 0, cp_y = 0;
791 GdkColor transparent, opaque;
793 gdouble tempX, tempY, r;
794 gdouble minX = 0, minY = 0, maxX = 0, maxY = 0;
796 if (image == NULL || image->
netlist == NULL) {
809 polarity = image->
info->polarity;
811 if (drawMode == DRAW_SELECTIONS)
814 gboolean useOptimizations = TRUE;
817 if (fabs(transform.
translateX) > GERBV_PRECISION_LINEAR_INCH
818 || fabs(transform.
translateY) > GERBV_PRECISION_LINEAR_INCH
819 || fabs(transform.
scaleX - 1) > GERBV_PRECISION_LINEAR_INCH
820 || fabs(transform.
scaleY - 1) > GERBV_PRECISION_LINEAR_INCH
822 useOptimizations = FALSE;
825 cairo_matrix_t fullMatrix, scaleMatrix;
826 cairo_matrix_init(&fullMatrix, 1, 0, 0, 1, 0, 0);
827 cairo_matrix_init(&scaleMatrix, 1, 0, 0, 1, 0, 0);
829 cairo_matrix_translate(&fullMatrix, trans_x, trans_y);
830 cairo_matrix_scale(&fullMatrix, scale, scale);
831 cairo_matrix_scale(&scaleMatrix, scale, scale);
836 gdouble scaleX = transform.
scaleX;
837 gdouble scaleY = -1 * transform.
scaleY;
838 cairo_matrix_scale(&scaleMatrix, scaleX, -1 * scaleY);
844 cairo_matrix_scale(&fullMatrix, scaleX, scaleY);
846 cairo_matrix_rotate(&fullMatrix, transform.
rotation);
850 cairo_matrix_rotate(&fullMatrix, image->
info->imageRotation);
852 if (useOptimizations) {
861 transparent.pixel = 1;
867 gdk_gc_set_foreground(gc, &transparent);
868 gdk_draw_rectangle(*pixmap, gc, TRUE, 0, 0, -1, -1);
869 gdk_gc_set_foreground(gc, &opaque);
871 gdk_gc_set_foreground(gc, &opaque);
872 gdk_draw_rectangle(*pixmap, gc, TRUE, 0, 0, -1, -1);
873 gdk_gc_set_foreground(gc, &transparent);
878 int repeat_X = 1, repeat_Y = 1;
879 double repeat_dist_X = 0.0, repeat_dist_Y = 0.0;
880 int repeat_i, repeat_j;
891 if (net->
state != oldState) {
894 draw_gdk_apply_netstate_transformation(&fullMatrix, &scaleMatrix, net->
state);
895 oldState = net->
state;
899 if (net->
layer != oldLayer) {
901 oldLayer = net->
layer;
904 if (drawMode == DRAW_SELECTIONS) {
905 gboolean foundNet = FALSE;
906 gerbv_selection_item_t sItem;
908 for (guint i = 0; i < selectionInfo->selectedNodeArray->len; i++) {
909 sItem = g_array_index(selectionInfo->selectedNodeArray, gerbv_selection_item_t, i);
910 if (sItem.net == net) {
919 for (repeat_i = 0; repeat_i < repeat_X; repeat_i++) {
920 for (repeat_j = 0; repeat_j < repeat_Y; repeat_j++) {
921 double sr_x = repeat_i * repeat_dist_X;
922 double sr_y = repeat_j * repeat_dist_Y;
924 if ((useOptimizations)
934 tempX = net->
cirseg->width;
935 tempY = net->
cirseg->height;
936 cairo_matrix_transform_point(&scaleMatrix, &tempX, &tempY);
944 tempX = net->
cirseg->cp_x;
945 tempY = net->
cirseg->cp_y;
946 cairo_matrix_transform_point(&fullMatrix, &tempX, &tempY);
947 cp_x = (int)round(tempX);
948 cp_y = (int)round(tempY);
955 gdk_gc_set_function(gc, GDK_COPY);
957 gdk_gc_set_foreground(gc, &opaque);
959 gdk_gc_set_foreground(gc, &transparent);
966 draw_gdk_render_polygon_object(
967 net, image, sr_x, sr_y, &fullMatrix, &scaleMatrix, gc, pgc, pixmap
993 cairo_matrix_transform_point(&fullMatrix, &tempX, &tempY);
994 xlong1 = (int)round(tempX);
995 ylong1 = (int)round(tempY);
997 tempX = net->
stop_x + sr_x;
998 tempY = net->
stop_y + sr_y;
999 cairo_matrix_transform_point(&fullMatrix, &tempX, &tempY);
1000 xlong2 = (int)round(tempX);
1001 ylong2 = (int)round(tempY);
1005 if ((xlong1 < -10000) && (xlong2 < -10000))
1007 if ((ylong1 < -10000) && (ylong2 < -10000))
1009 if ((xlong1 > 10000) && (xlong2 > 10000))
1011 if ((ylong1 > 10000) && (ylong2 > 10000))
1014 if (xlong1 > G_MAXINT)
1016 else if (xlong1 < G_MININT)
1021 if (xlong2 > G_MAXINT)
1023 else if (xlong2 < G_MININT)
1028 if (ylong1 > G_MAXINT)
1030 else if (ylong1 < G_MININT)
1035 if (ylong2 > G_MAXINT)
1037 else if (ylong2 < G_MININT)
1045 cairo_matrix_transform_point(&scaleMatrix, &tempX, &tempY);
1048 tempX = fabs(tempX);
1049 p1 = (int)round(tempX);
1051 gdk_gc_set_line_attributes(
1052 gc, p1, GDK_LINE_SOLID,
1062 GERB_MESSAGE(_(
"Linear != x1"));
1063 gdk_gc_set_line_attributes(gc, p1, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_MITER);
1064 gdk_draw_line(*pixmap, gc, x1, y1, x2, y2);
1065 gdk_gc_set_line_attributes(gc, p1, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER);
1069 gdk_draw_line(*pixmap, gc, x1, y1, x2, y2);
1074 r = p1 / 2.0 + hole_cross_inc_px;
1075 draw_gdk_cross(*pixmap, gc, x1, y1, r);
1076 draw_gdk_cross(*pixmap, gc, x2, y2, r);
1086 cairo_matrix_transform_point(&scaleMatrix, &tempX, &tempY);
1087 dx = (int)round(tempX);
1088 dy = (int)round(tempY);
1094 poly[0].x = x1 - dx;
1095 poly[0].y = y1 - dy;
1096 poly[1].x = x1 - dx;
1097 poly[1].y = y1 + dy;
1098 poly[2].x = x2 - dx;
1099 poly[2].y = y2 + dy;
1100 poly[3].x = x2 + dx;
1101 poly[3].y = y2 + dy;
1102 poly[4].x = x2 + dx;
1103 poly[4].y = y2 - dy;
1104 poly[5].x = x1 + dx;
1105 poly[5].y = y1 - dy;
1106 gdk_draw_polygon(*pixmap, gc, 1, poly, 6);
1112 *pixmap, gc, cp_x, cp_y, cir_width, cir_height,
1118 GERB_COMPILE_WARNING(_(
"Skipped interpolation type %d"), net->
interpolation);
1126 cairo_matrix_transform_point(&scaleMatrix, &tempX, &tempY);
1129 tempX = fabs(tempX);
1130 tempY = fabs(tempY);
1131 p1 = (int)round(tempX);
1132 p2 = (int)round(tempY);
1136 gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p1);
1140 r = p1 / 2.0 + hole_cross_inc_px;
1141 draw_gdk_cross(*pixmap, gc, x2, y2, r);
1151 gdk_gc_get_values(gc, &gc_values);
1152 if (gc_values.foreground.pixel == opaque.pixel) {
1153 gdk_gc_set_foreground(gc, &transparent);
1154 gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p2);
1155 gdk_gc_set_foreground(gc, &opaque);
1157 gdk_gc_set_foreground(gc, &opaque);
1158 gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p2);
1159 gdk_gc_set_foreground(gc, &transparent);
1165 gerbv_gdk_draw_rectangle(
1166 *pixmap, gc, TRUE, x2, y2, p1, p2,
1167 RAD2DEG(transform.
rotation + image->
info->imageRotation)
1171 gerbv_gdk_draw_oval(
1172 *pixmap, gc, TRUE, x2, y2, p1, p2,
1173 RAD2DEG(transform.
rotation + image->
info->imageRotation)
1178 gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p1);
1182 gerbv_gdk_draw_amacro(
1187 GERB_MESSAGE(_(
"Unknown aperture type %d"), image->
aperture[net->
aperture]->type);
1191 default: GERB_MESSAGE(_(
"Unknown aperture state %d"), net->
aperture_state);
return 0;
Header info for the GDK rendering functions.
gerbv_net_t * gerbv_image_return_next_renderable_object(gerbv_net_t *oldNet)
Return the next net entry which corresponds to a unique visible object.
const char * gerbv_aperture_type_name(gerbv_aperture_type_t type)
Return string name of gerbv_aperture_type_t aperture type.
The main header file for the libgerbv library.
@ GERBV_APERTURE_STATE_OFF
@ GERBV_APERTURE_STATE_ON
@ GERBV_APERTURE_STATE_FLASH
@ GERBV_POLARITY_NEGATIVE
@ GERBV_POLARITY_POSITIVE
@ GERBV_APTYPE_MACRO_LINE20
@ GERBV_APTYPE_MACRO_LINE21
@ GERBV_APTYPE_MACRO_OUTLINE
@ GERBV_APTYPE_MACRO_CIRCLE
@ GERBV_APTYPE_MACRO_POLYGON
@ GERBV_APTYPE_MACRO_THERMAL
@ GERBV_APTYPE_MACRO_LINE22
@ GERBV_APTYPE_MACRO_MOIRE
@ GERBV_INTERPOLATION_LINEARx01
@ GERBV_INTERPOLATION_PAREA_START
@ GERBV_INTERPOLATION_LINEARx001
@ GERBV_INTERPOLATION_DELETED
@ GERBV_INTERPOLATION_CW_CIRCULAR
@ GERBV_INTERPOLATION_PAREA_END
@ GERBV_INTERPOLATION_LINEARx10
@ GERBV_INTERPOLATION_CCW_CIRCULAR
@ GERBV_INTERPOLATION_LINEARx1
gerbv_layertype_t layertype
gerbv_aperture_t * aperture[APERTURE_MAX]
gerbv_netstate_t * states
gerbv_image_info_t * info
gerbv_step_and_repeat_t stepAndRepeat
gerbv_polarity_t polarity
gerbv_render_size_t boundingBox
gerbv_aperture_state_t aperture_state
gerbv_interpolation_t interpolation
gerbv_axis_select_t axisSelect
gerbv_mirror_state_t mirrorState
gboolean show_cross_on_drill_holes