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 {
175 
177 
183 
185 
187 typedef enum {
188  CIRCLE_EXPOSURE,
189  CIRCLE_DIAMETER,
190  CIRCLE_CENTER_X,
191  CIRCLE_CENTER_Y,
192  CIRCLE_ROTATION,
194 
195 typedef enum {
196  OUTLINE_EXPOSURE,
197  OUTLINE_NUMBER_OF_POINTS,
198  OUTLINE_FIRST_X, /* x0 */
199  OUTLINE_FIRST_Y, /* y0 */
200  /* x1, y1, x2, y2, ..., rotation */
201  OUTLINE_ROTATION, /* Rotation index is correct if outline has
202  no point except first */
203 } gerbv_aptype_macro_outline_index_t;
204 
205 /* Point number is from 0 (first) to (including) OUTLINE_NUMBER_OF_POINTS */
206 #define OUTLINE_X_IDX_OF_POINT(number) (2*(number) + OUTLINE_FIRST_X)
207 #define OUTLINE_Y_IDX_OF_POINT(number) (2*(number) + OUTLINE_FIRST_Y)
208 #define OUTLINE_ROTATION_IDX(param_array) \
209  ((int)param_array[OUTLINE_NUMBER_OF_POINTS]*2 + \
210  OUTLINE_ROTATION)
211 
212 typedef enum {
213  POLYGON_EXPOSURE,
214  POLYGON_NUMBER_OF_POINTS,
215  POLYGON_CENTER_X,
216  POLYGON_CENTER_Y,
217  POLYGON_DIAMETER,
218  POLYGON_ROTATION,
219 } gerbv_aptype_macro_polygon_index_t;
220 
221 typedef enum {
222  MOIRE_CENTER_X,
223  MOIRE_CENTER_Y,
224  MOIRE_OUTSIDE_DIAMETER,
225  MOIRE_CIRCLE_THICKNESS,
226  MOIRE_GAP_WIDTH,
227  MOIRE_NUMBER_OF_CIRCLES,
228  MOIRE_CROSSHAIR_THICKNESS,
229  MOIRE_CROSSHAIR_LENGTH,
230  MOIRE_ROTATION,
231 } gerbv_aptype_macro_moire_index_t;
232 
233 typedef enum {
234  THERMAL_CENTER_X,
235  THERMAL_CENTER_Y,
236  THERMAL_OUTSIDE_DIAMETER,
237  THERMAL_INSIDE_DIAMETER,
238  THERMAL_CROSSHAIR_THICKNESS,
239  THERMAL_ROTATION,
240 } gerbv_aptype_macro_thermal_index_t;
241 
243 typedef enum {
244  LINE20_EXPOSURE,
245  LINE20_LINE_WIDTH,
246  LINE20_WIDTH = LINE20_LINE_WIDTH, /* Unification alias */
247  LINE20_START_X,
248  LINE20_START_Y,
249  LINE20_END_X,
250  LINE20_END_Y,
251  LINE20_ROTATION,
253 
255 typedef enum {
256  LINE21_EXPOSURE,
257  LINE21_WIDTH,
258  LINE21_HEIGHT,
259  LINE21_CENTER_X,
260  LINE21_CENTER_Y,
261  LINE21_ROTATION,
263 
265 typedef enum {
266  LINE22_EXPOSURE,
267  LINE22_WIDTH,
268  LINE22_HEIGHT,
269  LINE22_LOWER_LEFT_X,
270  LINE22_LOWER_LEFT_Y,
271  LINE22_ROTATION,
273 
274 
276 typedef enum {GERBV_UNIT_INCH,
280 
282 typedef enum {GERBV_POLARITY_POSITIVE,
287 
294 
299 
313 
314 /* For backward compatibility */
315 enum {GERBV_INTERPOLATION_x10 = GERBV_INTERPOLATION_LINEARx10};
316 
318 
319 typedef enum {GERBV_ENCODING_NONE,
320  GERBV_ENCODING_ASCII,
321  GERBV_ENCODING_EBCDIC,
322  GERBV_ENCODING_BCD,
323  GERBV_ENCODING_ISO_ASCII,
324  GERBV_ENCODING_EIA
325 } gerbv_encoding_t;
326 
328 typedef enum {
334 
335 typedef enum {GERBV_KNOCKOUT_TYPE_NOKNOCKOUT,
336  GERBV_KNOCKOUT_TYPE_FIXEDKNOCK,
337  GERBV_KNOCKOUT_TYPE_BORDER
338 } gerbv_knockout_type_t;
339 
340 typedef enum {GERBV_MIRROR_STATE_NOMIRROR,
341  GERBV_MIRROR_STATE_FLIPA,
342  GERBV_MIRROR_STATE_FLIPB,
343  GERBV_MIRROR_STATE_FLIPAB
344 } gerbv_mirror_state_t;
345 
346 typedef enum {GERBV_AXIS_SELECT_NOSELECT,
347  GERBV_AXIS_SELECT_SWAPAB
348 } gerbv_axis_select_t;
349 
350 typedef enum {GERBV_JUSTIFY_NOJUSTIFY,
351  GERBV_JUSTIFY_LOWERLEFT,
352  GERBV_JUSTIFY_CENTERJUSTIFY
353 } gerbv_image_justify_type_t;
354 
356 typedef enum { GERBV_SELECTION_POINT_CLICK = 1,
359 
360 enum draw_mode {
361  DRAW_IMAGE = 0,
362  DRAW_SELECTIONS,
363  FIND_SELECTIONS,
364  FIND_SELECTIONS_TOGGLE,
365 };
366 
368 typedef enum {GERBV_RENDER_TYPE_GDK,
374 
375 /*
376  * The following typedef's are taken directly from src/hid.h in the
377  * pcb project. The names are kept the same to make it easier to
378  * compare to pcb's sources.
379  */
380 
381 /* Used for HID attributes (exporting and printing, mostly).
382  HA_boolean uses int_value, HA_enum sets int_value to the index and
383  str_value to the enumeration string. HID_Label just shows the
384  default str_value. HID_Mixed is a real_value followed by an enum,
385  like 0.5in or 100mm.
386 */
387 typedef struct {
388  int int_value;
389  char *str_value;
390  double real_value;
391 } gerbv_HID_Attr_Val;
392 
393 typedef struct {
394  char *name;
395  char *help_text;
396  enum
397  { HID_Label, HID_Integer, HID_Real, HID_String,
398  HID_Boolean, HID_Enum, HID_Mixed, HID_Path
399  } type;
400  int min_val, max_val; /* for integer and real */
401  gerbv_HID_Attr_Val default_val; /* Also actual value for global attributes. */
402  const char **enumerations;
403  /* If set, this is used for global attributes (i.e. those set
404  statically with REGISTER_ATTRIBUTES below) instead of changing
405  the default_val. Note that a HID_Mixed attribute must specify a
406  pointer to gerbv_HID_Attr_Val here, and HID_Boolean assumes this is
407  "char *" so the value should be initialized to zero, and may be
408  set to non-zero (not always one). */
409  void *value;
410  int hash; /* for detecting changes. */
411 } gerbv_HID_Attribute;
412 /* end of HID attributes from PCB */
413 
415 typedef struct error_list {
416  int layer;
417  gchar *error_text;
419  struct error_list *next;
421 
422 typedef struct instruction {
423  gerbv_opcodes_t opcode;
424  union {
425  int ival;
426  float fval;
427  } data;
428  struct instruction *next;
429 } gerbv_instruction_t;
430 
431 typedef struct amacro {
432  gchar *name;
433  gerbv_instruction_t *program;
434  unsigned int nuf_push; /* Nuf pushes in program to estimate stack size */
435  struct amacro *next;
436 } gerbv_amacro_t;
437 
438 typedef struct gerbv_simplified_amacro {
440  double parameter[APERTURE_PARAMETERS_MAX];
441  struct gerbv_simplified_amacro *next;
442 } gerbv_simplified_amacro_t;
443 
444 typedef struct gerbv_aperture {
446  gerbv_amacro_t *amacro;
447  gerbv_simplified_amacro_t *simplified;
448  double parameter[APERTURE_PARAMETERS_MAX];
449  int nuf_parameters;
450  gerbv_unit_t unit;
451  struct gerbv_net *block_netlist;
452 } gerbv_aperture_t;
453 
454 /* the gerb_aperture_list is used to keep track of
455  * apertures used in stats reporting */
456 typedef struct gerbv_aperture_list {
457  int number;
458  int layer;
459  int count;
461  double parameter[5];
462  struct gerbv_aperture_list *next;
463 } gerbv_aperture_list_t;
464 
466 typedef struct {
468  gerbv_aperture_list_t *aperture_list;
469  gerbv_aperture_list_t *D_code_list;
470 
471  int layer_count;
472  int G0;
473  int G1;
474  int G2;
475  int G3;
476  int G4;
477  int G10;
478  int G11;
479  int G12;
480  int G36;
481  int G37;
482  int G54;
483  int G55;
484  int G70;
485  int G71;
486  int G74;
487  int G75;
488  int G90;
489  int G91;
490  int G_unknown;
491 
492  int D1;
493  int D2;
494  int D3;
495 /* GHashTable *D_user_defined; */
496  int D_unknown;
497  int D_error;
498 
499  int M0;
500  int M1;
501  int M2;
502  int M_unknown;
503 
504  int X;
505  int Y;
506  int I;
507  int J;
508 
509  /* Must include % RS-274 codes */
510  int star;
511  int unknown;
512 
513 } gerbv_stats_t;
514 
516 typedef struct drill_list {
517  int drill_num;
518  double drill_size;
519  gchar *drill_unit;
520  int drill_count;
521  struct drill_list *next;
523 
525 typedef struct {
526  int layer_count;
527 
530  int comment;
531  int F;
532 
533  int G00;
534  int G01;
535  int G02;
536  int G03;
537  int G04;
538  int G05;
539  int G32;
540  int G33;
541  int G85;
542  int G87;
543  int G90;
544  int G91;
545  int G93;
546  int G_machine_only;
547  int G_unknown;
548 
549  int M00;
550  int M01;
551  int M02;
552  int M18;
553  int M25;
554  int M30;
555  int M31;
556  int M45;
557  int M47;
558  int M48;
559  int M70;
560  int M71;
561  int M72;
562  int M80;
563  int M90;
564  int M95;
565  int M97;
566  int M98;
567  int M_machine_only;
568  int M_unknown;
569 
570  int R;
571 
572  int unknown;
573 
574  /* used to total up the drill count across all layers/sizes */
575  int total_count;
576 
577  char *detect;
578 
580 
581 typedef struct {
582  gpointer image; /* gerbv_image_t* */
583  gpointer net; /* gerbv_net_t* */
584 } gerbv_selection_item_t;
585 
587 typedef struct {
588  gerbv_selection_t type;
589  gdouble lowerLeftX;
590  gdouble lowerLeftY;
591  gdouble upperRightX;
592  gdouble upperRightY;
593  GArray *selectedNodeArray;
595 
598 typedef struct {
599  gdouble translateX;
600  gdouble translateY;
601  gdouble scaleX;
602  gdouble scaleY;
603  gdouble rotation;
604  gboolean mirrorAroundX;
605  gboolean mirrorAroundY;
606  gboolean inverted;
608 
610 typedef struct {
611  double left;
612  double right;
613  double bottom;
614  double top;
616 
617 typedef struct gerbv_cirseg {
618  double cp_x; /* center point x */
619  double cp_y; /* center point y */
620  double width; /* used as diameter */
621  double height; /* */
622  double angle1; /* in degrees */
623  double angle2; /* in degrees */
624 } gerbv_cirseg_t;
625 
626 typedef struct gerbv_step_and_repeat { /* SR parameters */
627  int X;
628  int Y;
629  double dist_X;
630  double dist_Y;
631 } gerbv_step_and_repeat_t;
632 
633 typedef struct {
634  gboolean firstInstance;
635  gerbv_knockout_type_t type;
636  gerbv_polarity_t polarity;
637  gdouble lowerLeftX;
638  gdouble lowerLeftY;
639  gdouble width;
640  gdouble height;
641  gdouble border;
642 } gerbv_knockout_t;
643 
645 typedef struct {
646  gerbv_step_and_repeat_t stepAndRepeat;
647  gerbv_knockout_t knockout;
648  gdouble rotation;
650  gchar *name;
651  gpointer next;
652 } gerbv_layer_t;
653 
655 typedef struct {
656  gerbv_axis_select_t axisSelect;
657  gerbv_mirror_state_t mirrorState;
659  gdouble offsetA;
660  gdouble offsetB;
661  gdouble scaleA;
662  gdouble scaleB;
663  gdouble rotation;
664  gpointer next;
666 
668 typedef struct gerbv_net {
669  double start_x;
670  double start_y;
671  double stop_x;
672  double stop_y;
674  int aperture;
677  gerbv_cirseg_t *cirseg;
678  struct gerbv_net *next;
679  GString *label;
683 
686 typedef struct gerbv_format {
687  gerbv_omit_zeros_t omit_zeros;
688  gerbv_coordinate_t coordinate;
689  int x_int;
690  int x_dec;
691  int y_int;
692  int y_dec;
693  int lim_seqno; /* Length limit for codes of sequence number */
694  int lim_gf; /* Length limit for codes of general function */
695  int lim_pf; /* Length limit for codes of plot function */
696  int lim_mf; /* Length limit for codes of miscellaneous function */
698 
699 
701 typedef struct gerbv_image_info {
702  char *name;
703  gerbv_polarity_t polarity;
704  double min_x; /* Always in inches */
705  double min_y;
706  double max_x;
707  double max_y;
708  double offsetA;
709  double offsetB;
710  gerbv_encoding_t encoding;
711  double imageRotation;
712  gerbv_image_justify_type_t imageJustifyTypeA;
713  gerbv_image_justify_type_t imageJustifyTypeB;
714  gdouble imageJustifyOffsetA;
715  gdouble imageJustifyOffsetB;
716  gdouble imageJustifyOffsetActualA;
717  gdouble imageJustifyOffsetActualB;
718  gchar *plotterFilm;
719 
720  /* Descriptive string for the type of file (rs274-x, drill, etc)
721  * that this is
722  */
723  gchar *type;
724 
725  /* Attribute list that is used to hold all sorts of information
726  * about how the layer is to be parsed.
727  */
728  gerbv_HID_Attribute *attr_list;
729  int n_attr;
731 
733 typedef struct {
735  gerbv_aperture_t *aperture[APERTURE_MAX];
738  gerbv_amacro_t *amacro;
744 } gerbv_image_t;
745 
747 typedef struct {
749  GdkColor color;
750  guint16 alpha;
751  gboolean isVisible;
752  gpointer privateRenderData;
753  gchar *fullPathname;
754  gchar *name;
756  gboolean layer_dirty;
758 
761 typedef struct {
762  GdkColor background;
763  int max_files;
770  gchar *path;
771  gchar *execpath;
772  gchar *execname;
773  gchar *project;
774  gboolean use_cairo_svg;
776 
778 typedef struct{
779  unsigned char red;
780  unsigned char green;
781  unsigned char blue;
782  unsigned char alpha;
784 
786 typedef struct {
787  gdouble scaleFactorX;
788  gdouble scaleFactorY;
789  gdouble lowerLeftX;
790  gdouble lowerLeftY;
796 
800  const gchar *type
801 );
802 
805 );
806 
808 void
810  gerbv_user_transformation_t *transform,
811  gerbv_image_t *destinationImage
812 );
813 
818  gerbv_user_transformation_t *transform
819 );
820 
822 void
824 );
825 
826 gboolean
827 gerbv_image_reduce_area_of_selected_objects (GArray *selectionArray, gdouble areaReduction, gint paneRows,
828  gint paneColumns, gdouble paneSeparation);
829 
830 gboolean
831 gerbv_image_move_selected_objects (GArray *selectionArray, gdouble translationX,
832  gdouble translationY);
833 
835 gerbv_net_t *
837 
840 gerbv_create_project (void);
841 
843 void
845 );
846 
848 void
850  gerbv_project_t *gerbvProject,
851  gchar const* filename
852 );
853 
855 void
857  gchar const* filename,
858  guint16 red,
859  guint16 green,
860  guint16 blue,
861  guint16 alpha
862 );
863 
865 void
867 );
868 
869 gboolean
870 gerbv_save_layer_from_index(gerbv_project_t *gerbvProject, gint index, gchar *filename);
871 
872 int
873 gerbv_revert_file(gerbv_project_t *gerbvProject, int idx);
874 
875 void
876 gerbv_revert_all_files(gerbv_project_t *gerbvProject);
877 
878 void
879 gerbv_unload_layer(gerbv_project_t *gerbvProject, int index);
880 
881 void
882 gerbv_unload_all_layers (gerbv_project_t *gerbvProject);
883 
884 void
885 gerbv_change_layer_order(gerbv_project_t *gerbvProject, gint oldPosition, gint newPosition);
886 
887 gint
888 gerbv_add_parsed_image_to_project (gerbv_project_t *gerbvProject, gerbv_image_t *parsed_image,
889  gchar const* filename, gchar const* baseName, int idx, int reload);
890 int
891 gerbv_open_image(gerbv_project_t *gerbvProject, gchar const* filename, int idx, int reload,
892  gerbv_HID_Attribute *fattr, int n_fattr, gboolean forceLoadFile);
893 
894 void
895 gerbv_render_get_boundingbox(gerbv_project_t *gerbvProject, gerbv_render_size_t *boundingbox);
896 
898 void
900  gerbv_render_info_t *renderInfo
901 );
902 
903 void
904 gerbv_render_translate_to_fit_display (gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo);
905 
906 void
907 gerbv_render_to_pixmap_using_gdk (gerbv_project_t *gerbvProject, GdkPixmap *pixmap,
908  gerbv_render_info_t *renderInfo, gerbv_selection_info_t *selectionInfo,
909  GdkColor *selectionColor);
910 
911 #ifndef RENDER_USING_GDK
912 void
913 gerbv_render_all_layers_to_cairo_target_for_vector_output (gerbv_project_t *gerbvProject,
914  cairo_t *cr, gerbv_render_info_t *renderInfo);
915 
916 void
917 gerbv_render_all_layers_to_cairo_target (gerbv_project_t *gerbvProject, cairo_t *cr,
918  gerbv_render_info_t *renderInfo);
919 
921 void
923  gerbv_fileinfo_t *fileInfo,
924  gerbv_render_info_t *renderInfo
925 );
926 
927 void
928 gerbv_render_cairo_set_scale_and_translation(cairo_t *cr, gerbv_render_info_t *renderInfo);
929 
930 void
931 gerbv_render_layer_to_cairo_target_without_transforming(cairo_t *cr, gerbv_fileinfo_t *fileInfo, gerbv_render_info_t *renderInfo, gboolean pixelOutput );
932 #endif
933 
934 double
935 gerbv_get_tool_diameter(int toolNumber
936 );
937 
938 int
939 gerbv_process_tools_file(const char *toolFileName
940 );
941 
943 void
945  gerbv_project_t *gerbvProject,
946  int widthInPixels,
947  int heightInPixels,
948  gchar const* filename
949 );
950 
952 void
954  gerbv_project_t *gerbvProject,
955  gerbv_render_info_t *renderInfo,
956  gchar const* filename
957 );
958 
960 void
962  gerbv_project_t *gerbvProject,
963  gchar const* filename
964 );
965 
967 void
969  gerbv_project_t *gerbvProject,
970  gerbv_render_info_t *renderInfo,
971  gchar const* filename
972 );
973 
975 void
977  gerbv_project_t *gerbvProject,
978  gchar const* filename
979 );
980 
982 void
984  gerbv_project_t *gerbvProject,
985  gerbv_render_info_t *renderInfo,
986  gchar const* filename
987 );
988 
990 void
992  gerbv_project_t *gerbvProject,
993  gchar const* filename
994 );
995 
997 void
999  gerbv_project_t *gerbvProject,
1000  gchar const* filename,
1001  gboolean exportLayersAsSvgLayers
1002 );
1003 
1005 void
1007  gerbv_project_t *gerbvProject,
1008  gerbv_render_info_t *renderInfo,
1009  gchar const* filename
1010 );
1011 
1013 void
1015  gerbv_project_t *gerbvProject,
1016  gerbv_render_info_t *renderInfo,
1017  gchar const* filename,
1018  gboolean exportLayersAsSvgLayers
1019 );
1020 
1023 gboolean
1024 gerbv_export_dxf_file_from_image (const gchar *filename,
1025  gerbv_image_t *image,
1026  gerbv_user_transformation_t *transform
1027 );
1028 
1031 gerbv_image_t *
1032 gerbv_create_excellon_image_from_filename (const gchar *filename
1033 );
1034 
1037 gerbv_image_t *
1038 gerbv_create_rs274x_image_from_filename (const gchar *filename
1039 );
1040 
1043 gboolean
1044 gerbv_export_rs274x_file_from_image (const gchar *filename,
1045  gerbv_image_t *image,
1046  gerbv_user_transformation_t *transform
1047 );
1048 
1051 gboolean
1052 gerbv_export_drill_file_from_image (const gchar *filename,
1053  gerbv_image_t *image,
1054  gerbv_user_transformation_t *transform
1055 );
1056 
1059 gboolean
1060 gerbv_export_isel_drill_file_from_image (const gchar *filename,
1061  gerbv_image_t *image,
1062  gerbv_user_transformation_t *transform
1063 );
1064 
1067 gboolean
1068 gerbv_export_geda_pcb_file_from_image (const gchar *filename,
1069  gerbv_image_t *image,
1070  gerbv_user_transformation_t *transform
1071 );
1072 
1074 void
1076  gdouble startX,
1077  gdouble startY,
1078  gdouble endX,
1079  gdouble endY,
1080  gdouble lineWidth,
1081  gerbv_aperture_type_t apertureType
1082 );
1083 
1085 void
1087  gdouble centerX,
1088  gdouble centerY,
1089  gdouble radius,
1090  gdouble startAngle,
1091  gdouble endAngle,
1092  gdouble lineWidth,
1093  gerbv_aperture_type_t apertureType
1094 );
1095 
1097 void
1099  gdouble coordinateX,
1100  gdouble coordinateY,
1101  gdouble width,
1102  gdouble height
1103 );
1104 
1106 void
1108 );
1109 
1112 gerbv_drill_stats_new(void);
1113 
1115 void
1117 
1120 void
1122  gerbv_drill_stats_t *input_stats,
1123  int this_layer
1124 );
1125 
1127 gerbv_stats_t *
1128 gerbv_stats_new(void);
1129 
1131 void
1133 
1136 void
1137 gerbv_stats_add_layer(gerbv_stats_t *accum_stats,
1138  gerbv_stats_t *input_stats,
1139  int this_layer
1140 );
1141 
1142 void
1143 gerbv_attribute_destroy_HID_attribute (gerbv_HID_Attribute *attributeList, int n_attr);
1144 
1145 gerbv_HID_Attribute *
1146 gerbv_attribute_dup (gerbv_HID_Attribute *, int);
1147 
1151  const gerbv_project_t *project);
1152 
1154 int
1155 gerbv_transform_coord_for_image(double *x, double *y,
1156  const gerbv_image_t *image, const gerbv_project_t *project);
1157 
1159 gboolean
1160 gerbv_endswith(const char *path, const char *ext);
1161 
1163 gboolean
1164 gerbv_is_loadable_file(const char *filename);
1165 
1167 void
1168 gerbv_transform_coord(double *x, double *y,
1169  const gerbv_user_transformation_t *trans);
1170 
1172 void
1173 gerbv_rotate_coord(double *x, double *y, double rad);
1174 
1175 /* Standard C inline functions for MIN/MAX - works with any C99+ compiler */
1176 #undef MIN
1177 #undef MAX
1178 
1179 static inline int min_int(int x, int y) { return x < y ? x : y; }
1180 static inline int max_int(int x, int y) { return x > y ? x : y; }
1181 static inline double min_double(double x, double y) { return x < y ? x : y; }
1182 static inline double max_double(double x, double y) { return x > y ? x : y; }
1183 
1184 /* Generic macros using C11 _Generic for type-safe selection */
1185 #define MIN(x, y) _Generic((x), \
1186  int: min_int, \
1187  double: min_double, \
1188  default: min_double \
1189 )((x), (y))
1190 
1191 #define MAX(x, y) _Generic((x), \
1192  int: max_int, \
1193  double: max_double, \
1194  default: max_double \
1195 )((x), (y))
1196 
1197 #if defined(__cplusplus)
1198 }
1199 #endif
1200 
1201 #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:483
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:265
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:179
@ GERBV_APERTURE_STATE_OFF
Definition: gerbv.h:179
@ GERBV_APERTURE_STATE_ON
Definition: gerbv.h:180
@ GERBV_APERTURE_STATE_FLASH
Definition: gerbv.h:181
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:208
const char * gerbv_interpolation_name(gerbv_interpolation_t interp)
Return string name of gerbv_interpolation_t interpolation.
Definition: gerbv.c:116
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:289
@ GERBV_OMIT_ZEROS_TRAILING
Definition: gerbv.h:290
@ GERBV_OMIT_ZEROS_EXPLICIT
Definition: gerbv.h:291
@ GERBV_OMIT_ZEROS_LEADING
Definition: gerbv.h:289
@ GERBV_OMIT_ZEROS_UNSPECIFIED
Definition: gerbv.h:292
void gerbv_rotate_coord(double *x, double *y, double rad)
Definition: gerbv.c:1146
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:1063
gerbv_polarity_t
Definition: gerbv.h:282
@ GERBV_POLARITY_CLEAR
Definition: gerbv.h:285
@ GERBV_POLARITY_DARK
Definition: gerbv.h:284
@ GERBV_POLARITY_NEGATIVE
Definition: gerbv.h:283
@ GERBV_POLARITY_POSITIVE
Definition: gerbv.h:282
gerbv_image_t * gerbv_create_rs274x_image_from_filename(const gchar *filename)
Parse a RS274X file and return the parsed image.
Definition: gerbv.c:693
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:261
gerbv_aptype_macro_circle_index_t
Definition: gerbv.h:187
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:191
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:100
gboolean gerbv_is_loadable_file(const char *filename)
Definition: gerbv.c:657
gerbv_render_types_t
Definition: gerbv.h:368
@ GERBV_RENDER_TYPE_MAX
Definition: gerbv.h:372
@ GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY
Definition: gerbv.h:371
@ GERBV_RENDER_TYPE_GDK_XOR
Definition: gerbv.h:369
@ GERBV_RENDER_TYPE_GDK
Definition: gerbv.h:368
@ GERBV_RENDER_TYPE_CAIRO_NORMAL
Definition: gerbv.h:370
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:255
gerbv_coordinate_t
Definition: gerbv.h:296
@ GERBV_COORDINATE_INCREMENTAL
Definition: gerbv.h:297
@ GERBV_COORDINATE_ABSOLUTE
Definition: gerbv.h:296
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:1132
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:989
gerbv_selection_t
Definition: gerbv.h:356
@ GERBV_SELECTION_POINT_CLICK
Definition: gerbv.h:356
@ GERBV_SELECTION_DRAG_BOX
Definition: gerbv.h:357
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:243
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:243
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:1155
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:1205
gboolean gerbv_endswith(const char *path, const char *ext)
Definition: gerbv.c:1192
void gerbv_destroy_fileinfo(gerbv_fileinfo_t *fileInfo)
Free a fileinfo structure.
Definition: gerbv.c:231
void gerbv_image_delete_net(gerbv_net_t *currentNet)
Delete a net in an existing image.
Definition: gerb_image.c:1033
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:1387
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:783
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
@ GERBV_APTYPE_BLOCK
Definition: gerbv.h:173
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:1175
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:941
gerbv_unit_t
Definition: gerbv.h:276
@ GERBV_UNIT_INCH
Definition: gerbv.h:276
@ GERBV_UNIT_MM
Definition: gerbv.h:277
@ GERBV_UNIT_UNSPECIFIED
Definition: gerbv.h:278
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:1405
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:676
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:303
@ GERBV_INTERPOLATION_LINEARx01
Definition: gerbv.h:305
@ GERBV_INTERPOLATION_PAREA_START
Definition: gerbv.h:309
@ GERBV_INTERPOLATION_LINEARx001
Definition: gerbv.h:306
@ GERBV_INTERPOLATION_DELETED
Definition: gerbv.h:311
@ GERBV_INTERPOLATION_CW_CIRCULAR
Definition: gerbv.h:307
@ GERBV_INTERPOLATION_PAREA_END
Definition: gerbv.h:310
@ GERBV_INTERPOLATION_LINEARx10
Definition: gerbv.h:304
@ GERBV_INTERPOLATION_CCW_CIRCULAR
Definition: gerbv.h:308
@ GERBV_INTERPOLATION_LINEARx1
Definition: gerbv.h:303
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:1162
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:1027
gerbv_layertype_t
Definition: gerbv.h:328
@ GERBV_LAYERTYPE_PICKANDPLACE_BOT
Definition: gerbv.h:332
@ GERBV_LAYERTYPE_RS274X
Definition: gerbv.h:329
@ GERBV_LAYERTYPE_PICKANDPLACE_TOP
Definition: gerbv.h:331
@ GERBV_LAYERTYPE_DRILL
Definition: gerbv.h:330
guint16 alpha
Definition: gerbv.h:750
gchar * fullPathname
Definition: gerbv.h:753
gerbv_image_t * image
Definition: gerbv.h:748
gerbv_user_transformation_t transform
Definition: gerbv.h:755
gchar * name
Definition: gerbv.h:754
GdkColor color
Definition: gerbv.h:749
gboolean layer_dirty
Definition: gerbv.h:756
gpointer privateRenderData
Definition: gerbv.h:752
gboolean isVisible
Definition: gerbv.h:751
gerbv_amacro_t * amacro
Definition: gerbv.h:738
gerbv_stats_t * gerbv_stats
Definition: gerbv.h:742
gerbv_format_t * format
Definition: gerbv.h:739
gerbv_layer_t * layers
Definition: gerbv.h:736
gerbv_layertype_t layertype
Definition: gerbv.h:734
gerbv_net_t * netlist
Definition: gerbv.h:741
gerbv_drill_stats_t * drill_stats
Definition: gerbv.h:743
gerbv_netstate_t * states
Definition: gerbv.h:737
gerbv_image_info_t * info
Definition: gerbv.h:740
gchar * name
Definition: gerbv.h:650
gerbv_step_and_repeat_t stepAndRepeat
Definition: gerbv.h:646
gerbv_polarity_t polarity
Definition: gerbv.h:649
gerbv_knockout_t knockout
Definition: gerbv.h:647
gpointer next
Definition: gerbv.h:651
gdouble rotation
Definition: gerbv.h:648
gerbv_render_size_t boundingBox
Definition: gerbv.h:673
gerbv_layer_t * layer
Definition: gerbv.h:680
double stop_y
Definition: gerbv.h:672
GString * label
Definition: gerbv.h:679
gerbv_aperture_state_t aperture_state
Definition: gerbv.h:675
double stop_x
Definition: gerbv.h:671
double start_x
Definition: gerbv.h:669
gerbv_netstate_t * state
Definition: gerbv.h:681
struct gerbv_net * next
Definition: gerbv.h:678
double start_y
Definition: gerbv.h:670
gerbv_interpolation_t interpolation
Definition: gerbv.h:676
gerbv_cirseg_t * cirseg
Definition: gerbv.h:677
int aperture
Definition: gerbv.h:674
gdouble offsetB
Definition: gerbv.h:660
gdouble scaleA
Definition: gerbv.h:661
gdouble scaleB
Definition: gerbv.h:662
gerbv_axis_select_t axisSelect
Definition: gerbv.h:656
gpointer next
Definition: gerbv.h:664
gdouble rotation
Definition: gerbv.h:663
gerbv_unit_t unit
Definition: gerbv.h:658
gdouble offsetA
Definition: gerbv.h:659
gerbv_mirror_state_t mirrorState
Definition: gerbv.h:657
gboolean use_cairo_svg
Definition: gerbv.h:774
gerbv_fileinfo_t ** file
Definition: gerbv.h:764
gchar * project
Definition: gerbv.h:773
gboolean show_invisible_selection
Definition: gerbv.h:769
GdkColor background
Definition: gerbv.h:762
gboolean check_before_delete
Definition: gerbv.h:768
gchar * execname
Definition: gerbv.h:772
gchar * path
Definition: gerbv.h:770
int renderType
Definition: gerbv.h:767
gchar * execpath
Definition: gerbv.h:771
int max_files
Definition: gerbv.h:763
int curr_index
Definition: gerbv.h:765
int last_loaded
Definition: gerbv.h:766
gdouble lowerLeftY
Definition: gerbv.h:790
gboolean show_cross_on_drill_holes
Definition: gerbv.h:794
gdouble scaleFactorX
Definition: gerbv.h:787
gint displayHeight
Definition: gerbv.h:793
gdouble lowerLeftX
Definition: gerbv.h:789
gerbv_render_types_t renderType
Definition: gerbv.h:791
gdouble scaleFactorY
Definition: gerbv.h:788