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).
61 #if defined(__cplusplus)
72 #include <gdk/gdkkeysyms.h>
74 #ifndef RENDER_USING_GDK
78 #define APERTURE_MIN 10
79 #define APERTURE_MAX 9999
82 * Maximum number of aperture parameters is set by the outline aperture
83 * macro. There (p. 28) is defined up to 50 points in polygon.
84 * So 50 points with x and y plus two for holding extra data gives...
86 #define APERTURE_PARAMETERS_MAX 102
87 #define INITIAL_SCALE 200
88 #define MAX_ERRMSGLEN 25
89 #define MAX_COORDLEN 28
90 #define MAX_DISTLEN 90
91 #define MAX_STATUSMSGLEN (MAX_ERRMSGLEN+MAX_COORDLEN+MAX_DISTLEN)
93 /* Macros to convert between unscaled gerber coordinates and other units */
94 /* XXX NOTE: Currently unscaled units are assumed as inch, this is not
95 XXX necessarily true for all files */
96 #define COORD2MILS(c) ((c)*1000.0)
97 #define COORD2MMS(c) ((c)*25.4)
99 #define GERB_FATAL_ERROR(t...) g_log(NULL, G_LOG_LEVEL_ERROR, ##t);
100 #define GERB_COMPILE_ERROR(t...) g_log(NULL, G_LOG_LEVEL_CRITICAL, ##t);
101 #define GERB_COMPILE_WARNING(t...) g_log(NULL, G_LOG_LEVEL_WARNING, ##t);
102 #define GERB_MESSAGE(t...) g_log(NULL, G_LOG_LEVEL_MESSAGE, ##t);
104 /*! The aperture macro commands */
105 typedef enum {GERBV_OPCODE_NOP
, /*!< no operation */
106 GERBV_OPCODE_PUSH
, /*!< push the instruction onto the stack */
107 GERBV_OPCODE_PPUSH
, /*!< push parameter onto stack */
108 GERBV_OPCODE_PPOP
, /*!< pop parameter from stack */
109 GERBV_OPCODE_ADD
, /*!< mathmatical add operation */
110 GERBV_OPCODE_SUB
, /*!< mathmatical subtract operation */
111 GERBV_OPCODE_MUL
, /*!< mathmatical multiply operation */
112 GERBV_OPCODE_DIV
, /*!< mathmatical divide operation */
113 GERBV_OPCODE_PRIM
/*!< draw macro primative */
116 /*! The different message types used in libgerbv */
117 typedef enum {GERBV_MESSAGE_FATAL
, /*!< processing cannot continue */
118 GERBV_MESSAGE_ERROR
, /*!< something went wrong, but processing can still continue */
119 GERBV_MESSAGE_WARNING
, /*!< something was encountered that may provide the wrong output */
120 GERBV_MESSAGE_NOTE
/*!< an irregularity was encountered, but needs no intervention */
121 } gerbv_message_type_t
;
123 /*! The different aperture types available
124 * Please keep these in sync with the aperture names defined by
125 * ap_names in callbacks.c */
126 typedef enum {GERBV_APTYPE_NONE
, /*!< no aperture used */
127 GERBV_APTYPE_CIRCLE
, /*!< a round aperture */
128 GERBV_APTYPE_RECTANGLE
, /*!< a rectangular aperture */
129 GERBV_APTYPE_OVAL
, /*!< an ovular (obround) aperture */
130 GERBV_APTYPE_POLYGON
, /*!< a polygon aperture */
131 GERBV_APTYPE_MACRO
, /*!< a RS274X macro */
132 GERBV_APTYPE_MACRO_CIRCLE
, /*!< a RS274X circle macro */
133 GERBV_APTYPE_MACRO_OUTLINE
, /*!< a RS274X outline macro */
134 GERBV_APTYPE_MACRO_POLYGON
, /*!< a RS274X polygon macro */
135 GERBV_APTYPE_MACRO_MOIRE
, /*!< a RS274X moire macro */
136 GERBV_APTYPE_MACRO_THERMAL
, /*!< a RS274X thermal macro */
137 GERBV_APTYPE_MACRO_LINE20
, /*!< a RS274X line (code 20) macro */
138 GERBV_APTYPE_MACRO_LINE21
, /*!< a RS274X line (code 21) macro */
139 GERBV_APTYPE_MACRO_LINE22
/*!< a RS274X line (code 22) macro */
140 } gerbv_aperture_type_t
;
142 /*! the current state of the aperture drawing tool */
143 typedef enum {GERBV_APERTURE_STATE_OFF
, /*!< tool drawing is off, and nothing will be drawn */
144 GERBV_APERTURE_STATE_ON
, /*!< tool drawing is on, and something will be drawn */
145 GERBV_APERTURE_STATE_FLASH
/*!< tool is flashing, and will draw a single aperture */
146 } gerbv_aperture_state_t
;
148 /*! the current unit used */
149 typedef enum {GERBV_UNIT_INCH
, /*!< inches */
150 GERBV_UNIT_MM
, /*!< mm */
151 GERBV_UNIT_UNSPECIFIED
/*!< use default units */
154 /*! the different drawing polarities available */
155 typedef enum {GERBV_POLARITY_POSITIVE
, /*!< draw "positive", using the current layer's polarity */
156 GERBV_POLARITY_NEGATIVE
, /*!< draw "negative", reversing the current layer's polarity */
157 GERBV_POLARITY_DARK
, /*!< add to the current rendering */
158 GERBV_POLARITY_CLEAR
/*!< subtract from the current rendering */
161 /*! the decimal point parsing style used */
162 typedef enum {GERBV_OMIT_ZEROS_LEADING
, /*!< omit extra zeros before the decimal point */
163 GERBV_OMIT_ZEROS_TRAILING
, /*!< omit extra zeros after the decimal point */
164 GERBV_OMIT_ZEROS_EXPLICIT
, /*!< explicitly specify how many decimal places are used */
165 GERBV_OMIT_ZEROS_UNSPECIFIED
/*!< use the default parsing style */
166 } gerbv_omit_zeros_t
;
168 /*! the coordinate system used */
169 typedef enum {GERBV_COORDINATE_ABSOLUTE
, /*!< all coordinates are absolute from a common origin */
170 GERBV_COORDINATE_INCREMENTAL
/*!< all coordinates are relative to the previous coordinate */
171 } gerbv_coordinate_t
;
173 /*! the interpolation methods available */
174 typedef enum {GERBV_INTERPOLATION_LINEARx1
, /*!< draw a line */
175 GERBV_INTERPOLATION_x10
, /*!< draw a line */
176 GERBV_INTERPOLATION_LINEARx01
, /*!< draw a line */
177 GERBV_INTERPOLATION_LINEARx001
, /*!< draw a line */
178 GERBV_INTERPOLATION_CW_CIRCULAR
, /*!< draw an arc in the clockwise direction */
179 GERBV_INTERPOLATION_CCW_CIRCULAR
, /*!< draw an arc in the counter-clockwise direction */
180 GERBV_INTERPOLATION_PAREA_START
, /*!< start a polygon draw */
181 GERBV_INTERPOLATION_PAREA_END
, /*!< end a polygon draw */
182 GERBV_INTERPOLATION_DELETED
/*!< the net has been deleted by the user, and will not be drawn */
183 } gerbv_interpolation_t
;
185 typedef enum {GERBV_ENCODING_NONE
,
186 GERBV_ENCODING_ASCII
,
187 GERBV_ENCODING_EBCDIC
,
189 GERBV_ENCODING_ISO_ASCII
,
193 /*! The different layer types used */
194 typedef enum {GERBV_LAYERTYPE_RS274X
, /*!< the file is a RS274X file */
195 GERBV_LAYERTYPE_DRILL
, /*!< the file is an Excellon drill file */
196 GERBV_LAYERTYPE_PICKANDPLACE
/*!< the file is a CSV pick and place file */
199 typedef enum {GERBV_KNOCKOUT_TYPE_NOKNOCKOUT
,
200 GERBV_KNOCKOUT_TYPE_FIXEDKNOCK
,
201 GERBV_KNOCKOUT_TYPE_BORDER
202 } gerbv_knockout_type_t
;
204 typedef enum {GERBV_MIRROR_STATE_NOMIRROR
,
205 GERBV_MIRROR_STATE_FLIPA
,
206 GERBV_MIRROR_STATE_FLIPB
,
207 GERBV_MIRROR_STATE_FLIPAB
208 } gerbv_mirror_state_t
;
210 typedef enum {GERBV_AXIS_SELECT_NOSELECT
,
211 GERBV_AXIS_SELECT_SWAPAB
212 } gerbv_axis_select_t
;
214 typedef enum {GERBV_JUSTIFY_NOJUSTIFY
,
215 GERBV_JUSTIFY_LOWERLEFT
,
216 GERBV_JUSTIFY_CENTERJUSTIFY
217 } gerbv_image_justify_type_t
;
219 /*! The different selection modes available */
220 typedef enum {GERBV_SELECTION_EMPTY
, /*!< the selection buffer is empty */
221 GERBV_SELECTION_POINT_CLICK
, /*!< the user clicked on a single point */
222 GERBV_SELECTION_DRAG_BOX
/*!< the user dragged a box to encompass one or more objects */
225 /*! The different rendering modes available to libgerbv */
226 typedef enum {GERBV_RENDER_TYPE_GDK
, /*!< render using normal GDK drawing functions */
227 GERBV_RENDER_TYPE_GDK_XOR
, /*!< use the GDK_XOR mask to draw a pseudo-transparent scene */
228 GERBV_RENDER_TYPE_CAIRO_NORMAL
, /*!< use the cairo library */
229 GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY
/*!< use the cairo library with the smoothest edges */
230 } gerbv_render_types_t
;
233 * The following typedef's are taken directly from src/hid.h in the
234 * pcb project. The names are kept the same to make it easier to
235 * compare to pcb's sources.
238 /* Used for HID attributes (exporting and printing, mostly).
239 HA_boolean uses int_value, HA_enum sets int_value to the index and
240 str_value to the enumeration string. HID_Label just shows the
241 default str_value. HID_Mixed is a real_value followed by an enum,
248 } gerbv_HID_Attr_Val
;
254 { HID_Label
, HID_Integer
, HID_Real
, HID_String
,
255 HID_Boolean
, HID_Enum
, HID_Mixed
, HID_Path
257 int min_val
, max_val
; /* for integer and real */
258 gerbv_HID_Attr_Val default_val
; /* Also actual value for global attributes. */
259 const char **enumerations
;
260 /* If set, this is used for global attributes (i.e. those set
261 statically with REGISTER_ATTRIBUTES below) instead of changing
262 the default_val. Note that a HID_Mixed attribute must specify a
263 pointer to gerbv_HID_Attr_Val here, and HID_Boolean assumes this is
264 "char *" so the value should be initialized to zero, and may be
265 set to non-zero (not always one). */
267 int hash
; /* for detecting changes. */
268 } gerbv_HID_Attribute
;
269 /* end of HID attributes from PCB */
271 /*! A linked list of errors found in the files */
272 typedef struct error_list
{
275 gerbv_message_type_t type
;
276 struct error_list
*next
;
277 } gerbv_error_list_t
;
279 typedef struct instruction
{
280 gerbv_opcodes_t opcode
;
285 struct instruction
*next
;
286 } gerbv_instruction_t
;
288 typedef struct amacro
{
290 gerbv_instruction_t
*program
;
291 unsigned int nuf_push
; /* Nuf pushes in program to estimate stack size */
295 typedef struct gerbv_simplified_amacro
{
296 gerbv_aperture_type_t type
;
297 double parameter
[APERTURE_PARAMETERS_MAX
];
298 struct gerbv_simplified_amacro
*next
;
299 } gerbv_simplified_amacro_t
;
301 typedef struct gerbv_aperture
{
302 gerbv_aperture_type_t type
;
303 gerbv_amacro_t
*amacro
;
304 gerbv_simplified_amacro_t
*simplified
;
305 double parameter
[APERTURE_PARAMETERS_MAX
];
310 /* the gerb_aperture_list is used to keep track of
311 * apertures used in stats reporting */
312 typedef struct gerbv_aperture_list
{
316 gerbv_aperture_type_t type
;
318 struct gerbv_aperture_list
*next
;
319 } gerbv_aperture_list_t
;
321 /*! Contains statistics on the various codes used in a RS274X file */
323 gerbv_error_list_t
*error_list
;
324 gerbv_aperture_list_t
*aperture_list
;
325 gerbv_aperture_list_t
*D_code_list
;
351 /* GHashTable *D_user_defined; */
365 /* Must include % RS-274 codes */
371 /*! Linked list of drills found in active layers. Used in reporting statistics */
372 typedef struct drill_list
{
377 struct drill_list
*next
;
378 } gerbv_drill_list_t
;
380 /*! Struct holding statistics of drill commands used. Used in reporting statistics */
384 gerbv_error_list_t
*error_list
;
385 gerbv_drill_list_t
*drill_list
;
420 /* used to total up the drill count across all layers/sizes */
425 } gerbv_drill_stats_t
;
430 } gerbv_selection_item_t
;
432 /*! Struct holding info about the last selection */
434 gerbv_selection_t type
;
439 GArray
*selectedNodeArray
;
440 } gerbv_selection_info_t
;
442 /*! Stores image transformation information, used to modify the rendered
443 position/scale/etc of an image. */
445 gdouble translateX
; /*!< the X translation (in inches) */
446 gdouble translateY
; /*!< the Y translation (in inches) */
447 gdouble scaleX
; /*!< the X scale factor (1.0 is default) */
448 gdouble scaleY
; /*!< the Y scale factor (1.0 is default) */
449 gdouble rotation
; /*!< the rotation of the layer around the origin (in radians) */
450 gboolean mirrorAroundX
; /*!< TRUE if the layer is mirrored around the X axis (vertical flip) */
451 gboolean mirrorAroundY
; /*!< TRUE if the layer is mirrored around the Y axis (vertical flip) */
452 gboolean inverted
; /*!< TRUE if the image should be rendered "inverted" (light is dark and vice versa) */
453 } gerbv_user_transformation_t
;
455 /*! This defines a box location and size (used to rendering logic) */
457 double left
; /*!< the X coordinate of the left side */
458 double right
; /*!< the X coordinate of the right side */
459 double bottom
; /*!< the Y coordinate of the bottom side */
460 double top
; /*!< the Y coordinate of the top side */
461 } gerbv_render_size_t
;
463 typedef struct gerbv_cirseg
{
466 double width
; /* of oval */
467 double height
; /* of oval */
472 typedef struct gerbv_step_and_repeat
{ /* SR parameters */
477 } gerbv_step_and_repeat_t
;
480 gboolean firstInstance
;
481 gerbv_knockout_type_t type
;
482 gerbv_polarity_t polarity
;
490 /*! The structure used to keep track of RS274X layer groups */
492 gerbv_step_and_repeat_t stepAndRepeat
; /*!< the current step and repeat group (refer to RS274X spec) */
493 gerbv_knockout_t knockout
; /*!< the current knockout group (refer to RS274X spec) */
494 gdouble rotation
; /*!< the current rotation around the origin */
495 gerbv_polarity_t polarity
; /*!< the polarity of this layer */
496 gchar
*name
; /*!< the layer name (NULL for none) */
497 gpointer next
; /*!< the next layer group in the array */
500 /*! The structure used to keep track of RS274X state groups */
502 gerbv_axis_select_t axisSelect
; /*!< the AB to XY coordinate mapping (refer to RS274X spec) */
503 gerbv_mirror_state_t mirrorState
; /*!< any mirroring around the X or Y axis */
504 gerbv_unit_t unit
; /*!< the current length unit */
505 gdouble offsetA
; /*!< the offset along the A axis (usually this is the X axis) */
506 gdouble offsetB
; /*!< the offset along the B axis (usually this is the Y axis) */
507 gdouble scaleA
; /*!< the scale factor in the A axis (usually this is the X axis) */
508 gdouble scaleB
; /*!< the scale factor in the B axis (usually this is the Y axis) */
509 gpointer next
; /*!< the next state group in the array */
512 /*! The structure used to hold a geometric entity (line/polygon/etc)*/
513 typedef struct gerbv_net
{
514 double start_x
; /*!< the X coordinate of the start point */
515 double start_y
; /*!< the Y coordinate of the start point */
516 double stop_x
; /*!< the X coordinate of the end point */
517 double stop_y
; /*!< the Y coordinate of the end point */
518 gerbv_render_size_t boundingBox
; /*!< the bounding box containing this net (used for rendering optimizations) */
519 int aperture
; /*!< the index of the aperture used for this entity */
520 gerbv_aperture_state_t aperture_state
; /*!< the state of the aperture tool (on/off/etc) */
521 gerbv_interpolation_t interpolation
; /*!< the path interpolation method (linear/etc) */
522 gerbv_cirseg_t
*cirseg
; /*!< information for arc nets */
523 struct gerbv_net
*next
; /*!< the next net in the array */
524 GString
*label
; /*!< a label string for this net */
525 gerbv_layer_t
*layer
; /*!< the RS274X layer this net belongs to */
526 gerbv_netstate_t
*state
; /*!< the RS274X state this net belongs to */
529 /*! Struct holding info about interpreting the Gerber files read
530 * e.g. leading zeros, etc. */
531 typedef struct gerbv_format
{
532 gerbv_omit_zeros_t omit_zeros
;
533 gerbv_coordinate_t coordinate
;
538 int lim_seqno
; /* Length limit for codes of sequence number */
539 int lim_gf
; /* Length limit for codes of general function */
540 int lim_pf
; /* Length limit for codes of plot function */
541 int lim_mf
; /* Length limit for codes of miscellaneous function */
545 /*! Struct holding info about a particular image */
546 typedef struct gerbv_image_info
{
548 gerbv_polarity_t polarity
;
549 double min_x
; /* Always in inches */
555 gerbv_encoding_t encoding
;
556 double imageRotation
;
557 gerbv_image_justify_type_t imageJustifyTypeA
;
558 gerbv_image_justify_type_t imageJustifyTypeB
;
559 gdouble imageJustifyOffsetA
;
560 gdouble imageJustifyOffsetB
;
561 gdouble imageJustifyOffsetActualA
;
562 gdouble imageJustifyOffsetActualB
;
565 /* Descriptive string for the type of file (rs274-x, drill, etc)
570 /* Attribute list that is used to hold all sorts of information
571 * about how the layer is to be parsed.
573 gerbv_HID_Attribute
*attr_list
;
575 } gerbv_image_info_t
;
577 /*! The structure used to hold a layer (RS274X, drill, or pick-and-place data) */
579 gerbv_layertype_t layertype
; /*!< the type of layer (RS274X, drill, or pick-and-place) */
580 gerbv_aperture_t
*aperture
[APERTURE_MAX
]; /*!< an array with all apertures used */
581 gerbv_layer_t
*layers
; /*!< an array of all RS274X layers used (only used in RS274X types) */
582 gerbv_netstate_t
*states
; /*!< an array of all RS274X states used (only used in RS274X types) */
583 gerbv_amacro_t
*amacro
; /*!< an array of all macros used (only used in RS274X types) */
584 gerbv_format_t
*format
; /*!< formatting info */
585 gerbv_image_info_t
*info
; /*!< miscellaneous info regarding the layer such as overall size, etc */
586 gerbv_net_t
*netlist
; /*!< an array of all geometric entities in the layer */
587 gerbv_stats_t
*gerbv_stats
; /*!< RS274X statistics for the layer */
588 gerbv_drill_stats_t
*drill_stats
; /*!< Excellon drill statistics for the layer */
591 /*! Holds information related to an individual layer that is part of a project */
593 gerbv_image_t
*image
; /*!< the image holding all the geometry of the layer */
594 GdkColor color
; /*!< the color to render this layer with */
595 guint16 alpha
; /*!< the transparency to render this layer with */
596 gboolean isVisible
; /*!< TRUE if this layer should be rendered with the project */
597 gpointer privateRenderData
; /*!< private data holder for the rendering backend */
598 gchar
*fullPathname
; /*!< this full pathname to the file */
599 gchar
*name
; /*!< the name used when referring to this layer (e.g. in a layer selection menu) */
600 gerbv_user_transformation_t transform
; /*!< user-specified transformation for this layer (mirroring, translating, etc) */
601 gboolean layer_dirty
; /*!< True if layer has been modified since last save */
609 /*! The top-level structure used in libgerbv. A gerbv_project_t groups together
610 any number of layers, while keeping track of other basic paramters needed for rendering */
612 GdkColor background
; /*!< the background color used for rendering */
613 int max_files
; /*!< the current number of fileinfos in the file array */
614 gerbv_fileinfo_t
**file
; /*!< the array for holding the child fileinfos */
615 int curr_index
; /*!< the index of the currently active fileinfo */
616 int last_loaded
; /*!< the number of fileinfos currently in the project */
617 int renderType
; /*!< the type of renderer to use */
618 gboolean check_before_delete
; /*!< TRUE to ask before deleting objects */
619 gchar
*path
; /*!< the default path to load new files from */
620 gchar
*execpath
; /*!< the path to executed version of gerbv */
621 gchar
*execname
; /*!< the path plus executible name for gerbv */
622 gchar
*project
; /*!< the default name for the private project file */
625 /*! Color of layer */
633 /*! This contains the rendering info for a scene */
635 gdouble scaleFactorX
; /*!< the X direction scale factor */
636 gdouble scaleFactorY
; /*!< the Y direction scale factor */
637 gdouble lowerLeftX
; /*!< the X coordinate of the lower left corner (in real world coordinates, in inches) */
638 gdouble lowerLeftY
; /*!< the Y coordinate of the lower left corner (in real world coordinates, in inches) */
639 gerbv_render_types_t renderType
; /*!< the type of rendering to use */
640 gint displayWidth
; /*!< the width of the scene (in pixels, or points depending on the surface type) */
641 gint displayHeight
; /*!< the height of the scene (in pixels, or points depending on the surface type) */
642 } gerbv_render_info_t
;
644 //! Allocate a new gerbv_image structure
645 //! \return the newly created image
646 gerbv_image_t
*gerbv_create_image(gerbv_image_t
*image
, /*!< the old image to free or NULL */
647 const gchar
*type
/*!< the type of image to create */
650 //! Free an image structure
651 void gerbv_destroy_image(gerbv_image_t
*image
/*!< the image to free */
654 //! Copy an image into an existing image, effectively merging the two together
656 gerbv_image_copy_image (gerbv_image_t
*sourceImage
, /*!< the source image */
657 gerbv_user_transformation_t
*transform
, /*!< the transformation to apply to the new image, or NULL for none */
658 gerbv_image_t
*destinationImage
/*!< the destination image to copy to */
661 //! Duplicate an existing image and return the new copy
662 //! \return the newly created image
664 gerbv_image_duplicate_image (gerbv_image_t
*sourceImage
, /*!< the source image */
665 gerbv_user_transformation_t
*transform
/*!< the transformation to apply to the new image, or NULL for none */
668 //! Delete a net in an existing image
670 gerbv_image_delete_net (gerbv_net_t
*currentNet
/*!< the net to delete */
674 gerbv_image_delete_selected_nets (gerbv_image_t
*sourceImage
, GArray
*selectedNodeArray
);
677 gerbv_image_reduce_area_of_selected_objects (GArray
*selectionArray
, gdouble areaReduction
, gint paneRows
,
678 gint paneColumns
, gdouble paneSeparation
);
681 gerbv_image_move_selected_objects (GArray
*selectionArray
, gdouble translationX
,
682 gdouble translationY
);
684 //! Return the next net entry which corresponds to a unique visible object
686 gerbv_image_return_next_renderable_object (gerbv_net_t
*oldNet
);
688 //! Create a new project structure and initialize some important variables
690 gerbv_create_project (void);
692 //! Free a project and all related variables
694 gerbv_destroy_project (gerbv_project_t
*gerbvProject
/*!< the project to destroy */
697 //! Open a file, parse the contents, and add a new layer to an existing project
699 gerbv_open_layer_from_filename (
700 gerbv_project_t
*gerbvProject
, /*!< the existing project to add the new layer to */
701 gchar
*filename
/*!< the full pathname of the file to be parsed */
704 //! Open a file, parse the contents, and add a new layer to an existing project while setting the color of the layer
706 gerbv_open_layer_from_filename_with_color(gerbv_project_t
*gerbvProject
, /*!< the existing project to add the new layer to */
707 gchar
*filename
, /*!< the full pathname of the file to be parsed */
708 guint16 red
, /*!< the value for the red color component */
709 guint16 green
, /*!< the value for the green color component */
710 guint16 blue
, /*!< the value for the blue color component */
711 guint16 alpha
/*!< the value for the alpha color component */
714 //! Free a fileinfo structure
716 gerbv_destroy_fileinfo (gerbv_fileinfo_t
*fileInfo
/*!< the fileinfo to free */
720 gerbv_save_layer_from_index(gerbv_project_t
*gerbvProject
, gint index
, gchar
*filename
);
723 gerbv_revert_file(gerbv_project_t
*gerbvProject
, int idx
);
726 gerbv_revert_all_files(gerbv_project_t
*gerbvProject
);
729 gerbv_unload_layer(gerbv_project_t
*gerbvProject
, int index
);
732 gerbv_unload_all_layers (gerbv_project_t
*gerbvProject
);
735 gerbv_change_layer_order(gerbv_project_t
*gerbvProject
, gint oldPosition
, gint newPosition
);
738 gerbv_add_parsed_image_to_project (gerbv_project_t
*gerbvProject
, gerbv_image_t
*parsed_image
,
739 gchar
*filename
, gchar
*baseName
, int idx
, int reload
);
741 gerbv_open_image(gerbv_project_t
*gerbvProject
, char *filename
, int idx
, int reload
,
742 gerbv_HID_Attribute
*fattr
, int n_fattr
, gboolean forceLoadFile
);
745 gerbv_render_get_boundingbox(gerbv_project_t
*gerbvProject
, gerbv_render_size_t
*boundingbox
);
747 //! Calculate the zoom and translations to fit the rendered scene inside the given scene size
749 gerbv_render_zoom_to_fit_display (gerbv_project_t
*gerbvProject
, /*!< the project to use for calculating */
750 gerbv_render_info_t
*renderInfo
/*!< the scene render pointer (updates the values in this parameter) */
754 gerbv_render_translate_to_fit_display (gerbv_project_t
*gerbvProject
, gerbv_render_info_t
*renderInfo
);
757 gerbv_render_to_pixmap_using_gdk (gerbv_project_t
*gerbvProject
, GdkPixmap
*pixmap
,
758 gerbv_render_info_t
*renderInfo
, gerbv_selection_info_t
*selectionInfo
,
759 GdkColor
*selectionColor
);
761 #ifndef RENDER_USING_GDK
763 gerbv_render_all_layers_to_cairo_target_for_vector_output (gerbv_project_t
*gerbvProject
,
764 cairo_t
*cr
, gerbv_render_info_t
*renderInfo
);
767 gerbv_render_all_layers_to_cairo_target (gerbv_project_t
*gerbvProject
, cairo_t
*cr
,
768 gerbv_render_info_t
*renderInfo
);
770 //! Render a layer to a cairo context
772 gerbv_render_layer_to_cairo_target (cairo_t
*cr
, /*!< the cairo context */
773 gerbv_fileinfo_t
*fileInfo
, /*!< the layer fileinfo pointer */
774 gerbv_render_info_t
*renderInfo
/*!< the scene render info */
778 gerbv_render_cairo_set_scale_and_translation(cairo_t
*cr
, gerbv_render_info_t
*renderInfo
);
781 gerbv_render_layer_to_cairo_target_without_transforming(cairo_t
*cr
, gerbv_fileinfo_t
*fileInfo
, gerbv_render_info_t
*renderInfo
, gboolean limitPizelSize
);
785 gerbv_get_tool_diameter(int toolNumber
789 gerbv_process_tools_file(const char *toolFileName
792 //! Render a project to a PNG file, autoscaling the layers to fit inside the specified image dimensions
794 gerbv_export_png_file_from_project_autoscaled (
795 gerbv_project_t
*gerbvProject
, /*!< the project to render */
796 int widthInPixels
, /*!< the width of the rendered picture (in pixels) */
797 int heightInPixels
, /*!< the height of the rendered picture (in pixels) */
798 gchar
const* filename
/*!< the filename for the exported PNG file */
801 //! Render a project to a PNG file using user-specified render info
803 gerbv_export_png_file_from_project (
804 gerbv_project_t
*gerbvProject
, /*!< the project to render */
805 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
806 gchar
const* filename
/*!< the filename for the exported PNG file */
809 //! Render a project to a PDF file, autoscaling the layers to fit inside the specified image dimensions
811 gerbv_export_pdf_file_from_project_autoscaled (
812 gerbv_project_t
*gerbvProject
, /*!< the project to render */
813 gchar
const* filename
/*!< the filename for the exported PDF file */
816 //! Render a project to a PDF file using user-specified render info
818 gerbv_export_pdf_file_from_project (
819 gerbv_project_t
*gerbvProject
, /*!< the project to render */
820 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
821 gchar
const* filename
/*!< the filename for the exported PDF file */
824 //! Render a project to a Postscript file, autoscaling the layers to fit inside the specified image dimensions
826 gerbv_export_postscript_file_from_project_autoscaled (
827 gerbv_project_t
*gerbvProject
, /*!< the project to render */
828 gchar
const* filename
/*!< the filename for the exported Postscript file */
831 //! Render a project to a Postscript file using user-specified render info
833 gerbv_export_postscript_file_from_project (
834 gerbv_project_t
*gerbvProject
, /*!< the project to render */
835 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
836 gchar
const* filename
/*!< the filename for the exported Postscript file */
839 //! Render a project to a SVG file, autoscaling the layers to fit inside the specified image dimensions
841 gerbv_export_svg_file_from_project_autoscaled (
842 gerbv_project_t
*gerbvProject
, /*!< the project to render */
843 gchar
const* filename
/*!< the filename for the exported file */
846 //! Render a project to a file using user-specified render info
848 gerbv_export_svg_file_from_project (
849 gerbv_project_t
*gerbvProject
, /*!< the project to render */
850 gerbv_render_info_t
*renderInfo
, /*!< the render settings for the rendered image */
851 gchar
const* filename
/*!< the filename for the exported file */
854 //! Parse a RS274X file and return the parsed image
855 //! \return the new gerbv_image_t, or NULL if not successful
857 gerbv_create_rs274x_image_from_filename (gchar
*filename
/*!< the filename of the file to be parsed*/
860 //! Export an image to a new file in RS274X format
861 //! \return TRUE if successful, or FALSE if not
863 gerbv_export_rs274x_file_from_image (gchar
*filename
, /*!< the filename for the new file */
864 gerbv_image_t
*image
, /*!< the image to export */
865 gerbv_user_transformation_t
*transform
/*!< the transformation to apply before exporting */
868 //! Export an image to a new file in Excellon drill format
869 //! \return TRUE if successful, or FALSE if not
871 gerbv_export_drill_file_from_image (gchar
*filename
, /*!< the filename for the new file */
872 gerbv_image_t
*image
, /*!< the image to export */
873 gerbv_user_transformation_t
*transform
/*!< the transformation to apply before exporting */
876 //! Draw a line on the specified image
878 gerbv_image_create_line_object (gerbv_image_t
*image
, /*!< the image to draw to */
879 gdouble startX
, /*!< the starting X coordinate */
880 gdouble startY
, /*!< the starting Y coordinate */
881 gdouble endX
, /*!< the ending X coordinate */
882 gdouble endY
, /*!< the ending Y coordinate */
883 gdouble lineWidth
, /*!< the width of the line to draw */
884 gerbv_aperture_type_t apertureType
/*!< the type of aperture to use (e.g. CIRCLE) */
887 //! Draw an arc on the specified image
889 gerbv_image_create_arc_object (gerbv_image_t
*image
, /*!< the image to draw to */
890 gdouble centerX
, /*!< the center X coordinate */
891 gdouble centerY
, /*!< the center Y coordinate */
892 gdouble radius
, /*!< the arc radius */
893 gdouble startAngle
, /*!< the start angle (in CCW degrees) */
894 gdouble endAngle
, /*!< the start angle (in CCW degrees) */
895 gdouble lineWidth
, /*!< the width of the line to draw */
896 gerbv_aperture_type_t apertureType
/*!< the type of aperture to use (e.g. CIRCLE) */
899 //! Draw a filled rectangle on the specified image
901 gerbv_image_create_rectangle_object (gerbv_image_t
*image
, /*!< the image to draw to */
902 gdouble coordinateX
, /*!< the X coordinate of the lower left corner */
903 gdouble coordinateY
, /*!< the Y coordinate of the lower left corner */
904 gdouble width
, /*!< the width of the drawn rectangle */
905 gdouble height
/*!< the height of the drawn rectangle */
908 //! Create any missing apertures in the specified image
910 gerbv_image_create_dummy_apertures (gerbv_image_t
*parsed_image
/*!< the image to repair */
913 /*! Create new struct for holding drill stats */
914 gerbv_drill_stats_t
*
915 gerbv_drill_stats_new(void);
917 /*! Free the memory for a drill stats struct */
919 gerbv_drill_stats_destroy(gerbv_drill_stats_t
*);
921 /*! Add stats gathered from specified layer to accumulatedd drill stats
922 * compiled from all layers */
924 gerbv_drill_stats_add_layer(gerbv_drill_stats_t
*accum_stats
,
925 gerbv_drill_stats_t
*input_stats
,
929 /*! Create new struct for holding Gerber stats */
931 gerbv_stats_new(void);
933 /*! Free the memory for a stats struct */
935 gerbv_stats_destroy(gerbv_stats_t
*);
937 /*! Add stats gathered from specified layer to accumulated Gerber stats
938 * compiled from all layers */
940 gerbv_stats_add_layer(gerbv_stats_t
*accum_stats
,
941 gerbv_stats_t
*input_stats
,
946 gerbv_attribute_destroy_HID_attribute (gerbv_HID_Attribute
*attributeList
, int n_attr
);
948 gerbv_HID_Attribute
*
949 gerbv_attribute_dup (gerbv_HID_Attribute
*, int);
951 #if defined(__cplusplus)
955 #endif /* __GERBV_H__ */