43 #define DPRINTF(...) do { if (DEBUG) printf(__VA_ARGS__); } while (0)
45 static gboolean draw_do_vector_export_fix(cairo_t *cairoTarget,
46 double *bg_red,
double *bg_green,
double *bg_blue);
56 gboolean adjustByHalf, gboolean pixelOutput)
59 cairo_user_to_device (cairoTarget, &x, &y);
66 cairo_device_to_user (cairoTarget, &x, &y);
68 cairo_line_to (cairoTarget, x, y);
79 gboolean oddWidth, gboolean pixelOutput)
82 cairo_user_to_device (cairoTarget, &x, &y);
89 cairo_device_to_user (cairoTarget, &x, &y);
91 cairo_move_to (cairoTarget, x, y);
101 gboolean pixelOutput)
104 cairo_user_to_device (cairoTarget, &x, &y);
107 cairo_device_to_user (cairoTarget, &x, &y);
110 cairo_translate (cairoTarget, x, y);
123 gerbv_selection_item_t sItem;
125 for (guint i = 0; i < selection_length (selectionInfo); i++) {
126 sItem = selection_get_item_by_index (selectionInfo, i);
127 if (sItem.net == net) {
129 selection_clear_item_by_index (selectionInfo, i);
139 draw_check_if_object_is_in_selected_area (cairo_t *cairoTarget,
142 enum draw_mode drawMode)
144 gerbv_selection_item_t sItem = {image, net};
145 gdouble corner1X, corner1Y, corner2X, corner2Y;
146 gdouble x1, x2, y1, y2;
147 gdouble minX, minY, maxX, maxY;
149 corner1X = selectionInfo->lowerLeftX;
150 corner1Y = selectionInfo->lowerLeftY;
151 corner2X = selectionInfo->upperRightX;
152 corner2Y = selectionInfo->upperRightY;
156 cairo_device_to_user (cairoTarget, &corner1X, &corner1Y);
157 cairo_device_to_user (cairoTarget, &corner2X, &corner2Y);
159 switch (selectionInfo->type) {
163 if ((isStroke && cairo_in_stroke (cairoTarget, corner1X, corner1Y)) ||
164 (!isStroke && cairo_in_fill (cairoTarget, corner1X, corner1Y))) {
168 (drawMode == FIND_SELECTIONS_TOGGLE))) {
169 selection_add_item (selectionInfo, &sItem);
177 minX = MIN(corner1X,corner2X);
178 maxX = MAX(corner1X,corner2X);
179 minY = MIN(corner1Y,corner2Y);
180 maxY = MAX(corner1Y,corner2Y);
183 cairo_stroke_extents (cairoTarget, &x1, &y1, &x2, &y2);
185 cairo_fill_extents (cairoTarget, &x1, &y1, &x2, &y2);
187 if ((minX < x1) && (minY < y1) && (maxX > x2) && (maxY > y2)) {
190 (drawMode == FIND_SELECTIONS_TOGGLE))) {
191 selection_add_item (selectionInfo, &sItem);
200 cairo_new_path (cairoTarget);
204 draw_fill (cairo_t *cairoTarget,
enum draw_mode drawMode,
208 if ((drawMode == DRAW_IMAGE) || (drawMode == DRAW_SELECTIONS))
209 cairo_fill (cairoTarget);
211 draw_check_if_object_is_in_selected_area (cairoTarget, FALSE,
212 selectionInfo, image, net, drawMode);
216 draw_stroke (cairo_t *cairoTarget,
enum draw_mode drawMode,
220 if ((drawMode == DRAW_IMAGE) || (drawMode == DRAW_SELECTIONS))
221 cairo_stroke (cairoTarget);
223 draw_check_if_object_is_in_selected_area (cairoTarget, TRUE,
224 selectionInfo, image, net, drawMode);
233 cairo_arc (cairoTarget, 0.0, 0.0, diameter/2.0, 0, 2.0*M_PI);
245 gboolean pixelOutput)
248 cairo_user_to_device_distance (cairoTarget, &width, &height);
249 width -= (int)round(width) % 2;
250 height -= (int)round(height) % 2;
251 cairo_device_to_user_distance (cairoTarget, &width, &height);
254 cairo_rectangle (cairoTarget, -width/2.0, -height/2.0, width, height);
267 gdouble circleDiameter, strokeDistance;
269 cairo_new_path (cairoTarget);
270 if (width < height) {
271 circleDiameter = width;
272 strokeDistance = (height - width)/2.0;
273 cairo_arc (cairoTarget, 0.0, strokeDistance, circleDiameter/2.0, 0, -M_PI);
274 cairo_line_to (cairoTarget, -circleDiameter/2.0, -strokeDistance);
275 cairo_arc (cairoTarget, 0.0, -strokeDistance, circleDiameter/2.0, -M_PI, 0);
276 cairo_line_to (cairoTarget, circleDiameter/2.0, strokeDistance);
278 circleDiameter = height;
279 strokeDistance = (width - height)/2.0;
280 cairo_arc (cairoTarget, -strokeDistance, 0.0,
281 circleDiameter/2.0, M_PI_2, -M_PI_2);
282 cairo_line_to (cairoTarget, strokeDistance,
283 -circleDiameter/2.0);
284 cairo_arc (cairoTarget, strokeDistance, 0.0,
285 circleDiameter/2.0, -M_PI_2, M_PI_2);
286 cairo_line_to (cairoTarget, -strokeDistance,
294 cairo_save (cairoTarget);
295 cairo_scale (cairoTarget, width, height);
297 cairo_restore (cairoTarget);
303 gerbv_draw_polygon(cairo_t *cairoTarget, gdouble outsideDiameter,
304 gdouble numberOfSides, gdouble degreesOfRotation)
306 int i, numberOfSidesInteger = (int) numberOfSides;
308 cairo_rotate(cairoTarget, DEG2RAD(degreesOfRotation));
309 cairo_move_to(cairoTarget, outsideDiameter / 2.0, 0);
312 for (i = 1; i < numberOfSidesInteger; i++){
313 gdouble angle = ((double)i)*M_PI*2.0 / numberOfSidesInteger;
314 cairo_line_to (cairoTarget, cos(angle) * outsideDiameter / 2.0,
315 sin(angle) * outsideDiameter / 2.0);
323 gerbv_draw_aperture_hole(cairo_t *cairoTarget,
324 gdouble dimensionX, gdouble dimensionY, gboolean pixelOutput)
327 cairo_new_sub_path (cairoTarget);
330 dimensionX, dimensionY, pixelOutput);
339 draw_update_macro_exposure (cairo_t *cairoTarget, cairo_operator_t clearOperator,
340 cairo_operator_t darkOperator, gdouble exposureSetting){
342 if (exposureSetting == 0.0) {
343 cairo_set_operator (cairoTarget, clearOperator);
344 }
else if (exposureSetting == 1.0) {
345 cairo_set_operator (cairoTarget, darkOperator);
346 }
else if (exposureSetting == 2.0) {
348 cairo_operator_t currentOperator = cairo_get_operator (cairoTarget);
349 if (currentOperator == clearOperator) {
350 cairo_set_operator (cairoTarget, darkOperator);
352 cairo_set_operator (cairoTarget, clearOperator);
359 gerbv_draw_amacro(cairo_t *cairoTarget, cairo_operator_t clearOperator,
360 cairo_operator_t darkOperator, gerbv_simplified_amacro_t *s,
361 gint usesClearPrimitive, gdouble pixelWidth,
enum draw_mode drawMode,
365 gerbv_simplified_amacro_t *ls = s;
366 gboolean doVectorExportFix;
367 double bg_r, bg_g, bg_b;
370 DPRINTF(
"Drawing simplified aperture macros:\n");
373 draw_do_vector_export_fix (cairoTarget, &bg_r, &bg_g, &bg_b);
375 switch (cairo_surface_get_type (cairo_get_target (cairoTarget))) {
377 case CAIRO_SURFACE_TYPE_PDF:
378 case CAIRO_SURFACE_TYPE_PS:
379 case CAIRO_SURFACE_TYPE_SVG:
382 pixelWidth = DBL_MIN;
390 if (usesClearPrimitive)
391 cairo_push_group (cairoTarget);
399 cairo_save (cairoTarget);
400 cairo_new_path(cairoTarget);
402 DPRINTF(
"\t%s(): drawing %s\n", __FUNCTION__,
408 draw_update_macro_exposure (cairoTarget,
409 clearOperator, darkOperator,
410 ls->parameter[CIRCLE_EXPOSURE]);
411 cairo_rotate (cairoTarget, DEG2RAD(
412 ls->parameter[CIRCLE_ROTATION]));
413 cairo_translate (cairoTarget,
414 ls->parameter[CIRCLE_CENTER_X],
415 ls->parameter[CIRCLE_CENTER_Y]);
417 ls->parameter[CIRCLE_DIAMETER]);
419 if (doVectorExportFix
420 && CAIRO_OPERATOR_CLEAR ==
421 cairo_get_operator (cairoTarget)) {
422 cairo_save (cairoTarget);
423 cairo_set_source_rgba (cairoTarget,
424 bg_r, bg_g, bg_b, 1.0);
425 cairo_set_operator (cairoTarget,
426 CAIRO_OPERATOR_OVER);
428 draw_fill (cairoTarget, drawMode,
429 selectionInfo, image, net);
431 cairo_restore (cairoTarget);
436 draw_fill (cairoTarget, drawMode,
437 selectionInfo, image, net);
441 draw_update_macro_exposure (cairoTarget,
442 clearOperator, darkOperator,
443 ls->parameter[OUTLINE_EXPOSURE]);
444 cairo_rotate (cairoTarget, DEG2RAD(ls->parameter[
445 OUTLINE_ROTATION_IDX(ls->parameter)]));
446 cairo_move_to (cairoTarget,
447 ls->parameter[OUTLINE_FIRST_X],
448 ls->parameter[OUTLINE_FIRST_Y]);
450 for (
int point = 1; point <
451 1 + (int)ls->parameter[
452 OUTLINE_NUMBER_OF_POINTS];
454 cairo_line_to (cairoTarget,
455 ls->parameter[OUTLINE_X_IDX_OF_POINT(
457 ls->parameter[OUTLINE_Y_IDX_OF_POINT(
461 if (doVectorExportFix
462 && CAIRO_OPERATOR_CLEAR ==
463 cairo_get_operator (cairoTarget)) {
464 cairo_save (cairoTarget);
465 cairo_set_source_rgba (cairoTarget,
466 bg_r, bg_g, bg_b, 1.0);
467 cairo_set_operator (cairoTarget,
468 CAIRO_OPERATOR_OVER);
470 draw_fill (cairoTarget, drawMode,
471 selectionInfo, image, net);
473 cairo_restore (cairoTarget);
482 draw_fill (cairoTarget, drawMode,
483 selectionInfo, image, net);
487 draw_update_macro_exposure (cairoTarget,
488 clearOperator, darkOperator,
489 ls->parameter[POLYGON_EXPOSURE]);
490 cairo_translate (cairoTarget,
491 ls->parameter[POLYGON_CENTER_X],
492 ls->parameter[POLYGON_CENTER_Y]);
493 gerbv_draw_polygon(cairoTarget,
494 ls->parameter[POLYGON_DIAMETER],
495 ls->parameter[POLYGON_NUMBER_OF_POINTS],
496 ls->parameter[POLYGON_ROTATION]);
498 if (doVectorExportFix
499 && CAIRO_OPERATOR_CLEAR ==
500 cairo_get_operator (cairoTarget)) {
501 cairo_save (cairoTarget);
502 cairo_set_source_rgba (cairoTarget,
503 bg_r, bg_g, bg_b, 1.0);
504 cairo_set_operator (cairoTarget,
505 CAIRO_OPERATOR_OVER);
507 draw_fill (cairoTarget, drawMode,
508 selectionInfo, image, net);
510 cairo_restore (cairoTarget);
515 draw_fill (cairoTarget, drawMode,
516 selectionInfo, image, net);
520 gdouble diameter, diameterDifference, crosshairRadius;
522 cairo_translate (cairoTarget,
523 ls->parameter[MOIRE_CENTER_X],
524 ls->parameter[MOIRE_CENTER_Y]);
525 cairo_rotate (cairoTarget,
526 DEG2RAD(ls->parameter[MOIRE_ROTATION]));
527 diameter = ls->parameter[MOIRE_OUTSIDE_DIAMETER]
528 - ls->parameter[MOIRE_CIRCLE_THICKNESS];
529 diameterDifference = 2*(ls->parameter[MOIRE_GAP_WIDTH]
530 + ls->parameter[MOIRE_CIRCLE_THICKNESS]);
531 cairo_set_line_width (cairoTarget,
532 ls->parameter[MOIRE_CIRCLE_THICKNESS]);
534 if (doVectorExportFix
535 && CAIRO_OPERATOR_CLEAR ==
536 cairo_get_operator (cairoTarget)) {
537 cairo_save (cairoTarget);
538 cairo_set_source_rgba (cairoTarget,
539 bg_r, bg_g, bg_b, 1.0);
540 cairo_set_operator (cairoTarget,
541 CAIRO_OPERATOR_OVER);
544 for (
int circle = 0; circle < (int)ls->parameter[
545 MOIRE_NUMBER_OF_CIRCLES]; circle++) {
547 diameter - diameterDifference * circle;
550 GERB_COMPILE_WARNING (_(
"Ignoring %s "
551 "with non positive diameter"),
558 draw_stroke (cairoTarget, drawMode,
559 selectionInfo, image, net);
563 cairo_set_line_width (cairoTarget,
564 ls->parameter[MOIRE_CROSSHAIR_THICKNESS]);
566 ls->parameter[MOIRE_CROSSHAIR_LENGTH] / 2.0;
567 cairo_move_to (cairoTarget, -crosshairRadius, 0);
568 cairo_line_to (cairoTarget, crosshairRadius, 0);
569 cairo_move_to (cairoTarget, 0, -crosshairRadius);
570 cairo_line_to (cairoTarget, 0, crosshairRadius);
572 draw_stroke (cairoTarget, drawMode,
573 selectionInfo, image, net);
575 if (doVectorExportFix
576 && CAIRO_OPERATOR_CLEAR ==
577 cairo_get_operator (cairoTarget)) {
578 cairo_restore (cairoTarget);
584 gdouble startAngle1, startAngle2, endAngle1, endAngle2;
586 cairo_translate (cairoTarget,
587 ls->parameter[THERMAL_CENTER_X],
588 ls->parameter[THERMAL_CENTER_Y]);
589 cairo_rotate (cairoTarget,
590 DEG2RAD(ls->parameter[THERMAL_ROTATION]));
592 ls->parameter[THERMAL_CROSSHAIR_THICKNESS]/
593 ls->parameter[THERMAL_INSIDE_DIAMETER]);
594 endAngle1 = M_PI_2 - startAngle1;
596 ls->parameter[THERMAL_CROSSHAIR_THICKNESS]/
597 ls->parameter[THERMAL_OUTSIDE_DIAMETER]);
598 startAngle2 = M_PI_2 - endAngle2;
600 if (doVectorExportFix
601 && CAIRO_OPERATOR_CLEAR ==
602 cairo_get_operator (cairoTarget)) {
603 cairo_save (cairoTarget);
604 cairo_set_source_rgba (cairoTarget,
605 bg_r, bg_g, bg_b, 1.0);
606 cairo_set_operator (cairoTarget,
607 CAIRO_OPERATOR_OVER);
611 cairo_restore (cairoTarget);
616 for (gint i = 0; i < 4; i++) {
617 cairo_arc (cairoTarget, 0, 0,
619 THERMAL_INSIDE_DIAMETER]/2.0,
620 startAngle1, endAngle1);
621 cairo_arc_negative (cairoTarget, 0, 0,
623 THERMAL_OUTSIDE_DIAMETER]/2.0,
624 startAngle2, endAngle2);
625 draw_fill (cairoTarget,
626 drawMode, selectionInfo,
628 cairo_rotate (cairoTarget, M_PI_2);
634 draw_update_macro_exposure (cairoTarget,
635 clearOperator, darkOperator,
636 ls->parameter[LINE20_EXPOSURE]);
637 cairo_set_line_width (cairoTarget,
638 MAX(ls->parameter[LINE20_LINE_WIDTH],
640 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_BUTT);
641 cairo_rotate (cairoTarget, DEG2RAD(
642 ls->parameter[LINE20_ROTATION]));
643 cairo_move_to (cairoTarget,
644 ls->parameter[LINE20_START_X],
645 ls->parameter[LINE20_START_Y]);
646 cairo_line_to (cairoTarget,
647 ls->parameter[LINE20_END_X],
648 ls->parameter[LINE20_END_Y]);
650 if (doVectorExportFix
651 && CAIRO_OPERATOR_CLEAR ==
652 cairo_get_operator (cairoTarget)) {
653 cairo_save (cairoTarget);
654 cairo_set_source_rgba (cairoTarget,
655 bg_r, bg_g, bg_b, 1.0);
656 cairo_set_operator (cairoTarget,
657 CAIRO_OPERATOR_OVER);
659 draw_stroke (cairoTarget, drawMode,
660 selectionInfo, image, net);
662 cairo_restore (cairoTarget);
667 draw_stroke (cairoTarget, drawMode,
668 selectionInfo, image, net);
672 draw_update_macro_exposure (cairoTarget,
673 clearOperator, darkOperator,
674 ls->parameter[LINE21_EXPOSURE]);
675 cairo_rotate (cairoTarget, DEG2RAD(
676 ls->parameter[LINE21_ROTATION]));
677 cairo_translate (cairoTarget,
678 ls->parameter[LINE21_CENTER_X],
679 ls->parameter[LINE21_CENTER_Y]);
680 cairo_rectangle (cairoTarget,
681 -MAX(ls->parameter[LINE21_WIDTH]/2.0,
683 -MAX(ls->parameter[LINE21_HEIGHT]/2.0,
685 MAX(ls->parameter[LINE21_WIDTH],
687 MAX(ls->parameter[LINE21_HEIGHT],
689 if (doVectorExportFix
690 && CAIRO_OPERATOR_CLEAR ==
691 cairo_get_operator (cairoTarget)) {
692 cairo_save (cairoTarget);
693 cairo_set_source_rgba (cairoTarget,
694 bg_r, bg_g, bg_b, 1.0);
695 cairo_set_operator (cairoTarget,
696 CAIRO_OPERATOR_OVER);
698 draw_fill (cairoTarget, drawMode,
699 selectionInfo, image, net);
701 cairo_restore (cairoTarget);
706 draw_fill (cairoTarget, drawMode,
707 selectionInfo, image, net);
711 draw_update_macro_exposure (cairoTarget,
712 clearOperator, darkOperator,
713 ls->parameter[LINE22_EXPOSURE]);
714 cairo_rotate (cairoTarget, DEG2RAD(
715 ls->parameter[LINE22_ROTATION]));
716 cairo_translate (cairoTarget,
717 ls->parameter[LINE22_LOWER_LEFT_X],
718 ls->parameter[LINE22_LOWER_LEFT_Y]);
719 cairo_rectangle (cairoTarget, 0, 0,
720 MAX(ls->parameter[LINE22_WIDTH],
722 MAX(ls->parameter[LINE22_HEIGHT],
725 if (doVectorExportFix
726 && CAIRO_OPERATOR_CLEAR ==
727 cairo_get_operator (cairoTarget)) {
728 cairo_save (cairoTarget);
729 cairo_set_source_rgba (cairoTarget,
730 bg_r, bg_g, bg_b, 1.0);
731 cairo_set_operator (cairoTarget,
732 CAIRO_OPERATOR_OVER);
734 draw_fill (cairoTarget, drawMode,
735 selectionInfo, image, net);
737 cairo_restore (cairoTarget);
742 draw_fill (cairoTarget, drawMode,
743 selectionInfo, image, net);
747 GERB_COMPILE_WARNING(_(
"Unknown macro type: %s"),
752 cairo_restore (cairoTarget);
756 if (usesClearPrimitive) {
757 cairo_pop_group_to_source (cairoTarget);
758 cairo_paint (cairoTarget);
765 draw_apply_netstate_transformation (cairo_t *cairoTarget,
gerbv_netstate_t *state)
768 cairo_scale (cairoTarget, state->
scaleA, state->
scaleB);
773 case GERBV_MIRROR_STATE_FLIPA:
774 cairo_scale (cairoTarget, -1, 1);
776 case GERBV_MIRROR_STATE_FLIPB:
777 cairo_scale (cairoTarget, 1, -1);
779 case GERBV_MIRROR_STATE_FLIPAB:
780 cairo_scale (cairoTarget, -1, -1);
786 if (state->
axisSelect == GERBV_AXIS_SELECT_SWAPAB) {
789 cairo_rotate (cairoTarget, M_PI + M_PI_2);
790 cairo_scale (cairoTarget, 1, -1);
795 draw_render_polygon_object (
gerbv_net_t *oldNet, cairo_t *cairoTarget,
798 gboolean pixelOutput)
801 int haveDrawnFirstFillPoint = 0;
802 gdouble x2,y2,cp_x=0,cp_y=0;
804 haveDrawnFirstFillPoint = FALSE;
807 polygonStartNet = oldNet;
808 cairo_new_path(cairoTarget);
810 for (currentNet = oldNet->
next; currentNet!=NULL;
811 currentNet = currentNet->
next) {
812 x2 = currentNet->
stop_x + sr_x;
813 y2 = currentNet->
stop_y + sr_y;
817 cp_x = currentNet->
cirseg->cp_x + sr_x;
818 cp_y = currentNet->
cirseg->cp_y + sr_y;
820 if (!haveDrawnFirstFillPoint) {
822 haveDrawnFirstFillPoint=TRUE;
835 if (currentNet->
cirseg->angle2 > currentNet->
cirseg->angle1) {
836 cairo_arc (cairoTarget, cp_x, cp_y, currentNet->
cirseg->width/2.0,
837 DEG2RAD(currentNet->
cirseg->angle1),
838 DEG2RAD(currentNet->
cirseg->angle2));
840 cairo_arc_negative (cairoTarget, cp_x, cp_y, currentNet->
cirseg->width/2.0,
841 DEG2RAD(currentNet->
cirseg->angle1),
842 DEG2RAD(currentNet->
cirseg->angle2));
846 cairo_close_path(cairoTarget);
849 cairo_antialias_t oldAlias = cairo_get_antialias (cairoTarget);
850 cairo_set_antialias (cairoTarget, CAIRO_ANTIALIAS_NONE);
851 draw_fill (cairoTarget, drawMode, selectionInfo, image, polygonStartNet);
852 cairo_set_antialias (cairoTarget, oldAlias);
868 cairo_move_to (cairoTarget, xc, yc - r);
869 cairo_rel_line_to (cairoTarget, 0, 2*r);
870 cairo_move_to (cairoTarget, xc - r, yc);
871 cairo_rel_line_to (cairoTarget, 2*r, 0);
872 cairo_stroke (cairoTarget);
876 draw_calc_pnp_mark_coords(
struct gerbv_net *start_net,
877 double *label_x,
double *label_y)
881 const char *
label = NULL;
883 if (net && net->
label)
889 x = HUGE_VAL; y = -HUGE_VAL;
902 y = MAX(y, net->
stop_y + 0.01/2);
915 draw_image_to_cairo_target (cairo_t *cairoTarget,
gerbv_image_t *image,
916 gdouble pixelWidth,
enum draw_mode drawMode,
921 const int hole_cross_inc_px = 8;
922 struct gerbv_net *net, *polygonStartNet=NULL;
923 double x1, y1, x2, y2, cp_x=0, cp_y=0;
924 gdouble *p, p0, p1, dx, dy, lineWidth, r;
927 cairo_operator_t drawOperatorClear, drawOperatorDark;
928 gboolean invertPolarity = FALSE, oddWidth = FALSE;
929 gdouble minX=0, minY=0, maxX=0, maxY=0;
930 gdouble criticalRadius;
931 gdouble scaleX = transform.
scaleX;
932 gdouble scaleY = transform.
scaleY;
934 gdouble pnp_label_scale_x = 1, pnp_label_scale_y= -1;
935 gboolean limitLineWidth = TRUE;
936 gboolean displayPixel = TRUE;
937 gboolean doVectorExportFix;
938 double bg_r, bg_g, bg_b;
940 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
943 cairo_surface_t* cSurface = cairo_get_target(cairoTarget);
944 if (cairo_surface_get_type(cSurface) == CAIRO_SURFACE_TYPE_SVG) {
945 cairo_svg_surface_set_document_unit(cSurface, CAIRO_SVG_UNIT_PT);
950 draw_do_vector_export_fix (cairoTarget, &bg_r, &bg_g, &bg_b);
954 if ((scaleX != 1)||(scaleY != 1)){
955 limitLineWidth = FALSE;
960 pnp_label_scale_y = 1;
965 pnp_label_scale_x= -1;
969 cairo_scale (cairoTarget, scaleX, scaleY);
970 cairo_rotate (cairoTarget, transform.
rotation);
972 gboolean useOptimizations = allowOptimization;
976 if (fabs(transform.
translateX) > GERBV_PRECISION_LINEAR_INCH
977 || fabs(transform.
translateY) > GERBV_PRECISION_LINEAR_INCH
978 || fabs(transform.
scaleX - 1) > GERBV_PRECISION_LINEAR_INCH
979 || fabs(transform.
scaleY - 1) > GERBV_PRECISION_LINEAR_INCH
980 || fabs(transform.
rotation) > GERBV_PRECISION_ANGLE_RAD
982 useOptimizations = FALSE;
984 if (useOptimizations && pixelOutput) {
994 cairo_translate (cairoTarget, image->
info->imageJustifyOffsetActualA,
995 image->
info->imageJustifyOffsetActualB);
998 cairo_set_fill_rule (cairoTarget, CAIRO_FILL_RULE_EVEN_ODD);
1000 cairo_translate (cairoTarget, image->
info->offsetA, image->
info->offsetB);
1002 cairo_rotate (cairoTarget, image->
info->imageRotation);
1005 invertPolarity = transform.
inverted;
1007 invertPolarity = !invertPolarity;
1008 if (drawMode == DRAW_SELECTIONS)
1009 invertPolarity = FALSE;
1011 if (invertPolarity) {
1012 drawOperatorClear = CAIRO_OPERATOR_OVER;
1013 drawOperatorDark = CAIRO_OPERATOR_CLEAR;
1014 cairo_set_operator (cairoTarget, CAIRO_OPERATOR_OVER);
1015 cairo_paint (cairoTarget);
1016 cairo_set_operator (cairoTarget, CAIRO_OPERATOR_CLEAR);
1018 drawOperatorClear = CAIRO_OPERATOR_CLEAR;
1019 drawOperatorDark = CAIRO_OPERATOR_OVER;
1025 cairo_save (cairoTarget);
1026 cairo_save (cairoTarget);
1029 oldLayer = image->
layers;
1030 oldState = image->
states;
1032 const char *pnp_net_label_str_prev = NULL;
1038 if (net->
layer != oldLayer){
1041 cairo_restore (cairoTarget);
1042 cairo_restore (cairoTarget);
1043 cairo_save (cairoTarget);
1048 cairo_set_operator (cairoTarget, CAIRO_OPERATOR_CLEAR);
1049 drawOperatorClear = CAIRO_OPERATOR_OVER;
1050 drawOperatorDark = CAIRO_OPERATOR_CLEAR;
1053 cairo_set_operator (cairoTarget, CAIRO_OPERATOR_OVER);
1054 drawOperatorClear = CAIRO_OPERATOR_CLEAR;
1055 drawOperatorDark = CAIRO_OPERATOR_OVER;
1060 if (ko->firstInstance == TRUE) {
1061 cairo_save (cairoTarget);
1064 cairo_set_operator (cairoTarget, drawOperatorClear);
1066 cairo_set_operator (cairoTarget, drawOperatorDark);
1069 if (doVectorExportFix
1070 && CAIRO_OPERATOR_CLEAR ==
1071 cairo_get_operator (cairoTarget)) {
1073 cairo_set_operator (cairoTarget,
1074 CAIRO_OPERATOR_OVER);
1075 cairo_set_source_rgba (
1080 cairo_new_path (cairoTarget);
1081 cairo_rectangle (cairoTarget,
1082 ko->lowerLeftX - ko->border,
1083 ko->lowerLeftY - ko->border,
1084 ko->width + 2*ko->border,
1085 ko->height + 2*ko->border);
1086 draw_fill (cairoTarget, drawMode, selectionInfo, image, net);
1088 cairo_restore (cairoTarget);
1092 cairo_save (cairoTarget);
1093 draw_apply_netstate_transformation (cairoTarget, net->
state);
1094 oldLayer = net->
layer;
1098 if (net->
state != oldState){
1101 cairo_restore (cairoTarget);
1102 cairo_save (cairoTarget);
1105 draw_apply_netstate_transformation (cairoTarget, net->
state);
1106 oldState = net->
state;
1111 if (drawMode == DRAW_SELECTIONS) {
1116 if (!polygonStartNet) {
1118 selectionInfo, FALSE))
1126 if (drawMode != DRAW_SELECTIONS && net->
label
1129 && g_strcmp0 (net->
label->str, pnp_net_label_str_prev)) {
1131 double mark_x, mark_y;
1135 pnp_net_label_str_prev =
1138 if (draw_calc_pnp_mark_coords(net, &mark_x, &mark_y)) {
1139 cairo_save (cairoTarget);
1141 cairo_set_font_size (cairoTarget, 0.05);
1142 cairo_move_to (cairoTarget, mark_x, mark_y);
1143 cairo_scale (cairoTarget, pnp_label_scale_x,
1145 cairo_show_text (cairoTarget, net->
label->str);
1147 cairo_restore (cairoTarget);
1154 for (ix = 0; ix < sr->X; ix++) {
1155 for (iy = 0; iy < sr->Y; iy++) {
1156 double sr_x = ix * sr->dist_X;
1157 double sr_y = iy * sr->dist_Y;
1159 if (useOptimizations && pixelOutput
1174 cp_x = net->
cirseg->cp_x + sr_x;
1175 cp_y = net->
cirseg->cp_y + sr_y;
1182 if (doVectorExportFix
1183 && CAIRO_OPERATOR_CLEAR ==
1184 cairo_get_operator (cairoTarget)) {
1186 cairo_save (cairoTarget);
1188 cairo_set_operator (cairoTarget,
1189 CAIRO_OPERATOR_OVER);
1190 cairo_set_source_rgba (
1194 draw_render_polygon_object (net,
1197 drawMode, selectionInfo,
1200 cairo_restore (cairoTarget);
1202 draw_render_polygon_object (net,
1205 drawMode, selectionInfo,
1232 if (limitLineWidth&&((image->
aperture[net->
aperture]->parameter[0] < pixelWidth)&&
1234 criticalRadius = pixelWidth/2.0;
1237 lineWidth = criticalRadius*2.0;
1239 cairo_user_to_device_distance (cairoTarget, &lineWidth, &x1);
1241 lineWidth = round(lineWidth);
1242 if ((
int)lineWidth % 2) {
1249 cairo_device_to_user_distance (cairoTarget, &lineWidth, &x1);
1250 cairo_set_line_width (cairoTarget, lineWidth);
1257 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_ROUND);
1267 cairo_set_line_width (cairoTarget, pixelWidth);
1268 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_SQUARE);
1270 hole_cross_inc_px*pixelWidth;
1273 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_ROUND);
1274 cairo_set_line_width (cairoTarget, lineWidth);
1280 if (doVectorExportFix
1281 && CAIRO_OPERATOR_CLEAR ==
1282 cairo_get_operator (cairoTarget)) {
1283 cairo_save (cairoTarget);
1284 cairo_set_source_rgba (
1290 cairo_set_operator (
1292 CAIRO_OPERATOR_OVER);
1318 cairo_new_path(cairoTarget);
1325 draw_fill (cairoTarget, drawMode, selectionInfo, image, net);
1332 draw_stroke (cairoTarget, drawMode, selectionInfo, image, net);
1336 GERB_COMPILE_WARNING(
1337 _(
"Unknown aperture type: %s"),
1348 cairo_new_path(cairoTarget);
1350 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_SQUARE);
1353 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_ROUND);
1355 cairo_save (cairoTarget);
1356 cairo_translate(cairoTarget, cp_x, cp_y);
1357 cairo_scale (cairoTarget, net->
cirseg->width, net->
cirseg->height);
1359 cairo_arc (cairoTarget, 0.0, 0.0, 0.5,
1360 DEG2RAD(net->
cirseg->angle1),
1361 DEG2RAD(net->
cirseg->angle2));
1364 cairo_arc_negative (cairoTarget, 0.0, 0.0, 0.5,
1365 DEG2RAD(net->
cirseg->angle1),
1366 DEG2RAD(net->
cirseg->angle2));
1368 cairo_restore (cairoTarget);
1369 draw_stroke (cairoTarget, drawMode, selectionInfo, image, net);
1372 GERB_COMPILE_WARNING(
1373 _(
"Unknown interpolation type: %s"),
1383 cairo_save (cairoTarget);
1391 cairo_set_line_width (cairoTarget, pixelWidth);
1392 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_SQUARE);
1393 r = p[0]/2.0 + hole_cross_inc_px*pixelWidth;
1395 cairo_set_line_width (cairoTarget, lineWidth);
1396 cairo_set_line_cap (cairoTarget, CAIRO_LINE_CAP_ROUND);
1400 gerbv_draw_aperture_hole (cairoTarget, p[1], p[2], pixelOutput);
1405 displayPixel = pixelOutput;
1408 if (limitLineWidth && (p[0] < pixelWidth) && pixelOutput) {
1410 displayPixel = FALSE;
1412 if (limitLineWidth && (p[1] < pixelWidth) && pixelOutput) {
1414 displayPixel = FALSE;
1417 gerbv_draw_aperture_hole (cairoTarget, p[2], p[3], displayPixel);
1421 gerbv_draw_aperture_hole (cairoTarget, p[2], p[3], pixelOutput);
1424 gerbv_draw_polygon(cairoTarget, p[0], p[1], p[2]);
1425 gerbv_draw_aperture_hole (cairoTarget, p[3], p[4], pixelOutput);
1430 gerbv_draw_amacro(cairoTarget, drawOperatorClear, drawOperatorDark,
1432 (gint)p[0], pixelWidth,
1433 drawMode, selectionInfo, image, net);
1436 GERB_COMPILE_WARNING(
1437 _(
"Unknown aperture type: %s"),
1444 if (doVectorExportFix
1445 && CAIRO_OPERATOR_CLEAR ==
1446 cairo_get_operator (cairoTarget)) {
1447 cairo_set_source_rgba (
1451 cairo_set_operator (cairoTarget,
1452 CAIRO_OPERATOR_OVER);
1455 draw_fill (cairoTarget, drawMode, selectionInfo, image, net);
1456 cairo_restore (cairoTarget);
1459 GERB_COMPILE_WARNING(
1460 _(
"Unknown aperture state: %s"),
1471 cairo_restore (cairoTarget);
1472 cairo_restore (cairoTarget);
1480 draw_do_vector_export_fix(cairo_t *cairoTarget,
1481 double *bg_red,
double *bg_green,
double *bg_blue)
1489 switch (cairo_surface_get_type (cairo_get_target (cairoTarget))) {
1491 case CAIRO_SURFACE_TYPE_PDF:
1492 case CAIRO_SURFACE_TYPE_PS:
1493 case CAIRO_SURFACE_TYPE_SVG: {
1494 double *p0, *p1, *p2;
1498 p0 = cairo_get_user_data (cairoTarget,
1499 (cairo_user_data_key_t *)0);
1500 p1 = cairo_get_user_data (cairoTarget,
1501 (cairo_user_data_key_t *)1);
1502 p2 = cairo_get_user_data (cairoTarget,
1503 (cairo_user_data_key_t *)2);
1505 if (p0 != NULL && p1 != NULL && p2 != NULL) {
1510 *bg_red = *bg_green = *bg_blue = 1.0;
void draw_cairo_translate_adjust(cairo_t *cairoTarget, gdouble x, gdouble y, gboolean pixelOutput)
Cairo translate user-space origin.
static gboolean draw_net_is_in_selection_buffer_remove(gerbv_net_t *net, gerbv_selection_info_t *selectionInfo, gboolean remove)
Check if net is in selection buffer and possibly deselect it.
static void draw_cairo_cross(cairo_t *cairoTarget, gdouble xc, gdouble yc, gdouble r)
Draw Cairo cross.
static void gerbv_draw_rectangle(cairo_t *cairoTarget, gdouble width, gdouble height, gboolean pixelOutput)
Draw the rectangle centered at current Cairo coordinates.
void draw_cairo_line_to(cairo_t *cairoTarget, gdouble x, gdouble y, gboolean adjustByHalf, gboolean pixelOutput)
Draw Cairo line from current coordinates.
void draw_cairo_move_to(cairo_t *cairoTarget, gdouble x, gdouble y, gboolean oddWidth, gboolean pixelOutput)
Move Cairo coordinates.
static void gerbv_draw_oblong(cairo_t *cairoTarget, gdouble width, gdouble height)
Draw the oblong centered at current Cairo coordinates.
static void gerbv_draw_circle(cairo_t *cairoTarget, gdouble diameter)
Draw the circle centered at current Cairo coordinates.
Header info for the cairo rendering functions and the related selection calculating 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_interpolation_name(gerbv_interpolation_t interp)
Return string name of gerbv_interpolation_t interpolation.
const char * gerbv_aperture_state_name(gerbv_aperture_state_t state)
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_SELECTION_POINT_CLICK
@ GERBV_SELECTION_DRAG_BOX
@ 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_PICKANDPLACE_BOT
@ GERBV_LAYERTYPE_PICKANDPLACE_TOP
Header info for the selection support functions for libgerbv.
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_knockout_t knockout
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