75 #include <gdk/gdkkeysyms.h>
77 #ifndef RENDER_USING_GDK
82 # define M_PI 3.14159265358979323846
85 # define M_PI_2 1.57079632679489661923
88 # define M_1_PI 0.31830988618379067154
91 #if defined(__cplusplus)
95 #define APERTURE_MIN 10
96 #define APERTURE_MAX 9999
104 #define APERTURE_PARAMETERS_MAX 10006
105 #define GERBV_SCALE_MIN 10
106 #define GERBV_SCALE_MAX 40000
107 #define MAX_ERRMSGLEN 25
108 #define MAX_COORDLEN 28
109 #define MAX_DISTLEN 180
110 #define MAX_STATUSMSGLEN (MAX_ERRMSGLEN+MAX_COORDLEN+MAX_DISTLEN)
117 #define GERBV_PRECISION_ANGLE_RAD 1e-6
118 #define GERBV_PRECISION_LINEAR_INCH 1e-6
123 #define COORD2INS(c) (c)
124 #define COORD2MILS(c) ((c)*1000.0)
125 #define COORD2MMS(c) ((c)*25.4)
127 #define DEG2RAD(d) ((d)*M_PI/180.0)
128 #define RAD2DEG(r) ((r)*180.0*M_1_PI)
130 #define GERB_FATAL_ERROR(...) g_log(NULL, G_LOG_LEVEL_ERROR, __VA_ARGS__)
131 #define GERB_COMPILE_ERROR(...) g_log(NULL, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
132 #define GERB_COMPILE_WARNING(...) g_log(NULL, G_LOG_LEVEL_WARNING, __VA_ARGS__)
133 #define GERB_MESSAGE(...) g_log(NULL, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
134 #define GERB_NOTE(...) g_log(NULL, G_LOG_LEVEL_INFO, __VA_ARGS__)
196 OUTLINE_NUMBER_OF_POINTS,
202 } gerbv_aptype_macro_outline_index_t;
205 #define OUTLINE_X_IDX_OF_POINT(number) (2*(number) + OUTLINE_FIRST_X)
206 #define OUTLINE_Y_IDX_OF_POINT(number) (2*(number) + OUTLINE_FIRST_Y)
207 #define OUTLINE_ROTATION_IDX(param_array) \
208 ((int)param_array[OUTLINE_NUMBER_OF_POINTS]*2 + \
213 POLYGON_NUMBER_OF_POINTS,
218 } gerbv_aptype_macro_polygon_index_t;
223 MOIRE_OUTSIDE_DIAMETER,
224 MOIRE_CIRCLE_THICKNESS,
226 MOIRE_NUMBER_OF_CIRCLES,
227 MOIRE_CROSSHAIR_THICKNESS,
228 MOIRE_CROSSHAIR_LENGTH,
230 } gerbv_aptype_macro_moire_index_t;
235 THERMAL_OUTSIDE_DIAMETER,
236 THERMAL_INSIDE_DIAMETER,
237 THERMAL_CROSSHAIR_THICKNESS,
239 } gerbv_aptype_macro_thermal_index_t;
245 LINE20_WIDTH = LINE20_LINE_WIDTH,
318 typedef enum {GERBV_ENCODING_NONE,
319 GERBV_ENCODING_ASCII,
320 GERBV_ENCODING_EBCDIC,
322 GERBV_ENCODING_ISO_ASCII,
334 typedef enum {GERBV_KNOCKOUT_TYPE_NOKNOCKOUT,
335 GERBV_KNOCKOUT_TYPE_FIXEDKNOCK,
336 GERBV_KNOCKOUT_TYPE_BORDER
337 } gerbv_knockout_type_t;
339 typedef enum {GERBV_MIRROR_STATE_NOMIRROR,
340 GERBV_MIRROR_STATE_FLIPA,
341 GERBV_MIRROR_STATE_FLIPB,
342 GERBV_MIRROR_STATE_FLIPAB
343 } gerbv_mirror_state_t;
345 typedef enum {GERBV_AXIS_SELECT_NOSELECT,
346 GERBV_AXIS_SELECT_SWAPAB
347 } gerbv_axis_select_t;
349 typedef enum {GERBV_JUSTIFY_NOJUSTIFY,
350 GERBV_JUSTIFY_LOWERLEFT,
351 GERBV_JUSTIFY_CENTERJUSTIFY
352 } gerbv_image_justify_type_t;
363 FIND_SELECTIONS_TOGGLE,
390 } gerbv_HID_Attr_Val;
396 { HID_Label, HID_Integer, HID_Real, HID_String,
397 HID_Boolean, HID_Enum, HID_Mixed, HID_Path
399 int min_val, max_val;
400 gerbv_HID_Attr_Val default_val;
401 const char **enumerations;
410 } gerbv_HID_Attribute;
421 typedef struct instruction {
427 struct instruction *next;
428 } gerbv_instruction_t;
430 typedef struct amacro {
432 gerbv_instruction_t *program;
433 unsigned int nuf_push;
437 typedef struct gerbv_simplified_amacro {
439 double parameter[APERTURE_PARAMETERS_MAX];
440 struct gerbv_simplified_amacro *next;
441 } gerbv_simplified_amacro_t;
443 typedef struct gerbv_aperture {
445 gerbv_amacro_t *amacro;
446 gerbv_simplified_amacro_t *simplified;
447 double parameter[APERTURE_PARAMETERS_MAX];
454 typedef struct gerbv_aperture_list {
460 struct gerbv_aperture_list *next;
461 } gerbv_aperture_list_t;
466 gerbv_aperture_list_t *aperture_list;
467 gerbv_aperture_list_t *D_code_list;
573 } gerbv_selection_item_t;
582 GArray *selectedNodeArray;
606 typedef struct gerbv_cirseg {
615 typedef struct gerbv_step_and_repeat {
620 } gerbv_step_and_repeat_t;
623 gboolean firstInstance;
624 gerbv_knockout_type_t type;
698 gerbv_encoding_t encoding;
699 double imageRotation;
700 gerbv_image_justify_type_t imageJustifyTypeA;
701 gerbv_image_justify_type_t imageJustifyTypeB;
702 gdouble imageJustifyOffsetA;
703 gdouble imageJustifyOffsetB;
704 gdouble imageJustifyOffsetActualA;
705 gdouble imageJustifyOffsetActualB;
716 gerbv_HID_Attribute *attr_list;
723 gerbv_aperture_t *aperture[APERTURE_MAX];
815 gerbv_image_reduce_area_of_selected_objects (GArray *selectionArray, gdouble areaReduction, gint paneRows,
816 gint paneColumns, gdouble paneSeparation);
819 gerbv_image_move_selected_objects (GArray *selectionArray, gdouble translationX,
820 gdouble translationY);
839 gchar
const* filename
845 gchar
const* filename,
858 gerbv_save_layer_from_index(
gerbv_project_t *gerbvProject, gint index, gchar *filename);
873 gerbv_change_layer_order(
gerbv_project_t *gerbvProject, gint oldPosition, gint newPosition);
877 gchar
const* filename, gchar
const* baseName,
int idx,
int reload);
880 gerbv_HID_Attribute *fattr,
int n_fattr, gboolean forceLoadFile);
895 gerbv_render_to_pixmap_using_gdk (
gerbv_project_t *gerbvProject, GdkPixmap *pixmap,
897 GdkColor *selectionColor);
899 #ifndef RENDER_USING_GDK
901 gerbv_render_all_layers_to_cairo_target_for_vector_output (
gerbv_project_t *gerbvProject,
905 gerbv_render_all_layers_to_cairo_target (
gerbv_project_t *gerbvProject, cairo_t *cr,
916 gerbv_render_cairo_set_scale_and_translation(cairo_t *cr,
gerbv_render_info_t *renderInfo);
923 gerbv_get_tool_diameter(
int toolNumber
927 gerbv_process_tools_file(
const char *toolFileName
936 gchar
const* filename
944 gchar
const* filename
951 gchar
const* filename
959 gchar
const* filename
966 gchar
const* filename
974 gchar
const* filename
981 gchar
const* filename
988 gchar
const* filename,
989 gboolean exportLayersAsSvgLayers
997 gchar
const* filename
1005 gchar
const* filename,
1006 gboolean exportLayersAsSvgLayers
1087 gdouble coordinateX,
1088 gdouble coordinateY,
1131 gerbv_attribute_destroy_HID_attribute (gerbv_HID_Attribute *attributeList,
int n_attr);
1133 gerbv_HID_Attribute *
1134 gerbv_attribute_dup (gerbv_HID_Attribute *,
int);
1167 static inline int min_int(
int x,
int y) {
return x < y ? x : y; }
1168 static inline int max_int(
int x,
int y) {
return x > y ? x : y; }
1169 static inline double min_double(
double x,
double y) {
return x < y ? x : y; }
1170 static inline double max_double(
double x,
double y) {
return x > y ? x : y; }
1173 #define MIN(x, y) _Generic((x), \
1175 double: min_double, \
1176 default: min_double \
1179 #define MAX(x, y) _Generic((x), \
1181 double: max_double, \
1182 default: max_double \
1185 #if defined(__cplusplus)
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 *)
int gerbv_open_image(gerbv_project_t *gerbvProject, gchar const *filename, int idx, int reload, gerbv_HID_Attribute *fattr, int n_fattr, gboolean forceLoadFile)
void gerbv_export_png_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a PNG file using user-specified render info.
gerbv_aptype_macro_line22_index_t
void gerbv_export_postscript_file_from_project_autoscaled(gerbv_project_t *gerbvProject, gchar const *filename)
Render a project to a Postscript file, autoscaling the layers to fit inside the specified image dimen...
struct drill_list gerbv_drill_list_t
@ GERBV_APERTURE_STATE_OFF
@ GERBV_APERTURE_STATE_ON
@ GERBV_APERTURE_STATE_FLASH
struct error_list gerbv_error_list_t
void gerbv_drill_stats_destroy(gerbv_drill_stats_t *)
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.
void gerbv_export_svg_file_from_project_autoscaled_with_options(gerbv_project_t *gerbvProject, gchar const *filename, gboolean exportLayersAsSvgLayers)
Render a project to a SVG file, optionally exporting visible layers as Inkscape layers.
void gerbv_export_svg_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a file using user-specified render info.
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
@ 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_open_layer_from_filename_with_color(gerbv_project_t *gerbvProject, gchar const *filename, guint16 red, guint16 green, guint16 blue, guint16 alpha)
Open a file, parse the contents, and add a new layer to an existing project while setting the color o...
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.
const char * gerbv_aperture_state_name(gerbv_aperture_state_t state)
gboolean gerbv_is_loadable_file(const char *filename)
@ 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, gchar const *filename)
Render a project to a Postscript file using user-specified render info.
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
void gerbv_export_svg_file_from_project_with_options(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename, gboolean exportLayersAsSvgLayers)
Render a project to a SVG file using user-specified render info and export options.
void gerbv_export_png_file_from_project_autoscaled(gerbv_project_t *gerbvProject, int widthInPixels, int heightInPixels, gchar const *filename)
Render a project to a PNG file, autoscaling the layers to fit inside the specified image dimensions.
gerbv_aptype_macro_line20_index_t
void gerbv_open_layer_from_filename(gerbv_project_t *gerbvProject, gchar const *filename)
Open a file, parse the contents, and add a new layer to an existing project.
gerbv_image_t * gerbv_create_image(gerbv_image_t *image, const gchar *type)
Allocate a new gerbv_image structure.
void gerbv_export_pdf_file_from_project_autoscaled(gerbv_project_t *gerbvProject, gchar const *filename)
Render a project to a PDF file, autoscaling the layers to fit inside the specified image dimensions.
void gerbv_transform_coord(double *x, double *y, const gerbv_user_transformation_t *trans)
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.
void gerbv_export_pdf_file_from_project(gerbv_project_t *gerbvProject, gerbv_render_info_t *renderInfo, gchar const *filename)
Render a project to a PDF file using user-specified render info.
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)
void gerbv_export_svg_file_from_project_autoscaled(gerbv_project_t *gerbvProject, gchar const *filename)
Render a project to a SVG file, autoscaling the layers to fit inside the specified image dimensions.
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_image_t * gerbv_create_excellon_image_from_filename(const gchar *filename)
Parse an Excellon drill file and return the parsed 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