2 * gEDA - GNU Electronic Design Automation
3 * This file is a part of gerbv.
5 * Copyright (C) 2000-2003 Stefan Petersen (spe@stacken.kth.se)
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.
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.
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
24 //! \example example1.c
25 //! \example example2.c
26 //! \example example3.c
27 //! \example example4.c
28 //! \example example5.c
29 //! \example example6.c
31 //! \defgroup libgerbv libgerbv
32 //! \defgroup gerbv Gerbv
35 \brief The main header file for the libgerbv library
40 \mainpage Gerbv/libgerbv Index Page
42 \section intro_sec Introduction
44 Gerbv is a program which can display, edit, export, and do other manipulation of
45 file formats used in PCB design (RS274X, Excellon drill, and pick-and-place). The core
46 library (libgerbv) is available as a separate library, allowing other software to easily
47 incorporate advanced Gerber functionality.
49 This code documentation is mainly intended to help explain the libgerbv API to developers
50 wishing to use libgerbv in his/her own projects. The easiest way to learn to use libgerbv is
51 by reading through and compiling the example source files (click on "Examples" in the navigation
52 tree in the left pane, or look in the doc/example-code/ directory in CVS).
54 For help with using the standalone Gerbv software, please refer to the man page (using
55 the command "man gerbv") or go to the Gerbv homepage for documentation (http://gerbv.sourceforge.net).
68 #include <gdk/gdkkeysyms.h>
70 #ifndef RENDER_USING_GDK
74 #define APERTURE_MIN 10
75 #define APERTURE_MAX 9999
78 * Maximum number of aperture parameters is set by the outline aperture
79 * macro. There (p. 28) is defined up to 50 points in polygon.
80 * So 50 points with x and y plus two for holding extra data gives...
82 #define APERTURE_PARAMETERS_MAX 102
83 #define INITIAL_SCALE 200
84 #define MAX_ERRMSGLEN 25
85 #define MAX_COORDLEN 28
86 #define MAX_DISTLEN 90
87 #define MAX_STATUSMSGLEN (MAX_ERRMSGLEN+MAX_COORDLEN+MAX_DISTLEN)
89 /* Macros to convert between unscaled gerber coordinates and other units */
90 /* XXX NOTE: Currently unscaled units are assumed as inch, this is not
91 XXX necessarily true for all files */
92 #define COORD2MILS(c) ((c)*1000.0)
93 #define COORD2MMS(c) ((c)*25.4)
95 #define GERB_FATAL_ERROR(t...) g_log(NULL, G_LOG_LEVEL_ERROR, ##t);
96 #define GERB_COMPILE_ERROR(t...) g_log(NULL, G_LOG_LEVEL_CRITICAL, ##t);
97 #define GERB_COMPILE_WARNING(t...) g_log(NULL, G_LOG_LEVEL_WARNING, ##t);
98 #define GERB_MESSAGE(t...) g_log(NULL, G_LOG_LEVEL_MESSAGE, ##t);
100 /*! The aperture macro commands */
101 typedef enum {GERBV_OPCODE_NOP
, /*!< no operation */
102 GERBV_OPCODE_PUSH
, /*!< push the instruction onto the stack */
103 GERBV_OPCODE_PPUSH
, /*!< push parameter onto stack */
104 GERBV_OPCODE_PPOP
, /*!< pop parameter from stack */
105 GERBV_OPCODE_ADD
, /*!< mathmatical add operation */
106 GERBV_OPCODE_SUB
, /*!< mathmatical subtract operation */
107 GERBV_OPCODE_MUL
, /*!< mathmatical multiply operation */
108 GERBV_OPCODE_DIV
, /*!< mathmatical divide operation */
109 GERBV_OPCODE_PRIM
/*!< draw macro primative */
112 /*! The different message types used in libgerbv */
113 typedef enum {GERBV_MESSAGE_FATAL
, /*!< processing cannot continue */
114 GERBV_MESSAGE_ERROR
, /*!< something went wrong, but processing can still continue */
115 GERBV_MESSAGE_WARNING
, /*!< something was encountered that may provide the wrong output */
116 GERBV_MESSAGE_NOTE
/*!< an irregularity was encountered, but needs no intervention */
117 } gerbv_message_type_t
;
119 /*! The different aperture types available
120 * Please keep these in sync with the aperture names defined by
121 * ap_names in callbacks.c */
122 typedef enum {GERBV_APTYPE_NONE
, /*!< no aperture used */
123 GERBV_APTYPE_CIRCLE
, /*!< a round aperture */
124 GERBV_APTYPE_RECTANGLE
, /*!< a rectangular aperture */
125 GERBV_APTYPE_OVAL
, /*!< an ovular (obround) aperture */
126 GERBV_APTYPE_POLYGON
, /*!< a polygon aperture */
127 GERBV_APTYPE_MACRO
, /*!< a RS274X macro */
128 GERBV_APTYPE_MACRO_CIRCLE
, /*!< a RS274X circle macro */
129 GERBV_APTYPE_MACRO_OUTLINE
, /*!< a RS274X outline macro */
130 GERBV_APTYPE_MACRO_POLYGON
, /*!< a RS274X polygon macro */
131 GERBV_APTYPE_MACRO_MOIRE
, /*!< a RS274X moire macro */
132 GERBV_APTYPE_MACRO_THERMAL
, /*!< a RS274X thermal macro */
133 GERBV_APTYPE_MACRO_LINE20
, /*!< a RS274X line (code 20) macro */
134 GERBV_APTYPE_MACRO_LINE21
, /*!< a RS274X line (code 21) macro */
135 GERBV_APTYPE_MACRO_LINE22
/*!< a RS274X line (code 22) macro */
136 } gerbv_aperture_type_t
;
138 /*! the current state of the aperture drawing tool */
139 typedef enum {GERBV_APERTURE_STATE_OFF
, /*!< tool drawing is off, and nothing will be drawn */
140 GERBV_APERTURE_STATE_ON
, /*!< tool drawing is on, and something will be drawn */
141 GERBV_APERTURE_STATE_FLASH
/*!< tool is flashing, and will draw a single aperture */
142 } gerbv_aperture_state_t
;
144 /*! the current unit used */
145 typedef enum {GERBV_UNIT_INCH
, /*!< inches */
146 GERBV_UNIT_MM
, /*!< mm */
147 GERBV_UNIT_UNSPECIFIED
/*!< use default units */
150 /*! the different drawing polarities available */
151 typedef enum {GERBV_POLARITY_POSITIVE
, /*!< draw "positive", using the current layer's polarity */
152 GERBV_POLARITY_NEGATIVE
, /*!< draw "negative", reversing the current layer's polarity */
153 GERBV_POLARITY_DARK
, /*!< add to the current rendering */
154 GERBV_POLARITY_CLEAR
/*!< subtract from the current rendering */
157 /*! the decimal point parsing style used */
158 typedef enum {GERBV_OMIT_ZEROS_LEADING
, /*!< omit extra zeros before the decimal point */
159 GERBV_OMIT_ZEROS_TRAILING
, /*!< omit extra zeros after the decimal point */
160 GERBV_OMIT_ZEROS_EXPLICIT
, /*!< explicitly specify how many decimal places are used */
161 GERBV_OMIT_ZEROS_UNSPECIFIED
/*!< use the default parsing style */
162 } gerbv_omit_zeros_t
;
164 /*! the coordinate system used */
165 typedef enum {GERBV_COORDINATE_ABSOLUTE
, /*!< all coordinates are absolute from a common origin */
166 GERBV_COORDINATE_INCREMENTAL
/*!< all coordinates are relative to the previous coordinate */
167 } gerbv_coordinate_t
;
169 /*! the interpolation methods available */
170 typedef enum {GERBV_INTERPOLATION_LINEARx1
, /*!< draw a line */
171 GERBV_INTERPOLATION_x10
, /*!< draw a line */
172 GERBV_INTERPOLATION_LINEARx01
, /*!< draw a line */
173 GERBV_INTERPOLATION_LINEARx001
, /*!< draw a line */
174 GERBV_INTERPOLATION_CW_CIRCULAR
, /*!< draw an arc in the clockwise direction */
175 GERBV_INTERPOLATION_CCW_CIRCULAR
, /*!< draw an arc in the counter-clockwise direction */
176 GERBV_INTERPOLATION_PAREA_START
, /*!< start a polygon draw */
177 GERBV_INTERPOLATION_PAREA_END
, /*!< end a polygon draw */
178 GERBV_INTERPOLATION_DELETED
/*!< the net has been deleted by the user, and will not be drawn */
179 } gerbv_interpolation_t
;
181 typedef enum {GERBV_ENCODING_NONE
,
182 GERBV_ENCODING_ASCII
,
183 GERBV_ENCODING_EBCDIC
,
185 GERBV_ENCODING_ISO_ASCII
,
189 /*! The different layer types used */
190 typedef enum {GERBV_LAYERTYPE_RS274X
, /*!< the file is a RS274X file */
191 GERBV_LAYERTYPE_DRILL
, /*!< the file is an Excellon drill file */
192 GERBV_LAYERTYPE_PICKANDPLACE
/*!< the file is a CSV pick and place file */
195 typedef enum {GERBV_KNOCKOUT_TYPE_NOKNOCKOUT
,
196 GERBV_KNOCKOUT_TYPE_FIXEDKNOCK
,
197 GERBV_KNOCKOUT_TYPE_BORDER
198 } gerbv_knockout_type_t
;
200 typedef enum {GERBV_MIRROR_STATE_NOMIRROR
,
201 GERBV_MIRROR_STATE_FLIPA
,
202 GERBV_MIRROR_STATE_FLIPB
,
203 GERBV_MIRROR_STATE_FLIPAB
204 } gerbv_mirror_state_t
;
206 typedef enum {GERBV_AXIS_SELECT_NOSELECT
,
207 GERBV_AXIS_SELECT_SWAPAB
208 } gerbv_axis_select_t
;
210 typedef enum {GERBV_JUSTIFY_NOJUSTIFY
,
211 GERBV_JUSTIFY_LOWERLEFT
,
212 GERBV_JUSTIFY_CENTERJUSTIFY
213 } gerbv_image_justify_type_t
;
215 /*! The different selection modes available */
216 typedef enum {GERBV_SELECTION_EMPTY
, /*!< the selection buffer is empty */
217 GERBV_SELECTION_POINT_CLICK
, /*!< the user clicked on a single point */
218 GERBV_SELECTION_DRAG_BOX
/*!< the user dragged a box to encompass one or more objects */
221 /*! The different rendering modes available to libgerbv */
222 typedef enum {GERBV_RENDER_TYPE_GDK
, /*!< render using normal GDK drawing functions */
223 GERBV_RENDER_TYPE_GDK_XOR
, /*!< use the GDK_XOR mask to draw a pseudo-transparent scene */
224 GERBV_RENDER_TYPE_CAIRO_NORMAL
, /*!< use the cairo library */
225 GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY
/*!< use the cairo library with the smoothest edges */
226 } gerbv_render_types_t
;
229 * The following typedef's are taken directly from src/hid.h in the
230 * pcb project. The names are kept the same to make it easier to
231 * compare to pcb's sources.
234 /* Used for HID attributes (exporting and printing, mostly).
235 HA_boolean uses int_value, HA_enum sets int_value to the index and
236 str_value to the enumeration string. HID_Label just shows the
237 default str_value. HID_Mixed is a real_value followed by an enum,
244 } gerbv_HID_Attr_Val
;
250 { HID_Label
, HID_Integer
, HID_Real
, HID_String
,
251 HID_Boolean
, HID_Enum
, HID_Mixed
, HID_Path
253 int min_val
, max_val
; /* for integer and real */
254 gerbv_HID_Attr_Val default_val
; /* Also actual value for global attributes. */
255 const char **enumerations
;
256 /* If set, this is used for global attributes (i.e. those set
257 statically with REGISTER_ATTRIBUTES below) instead of changing
258 the default_val. Note that a HID_Mixed attribute must specify a
259 pointer to gerbv_HID_Attr_Val here, and HID_Boolean assumes this is
260 "char *" so the value should be initialized to zero, and may be
261 set to non-zero (not always one). */
263 int hash
; /* for detecting changes. */
264 } gerbv_HID_Attribute
;
265 /* end of HID attributes from PCB */
267 /*! A linked list of errors found in the files */
268 typedef struct error_list
{
271 gerbv_message_type_t type
;
272 struct error_list
*next
;
273 } gerbv_error_list_t
;
275 typedef struct instruction
{
276 gerbv_opcodes_t opcode
;
281 struct instruction
*next
;
282 } gerbv_instruction_t
;
284 typedef struct amacro
{
286 gerbv_instruction_t
*program
;
287 unsigned int nuf_push
; /* Nuf pushes in program to estimate stack size */
291 typedef struct gerbv_simplified_amacro
{
292 gerbv_aperture_type_t type
;
293 double parameter
[APERTURE_PARAMETERS_MAX
];
294 struct gerbv_simplified_amacro
*next
;
295 } gerbv_simplified_amacro_t
;
297 typedef struct gerbv_aperture
{
298 gerbv_aperture_type_t type
;
299 gerbv_amacro_t
*amacro
;
300 gerbv_simplified_amacro_t
*simplified
;
301 double parameter
[APERTURE_PARAMETERS_MAX
];
306 /* the gerb_aperture_list is used to keep track of
307 * apertures used in stats reporting */
308 typedef struct gerbv_aperture_list
{
312 gerbv_aperture_type_t type
;
314 struct gerbv_aperture_list
*next
;
315 } gerbv_aperture_list_t
;
317 /*! Contains statistics on the various codes used in a RS274X file */
319 gerbv_error_list_t
*error_list
;
320 gerbv_aperture_list_t
*aperture_list
;
321 gerbv_aperture_list_t
*D_code_list
;
347 /* GHashTable *D_user_defined; */
361 /* Must include % RS-274 codes */
367 /*! Linked list of drills found in active layers. Used in reporting statistics */
368 typedef struct drill_list
{
373 struct drill_list
*next
;
374 } gerbv_drill_list_t
;
376 /*! Struct holding statistics of drill commands used. Used in reporting statistics */
380 gerbv_error_list_t
*error_list
;
381 gerbv_drill_list_t
*drill_list
;
416 } gerbv_drill_stats_t
;
421 } gerbv_selection_item_t
;
423 /*! Struct holding info about the last selection */
425 gerbv_selection_t type
;
430 GArray
*selectedNodeArray
;
431 } gerbv_selection_info_t
;
433 /*! Stores image transformation information, used to modify the rendered
434 position/scale/etc of an image. */
436 gdouble translateX
; /*!< the X translation (in inches) */
437 gdouble translateY
; /*!< the Y translation (in inches) */
438 gdouble scaleX
; /*!< the X scale factor (1.0 is default) */
439 gdouble scaleY
; /*!< the Y scale factor (1.0 is default) */
440 gboolean inverted
; /*!< TRUE if the image should be rendered "inverted" (light is dark and vice versa) */
441 } gerbv_user_transformation_t
;
443 /*! This defines a box location and size (used to rendering logic) */
445 double left
; /*!< the X coordinate of the left side */
446 double right
; /*!< the X coordinate of the right side */
447 double bottom
; /*!< the Y coordinate of the bottom side */
448 double top
; /*!< the Y coordinate of the top side */
449 } gerbv_render_size_t
;
451 typedef struct gerbv_cirseg
{
454 double width
; /* of oval */
455 double height
; /* of oval */
460 typedef struct gerbv_step_and_repeat
{ /* SR parameters */
465 } gerbv_step_and_repeat_t
;
468 gboolean firstInstance
;
469 gerbv_knockout_type_t type
;
470 gerbv_polarity_t polarity
;
478 /*! The structure used to keep track of RS274X layer groups */
480 gerbv_step_and_repeat_t stepAndRepeat
; /*!< the current step and repeat group (refer to RS274X spec) */
481 gerbv_knockout_t knockout
; /*!< the current knockout group (refer to RS274X spec) */
482 gdouble rotation
; /*!< the current rotation around the origin */
483 gerbv_polarity_t polarity
; /*!< the polarity of this layer */
484 gchar
*name
; /*!< the layer name (NULL for none) */
485 gpointer next
; /*!< the next layer group in the array */
488 /*! The structure used to keep track of RS274X state groups */
490 gerbv_axis_select_t axisSelect
; /*!< the AB to XY coordinate mapping (refer to RS274X spec) */
491 gerbv_mirror_state_t mirrorState
; /*!< any mirroring around the X or Y axis */
492 gerbv_unit_t unit
; /*!< the current length unit */
493 gdouble offsetA
; /*!< the offset along the A axis (usually this is the X axis) */
494 gdouble offsetB
; /*!< the offset along the B axis (usually this is the Y axis) */
495 gdouble scaleA
; /*!< the scale factor in the A axis (usually this is the X axis) */
496 gdouble scaleB
; /*!< the scale factor in the B axis (usually this is the Y axis) */
497 gpointer next
; /*!< the next state group in the array */
500 /*! The structure used to hold a geometric entity (line/polygon/etc)*/
501 typedef struct gerbv_net
{
502 double start_x
; /*!< the X coordinate of the start point */
503 double start_y
; /*!< the Y coordinate of the start point */
504 double stop_x
; /*!< the X coordinate of the end point */
505 double stop_y
; /*!< the Y coordinate of the end point */
506 gerbv_render_size_t boundingBox
; /*!< the bounding box containing this net (used for rendering optimizations) */
507 int aperture
; /*!< the index of the aperture used for this entity */
508 gerbv_aperture_state_t aperture_state
; /*!< the state of the aperture tool (on/off/etc) */
509 gerbv_interpolation_t interpolation
; /*!< the path interpolation method (linear/etc) */
510 gerbv_cirseg_t
*cirseg
; /*!< information for arc nets */
511 struct gerbv_net
*next
; /*!< the next net in the array */
512 GString
*label
; /*!< a label string for this net */
513 gerbv_layer_t
*layer
; /*!< the RS274X layer this net belongs to */
514 gerbv_netstate_t
*state
; /*!< the RS274X state this net belongs to */
517 /*! Struct holding info about interpreting the Gerber files read
518 * e.g. leading zeros, etc. */
519 typedef struct gerbv_format
{
520 gerbv_omit_zeros_t omit_zeros
;
521 gerbv_coordinate_t coordinate
;
526 int lim_seqno
; /* Length limit for codes of sequence number */
527 int lim_gf
; /* Length limit for codes of general function */
528 int lim_pf
; /* Length limit for codes of plot function */
529 int lim_mf
; /* Length limit for codes of miscellaneous function */
533 /*! Struct holding info about a particular image */
534 typedef struct gerbv_image_info
{
536 gerbv_polarity_t polarity
;
537 double min_x
; /* Always in inches */
543 gerbv_encoding_t encoding
;
544 double imageRotation
;
545 gerbv_image_justify_type_t imageJustifyTypeA
;
546 gerbv_image_justify_type_t imageJustifyTypeB
;
547 gdouble imageJustifyOffsetA
;
548 gdouble imageJustifyOffsetB
;
549 gdouble imageJustifyOffsetActualA
;
550 gdouble imageJustifyOffsetActualB
;
553 /* Descriptive string for the type of file (rs274-x, drill, etc)
558 /* Attribute list that is used to hold all sorts of information
559 * about how the layer is to be parsed.
561 gerbv_HID_Attribute
*attr_list
;
563 } gerbv_image_info_t
;
565 /*! The structure used to hold a layer (RS274X, drill, or pick-and-place data) */
567 gerbv_layertype_t layertype
; /*!< the type of layer (RS274X, drill, or pick-and-place) */
568 gerbv_aperture_t
*aperture
[APERTURE_MAX
]; /*!< an array with all apertures used */
569 gerbv_layer_t
*layers
; /*!< an array of all RS274X layers used (only used in RS274X types) */
570 gerbv_netstate_t
*states
; /*!< an array of all RS274X states used (only used in RS274X types) */
571 gerbv_amacro_t
*amacro
; /*!< an array of all macros used (only used in RS274X types) */
572 gerbv_format_t
*format
; /*!< formatting info */
573 gerbv_image_info_t
*info
; /*!< miscellaneous info regarding the layer such as overall size, etc */
574 gerbv_net_t
*netlist
; /*!< an array of all geometric entities in the layer */
575 gerbv_stats_t
*gerbv_stats
; /*!< RS274X statistics for the layer */
576 gerbv_drill_stats_t
*drill_stats
; /*!< Excellon drill statistics for the layer */
579 /*! Holds information related to an individual layer that is part of a project */
581 gerbv_image_t
*image
; /*!< the image holding all the geometry of the layer */
582 GdkColor color
; /*!< the color to render this layer with */
583 guint16 alpha
; /*!< the transparency to render this layer with */
584 gboolean isVisible
; /*!< TRUE if this layer should be rendered with the project */
585 gpointer privateRenderData
; /*!< private data holder for the rendering backend */
586 gchar
*fullPathname
; /*!< this full pathname to the file */
587 gchar
*name
; /*!< the name used when referring to this layer (e.g. in a layer selection menu) */
588 gerbv_user_transformation_t transform
; /*!< user-specified transformation for this layer (mirroring, translating, etc) */
589 gboolean layer_dirty
; /*!< True if layer has been modified since last save */
597 /*! The top-level structure used in libgerbv. A gerbv_project_t groups together
598 any number of layers, while keeping track of other basic paramters needed for rendering */
600 GdkColor background
; /*!< the background color used for rendering */
601 int max_files
; /*!< the current number of fileinfos in the file array */
602 gerbv_fileinfo_t
**file
; /*!< the array for holding the child fileinfos */
603 int curr_index
; /*!< the index of the currently active fileinfo */
604 int last_loaded
; /*!< the number of fileinfos currently in the project */
605 int renderType
; /*!< the type of renderer to use */
606 gboolean check_before_delete
; /*!< TRUE to ask before deleting objects */
607 gchar
*path
; /*!< the default path to load new files from */
608 gchar
*execpath
; /*!< the path to executed version of gerbv */
609 gchar
*execname
; /*!< the path plus executible name for gerbv */
610 gchar
*project
; /*!< the default name for the private project file */
613 /*! Color of layer */
621 /*! This contains the rendering info for a scene */
623 gdouble scaleFactorX
; /*!< the X direction scale factor */
624 gdouble scaleFactorY
; /*!< the Y direction scale factor */
625 gdouble lowerLeftX
; /*!< the X coordinate of the lower left corner (in real world coordinates, in inches) */
626 gdouble lowerLeftY
; /*!< the Y coordinate of the lower left corner (in real world coordinates, in inches) */
627 gerbv_render_types_t renderType
; /*!< the type of rendering to use */
628 gint displayWidth
; /*!< the width of the scene (in pixels, or points depending on the surface type) */
629 gint displayHeight
; /*!< the height of the scene (in pixels, or points depending on the surface type) */
630 } gerbv_render_info_t
;
632 //! Allocate a new gerbv_image structure
633 //! \return the newly created image
634 gerbv_image_t
*gerbv_create_image(gerbv_image_t
*image
, /*!< the old image to free or NULL */
635 const gchar
*type
/*!< the type of image to create */
638 //! Free an image structure
639 void gerbv_destroy_image(gerbv_image_t
*image
/*!< the image to free */
642 //! Copy an image into an existing image, effectively merging the two together
644 gerbv_image_copy_image (gerbv_image_t
*sourceImage
, /*!< the source image */
645 gerbv_user_transformation_t
*transform
, /*!< the transformation to apply to the new image, or NULL for none */
646 gerbv_image_t
*destinationImage
/*!< the destination image to copy to */
649 //! Duplicate an existing image and return the new copy
650 //! \return the newly created image
652 gerbv_image_duplicate_image (gerbv_image_t
*sourceImage
, /*!< the source image */
653 gerbv_user_transformation_t
*transform
/*!< the transformation to apply to the new image, or NULL for none */
656 //! Delete a net in an existing image
658 gerbv_image_delete_net (gerbv_net_t
*currentNet
/*!< the net to delete */
662 gerbv_image_delete_selected_nets (gerbv_image_t
*sourceImage
, GArray
*selectedNodeArray
);
665 gerbv_image_reduce_area_of_selected_objects (GArray
*selectionArray
, gdouble areaReduction
, gint paneRows
,
666 gint paneColumns
, gdouble paneSeparation
);
669 gerbv_image_move_selected_objects (GArray
*selectionArray
, gdouble translationX
,
670 gdouble translationY
);
672 //! Return the next net entry which corresponds to a unique visible object
674 gerbv_image_return_next_renderable_object (gerbv_net_t
*oldNet
);
676 //! Create a new project structure and initialize some important variables
678 gerbv_create_project (void);
680 //! Free a project and all related variables
682 gerbv_destroy_project (gerbv_project_t
*gerbvProject
/*!< the project to destroy */
685 //! Open a file, parse the contents, and add a new layer to an existing project
687 gerbv_open_layer_from_filename (
688 gerbv_project_t
*gerbvProject
, /*!< the existing project to add the new layer to */
689 gchar
*filename
/*!< the full pathname of the file to be parsed */
692 //! Open a file, parse the contents, and add a new layer to an existing project while setting the color of the layer
694 gerbv_open_layer_from_filename_with_color(gerbv_project_t
*gerbvProject
, /*!< the existing project to add the new layer to */
695 gchar
*filename
, /*!< the full pathname of the file to be parsed */
696 guint16 red
, /*!< the value for the red color component */
697 guint16 green
, /*!< the value for the green color component */
698 guint16 blue
, /*!< the value for the blue color component */
699 guint16 alpha
/*!< the value for the alpha color component */
702 //! Free a fileinfo structure
704 gerbv_destroy_fileinfo (gerbv_fileinfo_t
*fileInfo
/*!< the fileinfo to free */
708 gerbv_save_layer_from_index(gerbv_project_t
*gerbvProject
, gint index
, gchar
*filename
);
711 gerbv_revert_file(gerbv_project_t
*gerbvProject
, int idx
);
714 gerbv_revert_all_files(gerbv_project_t
*gerbvProject
);
717 gerbv_unload_layer(gerbv_project_t
*gerbvProject
, int index
);
720 gerbv_unload_all_layers (gerbv_project_t
*gerbvProject
);
723 gerbv_change_layer_order(gerbv_project_t
*gerbvProject
, gint oldPosition
, gint newPosition
);
726 gerbv_add_parsed_image_to_project (gerbv_project_t
*gerbvProject
, gerbv_image_t
*parsed_image
,
727 gchar
*filename
, gchar
*baseName
, int idx
, int reload
);
729 gerbv_open_image(gerbv_project_t
*gerbvProject
, char *filename
, int idx
, int reload
,
730 gerbv_HID_Attribute
*fattr
, int n_fattr
, gboolean forceLoadFile
);
733 gerbv_render_get_boundingbox(gerbv_project_t
*gerbvProject
, gerbv_render_size_t
*boundingbox
);
735 //! Calculate the zoom and translations to fit the rendered scene inside the given scene size
737 gerbv_render_zoom_to_fit_display (gerbv_project_t
*gerbvProject
, /*!< the project to use for calculating */
738 gerbv_render_info_t
*renderInfo
/*!< the scene render pointer (updates the values in this parameter) */
742 gerbv_render_translate_to_fit_display (gerbv_project_t
*gerbvProject
, gerbv_render_info_t
*renderInfo
);
745 gerbv_render_to_pixmap_using_gdk (gerbv_project_t
*gerbvProject
, GdkPixmap
*pixmap
,
746 gerbv_render_info_t
*renderInfo
, gerbv_selection_info_t
*selectionInfo
,
747 GdkColor
*selectionColor
);
749 #ifndef RENDER_USING_GDK
751 gerbv_render_all_layers_to_cairo_target_for_vector_output (gerbv_project_t
*gerbvProject
,
752 cairo_t
*cr
, gerbv_render_info_t
*renderInfo
);
755 gerbv_render_all_layers_to_cairo_target (gerbv_project_t
*gerbvProject
, cairo_t
*cr
,
756 gerbv_render_info_t
*renderInfo
);
758 //! Render a layer to a cairo context
760 gerbv_render_layer_to_cairo_target (cairo_t
*cr
, /*!< the cairo context */
761 gerbv_fileinfo_t
*fileInfo
, /*!< the layer fileinfo pointer */
762 gerbv_render_info_t
*renderInfo
/*!< the scene render info */
766 gerbv_render_cairo_set_scale_and_translation(cairo_t
*cr
, gerbv_render_info_t
*renderInfo
);
769 gerbv_render_layer_to_cairo_target_without_transforming(cairo_t
*cr
, gerbv_fileinfo_t
*fileInfo
, gerbv_render_info_t
*renderInfo
);
773 gerbv_get_tool_diameter(int toolNumber
777 gerbv_process_tools_file(const char *toolFileName
780 //! Render a project to a PNG file, autoscaling the layers to fit inside the specified image dimensions
782 gerbv_export_png_file_from_project_autoscaled (
783 gerbv_project_t
*gerbvProject
, /*!< the project to render */
784 int widthInPixels
, /*!< the width of the rendered picture (in pixels) */
785 int heightInPixels
, /*!< the height of the rendered picture (in pixels) */
786 gchar
const* filename
/*!< the filename for the exported PNG file */
789 //! Render a project to a PNG file using user-specified render info
791 gerbv_export_png_file_from_project (
792 gerbv_project_t
*gerbvProject
, /*!< the project to render */
793 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
794 gchar
const* filename
/*!< the filename for the exported PNG file */
797 //! Render a project to a PDF file, autoscaling the layers to fit inside the specified image dimensions
799 gerbv_export_pdf_file_from_project_autoscaled (
800 gerbv_project_t
*gerbvProject
, /*!< the project to render */
801 int widthInPixels
, /*!< the width of the rendered picture (in pixels) */
802 int heightInPixels
, /*!< the height of the rendered picture (in pixels) */
803 gchar
const* filename
/*!< the filename for the exported PDF file */
806 //! Render a project to a PDF file using user-specified render info
808 gerbv_export_pdf_file_from_project (
809 gerbv_project_t
*gerbvProject
, /*!< the project to render */
810 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
811 gchar
const* filename
/*!< the filename for the exported PDF file */
814 //! Render a project to a Postscript file, autoscaling the layers to fit inside the specified image dimensions
816 gerbv_export_postscript_file_from_project_autoscaled (
817 gerbv_project_t
*gerbvProject
, /*!< the project to render */
818 int widthInPixels
, /*!< the width of the rendered picture (in pixels) */
819 int heightInPixels
, /*!< the height of the rendered picture (in pixels) */
820 gchar
const* filename
/*!< the filename for the exported Postscript file */
823 //! Render a project to a Postscript file using user-specified render info
825 gerbv_export_postscript_file_from_project (
826 gerbv_project_t
*gerbvProject
, /*!< the project to render */
827 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
828 gchar
const* filename
/*!< the filename for the exported Postscript file */
831 //! Render a project to a SVG file, autoscaling the layers to fit inside the specified image dimensions
833 gerbv_export_svg_file_from_project_autoscaled (
834 gerbv_project_t
*gerbvProject
, /*!< the project to render */
835 int widthInPixels
, /*!< the width of the rendered picture (in pixels) */
836 int heightInPixels
, /*!< the height of the rendered picture (in pixels) */
837 gchar
const* filename
/*!< the filename for the exported file */
840 //! Render a project to a file using user-specified render info
842 gerbv_export_svg_file_from_project (
843 gerbv_project_t
*gerbvProject
, /*!< the project to render */
844 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
845 gchar
const* filename
/*!< the filename for the exported file */
848 //! Parse a RS274X file and return the parsed image
849 //! \return the new gerbv_image_t, or NULL if not successful
851 gerbv_create_rs274x_image_from_filename (gchar
*filename
/*!< the filename of the file to be parsed*/
854 //! Export an image to a new file in RS274X format
855 //! \return TRUE if successful, or FALSE if not
857 gerbv_export_rs274x_file_from_image (gchar
*filename
, /*!< the filename for the new file */
858 gerbv_image_t
*image
/*!< the image to export */
861 //! Export an image to a new file in Excellon drill format
862 //! \return TRUE if successful, or FALSE if not
864 gerbv_export_drill_file_from_image (gchar
*filename
, /*!< the filename for the new file */
865 gerbv_image_t
*image
/*!< the image to export */
868 //! Draw a line on the specified image
870 gerbv_image_create_line_object (gerbv_image_t
*image
, /*!< the image to draw to */
871 gdouble startX
, /*!< the starting X coordinate */
872 gdouble startY
, /*!< the starting Y coordinate */
873 gdouble endX
, /*!< the ending X coordinate */
874 gdouble endY
, /*!< the ending Y coordinate */
875 gdouble lineWidth
, /*!< the width of the line to draw */
876 gerbv_aperture_type_t apertureType
/*!< the type of aperture to use (e.g. CIRCLE) */
879 //! Draw an arc on the specified image
881 gerbv_image_create_arc_object (gerbv_image_t
*image
, /*!< the image to draw to */
882 gdouble centerX
, /*!< the center X coordinate */
883 gdouble centerY
, /*!< the center Y coordinate */
884 gdouble radius
, /*!< the arc radius */
885 gdouble startAngle
, /*!< the start angle (in CCW degrees) */
886 gdouble endAngle
, /*!< the start angle (in CCW degrees) */
887 gdouble lineWidth
, /*!< the width of the line to draw */
888 gerbv_aperture_type_t apertureType
/*!< the type of aperture to use (e.g. CIRCLE) */
891 //! Draw a filled rectangle on the specified image
893 gerbv_image_create_rectangle_object (gerbv_image_t
*image
, /*!< the image to draw to */
894 gdouble coordinateX
, /*!< the X coordinate of the lower left corner */
895 gdouble coordinateY
, /*!< the Y coordinate of the lower left corner */
896 gdouble width
, /*!< the width of the drawn rectangle */
897 gdouble height
/*!< the height of the drawn rectangle */
900 /*! Create new struct for holding drill stats */
901 gerbv_drill_stats_t
*
902 gerbv_drill_stats_new(void);
904 /*! Free the memory for a drill stats struct */
906 gerbv_drill_stats_destroy(gerbv_drill_stats_t
*);
908 /*! Add stats gathered from specified layer to accumulatedd drill stats
909 * compiled from all layers */
911 gerbv_drill_stats_add_layer(gerbv_drill_stats_t
*accum_stats
,
912 gerbv_drill_stats_t
*input_stats
,
916 /*! Create new struct for holding Gerber stats */
918 gerbv_stats_new(void);
920 /*! Free the memory for a stats struct */
922 gerbv_stats_destroy(gerbv_stats_t
*);
924 /*! Add stats gathered from specified layer to accumulated Gerber stats
925 * compiled from all layers */
927 gerbv_stats_add_layer(gerbv_stats_t
*accum_stats
,
928 gerbv_stats_t
*input_stats
,
933 gerbv_attribute_destroy_HID_attribute (gerbv_HID_Attribute
*attributeList
, int n_attr
);
935 gerbv_HID_Attribute
*
936 gerbv_attribute_dup (gerbv_HID_Attribute
*, int);
938 #endif /* __GERBV_H__ */