gerbv  2.10.1-dev~93f1b5
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 <stdbool.h>
73 #include <glib.h>
74 #include <gtk/gtk.h>
75 #include <gdk/gdk.h>
76 #include <gdk/gdkkeysyms.h>
77 
78 #ifndef RENDER_USING_GDK
79 #include <cairo.h>
80 #endif
81 
82 #if defined(__cplusplus)
83 extern "C" {
84 #endif
85 
86 #define APERTURE_MIN 10
87 #define APERTURE_MAX 9999
88 
89 /*
90  * Maximum number of aperture parameters is set by the outline aperture macro.
91  * There (p. 62) is defined up to 5000 points in outline. So 5000 points with x
92  * and y plus outline shape code, exposure, # of vertices, and duplication of
93  * start/end point gives
94  */
95 #define APERTURE_PARAMETERS_MAX 10006
96 #define GERBV_SCALE_MIN 10
97 #define GERBV_SCALE_MAX 40000
98 #define MAX_ERRMSGLEN 25
99 #define MAX_COORDLEN 28
100 #define MAX_DISTLEN 180
101 #define MAX_STATUSMSGLEN (MAX_ERRMSGLEN + MAX_COORDLEN + MAX_DISTLEN)
102 
103 /*
104  * Files only have a limited precision in their data, so when interpreting
105  * layer rotations or linear size that have been read from a project file, we
106  * have to tolerate a certain amount of error.
107  */
108 #define GERBV_PRECISION_ANGLE_RAD 1e-6
109 #define GERBV_PRECISION_LINEAR_INCH 1e-6
110 
111 /* Macros to convert between unscaled gerber coordinates and other units */
112 /* XXX NOTE: Currently unscaled units are assumed as inch, this is not
113  XXX necessarily true for all files */
114 #define COORD2INS(c) (c)
115 #define COORD2MILS(c) ((c)*1000.0)
116 #define COORD2MMS(c) ((c)*25.4)
117 
118 #define DEG2RAD(d) ((d)*M_PI / 180.0)
119 #define RAD2DEG(r) ((r)*180.0 * M_1_PI)
120 
121 #define GERB_FATAL_ERROR(...) g_log(NULL, G_LOG_LEVEL_ERROR, __VA_ARGS__)
122 #define GERB_COMPILE_ERROR(...) g_log(NULL, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
123 #define GERB_COMPILE_WARNING(...) g_log(NULL, G_LOG_LEVEL_WARNING, __VA_ARGS__)
124 #define GERB_MESSAGE(...) g_log(NULL, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
125 
127 typedef enum {
138 
140 typedef enum {
146 
150 typedef enum {
166 
168 
170 typedef enum {
175 
177 typedef enum {
178  CIRCLE_EXPOSURE,
179  CIRCLE_DIAMETER,
180  CIRCLE_CENTER_X,
181  CIRCLE_CENTER_Y,
183 
184 typedef enum {
185  OUTLINE_EXPOSURE,
186  OUTLINE_NUMBER_OF_POINTS,
187  OUTLINE_FIRST_X, /* x0 */
188  OUTLINE_FIRST_Y, /* y0 */
189  /* x1, y1, x2, y2, ..., rotation */
190  OUTLINE_ROTATION, /* Rotation index is correct if outline has
191  no point except first */
192 } gerbv_aptype_macro_outline_index_t;
193 
194 /* Point number is from 0 (first) to (including) OUTLINE_NUMBER_OF_POINTS */
195 #define OUTLINE_X_IDX_OF_POINT(number) (2 * (number) + OUTLINE_FIRST_X)
196 #define OUTLINE_Y_IDX_OF_POINT(number) (2 * (number) + OUTLINE_FIRST_Y)
197 #define OUTLINE_ROTATION_IDX(param_array) ((int)param_array[OUTLINE_NUMBER_OF_POINTS] * 2 + OUTLINE_ROTATION)
198 
199 typedef enum {
200  POLYGON_EXPOSURE,
201  POLYGON_NUMBER_OF_POINTS,
202  POLYGON_CENTER_X,
203  POLYGON_CENTER_Y,
204  POLYGON_DIAMETER,
205  POLYGON_ROTATION,
206 } gerbv_aptype_macro_polygon_index_t;
207 
208 typedef enum {
209  MOIRE_CENTER_X,
210  MOIRE_CENTER_Y,
211  MOIRE_OUTSIDE_DIAMETER,
212  MOIRE_CIRCLE_THICKNESS,
213  MOIRE_GAP_WIDTH,
214  MOIRE_NUMBER_OF_CIRCLES,
215  MOIRE_CROSSHAIR_THICKNESS,
216  MOIRE_CROSSHAIR_LENGTH,
217  MOIRE_ROTATION,
218 } gerbv_aptype_macro_moire_index_t;
219 
220 typedef enum {
221  THERMAL_CENTER_X,
222  THERMAL_CENTER_Y,
223  THERMAL_OUTSIDE_DIAMETER,
224  THERMAL_INSIDE_DIAMETER,
225  THERMAL_CROSSHAIR_THICKNESS,
226  THERMAL_ROTATION,
227 } gerbv_aptype_macro_thermal_index_t;
228 
230 typedef enum {
231  LINE20_EXPOSURE,
232  LINE20_LINE_WIDTH,
233  LINE20_WIDTH = LINE20_LINE_WIDTH, /* Unification alias */
234  LINE20_START_X,
235  LINE20_START_Y,
236  LINE20_END_X,
237  LINE20_END_Y,
238  LINE20_ROTATION,
240 
242 typedef enum {
243  LINE21_EXPOSURE,
244  LINE21_WIDTH,
245  LINE21_HEIGHT,
246  LINE21_CENTER_X,
247  LINE21_CENTER_Y,
248  LINE21_ROTATION,
250 
252 typedef enum {
253  LINE22_EXPOSURE,
254  LINE22_WIDTH,
255  LINE22_HEIGHT,
256  LINE22_LOWER_LEFT_X,
257  LINE22_LOWER_LEFT_Y,
258  LINE22_ROTATION,
260 
262 typedef enum {
267 
269 typedef enum {
275 
277 typedef enum {
283 
285 typedef enum {
289 
293 typedef enum {
304 
305 /* For backward compatibility */
306 enum {
307  GERBV_INTERPOLATION_x10 = GERBV_INTERPOLATION_LINEARx10
308 };
309 
311 
312 typedef enum {
313  GERBV_ENCODING_NONE,
314  GERBV_ENCODING_ASCII,
315  GERBV_ENCODING_EBCDIC,
316  GERBV_ENCODING_BCD,
317  GERBV_ENCODING_ISO_ASCII,
318  GERBV_ENCODING_EIA
319 } gerbv_encoding_t;
320 
322 typedef enum {
328 
329 typedef enum {
330  GERBV_KNOCKOUT_TYPE_NOKNOCKOUT,
331  GERBV_KNOCKOUT_TYPE_FIXEDKNOCK,
332  GERBV_KNOCKOUT_TYPE_BORDER
333 } gerbv_knockout_type_t;
334 
335 typedef enum {
336  GERBV_MIRROR_STATE_NOMIRROR,
337  GERBV_MIRROR_STATE_FLIPA,
338  GERBV_MIRROR_STATE_FLIPB,
339  GERBV_MIRROR_STATE_FLIPAB
340 } gerbv_mirror_state_t;
341 
342 typedef enum {
343  GERBV_AXIS_SELECT_NOSELECT,
344  GERBV_AXIS_SELECT_SWAPAB
345 } gerbv_axis_select_t;
346 
347 typedef enum {
348  GERBV_JUSTIFY_NOJUSTIFY,
349  GERBV_JUSTIFY_LOWERLEFT,
350  GERBV_JUSTIFY_CENTERJUSTIFY
351 } gerbv_image_justify_type_t;
352 
354 typedef enum {
358 
359 enum draw_mode {
360  DRAW_IMAGE = 0,
361  DRAW_SELECTIONS,
362  FIND_SELECTIONS,
363  FIND_SELECTIONS_TOGGLE,
364 };
365 
367 typedef enum {
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; // NOTE: memory here is released via `free()` (thus cannot be `const char*`)
390  double real_value;
391 } gerbv_HID_Attr_Val;
392 
393 typedef struct {
394  const char* name; // Allow 'const' variables (e.g., stored in read-only pages)
395  const char* help_text; // Allow 'const' variables (e.g., stored in read-only pages)
396 
397  enum {
398  HID_Label,
399  HID_Integer,
400  HID_Real,
401  HID_String,
402  HID_Boolean,
403  HID_Enum,
404  HID_Mixed,
405  HID_Path
406  } type;
407 
408  int min_val, max_val; /* for integer and real */
409  gerbv_HID_Attr_Val default_val; /* Also actual value for global attributes. */
410  const char** enumerations;
411  /* If set, this is used for global attributes (i.e. those set
412  statically with REGISTER_ATTRIBUTES below) instead of changing
413  the default_val. Note that a HID_Mixed attribute must specify a
414  pointer to gerbv_HID_Attr_Val here, and HID_Boolean assumes this is
415  "char *" so the value should be initialized to zero, and may be
416  set to non-zero (not always one). */
417  void* value;
418  int hash; /* for detecting changes. */
419 } gerbv_HID_Attribute;
420 
421 /* end of HID attributes from PCB */
422 
424 typedef struct error_list {
425  int layer;
426  gchar* error_text;
428  struct error_list* next;
430 
431 typedef struct instruction {
432  gerbv_opcodes_t opcode;
433 
434  union {
435  int ival;
436  float fval;
437  } data;
438  struct instruction* next;
439 } gerbv_instruction_t;
440 
441 typedef struct amacro {
442  gchar* name;
443  gerbv_instruction_t* program;
444  unsigned int nuf_push; /* Nuf pushes in program to estimate stack size */
445  struct amacro* next;
446 } gerbv_amacro_t;
447 
448 typedef struct gerbv_simplified_amacro {
450  double parameter[APERTURE_PARAMETERS_MAX];
451  struct gerbv_simplified_amacro* next;
452 } gerbv_simplified_amacro_t;
453 
454 typedef struct gerbv_aperture {
456  gerbv_amacro_t* amacro;
457  gerbv_simplified_amacro_t* simplified;
458  double parameter[APERTURE_PARAMETERS_MAX];
459  int nuf_parameters;
460  gerbv_unit_t unit;
461 } gerbv_aperture_t;
462 
463 /* the gerb_aperture_list is used to keep track of
464  * apertures used in stats reporting */
465 typedef struct gerbv_aperture_list {
466  int number;
467  int layer;
468  int count;
470  double parameter[5];
471  struct gerbv_aperture_list* next;
472 } gerbv_aperture_list_t;
473 
475 typedef struct {
477  gerbv_aperture_list_t* aperture_list;
478  gerbv_aperture_list_t* D_code_list;
479 
480  int layer_count;
481  int G0;
482  int G1;
483  int G2;
484  int G3;
485  int G4;
486  int G10;
487  int G11;
488  int G12;
489  int G36;
490  int G37;
491  int G54;
492  int G55;
493  int G70;
494  int G71;
495  int G74;
496  int G75;
497  int G90;
498  int G91;
499  int G_unknown;
500 
501  int D1;
502  int D2;
503  int D3;
504  /* GHashTable *D_user_defined; */
505  int D_unknown;
506  int D_error;
507 
508  int M0;
509  int M1;
510  int M2;
511  int M_unknown;
512 
513  int X;
514  int Y;
515  int I;
516  int J;
517 
518  /* Must include % RS-274 codes */
519  int star;
520  int unknown;
521 
522 } gerbv_stats_t;
523 
525 typedef struct drill_list {
526  int drill_num;
527  double drill_size;
528  gchar* drill_unit;
529  int drill_count;
530  struct drill_list* next;
532 
534 typedef struct {
535  int layer_count;
536 
539  int comment;
540  int F;
541 
542  int G00;
543  int G01;
544  int G02;
545  int G03;
546  int G04;
547  int G05;
548  int G85;
549  int G90;
550  int G91;
551  int G93;
552  int G_unknown;
553 
554  int M00;
555  int M01;
556  int M18;
557  int M25;
558  int M30;
559  int M31;
560  int M45;
561  int M47;
562  int M48;
563  int M71;
564  int M72;
565  int M95;
566  int M97;
567  int M98;
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  gpointer next;
665 
667 typedef struct gerbv_net {
668  double start_x;
669  double start_y;
670  double stop_x;
671  double stop_y;
673  int aperture;
676  gerbv_cirseg_t* cirseg;
677  struct gerbv_net* next;
678  GString* label;
682 
685 typedef struct gerbv_format {
686  gerbv_omit_zeros_t omit_zeros;
687  gerbv_coordinate_t coordinate;
688  int x_int;
689  int x_dec;
690  int y_int;
691  int y_dec;
692  int lim_seqno; /* Length limit for codes of sequence number */
693  int lim_gf; /* Length limit for codes of general function */
694  int lim_pf; /* Length limit for codes of plot function */
695  int lim_mf; /* Length limit for codes of miscellaneous function */
697 
699 typedef struct gerbv_image_info {
700  char* name;
701  gerbv_polarity_t polarity;
702  double min_x; /* Always in inches */
703  double min_y;
704  double max_x;
705  double max_y;
706  double offsetA;
707  double offsetB;
708  gerbv_encoding_t encoding;
709  double imageRotation;
710  gerbv_image_justify_type_t imageJustifyTypeA;
711  gerbv_image_justify_type_t imageJustifyTypeB;
712  gdouble imageJustifyOffsetA;
713  gdouble imageJustifyOffsetB;
714  gdouble imageJustifyOffsetActualA;
715  gdouble imageJustifyOffsetActualB;
716  gchar* plotterFilm;
717 
718  /* Descriptive string for the type of file (rs274-x, drill, etc)
719  * that this is
720  */
721  gchar* type;
722 
723  /* Attribute list that is used to hold all sorts of information
724  * about how the layer is to be parsed.
725  */
726  gerbv_HID_Attribute* attr_list;
727  int n_attr;
729 
731 typedef struct {
733  gerbv_aperture_t* aperture[APERTURE_MAX];
736  gerbv_amacro_t* amacro;
742 } gerbv_image_t;
743 
745 typedef struct {
747  GdkColor color;
748  guint16 alpha;
749  gboolean isVisible;
750  gpointer privateRenderData;
751  gchar* fullPathname;
752  gchar* name;
755  gboolean layer_dirty;
757 
760 typedef struct {
761  GdkColor background;
762  int max_files;
769  gchar* path;
770  gchar* execpath;
771  gchar* execname;
772  gchar* project;
774 
776 typedef struct {
777  unsigned char red;
778  unsigned char green;
779  unsigned char blue;
780  unsigned char alpha;
782 
784 typedef struct {
785  gdouble scaleFactorX;
786  gdouble scaleFactorY;
787  gdouble lowerLeftX;
788  gdouble lowerLeftY;
794 
798  gerbv_image_t* image,
799  const gchar* type
800 );
801 
804 );
805 
808  gerbv_image_t* sourceImage,
809  gerbv_user_transformation_t* transform,
810  gerbv_image_t* destinationImage
811 );
812 
816  gerbv_image_t* sourceImage,
817  gerbv_user_transformation_t* transform
818 );
819 
821 void gerbv_image_delete_net(gerbv_net_t* currentNet
822 );
823 
824 gboolean gerbv_image_reduce_area_of_selected_objects(
825  GArray* selectionArray, gdouble areaReduction, gint paneRows, gint paneColumns, gdouble paneSeparation
826 );
827 
828 gboolean gerbv_image_move_selected_objects(GArray* selectionArray, gdouble translationX, gdouble translationY);
829 
832 
835 
837 void gerbv_destroy_project(gerbv_project_t* gerbvProject
838 );
839 
842  gerbv_project_t* gerbvProject,
843  const gchar* filename
844 );
845 
848  gerbv_project_t* gerbvProject,
849  const gchar* filename,
850  guint16 red,
851  guint16 green,
852  guint16 blue,
853  guint16 alpha
854 );
855 
858 );
859 
860 gboolean gerbv_save_layer_from_index(gerbv_project_t* gerbvProject, gint index, gchar* filename);
861 
862 int gerbv_revert_file(gerbv_project_t* gerbvProject, int idx);
863 
864 void gerbv_revert_all_files(gerbv_project_t* gerbvProject);
865 
866 void gerbv_unload_layer(gerbv_project_t* gerbvProject, int index);
867 
868 void gerbv_unload_all_layers(gerbv_project_t* gerbvProject);
869 
870 void gerbv_change_layer_order(gerbv_project_t* gerbvProject, gint oldPosition, gint newPosition);
871 
872 gint gerbv_add_parsed_image_to_project(
873  gerbv_project_t* gerbvProject, gerbv_image_t* parsed_image, const gchar* filename, const gchar* baseName, int idx,
874  int reload
875 );
876 int gerbv_open_image(
877  gerbv_project_t* gerbvProject, const gchar* filename, int idx, int reload, gerbv_HID_Attribute* fattr, int n_fattr,
878  gboolean forceLoadFile
879 );
880 
881 void gerbv_render_get_boundingbox(gerbv_project_t* gerbvProject, gerbv_render_size_t* boundingbox);
882 
885  gerbv_project_t* gerbvProject,
886  gerbv_render_info_t* renderInfo
887 );
888 
889 void gerbv_render_translate_to_fit_display(gerbv_project_t* gerbvProject, gerbv_render_info_t* renderInfo);
890 
891 void gerbv_render_to_pixmap_using_gdk(
892  gerbv_project_t* gerbvProject, GdkPixmap* pixmap, gerbv_render_info_t* renderInfo,
893  gerbv_selection_info_t* selectionInfo, GdkColor* selectionColor
894 );
895 
896 #ifndef RENDER_USING_GDK
897 void gerbv_render_all_layers_to_cairo_target_for_vector_output(
898  gerbv_project_t* gerbvProject, cairo_t* cr, gerbv_render_info_t* renderInfo
899 );
900 
901 void
902 gerbv_render_all_layers_to_cairo_target(gerbv_project_t* gerbvProject, cairo_t* cr, gerbv_render_info_t* renderInfo);
903 
906  cairo_t* cr,
907  gerbv_fileinfo_t* fileInfo,
908  gerbv_render_info_t* renderInfo
909 );
910 
911 void gerbv_render_cairo_set_scale_and_translation(cairo_t* cr, gerbv_render_info_t* renderInfo);
912 
913 void gerbv_render_layer_to_cairo_target_without_transforming(
914  cairo_t* cr, gerbv_fileinfo_t* fileInfo, gerbv_render_info_t* renderInfo, gboolean pixelOutput
915 );
916 #endif
917 
918 double gerbv_get_tool_diameter(int toolNumber);
919 
920 int gerbv_process_tools_file(const char* toolFileName);
921 
924  gerbv_project_t* gerbvProject,
925  int widthInPixels,
926  int heightInPixels,
927  const gchar* filename
928 );
929 
932  gerbv_project_t* gerbvProject,
933  gerbv_render_info_t* renderInfo,
934  const gchar* filename
935 );
936 
939  gerbv_project_t* gerbvProject,
940  const gchar* filename
941 );
942 
945  gerbv_project_t* gerbvProject,
946  gerbv_render_info_t* renderInfo,
947  const gchar* filename
948 );
949 
952  gerbv_project_t* gerbvProject,
953  const gchar* filename
954 );
955 
958  gerbv_project_t* gerbvProject,
959  gerbv_render_info_t* renderInfo,
960  const gchar* filename
961 );
962 
965  gerbv_project_t* gerbvProject,
966  const gchar* filename
967 );
968 
971  gerbv_project_t* gerbvProject,
972  gerbv_render_info_t* renderInfo,
973  const gchar* filename
974 );
975 
979  const gchar* filename,
980  gerbv_image_t* image,
981  gerbv_user_transformation_t* transform
982 );
983 
987 gerbv_create_rs274x_image_from_filename(const gchar* filename
988 );
989 
993  const gchar* filename,
994  gerbv_image_t* image,
995  gerbv_user_transformation_t* transform
996 );
997 
1001  const gchar* filename,
1002  gerbv_image_t* image,
1003  gerbv_user_transformation_t* transform
1004 );
1005 
1009  const gchar* filename,
1010  gerbv_image_t* image,
1011  gerbv_user_transformation_t* transform
1012 );
1013 
1017  const gchar* filename,
1018  gerbv_image_t* image,
1019  gerbv_user_transformation_t* transform
1020 );
1021 
1024  gerbv_image_t* image,
1025  gdouble startX,
1026  gdouble startY,
1027  gdouble endX,
1028  gdouble endY,
1029  gdouble lineWidth,
1030  gerbv_aperture_type_t apertureType
1031 );
1032 
1035  gerbv_image_t* image,
1036  gdouble centerX,
1037  gdouble centerY,
1038  gdouble radius,
1039  gdouble startAngle,
1040  gdouble endAngle,
1041  gdouble lineWidth,
1042  gerbv_aperture_type_t apertureType
1043 );
1044 
1047  gerbv_image_t* image,
1048  gdouble coordinateX,
1049  gdouble coordinateY,
1050  gdouble width,
1051  gdouble height
1052 );
1053 
1056 );
1057 
1060 
1063 
1066 void gerbv_drill_stats_add_layer(gerbv_drill_stats_t* accum_stats, gerbv_drill_stats_t* input_stats, int this_layer);
1067 
1070 
1073 
1076 void gerbv_stats_add_layer(gerbv_stats_t* accum_stats, gerbv_stats_t* input_stats, int this_layer);
1077 
1078 void gerbv_attribute_destroy_HID_attribute(gerbv_HID_Attribute* attributeList, int n_attr);
1079 
1080 gerbv_HID_Attribute* gerbv_attribute_dup(gerbv_HID_Attribute*, int);
1081 
1084 
1086 int gerbv_transform_coord_for_image(double* x, double* y, const gerbv_image_t* image, const gerbv_project_t* project);
1087 
1089 gboolean gerbv_endswith(const char* path, const char* ext);
1090 
1092 void gerbv_transform_coord(double* x, double* y, const gerbv_user_transformation_t* trans);
1093 
1095 void gerbv_rotate_coord(double* x, double* y, double rad);
1096 
1097 #if defined(__cplusplus)
1098 
1099 #undef MIN
1100 #undef MAX
1101 #define MIN(x, y) \
1102  ({ \
1103  typeof(x) _x = (x); \
1104  typeof(y) _y = (y); \
1105  (void)(&_x == &_y); \
1106  _x < _y ? _x : _y; \
1107  })
1108 #define MAX(x, y) \
1109  ({ \
1110  typeof(x) _x = (x); \
1111  typeof(y) _y = (y); \
1112  (void)(&_x == &_y); \
1113  _x > _y ? _x : _y; \
1114  })
1115 }
1116 #endif
1117 
1118 #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:77
void gerbv_stats_destroy(gerbv_stats_t *)
Definition: gerb_stats.c:104
void gerbv_export_png_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, const gchar *filename)
Render a project to a PNG file using user-specified render info.
Definition: export-image.c:89
gerbv_aptype_macro_line22_index_t
Definition: gerbv.h:252
struct drill_list gerbv_drill_list_t
gerbv_aperture_state_t
Definition: gerbv.h:170
@ GERBV_APERTURE_STATE_OFF
Definition: gerbv.h:171
@ GERBV_APERTURE_STATE_ON
Definition: gerbv.h:172
@ GERBV_APERTURE_STATE_FLASH
Definition: gerbv.h:173
void gerbv_open_layer_from_filename(gerbv_project_t *gerbvProject, const gchar *filename)
Open a file, parse the contents, and add a new layer to an existing project.
Definition: gerbv.c:214
struct error_list gerbv_error_list_t
void gerbv_drill_stats_destroy(gerbv_drill_stats_t *)
Definition: drill_stats.c:101
void gerbv_export_svg_file_from_project_autoscaled(gerbv_project_t *gerbvProject, const gchar *filename)
Render a project to a SVG file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:133
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
Definition: gerb_image.c:104
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:43
void gerbv_destroy_project(gerbv_project_t *gerbvProject)
Free a project and all related variables.
Definition: gerbv.c:181
const char * gerbv_interpolation_name(gerbv_interpolation_t interp)
Return string name of gerbv_interpolation_t interpolation.
Definition: gerbv.c:97
struct gerbv_net gerbv_net_t
gerbv_omit_zeros_t
Definition: gerbv.h:277
@ GERBV_OMIT_ZEROS_TRAILING
Definition: gerbv.h:279
@ GERBV_OMIT_ZEROS_EXPLICIT
Definition: gerbv.h:280
@ GERBV_OMIT_ZEROS_LEADING
Definition: gerbv.h:278
@ GERBV_OMIT_ZEROS_UNSPECIFIED
Definition: gerbv.h:281
void gerbv_rotate_coord(double *x, double *y, double rad)
Definition: gerbv.c:1030
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:934
void gerbv_export_pdf_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, const gchar *filename)
Render a project to a PDF file using user-specified render info.
Definition: export-image.c:110
void gerbv_export_postscript_file_from_project_autoscaled(gerbv_project_t *gerbvProject, const gchar *filename)
Render a project to a Postscript file, autoscaling the layers to fit inside the specified image dimen...
Definition: export-image.c:119
void gerbv_export_svg_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, const gchar *filename)
Render a project to a file using user-specified render info.
Definition: export-image.c:139
gerbv_polarity_t
Definition: gerbv.h:269
@ GERBV_POLARITY_CLEAR
Definition: gerbv.h:273
@ GERBV_POLARITY_DARK
Definition: gerbv.h:272
@ GERBV_POLARITY_NEGATIVE
Definition: gerbv.h:271
@ GERBV_POLARITY_POSITIVE
Definition: gerbv.h:270
gerbv_image_t * gerbv_create_rs274x_image_from_filename(const gchar *filename)
Parse a RS274X file and return the parsed image.
Definition: gerbv.c:595
void gerbv_export_pdf_file_from_project_autoscaled(gerbv_project_t *gerbvProject, const gchar *filename)
Render a project to a PDF file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:104
gerbv_aptype_macro_circle_index_t
Definition: gerbv.h:177
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:164
gerbv_stats_t * gerbv_stats_new(void)
Allocates a new gerbv_stats structure.
Definition: gerb_stats.c:46
gerbv_render_types_t
Definition: gerbv.h:367
@ 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:242
gerbv_coordinate_t
Definition: gerbv.h:285
@ GERBV_COORDINATE_INCREMENTAL
Definition: gerbv.h:287
@ GERBV_COORDINATE_ABSOLUTE
Definition: gerbv.h:286
void gerbv_export_postscript_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, const gchar *filename)
Render a project to a Postscript file using user-specified render info.
Definition: export-image.c:125
gerbv_message_type_t
Definition: gerbv.h:140
@ GERBV_MESSAGE_ERROR
Definition: gerbv.h:142
@ GERBV_MESSAGE_NOTE
Definition: gerbv.h:144
@ GERBV_MESSAGE_FATAL
Definition: gerbv.h:141
@ GERBV_MESSAGE_WARNING
Definition: gerbv.h:143
void gerbv_open_layer_from_filename_with_color(gerbv_project_t *gerbvProject, const gchar *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:230
gerbv_fileinfo_t * gerbv_get_fileinfo_for_image(const gerbv_image_t *image, const gerbv_project_t *project)
Definition: gerbv.c:1018
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:854
gerbv_selection_t
Definition: gerbv.h:354
@ GERBV_SELECTION_POINT_CLICK
Definition: gerbv.h:355
@ GERBV_SELECTION_DRAG_BOX
Definition: gerbv.h:356
struct gerbv_format gerbv_format_t
gerbv_opcodes_t
Definition: gerbv.h:127
@ GERBV_OPCODE_PPUSH
Definition: gerbv.h:130
@ GERBV_OPCODE_ADD
Definition: gerbv.h:132
@ GERBV_OPCODE_PPOP
Definition: gerbv.h:131
@ GERBV_OPCODE_PUSH
Definition: gerbv.h:129
@ GERBV_OPCODE_SUB
Definition: gerbv.h:133
@ GERBV_OPCODE_NOP
Definition: gerbv.h:128
@ GERBV_OPCODE_DIV
Definition: gerbv.h:135
@ GERBV_OPCODE_MUL
Definition: gerbv.h:134
@ GERBV_OPCODE_PRIM
Definition: gerbv.h:136
gerbv_aptype_macro_line20_index_t
Definition: gerbv.h:230
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_transform_coord(double *x, double *y, const gerbv_user_transformation_t *trans)
Definition: gerbv.c:1038
void gerbv_export_png_file_from_project_autoscaled(gerbv_project_t *gerbvProject, int widthInPixels, int heightInPixels, const gchar *filename)
Render a project to a PNG file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:77
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:1072
gboolean gerbv_endswith(const char *path, const char *ext)
Definition: gerbv.c:1070
void gerbv_destroy_fileinfo(gerbv_fileinfo_t *fileInfo)
Free a fileinfo structure.
Definition: gerbv.c:203
void gerbv_image_delete_net(gerbv_net_t *currentNet)
Delete a net in an existing image.
Definition: gerb_image.c:904
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
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:1259
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:683
struct gerbv_image_info gerbv_image_info_t
gerbv_aperture_type_t
Definition: gerbv.h:150
@ GERBV_APTYPE_MACRO_LINE20
Definition: gerbv.h:162
@ GERBV_APTYPE_MACRO_LINE21
Definition: gerbv.h:163
@ GERBV_APTYPE_OVAL
Definition: gerbv.h:154
@ GERBV_APTYPE_MACRO_OUTLINE
Definition: gerbv.h:158
@ GERBV_APTYPE_MACRO_CIRCLE
Definition: gerbv.h:157
@ GERBV_APTYPE_MACRO
Definition: gerbv.h:156
@ GERBV_APTYPE_CIRCLE
Definition: gerbv.h:152
@ GERBV_APTYPE_NONE
Definition: gerbv.h:151
@ GERBV_APTYPE_POLYGON
Definition: gerbv.h:155
@ GERBV_APTYPE_MACRO_POLYGON
Definition: gerbv.h:159
@ GERBV_APTYPE_RECTANGLE
Definition: gerbv.h:153
@ GERBV_APTYPE_MACRO_THERMAL
Definition: gerbv.h:161
@ GERBV_APTYPE_MACRO_LINE22
Definition: gerbv.h:164
@ GERBV_APTYPE_MACRO_MOIRE
Definition: gerbv.h:160
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:1056
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:815
gerbv_unit_t
Definition: gerbv.h:262
@ GERBV_UNIT_INCH
Definition: gerbv.h:263
@ GERBV_UNIT_MM
Definition: gerbv.h:264
@ GERBV_UNIT_UNSPECIFIED
Definition: gerbv.h:265
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:1276
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:293
@ GERBV_INTERPOLATION_LINEARx01
Definition: gerbv.h:296
@ GERBV_INTERPOLATION_PAREA_START
Definition: gerbv.h:300
@ GERBV_INTERPOLATION_LINEARx001
Definition: gerbv.h:297
@ GERBV_INTERPOLATION_DELETED
Definition: gerbv.h:302
@ GERBV_INTERPOLATION_CW_CIRCULAR
Definition: gerbv.h:298
@ GERBV_INTERPOLATION_PAREA_END
Definition: gerbv.h:301
@ GERBV_INTERPOLATION_LINEARx10
Definition: gerbv.h:295
@ GERBV_INTERPOLATION_CCW_CIRCULAR
Definition: gerbv.h:299
@ GERBV_INTERPOLATION_LINEARx1
Definition: gerbv.h:294
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:1029
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:916
gerbv_layertype_t
Definition: gerbv.h:322
@ GERBV_LAYERTYPE_PICKANDPLACE_BOT
Definition: gerbv.h:326
@ GERBV_LAYERTYPE_RS274X
Definition: gerbv.h:323
@ GERBV_LAYERTYPE_PICKANDPLACE_TOP
Definition: gerbv.h:325
@ GERBV_LAYERTYPE_DRILL
Definition: gerbv.h:324
guint16 alpha
Definition: gerbv.h:748
gchar * fullPathname
Definition: gerbv.h:751
gerbv_image_t * image
Definition: gerbv.h:746
gerbv_user_transformation_t transform
Definition: gerbv.h:754
gchar * name
Definition: gerbv.h:752
GdkColor color
Definition: gerbv.h:747
gboolean layer_dirty
Definition: gerbv.h:755
gpointer privateRenderData
Definition: gerbv.h:750
gboolean isVisible
Definition: gerbv.h:749
gerbv_amacro_t * amacro
Definition: gerbv.h:736
gerbv_stats_t * gerbv_stats
Definition: gerbv.h:740
gerbv_format_t * format
Definition: gerbv.h:737
gerbv_layer_t * layers
Definition: gerbv.h:734
gerbv_layertype_t layertype
Definition: gerbv.h:732
gerbv_net_t * netlist
Definition: gerbv.h:739
gerbv_drill_stats_t * drill_stats
Definition: gerbv.h:741
gerbv_netstate_t * states
Definition: gerbv.h:735
gerbv_image_info_t * info
Definition: gerbv.h:738
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:672
gerbv_layer_t * layer
Definition: gerbv.h:679
double stop_y
Definition: gerbv.h:671
GString * label
Definition: gerbv.h:678
gerbv_aperture_state_t aperture_state
Definition: gerbv.h:674
double stop_x
Definition: gerbv.h:670
double start_x
Definition: gerbv.h:668
gerbv_netstate_t * state
Definition: gerbv.h:680
struct gerbv_net * next
Definition: gerbv.h:677
double start_y
Definition: gerbv.h:669
gerbv_interpolation_t interpolation
Definition: gerbv.h:675
gerbv_cirseg_t * cirseg
Definition: gerbv.h:676
int aperture
Definition: gerbv.h:673
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:663
gerbv_unit_t unit
Definition: gerbv.h:658
gdouble offsetA
Definition: gerbv.h:659
gerbv_mirror_state_t mirrorState
Definition: gerbv.h:657
gerbv_fileinfo_t ** file
Definition: gerbv.h:763
gchar * project
Definition: gerbv.h:772
gboolean show_invisible_selection
Definition: gerbv.h:768
GdkColor background
Definition: gerbv.h:761
gboolean check_before_delete
Definition: gerbv.h:767
gchar * execname
Definition: gerbv.h:771
gchar * path
Definition: gerbv.h:769
int renderType
Definition: gerbv.h:766
gchar * execpath
Definition: gerbv.h:770
int max_files
Definition: gerbv.h:762
int curr_index
Definition: gerbv.h:764
int last_loaded
Definition: gerbv.h:765
gdouble lowerLeftY
Definition: gerbv.h:788
gboolean show_cross_on_drill_holes
Definition: gerbv.h:792
gdouble scaleFactorX
Definition: gerbv.h:785
gint displayHeight
Definition: gerbv.h:791
gdouble lowerLeftX
Definition: gerbv.h:787
gerbv_render_types_t renderType
Definition: gerbv.h:789
gdouble scaleFactorY
Definition: gerbv.h:786