gerbv
gerbv.h
Go to the documentation of this file.
1 /*
2  * gEDA - GNU Electronic Design Automation
3  * This file is a part of Gerbv.
4  *
5  * Copyright (C) 2000-2003 Stefan Petersen (spe@stacken.kth.se)
6  *
7  * $Id$
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
22  */
23 
30 
33 
36 
65 #ifndef __GERBV_H__
66 #define __GERBV_H__
67 
68 #ifdef HAVE_CONFIG_H
69 # include "config.h"
70 #endif
71 
72 #include <glib.h>
73 #include <gtk/gtk.h>
74 #include <gdk/gdk.h>
75 #include <gdk/gdkkeysyms.h>
76 
77 #ifndef RENDER_USING_GDK
78 # include <cairo.h>
79 #endif
80 
81 #ifndef M_PI
82 # define M_PI 3.14159265358979323846 /* pi */
83 #endif
84 #ifndef M_PI_2
85 # define M_PI_2 1.57079632679489661923 /* pi/2 */
86 #endif
87 #ifndef M_1_PI
88 # define M_1_PI 0.31830988618379067154 /* 1/pi */
89 #endif
90 
91 #if defined(__cplusplus)
92 extern "C" {
93 #endif
94 
95 #define APERTURE_MIN 10
96 #define APERTURE_MAX 9999
97 
98 /*
99  * Maximum number of aperture parameters is set by the outline aperture macro.
100  * There (p. 62) is defined up to 5000 points in outline. So 5000 points with x
101  * and y plus outline shape code, exposure, # of vertices, and duplication of
102  * start/end point gives
103  */
104 #define APERTURE_PARAMETERS_MAX 10006
105 #define GERBV_SCALE_MIN 10
106 #define GERBV_SCALE_MAX 40000
107 #define MAX_ERRMSGLEN 25
108 #define MAX_COORDLEN 28
109 #define MAX_DISTLEN 180
110 #define MAX_STATUSMSGLEN (MAX_ERRMSGLEN+MAX_COORDLEN+MAX_DISTLEN)
111 
112 /*
113  * Files only have a limited precision in their data, so when interpreting
114  * layer rotations or linear size that have been read from a project file, we
115  * have to tolerate a certain amount of error.
116  */
117 #define GERBV_PRECISION_ANGLE_RAD 1e-6
118 #define GERBV_PRECISION_LINEAR_INCH 1e-6
119 
120 /* Macros to convert between unscaled gerber coordinates and other units */
121 /* XXX NOTE: Currently unscaled units are assumed as inch, this is not
122  XXX necessarily true for all files */
123 #define COORD2INS(c) (c)
124 #define COORD2MILS(c) ((c)*1000.0)
125 #define COORD2MMS(c) ((c)*25.4)
126 
127 #define DEG2RAD(d) ((d)*M_PI/180.0)
128 #define RAD2DEG(r) ((r)*180.0*M_1_PI)
129 
130 #define GERB_FATAL_ERROR(...) g_log(NULL, G_LOG_LEVEL_ERROR, __VA_ARGS__)
131 #define GERB_COMPILE_ERROR(...) g_log(NULL, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
132 #define GERB_COMPILE_WARNING(...) g_log(NULL, G_LOG_LEVEL_WARNING, __VA_ARGS__)
133 #define GERB_MESSAGE(...) g_log(NULL, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
134 #define GERB_NOTE(...) g_log(NULL, G_LOG_LEVEL_INFO, __VA_ARGS__)
135 
137 typedef enum {GERBV_OPCODE_NOP,
147 
149 typedef enum {GERBV_MESSAGE_FATAL,
154 
158 typedef enum {
174 
176 
182 
184 
186 typedef enum {
187  CIRCLE_EXPOSURE,
188  CIRCLE_DIAMETER,
189  CIRCLE_CENTER_X,
190  CIRCLE_CENTER_Y,
191  CIRCLE_ROTATION,
193 
194 typedef enum {
195  OUTLINE_EXPOSURE,
196  OUTLINE_NUMBER_OF_POINTS,
197  OUTLINE_FIRST_X, /* x0 */
198  OUTLINE_FIRST_Y, /* y0 */
199  /* x1, y1, x2, y2, ..., rotation */
200  OUTLINE_ROTATION, /* Rotation index is correct if outline has
201  no point except first */
202 } gerbv_aptype_macro_outline_index_t;
203 
204 /* Point number is from 0 (first) to (including) OUTLINE_NUMBER_OF_POINTS */
205 #define OUTLINE_X_IDX_OF_POINT(number) (2*(number) + OUTLINE_FIRST_X)
206 #define OUTLINE_Y_IDX_OF_POINT(number) (2*(number) + OUTLINE_FIRST_Y)
207 #define OUTLINE_ROTATION_IDX(param_array) \
208  ((int)param_array[OUTLINE_NUMBER_OF_POINTS]*2 + \
209  OUTLINE_ROTATION)
210 
211 typedef enum {
212  POLYGON_EXPOSURE,
213  POLYGON_NUMBER_OF_POINTS,
214  POLYGON_CENTER_X,
215  POLYGON_CENTER_Y,
216  POLYGON_DIAMETER,
217  POLYGON_ROTATION,
218 } gerbv_aptype_macro_polygon_index_t;
219 
220 typedef enum {
221  MOIRE_CENTER_X,
222  MOIRE_CENTER_Y,
223  MOIRE_OUTSIDE_DIAMETER,
224  MOIRE_CIRCLE_THICKNESS,
225  MOIRE_GAP_WIDTH,
226  MOIRE_NUMBER_OF_CIRCLES,
227  MOIRE_CROSSHAIR_THICKNESS,
228  MOIRE_CROSSHAIR_LENGTH,
229  MOIRE_ROTATION,
230 } gerbv_aptype_macro_moire_index_t;
231 
232 typedef enum {
233  THERMAL_CENTER_X,
234  THERMAL_CENTER_Y,
235  THERMAL_OUTSIDE_DIAMETER,
236  THERMAL_INSIDE_DIAMETER,
237  THERMAL_CROSSHAIR_THICKNESS,
238  THERMAL_ROTATION,
239 } gerbv_aptype_macro_thermal_index_t;
240 
242 typedef enum {
243  LINE20_EXPOSURE,
244  LINE20_LINE_WIDTH,
245  LINE20_WIDTH = LINE20_LINE_WIDTH, /* Unification alias */
246  LINE20_START_X,
247  LINE20_START_Y,
248  LINE20_END_X,
249  LINE20_END_Y,
250  LINE20_ROTATION,
252 
254 typedef enum {
255  LINE21_EXPOSURE,
256  LINE21_WIDTH,
257  LINE21_HEIGHT,
258  LINE21_CENTER_X,
259  LINE21_CENTER_Y,
260  LINE21_ROTATION,
262 
264 typedef enum {
265  LINE22_EXPOSURE,
266  LINE22_WIDTH,
267  LINE22_HEIGHT,
268  LINE22_LOWER_LEFT_X,
269  LINE22_LOWER_LEFT_Y,
270  LINE22_ROTATION,
272 
273 
275 typedef enum {GERBV_UNIT_INCH,
279 
281 typedef enum {GERBV_POLARITY_POSITIVE,
286 
293 
298 
312 
313 /* For backward compatibility */
314 enum {GERBV_INTERPOLATION_x10 = GERBV_INTERPOLATION_LINEARx10};
315 
317 
318 typedef enum {GERBV_ENCODING_NONE,
319  GERBV_ENCODING_ASCII,
320  GERBV_ENCODING_EBCDIC,
321  GERBV_ENCODING_BCD,
322  GERBV_ENCODING_ISO_ASCII,
323  GERBV_ENCODING_EIA
324 } gerbv_encoding_t;
325 
327 typedef enum {
333 
334 typedef enum {GERBV_KNOCKOUT_TYPE_NOKNOCKOUT,
335  GERBV_KNOCKOUT_TYPE_FIXEDKNOCK,
336  GERBV_KNOCKOUT_TYPE_BORDER
337 } gerbv_knockout_type_t;
338 
339 typedef enum {GERBV_MIRROR_STATE_NOMIRROR,
340  GERBV_MIRROR_STATE_FLIPA,
341  GERBV_MIRROR_STATE_FLIPB,
342  GERBV_MIRROR_STATE_FLIPAB
343 } gerbv_mirror_state_t;
344 
345 typedef enum {GERBV_AXIS_SELECT_NOSELECT,
346  GERBV_AXIS_SELECT_SWAPAB
347 } gerbv_axis_select_t;
348 
349 typedef enum {GERBV_JUSTIFY_NOJUSTIFY,
350  GERBV_JUSTIFY_LOWERLEFT,
351  GERBV_JUSTIFY_CENTERJUSTIFY
352 } gerbv_image_justify_type_t;
353 
355 typedef enum { GERBV_SELECTION_POINT_CLICK = 1,
358 
359 enum draw_mode {
360  DRAW_IMAGE = 0,
361  DRAW_SELECTIONS,
362  FIND_SELECTIONS,
363  FIND_SELECTIONS_TOGGLE,
364 };
365 
367 typedef enum {GERBV_RENDER_TYPE_GDK,
373 
374 /*
375  * The following typedef's are taken directly from src/hid.h in the
376  * pcb project. The names are kept the same to make it easier to
377  * compare to pcb's sources.
378  */
379 
380 /* Used for HID attributes (exporting and printing, mostly).
381  HA_boolean uses int_value, HA_enum sets int_value to the index and
382  str_value to the enumeration string. HID_Label just shows the
383  default str_value. HID_Mixed is a real_value followed by an enum,
384  like 0.5in or 100mm.
385 */
386 typedef struct {
387  int int_value;
388  char *str_value;
389  double real_value;
390 } gerbv_HID_Attr_Val;
391 
392 typedef struct {
393  char *name;
394  char *help_text;
395  enum
396  { HID_Label, HID_Integer, HID_Real, HID_String,
397  HID_Boolean, HID_Enum, HID_Mixed, HID_Path
398  } type;
399  int min_val, max_val; /* for integer and real */
400  gerbv_HID_Attr_Val default_val; /* Also actual value for global attributes. */
401  const char **enumerations;
402  /* If set, this is used for global attributes (i.e. those set
403  statically with REGISTER_ATTRIBUTES below) instead of changing
404  the default_val. Note that a HID_Mixed attribute must specify a
405  pointer to gerbv_HID_Attr_Val here, and HID_Boolean assumes this is
406  "char *" so the value should be initialized to zero, and may be
407  set to non-zero (not always one). */
408  void *value;
409  int hash; /* for detecting changes. */
410 } gerbv_HID_Attribute;
411 /* end of HID attributes from PCB */
412 
414 typedef struct error_list {
415  int layer;
416  gchar *error_text;
418  struct error_list *next;
420 
421 typedef struct instruction {
422  gerbv_opcodes_t opcode;
423  union {
424  int ival;
425  float fval;
426  } data;
427  struct instruction *next;
428 } gerbv_instruction_t;
429 
430 typedef struct amacro {
431  gchar *name;
432  gerbv_instruction_t *program;
433  unsigned int nuf_push; /* Nuf pushes in program to estimate stack size */
434  struct amacro *next;
435 } gerbv_amacro_t;
436 
437 typedef struct gerbv_simplified_amacro {
439  double parameter[APERTURE_PARAMETERS_MAX];
440  struct gerbv_simplified_amacro *next;
441 } gerbv_simplified_amacro_t;
442 
443 typedef struct gerbv_aperture {
445  gerbv_amacro_t *amacro;
446  gerbv_simplified_amacro_t *simplified;
447  double parameter[APERTURE_PARAMETERS_MAX];
448  int nuf_parameters;
449  gerbv_unit_t unit;
450 } gerbv_aperture_t;
451 
452 /* the gerb_aperture_list is used to keep track of
453  * apertures used in stats reporting */
454 typedef struct gerbv_aperture_list {
455  int number;
456  int layer;
457  int count;
459  double parameter[5];
460  struct gerbv_aperture_list *next;
461 } gerbv_aperture_list_t;
462 
464 typedef struct {
466  gerbv_aperture_list_t *aperture_list;
467  gerbv_aperture_list_t *D_code_list;
468 
469  int layer_count;
470  int G0;
471  int G1;
472  int G2;
473  int G3;
474  int G4;
475  int G10;
476  int G11;
477  int G12;
478  int G36;
479  int G37;
480  int G54;
481  int G55;
482  int G70;
483  int G71;
484  int G74;
485  int G75;
486  int G90;
487  int G91;
488  int G_unknown;
489 
490  int D1;
491  int D2;
492  int D3;
493 /* GHashTable *D_user_defined; */
494  int D_unknown;
495  int D_error;
496 
497  int M0;
498  int M1;
499  int M2;
500  int M_unknown;
501 
502  int X;
503  int Y;
504  int I;
505  int J;
506 
507  /* Must include % RS-274 codes */
508  int star;
509  int unknown;
510 
511 } gerbv_stats_t;
512 
514 typedef struct drill_list {
515  int drill_num;
516  double drill_size;
517  gchar *drill_unit;
518  int drill_count;
519  struct drill_list *next;
521 
523 typedef struct {
524  int layer_count;
525 
528  int comment;
529  int F;
530 
531  int G00;
532  int G01;
533  int G02;
534  int G03;
535  int G04;
536  int G05;
537  int G85;
538  int G90;
539  int G91;
540  int G93;
541  int G_unknown;
542 
543  int M00;
544  int M01;
545  int M18;
546  int M25;
547  int M30;
548  int M31;
549  int M45;
550  int M47;
551  int M48;
552  int M71;
553  int M72;
554  int M95;
555  int M97;
556  int M98;
557  int M_unknown;
558 
559  int R;
560 
561  int unknown;
562 
563  /* used to total up the drill count across all layers/sizes */
564  int total_count;
565 
566  char *detect;
567 
569 
570 typedef struct {
571  gpointer image; /* gerbv_image_t* */
572  gpointer net; /* gerbv_net_t* */
573 } gerbv_selection_item_t;
574 
576 typedef struct {
577  gerbv_selection_t type;
578  gdouble lowerLeftX;
579  gdouble lowerLeftY;
580  gdouble upperRightX;
581  gdouble upperRightY;
582  GArray *selectedNodeArray;
584 
587 typedef struct {
588  gdouble translateX;
589  gdouble translateY;
590  gdouble scaleX;
591  gdouble scaleY;
592  gdouble rotation;
593  gboolean mirrorAroundX;
594  gboolean mirrorAroundY;
595  gboolean inverted;
597 
599 typedef struct {
600  double left;
601  double right;
602  double bottom;
603  double top;
605 
606 typedef struct gerbv_cirseg {
607  double cp_x; /* center point x */
608  double cp_y; /* center point y */
609  double width; /* used as diameter */
610  double height; /* */
611  double angle1; /* in degrees */
612  double angle2; /* in degrees */
613 } gerbv_cirseg_t;
614 
615 typedef struct gerbv_step_and_repeat { /* SR parameters */
616  int X;
617  int Y;
618  double dist_X;
619  double dist_Y;
620 } gerbv_step_and_repeat_t;
621 
622 typedef struct {
623  gboolean firstInstance;
624  gerbv_knockout_type_t type;
625  gerbv_polarity_t polarity;
626  gdouble lowerLeftX;
627  gdouble lowerLeftY;
628  gdouble width;
629  gdouble height;
630  gdouble border;
631 } gerbv_knockout_t;
632 
634 typedef struct {
635  gerbv_step_and_repeat_t stepAndRepeat;
636  gerbv_knockout_t knockout;
637  gdouble rotation;
639  gchar *name;
640  gpointer next;
641 } gerbv_layer_t;
642 
644 typedef struct {
645  gerbv_axis_select_t axisSelect;
646  gerbv_mirror_state_t mirrorState;
648  gdouble offsetA;
649  gdouble offsetB;
650  gdouble scaleA;
651  gdouble scaleB;
652  gpointer next;
654 
656 typedef struct gerbv_net {
657  double start_x;
658  double start_y;
659  double stop_x;
660  double stop_y;
662  int aperture;
665  gerbv_cirseg_t *cirseg;
666  struct gerbv_net *next;
667  GString *label;
671 
674 typedef struct gerbv_format {
675  gerbv_omit_zeros_t omit_zeros;
676  gerbv_coordinate_t coordinate;
677  int x_int;
678  int x_dec;
679  int y_int;
680  int y_dec;
681  int lim_seqno; /* Length limit for codes of sequence number */
682  int lim_gf; /* Length limit for codes of general function */
683  int lim_pf; /* Length limit for codes of plot function */
684  int lim_mf; /* Length limit for codes of miscellaneous function */
686 
687 
689 typedef struct gerbv_image_info {
690  char *name;
691  gerbv_polarity_t polarity;
692  double min_x; /* Always in inches */
693  double min_y;
694  double max_x;
695  double max_y;
696  double offsetA;
697  double offsetB;
698  gerbv_encoding_t encoding;
699  double imageRotation;
700  gerbv_image_justify_type_t imageJustifyTypeA;
701  gerbv_image_justify_type_t imageJustifyTypeB;
702  gdouble imageJustifyOffsetA;
703  gdouble imageJustifyOffsetB;
704  gdouble imageJustifyOffsetActualA;
705  gdouble imageJustifyOffsetActualB;
706  gchar *plotterFilm;
707 
708  /* Descriptive string for the type of file (rs274-x, drill, etc)
709  * that this is
710  */
711  gchar *type;
712 
713  /* Attribute list that is used to hold all sorts of information
714  * about how the layer is to be parsed.
715  */
716  gerbv_HID_Attribute *attr_list;
717  int n_attr;
719 
721 typedef struct {
723  gerbv_aperture_t *aperture[APERTURE_MAX];
726  gerbv_amacro_t *amacro;
732 } gerbv_image_t;
733 
735 typedef struct {
737  GdkColor color;
738  guint16 alpha;
739  gboolean isVisible;
740  gpointer privateRenderData;
741  gchar *fullPathname;
742  gchar *name;
744  gboolean layer_dirty;
746 
749 typedef struct {
750  GdkColor background;
751  int max_files;
758  gchar *path;
759  gchar *execpath;
760  gchar *execname;
761  gchar *project;
762  gboolean use_cairo_svg;
764 
766 typedef struct{
767  unsigned char red;
768  unsigned char green;
769  unsigned char blue;
770  unsigned char alpha;
772 
774 typedef struct {
775  gdouble scaleFactorX;
776  gdouble scaleFactorY;
777  gdouble lowerLeftX;
778  gdouble lowerLeftY;
784 
788  const gchar *type
789 );
790 
793 );
794 
796 void
798  gerbv_user_transformation_t *transform,
799  gerbv_image_t *destinationImage
800 );
801 
806  gerbv_user_transformation_t *transform
807 );
808 
810 void
812 );
813 
814 gboolean
815 gerbv_image_reduce_area_of_selected_objects (GArray *selectionArray, gdouble areaReduction, gint paneRows,
816  gint paneColumns, gdouble paneSeparation);
817 
818 gboolean
819 gerbv_image_move_selected_objects (GArray *selectionArray, gdouble translationX,
820  gdouble translationY);
821 
823 gerbv_net_t *
825 
828 gerbv_create_project (void);
829 
831 void
833 );
834 
836 void
838  gerbv_project_t *gerbvProject,
839  gchar const* filename
840 );
841 
843 void
845  gchar const* filename,
846  guint16 red,
847  guint16 green,
848  guint16 blue,
849  guint16 alpha
850 );
851 
853 void
855 );
856 
857 gboolean
858 gerbv_save_layer_from_index(gerbv_project_t *gerbvProject, gint index, gchar *filename);
859 
860 int
861 gerbv_revert_file(gerbv_project_t *gerbvProject, int idx);
862 
863 void
864 gerbv_revert_all_files(gerbv_project_t *gerbvProject);
865 
866 void
867 gerbv_unload_layer(gerbv_project_t *gerbvProject, int index);
868 
869 void
870 gerbv_unload_all_layers (gerbv_project_t *gerbvProject);
871 
872 void
873 gerbv_change_layer_order(gerbv_project_t *gerbvProject, gint oldPosition, gint newPosition);
874 
875 gint
876 gerbv_add_parsed_image_to_project (gerbv_project_t *gerbvProject, gerbv_image_t *parsed_image,
877  gchar const* filename, gchar const* baseName, int idx, int reload);
878 int
879 gerbv_open_image(gerbv_project_t *gerbvProject, gchar const* filename, int idx, int reload,
880  gerbv_HID_Attribute *fattr, int n_fattr, gboolean forceLoadFile);
881 
882 void
883 gerbv_render_get_boundingbox(gerbv_project_t *gerbvProject, gerbv_render_size_t *boundingbox);
884 
886 void
888  gerbv_render_info_t *renderInfo
889 );
890 
891 void
892 gerbv_render_translate_to_fit_display (gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo);
893 
894 void
895 gerbv_render_to_pixmap_using_gdk (gerbv_project_t *gerbvProject, GdkPixmap *pixmap,
896  gerbv_render_info_t *renderInfo, gerbv_selection_info_t *selectionInfo,
897  GdkColor *selectionColor);
898 
899 #ifndef RENDER_USING_GDK
900 void
901 gerbv_render_all_layers_to_cairo_target_for_vector_output (gerbv_project_t *gerbvProject,
902  cairo_t *cr, gerbv_render_info_t *renderInfo);
903 
904 void
905 gerbv_render_all_layers_to_cairo_target (gerbv_project_t *gerbvProject, cairo_t *cr,
906  gerbv_render_info_t *renderInfo);
907 
909 void
911  gerbv_fileinfo_t *fileInfo,
912  gerbv_render_info_t *renderInfo
913 );
914 
915 void
916 gerbv_render_cairo_set_scale_and_translation(cairo_t *cr, gerbv_render_info_t *renderInfo);
917 
918 void
919 gerbv_render_layer_to_cairo_target_without_transforming(cairo_t *cr, gerbv_fileinfo_t *fileInfo, gerbv_render_info_t *renderInfo, gboolean pixelOutput );
920 #endif
921 
922 double
923 gerbv_get_tool_diameter(int toolNumber
924 );
925 
926 int
927 gerbv_process_tools_file(const char *toolFileName
928 );
929 
931 void
933  gerbv_project_t *gerbvProject,
934  int widthInPixels,
935  int heightInPixels,
936  gchar const* filename
937 );
938 
940 void
942  gerbv_project_t *gerbvProject,
943  gerbv_render_info_t *renderInfo,
944  gchar const* filename
945 );
946 
948 void
950  gerbv_project_t *gerbvProject,
951  gchar const* filename
952 );
953 
955 void
957  gerbv_project_t *gerbvProject,
958  gerbv_render_info_t *renderInfo,
959  gchar const* filename
960 );
961 
963 void
965  gerbv_project_t *gerbvProject,
966  gchar const* filename
967 );
968 
970 void
972  gerbv_project_t *gerbvProject,
973  gerbv_render_info_t *renderInfo,
974  gchar const* filename
975 );
976 
978 void
980  gerbv_project_t *gerbvProject,
981  gchar const* filename
982 );
983 
985 void
987  gerbv_project_t *gerbvProject,
988  gchar const* filename,
989  gboolean exportLayersAsSvgLayers
990 );
991 
993 void
995  gerbv_project_t *gerbvProject,
996  gerbv_render_info_t *renderInfo,
997  gchar const* filename
998 );
999 
1001 void
1003  gerbv_project_t *gerbvProject,
1004  gerbv_render_info_t *renderInfo,
1005  gchar const* filename,
1006  gboolean exportLayersAsSvgLayers
1007 );
1008 
1011 gboolean
1012 gerbv_export_dxf_file_from_image (const gchar *filename,
1013  gerbv_image_t *image,
1014  gerbv_user_transformation_t *transform
1015 );
1016 
1019 gerbv_image_t *
1020 gerbv_create_excellon_image_from_filename (const gchar *filename
1021 );
1022 
1025 gerbv_image_t *
1026 gerbv_create_rs274x_image_from_filename (const gchar *filename
1027 );
1028 
1031 gboolean
1032 gerbv_export_rs274x_file_from_image (const gchar *filename,
1033  gerbv_image_t *image,
1034  gerbv_user_transformation_t *transform
1035 );
1036 
1039 gboolean
1040 gerbv_export_drill_file_from_image (const gchar *filename,
1041  gerbv_image_t *image,
1042  gerbv_user_transformation_t *transform
1043 );
1044 
1047 gboolean
1048 gerbv_export_isel_drill_file_from_image (const gchar *filename,
1049  gerbv_image_t *image,
1050  gerbv_user_transformation_t *transform
1051 );
1052 
1055 gboolean
1056 gerbv_export_geda_pcb_file_from_image (const gchar *filename,
1057  gerbv_image_t *image,
1058  gerbv_user_transformation_t *transform
1059 );
1060 
1062 void
1064  gdouble startX,
1065  gdouble startY,
1066  gdouble endX,
1067  gdouble endY,
1068  gdouble lineWidth,
1069  gerbv_aperture_type_t apertureType
1070 );
1071 
1073 void
1075  gdouble centerX,
1076  gdouble centerY,
1077  gdouble radius,
1078  gdouble startAngle,
1079  gdouble endAngle,
1080  gdouble lineWidth,
1081  gerbv_aperture_type_t apertureType
1082 );
1083 
1085 void
1087  gdouble coordinateX,
1088  gdouble coordinateY,
1089  gdouble width,
1090  gdouble height
1091 );
1092 
1094 void
1096 );
1097 
1100 gerbv_drill_stats_new(void);
1101 
1103 void
1105 
1108 void
1110  gerbv_drill_stats_t *input_stats,
1111  int this_layer
1112 );
1113 
1115 gerbv_stats_t *
1116 gerbv_stats_new(void);
1117 
1119 void
1121 
1124 void
1125 gerbv_stats_add_layer(gerbv_stats_t *accum_stats,
1126  gerbv_stats_t *input_stats,
1127  int this_layer
1128 );
1129 
1130 void
1131 gerbv_attribute_destroy_HID_attribute (gerbv_HID_Attribute *attributeList, int n_attr);
1132 
1133 gerbv_HID_Attribute *
1134 gerbv_attribute_dup (gerbv_HID_Attribute *, int);
1135 
1139  const gerbv_project_t *project);
1140 
1142 int
1143 gerbv_transform_coord_for_image(double *x, double *y,
1144  const gerbv_image_t *image, const gerbv_project_t *project);
1145 
1147 gboolean
1148 gerbv_endswith(const char *path, const char *ext);
1149 
1151 gboolean
1152 gerbv_is_loadable_file(const char *filename);
1153 
1155 void
1156 gerbv_transform_coord(double *x, double *y,
1157  const gerbv_user_transformation_t *trans);
1158 
1160 void
1161 gerbv_rotate_coord(double *x, double *y, double rad);
1162 
1163 /* Standard C inline functions for MIN/MAX - works with any C99+ compiler */
1164 #undef MIN
1165 #undef MAX
1166 
1167 static inline int min_int(int x, int y) { return x < y ? x : y; }
1168 static inline int max_int(int x, int y) { return x > y ? x : y; }
1169 static inline double min_double(double x, double y) { return x < y ? x : y; }
1170 static inline double max_double(double x, double y) { return x > y ? x : y; }
1171 
1172 /* Generic macros using C11 _Generic for type-safe selection */
1173 #define MIN(x, y) _Generic((x), \
1174  int: min_int, \
1175  double: min_double, \
1176  default: min_double \
1177 )((x), (y))
1178 
1179 #define MAX(x, y) _Generic((x), \
1180  int: max_int, \
1181  double: max_double, \
1182  default: max_double \
1183 )((x), (y))
1184 
1185 #if defined(__cplusplus)
1186 }
1187 #endif
1188 
1189 #endif /* __GERBV_H__ */
gboolean gerbv_export_dxf_file_from_image(const gchar *filename, gerbv_image_t *image, gerbv_user_transformation_t *transform)
Export an image to a new file in DXF format.
Definition: export-dxf.cpp:78
void gerbv_stats_destroy(gerbv_stats_t *)
Definition: gerb_stats.c:103
int gerbv_open_image(gerbv_project_t *gerbvProject, gchar const *filename, int idx, int reload, gerbv_HID_Attribute *fattr, int n_fattr, gboolean forceLoadFile)
Definition: gerbv.c:481
void gerbv_export_png_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a PNG file using user-specified render info.
Definition: export-image.c:229
gerbv_aptype_macro_line22_index_t
Definition: gerbv.h:264
void gerbv_export_postscript_file_from_project_autoscaled(gerbv_project_t *gerbvProject, gchar const *filename)
Render a project to a Postscript file, autoscaling the layers to fit inside the specified image dimen...
Definition: export-image.c:254
struct drill_list gerbv_drill_list_t
gerbv_aperture_state_t
Definition: gerbv.h:178
@ GERBV_APERTURE_STATE_OFF
Definition: gerbv.h:178
@ GERBV_APERTURE_STATE_ON
Definition: gerbv.h:179
@ GERBV_APERTURE_STATE_FLASH
Definition: gerbv.h:180
struct error_list gerbv_error_list_t
void gerbv_drill_stats_destroy(gerbv_drill_stats_t *)
Definition: drill_stats.c:101
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
Definition: gerb_image.c:106
gboolean gerbv_export_isel_drill_file_from_image(const gchar *filename, gerbv_image_t *image, gerbv_user_transformation_t *transform)
Export an image to a new file in ISEL NCP drill format.
gboolean gerbv_export_drill_file_from_image(const gchar *filename, gerbv_image_t *image, gerbv_user_transformation_t *transform)
Export an image to a new file in Excellon drill format.
Definition: export-drill.c:42
void gerbv_destroy_project(gerbv_project_t *gerbvProject)
Free a project and all related variables.
Definition: gerbv.c:207
const char * gerbv_interpolation_name(gerbv_interpolation_t interp)
Return string name of gerbv_interpolation_t interpolation.
Definition: gerbv.c:115
void gerbv_export_svg_file_from_project_autoscaled_with_options(gerbv_project_t *gerbvProject, gchar const *filename, gboolean exportLayersAsSvgLayers)
Render a project to a SVG file, optionally exporting visible layers as Inkscape layers.
Definition: export-image.c:276
void gerbv_export_svg_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a file using user-specified render info.
Definition: export-image.c:271
struct gerbv_net gerbv_net_t
gerbv_omit_zeros_t
Definition: gerbv.h:288
@ GERBV_OMIT_ZEROS_TRAILING
Definition: gerbv.h:289
@ GERBV_OMIT_ZEROS_EXPLICIT
Definition: gerbv.h:290
@ GERBV_OMIT_ZEROS_LEADING
Definition: gerbv.h:288
@ GERBV_OMIT_ZEROS_UNSPECIFIED
Definition: gerbv.h:291
void gerbv_rotate_coord(double *x, double *y, double rad)
Definition: gerbv.c:1144
void gerbv_image_create_rectangle_object(gerbv_image_t *image, gdouble coordinateX, gdouble coordinateY, gdouble width, gdouble height)
Draw a filled rectangle on the specified image
Definition: gerb_image.c:1032
gerbv_polarity_t
Definition: gerbv.h:281
@ GERBV_POLARITY_CLEAR
Definition: gerbv.h:284
@ GERBV_POLARITY_DARK
Definition: gerbv.h:283
@ GERBV_POLARITY_NEGATIVE
Definition: gerbv.h:282
@ GERBV_POLARITY_POSITIVE
Definition: gerbv.h:281
gerbv_image_t * gerbv_create_rs274x_image_from_filename(const gchar *filename)
Parse a RS274X file and return the parsed image.
Definition: gerbv.c:691
void gerbv_open_layer_from_filename_with_color(gerbv_project_t *gerbvProject, gchar const *filename, guint16 red, guint16 green, guint16 blue, guint16 alpha)
Open a file, parse the contents, and add a new layer to an existing project while setting the color o...
Definition: gerbv.c:260
gerbv_aptype_macro_circle_index_t
Definition: gerbv.h:186
gboolean gerbv_export_geda_pcb_file_from_image(const gchar *filename, gerbv_image_t *image, gerbv_user_transformation_t *transform)
Export an image to a new file in gEDA PCB format.
gerbv_project_t * gerbv_create_project(void)
Create a new project structure and initialize some important variables.
Definition: gerbv.c:190
gerbv_stats_t * gerbv_stats_new(void)
Allocates a new gerbv_stats structure.
Definition: gerb_stats.c:45
const char * gerbv_aperture_state_name(gerbv_aperture_state_t state)
Definition: gerbv.c:99
gboolean gerbv_is_loadable_file(const char *filename)
Definition: gerbv.c:655
gerbv_render_types_t
Definition: gerbv.h:367
@ GERBV_RENDER_TYPE_MAX
Definition: gerbv.h:371
@ GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY
Definition: gerbv.h:370
@ GERBV_RENDER_TYPE_GDK_XOR
Definition: gerbv.h:368
@ GERBV_RENDER_TYPE_GDK
Definition: gerbv.h:367
@ GERBV_RENDER_TYPE_CAIRO_NORMAL
Definition: gerbv.h:369
void gerbv_stats_add_layer(gerbv_stats_t *accum_stats, gerbv_stats_t *input_stats, int this_layer)
Definition: gerb_stats.c:121
gerbv_aptype_macro_line21_index_t
Definition: gerbv.h:254
gerbv_coordinate_t
Definition: gerbv.h:295
@ GERBV_COORDINATE_INCREMENTAL
Definition: gerbv.h:296
@ GERBV_COORDINATE_ABSOLUTE
Definition: gerbv.h:295
gerbv_message_type_t
Definition: gerbv.h:149
@ GERBV_MESSAGE_ERROR
Definition: gerbv.h:150
@ GERBV_MESSAGE_NOTE
Definition: gerbv.h:152
@ GERBV_MESSAGE_FATAL
Definition: gerbv.h:149
@ GERBV_MESSAGE_WARNING
Definition: gerbv.h:151
void gerbv_export_postscript_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a Postscript file using user-specified render info.
Definition: export-image.c:259
gerbv_fileinfo_t * gerbv_get_fileinfo_for_image(const gerbv_image_t *image, const gerbv_project_t *project)
Definition: gerbv.c:1130
void gerbv_image_copy_image(gerbv_image_t *sourceImage, gerbv_user_transformation_t *transform, gerbv_image_t *destinationImage)
Copy an image into an existing image, effectively merging the two together.
Definition: gerb_image.c:958
gerbv_selection_t
Definition: gerbv.h:355
@ GERBV_SELECTION_POINT_CLICK
Definition: gerbv.h:355
@ GERBV_SELECTION_DRAG_BOX
Definition: gerbv.h:356
struct gerbv_format gerbv_format_t
void gerbv_export_svg_file_from_project_with_options(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename, gboolean exportLayersAsSvgLayers)
Render a project to a SVG file using user-specified render info and export options.
Definition: export-image.c:283
void gerbv_export_png_file_from_project_autoscaled(gerbv_project_t *gerbvProject, int widthInPixels, int heightInPixels, gchar const *filename)
Render a project to a PNG file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:219
gerbv_opcodes_t
Definition: gerbv.h:137
@ GERBV_OPCODE_PPUSH
Definition: gerbv.h:139
@ GERBV_OPCODE_ADD
Definition: gerbv.h:141
@ GERBV_OPCODE_PPOP
Definition: gerbv.h:140
@ GERBV_OPCODE_PUSH
Definition: gerbv.h:138
@ GERBV_OPCODE_SUB
Definition: gerbv.h:142
@ GERBV_OPCODE_NOP
Definition: gerbv.h:137
@ GERBV_OPCODE_DIV
Definition: gerbv.h:144
@ GERBV_OPCODE_MUL
Definition: gerbv.h:143
@ GERBV_OPCODE_PRIM
Definition: gerbv.h:145
gerbv_aptype_macro_line20_index_t
Definition: gerbv.h:242
void gerbv_open_layer_from_filename(gerbv_project_t *gerbvProject, gchar const *filename)
Open a file, parse the contents, and add a new layer to an existing project.
Definition: gerbv.c:242
gerbv_image_t * gerbv_create_image(gerbv_image_t *image, const gchar *type)
Allocate a new gerbv_image structure.
Definition: gerb_image.c:46
void gerbv_export_pdf_file_from_project_autoscaled(gerbv_project_t *gerbvProject, gchar const *filename)
Render a project to a PDF file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:241
void gerbv_transform_coord(double *x, double *y, const gerbv_user_transformation_t *trans)
Definition: gerbv.c:1153
void gerbv_image_create_line_object(gerbv_image_t *image, gdouble startX, gdouble startY, gdouble endX, gdouble endY, gdouble lineWidth, gerbv_aperture_type_t apertureType)
Draw a line on the specified image.
Definition: gerb_image.c:1174
gboolean gerbv_endswith(const char *path, const char *ext)
Definition: gerbv.c:1190
void gerbv_destroy_fileinfo(gerbv_fileinfo_t *fileInfo)
Free a fileinfo structure.
Definition: gerbv.c:230
void gerbv_image_delete_net(gerbv_net_t *currentNet)
Delete a net in an existing image.
Definition: gerb_image.c:1002
const char * gerbv_aperture_type_name(gerbv_aperture_type_t type)
Return string name of gerbv_aperture_type_t aperture type.
Definition: gerbv.c:72
void gerbv_export_pdf_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a PDF file using user-specified render info.
Definition: export-image.c:246
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.
Definition: gerb_image.c:1356
void gerbv_render_zoom_to_fit_display(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo)
Calculate the zoom and translations to fit the rendered scene inside the given scene size.
Definition: gerbv.c:781
struct gerbv_image_info gerbv_image_info_t
gerbv_aperture_type_t
Definition: gerbv.h:158
@ GERBV_APTYPE_MACRO_LINE20
Definition: gerbv.h:170
@ GERBV_APTYPE_MACRO_LINE21
Definition: gerbv.h:171
@ GERBV_APTYPE_OVAL
Definition: gerbv.h:162
@ GERBV_APTYPE_MACRO_OUTLINE
Definition: gerbv.h:166
@ GERBV_APTYPE_MACRO_CIRCLE
Definition: gerbv.h:165
@ GERBV_APTYPE_MACRO
Definition: gerbv.h:164
@ GERBV_APTYPE_CIRCLE
Definition: gerbv.h:160
@ GERBV_APTYPE_NONE
Definition: gerbv.h:159
@ GERBV_APTYPE_POLYGON
Definition: gerbv.h:163
@ GERBV_APTYPE_MACRO_POLYGON
Definition: gerbv.h:167
@ GERBV_APTYPE_RECTANGLE
Definition: gerbv.h:161
@ GERBV_APTYPE_MACRO_THERMAL
Definition: gerbv.h:169
@ GERBV_APTYPE_MACRO_LINE22
Definition: gerbv.h:172
@ GERBV_APTYPE_MACRO_MOIRE
Definition: gerbv.h:168
void gerbv_drill_stats_add_layer(gerbv_drill_stats_t *accum_stats, gerbv_drill_stats_t *input_stats, int this_layer)
Definition: drill_stats.c:111
int gerbv_transform_coord_for_image(double *x, double *y, const gerbv_image_t *image, const gerbv_project_t *project)
Definition: gerbv.c:1173
void gerbv_export_svg_file_from_project_autoscaled(gerbv_project_t *gerbvProject, gchar const *filename)
Render a project to a SVG file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:266
gerbv_image_t * gerbv_image_duplicate_image(gerbv_image_t *sourceImage, gerbv_user_transformation_t *transform)
Duplicate an existing image and return the new copy.
Definition: gerb_image.c:920
gerbv_unit_t
Definition: gerbv.h:275
@ GERBV_UNIT_INCH
Definition: gerbv.h:275
@ GERBV_UNIT_MM
Definition: gerbv.h:276
@ GERBV_UNIT_UNSPECIFIED
Definition: gerbv.h:277
gboolean gerbv_export_rs274x_file_from_image(const gchar *filename, gerbv_image_t *image, gerbv_user_transformation_t *transform)
Export an image to a new file in RS274X format.
void gerbv_image_create_dummy_apertures(gerbv_image_t *parsed_image)
Create any missing apertures in the specified image.
Definition: gerb_image.c:1374
gerbv_image_t * gerbv_create_excellon_image_from_filename(const gchar *filename)
Parse an Excellon drill file and return the parsed image.
Definition: gerbv.c:674
gerbv_drill_stats_t * gerbv_drill_stats_new(void)
Allocates a new drill_stats structure.
Definition: drill_stats.c:48
gerbv_interpolation_t
Definition: gerbv.h:302
@ GERBV_INTERPOLATION_LINEARx01
Definition: gerbv.h:304
@ GERBV_INTERPOLATION_PAREA_START
Definition: gerbv.h:308
@ GERBV_INTERPOLATION_LINEARx001
Definition: gerbv.h:305
@ GERBV_INTERPOLATION_DELETED
Definition: gerbv.h:310
@ GERBV_INTERPOLATION_CW_CIRCULAR
Definition: gerbv.h:306
@ GERBV_INTERPOLATION_PAREA_END
Definition: gerbv.h:309
@ GERBV_INTERPOLATION_LINEARx10
Definition: gerbv.h:303
@ GERBV_INTERPOLATION_CCW_CIRCULAR
Definition: gerbv.h:307
@ GERBV_INTERPOLATION_LINEARx1
Definition: gerbv.h:302
void gerbv_image_create_arc_object(gerbv_image_t *image, gdouble centerX, gdouble centerY, gdouble radius, gdouble startAngle, gdouble endAngle, gdouble lineWidth, gerbv_aperture_type_t apertureType)
Draw an arc on the specified image.
Definition: gerb_image.c:1131
void gerbv_render_layer_to_cairo_target(cairo_t *cr, gerbv_fileinfo_t *fileInfo, gerbv_render_info_t *renderInfo)
Render a layer to a cairo context.
Definition: gerbv.c:1025
gerbv_layertype_t
Definition: gerbv.h:327
@ GERBV_LAYERTYPE_PICKANDPLACE_BOT
Definition: gerbv.h:331
@ GERBV_LAYERTYPE_RS274X
Definition: gerbv.h:328
@ GERBV_LAYERTYPE_PICKANDPLACE_TOP
Definition: gerbv.h:330
@ GERBV_LAYERTYPE_DRILL
Definition: gerbv.h:329
guint16 alpha
Definition: gerbv.h:738
gchar * fullPathname
Definition: gerbv.h:741
gerbv_image_t * image
Definition: gerbv.h:736
gerbv_user_transformation_t transform
Definition: gerbv.h:743
gchar * name
Definition: gerbv.h:742
GdkColor color
Definition: gerbv.h:737
gboolean layer_dirty
Definition: gerbv.h:744
gpointer privateRenderData
Definition: gerbv.h:740
gboolean isVisible
Definition: gerbv.h:739
gerbv_amacro_t * amacro
Definition: gerbv.h:726
gerbv_stats_t * gerbv_stats
Definition: gerbv.h:730
gerbv_format_t * format
Definition: gerbv.h:727
gerbv_layer_t * layers
Definition: gerbv.h:724
gerbv_layertype_t layertype
Definition: gerbv.h:722
gerbv_net_t * netlist
Definition: gerbv.h:729
gerbv_drill_stats_t * drill_stats
Definition: gerbv.h:731
gerbv_netstate_t * states
Definition: gerbv.h:725
gerbv_image_info_t * info
Definition: gerbv.h:728
gchar * name
Definition: gerbv.h:639
gerbv_step_and_repeat_t stepAndRepeat
Definition: gerbv.h:635
gerbv_polarity_t polarity
Definition: gerbv.h:638
gerbv_knockout_t knockout
Definition: gerbv.h:636
gpointer next
Definition: gerbv.h:640
gdouble rotation
Definition: gerbv.h:637
gerbv_render_size_t boundingBox
Definition: gerbv.h:661
gerbv_layer_t * layer
Definition: gerbv.h:668
double stop_y
Definition: gerbv.h:660
GString * label
Definition: gerbv.h:667
gerbv_aperture_state_t aperture_state
Definition: gerbv.h:663
double stop_x
Definition: gerbv.h:659
double start_x
Definition: gerbv.h:657
gerbv_netstate_t * state
Definition: gerbv.h:669
struct gerbv_net * next
Definition: gerbv.h:666
double start_y
Definition: gerbv.h:658
gerbv_interpolation_t interpolation
Definition: gerbv.h:664
gerbv_cirseg_t * cirseg
Definition: gerbv.h:665
int aperture
Definition: gerbv.h:662
gdouble offsetB
Definition: gerbv.h:649
gdouble scaleA
Definition: gerbv.h:650
gdouble scaleB
Definition: gerbv.h:651
gerbv_axis_select_t axisSelect
Definition: gerbv.h:645
gpointer next
Definition: gerbv.h:652
gerbv_unit_t unit
Definition: gerbv.h:647
gdouble offsetA
Definition: gerbv.h:648
gerbv_mirror_state_t mirrorState
Definition: gerbv.h:646
gboolean use_cairo_svg
Definition: gerbv.h:762
gerbv_fileinfo_t ** file
Definition: gerbv.h:752
gchar * project
Definition: gerbv.h:761
gboolean show_invisible_selection
Definition: gerbv.h:757
GdkColor background
Definition: gerbv.h:750
gboolean check_before_delete
Definition: gerbv.h:756
gchar * execname
Definition: gerbv.h:760
gchar * path
Definition: gerbv.h:758
int renderType
Definition: gerbv.h:755
gchar * execpath
Definition: gerbv.h:759
int max_files
Definition: gerbv.h:751
int curr_index
Definition: gerbv.h:753
int last_loaded
Definition: gerbv.h:754
gdouble lowerLeftY
Definition: gerbv.h:778
gboolean show_cross_on_drill_holes
Definition: gerbv.h:782
gdouble scaleFactorX
Definition: gerbv.h:775
gint displayHeight
Definition: gerbv.h:781
gdouble lowerLeftX
Definition: gerbv.h:777
gerbv_render_types_t renderType
Definition: gerbv.h:779
gdouble scaleFactorY
Definition: gerbv.h:776