76 #include <gdk/gdkkeysyms.h>
78 #ifndef RENDER_USING_GDK
82 #if defined(__cplusplus)
86 #define APERTURE_MIN 10
87 #define APERTURE_MAX 9999
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)
108 #define GERBV_PRECISION_ANGLE_RAD 1e-6
109 #define GERBV_PRECISION_LINEAR_INCH 1e-6
114 #define COORD2INS(c) (c)
115 #define COORD2MILS(c) ((c)*1000.0)
116 #define COORD2MMS(c) ((c)*25.4)
118 #define DEG2RAD(d) ((d)*M_PI / 180.0)
119 #define RAD2DEG(r) ((r)*180.0 * M_1_PI)
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__)
186 OUTLINE_NUMBER_OF_POINTS,
192 } gerbv_aptype_macro_outline_index_t;
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)
201 POLYGON_NUMBER_OF_POINTS,
206 } gerbv_aptype_macro_polygon_index_t;
211 MOIRE_OUTSIDE_DIAMETER,
212 MOIRE_CIRCLE_THICKNESS,
214 MOIRE_NUMBER_OF_CIRCLES,
215 MOIRE_CROSSHAIR_THICKNESS,
216 MOIRE_CROSSHAIR_LENGTH,
218 } gerbv_aptype_macro_moire_index_t;
223 THERMAL_OUTSIDE_DIAMETER,
224 THERMAL_INSIDE_DIAMETER,
225 THERMAL_CROSSHAIR_THICKNESS,
227 } gerbv_aptype_macro_thermal_index_t;
233 LINE20_WIDTH = LINE20_LINE_WIDTH,
314 GERBV_ENCODING_ASCII,
315 GERBV_ENCODING_EBCDIC,
317 GERBV_ENCODING_ISO_ASCII,
330 GERBV_KNOCKOUT_TYPE_NOKNOCKOUT,
331 GERBV_KNOCKOUT_TYPE_FIXEDKNOCK,
332 GERBV_KNOCKOUT_TYPE_BORDER
333 } gerbv_knockout_type_t;
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;
343 GERBV_AXIS_SELECT_NOSELECT,
344 GERBV_AXIS_SELECT_SWAPAB
345 } gerbv_axis_select_t;
348 GERBV_JUSTIFY_NOJUSTIFY,
349 GERBV_JUSTIFY_LOWERLEFT,
350 GERBV_JUSTIFY_CENTERJUSTIFY
351 } gerbv_image_justify_type_t;
363 FIND_SELECTIONS_TOGGLE,
391 } gerbv_HID_Attr_Val;
395 const char* help_text;
408 int min_val, max_val;
409 gerbv_HID_Attr_Val default_val;
410 const char** enumerations;
419 } gerbv_HID_Attribute;
431 typedef struct instruction {
438 struct instruction* next;
439 } gerbv_instruction_t;
441 typedef struct amacro {
443 gerbv_instruction_t* program;
444 unsigned int nuf_push;
448 typedef struct gerbv_simplified_amacro {
450 double parameter[APERTURE_PARAMETERS_MAX];
451 struct gerbv_simplified_amacro* next;
452 } gerbv_simplified_amacro_t;
454 typedef struct gerbv_aperture {
456 gerbv_amacro_t* amacro;
457 gerbv_simplified_amacro_t* simplified;
458 double parameter[APERTURE_PARAMETERS_MAX];
465 typedef struct gerbv_aperture_list {
471 struct gerbv_aperture_list* next;
472 } gerbv_aperture_list_t;
477 gerbv_aperture_list_t* aperture_list;
478 gerbv_aperture_list_t* D_code_list;
584 } gerbv_selection_item_t;
593 GArray* selectedNodeArray;
617 typedef struct gerbv_cirseg {
626 typedef struct gerbv_step_and_repeat {
631 } gerbv_step_and_repeat_t;
634 gboolean firstInstance;
635 gerbv_knockout_type_t type;
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;
726 gerbv_HID_Attribute* attr_list;
733 gerbv_aperture_t* aperture[APERTURE_MAX];
824 gboolean gerbv_image_reduce_area_of_selected_objects(
825 GArray* selectionArray, gdouble areaReduction, gint paneRows, gint paneColumns, gdouble paneSeparation
828 gboolean gerbv_image_move_selected_objects(GArray* selectionArray, gdouble translationX, gdouble translationY);
843 const gchar* filename
849 const gchar* filename,
860 gboolean gerbv_save_layer_from_index(
gerbv_project_t* gerbvProject, gint index, gchar* filename);
870 void gerbv_change_layer_order(
gerbv_project_t* gerbvProject, gint oldPosition, gint newPosition);
872 gint gerbv_add_parsed_image_to_project(
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
891 void gerbv_render_to_pixmap_using_gdk(
896 #ifndef RENDER_USING_GDK
897 void gerbv_render_all_layers_to_cairo_target_for_vector_output(
911 void gerbv_render_cairo_set_scale_and_translation(cairo_t* cr,
gerbv_render_info_t* renderInfo);
913 void gerbv_render_layer_to_cairo_target_without_transforming(
918 double gerbv_get_tool_diameter(
int toolNumber);
920 int gerbv_process_tools_file(
const char* toolFileName);
927 const gchar* filename
934 const gchar* filename
940 const gchar* filename
947 const gchar* filename
953 const gchar* filename
960 const gchar* filename
966 const gchar* filename
973 const gchar* filename
979 const gchar* filename,
993 const gchar* filename,
1001 const gchar* filename,
1009 const gchar* filename,
1017 const gchar* filename,
1048 gdouble coordinateX,
1049 gdouble coordinateY,
1078 void gerbv_attribute_destroy_HID_attribute(gerbv_HID_Attribute* attributeList,
int n_attr);
1080 gerbv_HID_Attribute* gerbv_attribute_dup(gerbv_HID_Attribute*,
int);
1097 #if defined(__cplusplus)
1103 typeof(x) _x = (x); \
1104 typeof(y) _y = (y); \
1105 (void)(&_x == &_y); \
1106 _x < _y ? _x : _y; \
1110 typeof(x) _x = (x); \
1111 typeof(y) _y = (y); \
1112 (void)(&_x == &_y); \
1113 _x > _y ? _x : _y; \
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.
void gerbv_stats_destroy(gerbv_stats_t *)
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.
gerbv_aptype_macro_line22_index_t
struct drill_list gerbv_drill_list_t
@ GERBV_APERTURE_STATE_OFF
@ GERBV_APERTURE_STATE_ON
@ GERBV_APERTURE_STATE_FLASH
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.
struct error_list gerbv_error_list_t
void gerbv_drill_stats_destroy(gerbv_drill_stats_t *)
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.
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
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.
void gerbv_destroy_project(gerbv_project_t *gerbvProject)
Free a project and all related variables.
const char * gerbv_interpolation_name(gerbv_interpolation_t interp)
Return string name of gerbv_interpolation_t interpolation.
struct gerbv_net gerbv_net_t
@ GERBV_OMIT_ZEROS_TRAILING
@ GERBV_OMIT_ZEROS_EXPLICIT
@ GERBV_OMIT_ZEROS_LEADING
@ GERBV_OMIT_ZEROS_UNSPECIFIED
void gerbv_rotate_coord(double *x, double *y, double rad)
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.
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.
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...
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.
@ GERBV_POLARITY_NEGATIVE
@ GERBV_POLARITY_POSITIVE
gerbv_image_t * gerbv_create_rs274x_image_from_filename(const gchar *filename)
Parse a RS274X file and return the parsed image.
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.
gerbv_aptype_macro_circle_index_t
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.
gerbv_stats_t * gerbv_stats_new(void)
Allocates a new gerbv_stats structure.
@ GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY
@ GERBV_RENDER_TYPE_GDK_XOR
@ GERBV_RENDER_TYPE_CAIRO_NORMAL
void gerbv_stats_add_layer(gerbv_stats_t *accum_stats, gerbv_stats_t *input_stats, int this_layer)
gerbv_aptype_macro_line21_index_t
@ GERBV_COORDINATE_INCREMENTAL
@ GERBV_COORDINATE_ABSOLUTE
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.
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...
gerbv_fileinfo_t * gerbv_get_fileinfo_for_image(const gerbv_image_t *image, const gerbv_project_t *project)
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.
@ GERBV_SELECTION_POINT_CLICK
@ GERBV_SELECTION_DRAG_BOX
struct gerbv_format gerbv_format_t
gerbv_aptype_macro_line20_index_t
gerbv_image_t * gerbv_create_image(gerbv_image_t *image, const gchar *type)
Allocate a new gerbv_image structure.
void gerbv_transform_coord(double *x, double *y, const gerbv_user_transformation_t *trans)
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.
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.
gboolean gerbv_endswith(const char *path, const char *ext)
void gerbv_destroy_fileinfo(gerbv_fileinfo_t *fileInfo)
Free a fileinfo structure.
void gerbv_image_delete_net(gerbv_net_t *currentNet)
Delete a net in an existing image.
const char * gerbv_aperture_type_name(gerbv_aperture_type_t type)
Return string name of gerbv_aperture_type_t aperture type.
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.
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.
struct gerbv_image_info gerbv_image_info_t
@ GERBV_APTYPE_MACRO_LINE20
@ GERBV_APTYPE_MACRO_LINE21
@ GERBV_APTYPE_MACRO_OUTLINE
@ GERBV_APTYPE_MACRO_CIRCLE
@ GERBV_APTYPE_MACRO_POLYGON
@ GERBV_APTYPE_MACRO_THERMAL
@ GERBV_APTYPE_MACRO_LINE22
@ GERBV_APTYPE_MACRO_MOIRE
void gerbv_drill_stats_add_layer(gerbv_drill_stats_t *accum_stats, gerbv_drill_stats_t *input_stats, int this_layer)
int gerbv_transform_coord_for_image(double *x, double *y, const gerbv_image_t *image, const gerbv_project_t *project)
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.
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.
gerbv_drill_stats_t * gerbv_drill_stats_new(void)
Allocates a new drill_stats structure.
@ GERBV_INTERPOLATION_LINEARx01
@ GERBV_INTERPOLATION_PAREA_START
@ GERBV_INTERPOLATION_LINEARx001
@ GERBV_INTERPOLATION_DELETED
@ GERBV_INTERPOLATION_CW_CIRCULAR
@ GERBV_INTERPOLATION_PAREA_END
@ GERBV_INTERPOLATION_LINEARx10
@ GERBV_INTERPOLATION_CCW_CIRCULAR
@ GERBV_INTERPOLATION_LINEARx1
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.
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.
@ GERBV_LAYERTYPE_PICKANDPLACE_BOT
@ GERBV_LAYERTYPE_PICKANDPLACE_TOP
gerbv_user_transformation_t transform
gpointer privateRenderData
gerbv_stats_t * gerbv_stats
gerbv_layertype_t layertype
gerbv_drill_stats_t * drill_stats
gerbv_netstate_t * states
gerbv_image_info_t * info
gerbv_step_and_repeat_t stepAndRepeat
gerbv_polarity_t polarity
gerbv_knockout_t knockout
gerbv_render_size_t boundingBox
gerbv_aperture_state_t aperture_state
gerbv_interpolation_t interpolation
gerbv_axis_select_t axisSelect
gerbv_mirror_state_t mirrorState
gboolean show_invisible_selection
gboolean check_before_delete
gboolean show_cross_on_drill_holes
gerbv_render_types_t renderType