@huaqiu/js-gerbv 0.0.0-stage → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +151 -0
- package/LICENSE +674 -0
- package/README.md +105 -2
- package/include/config.h +34 -0
- package/include/gettext.h +9 -0
- package/index.js +382 -0
- package/package.json +46 -4
- package/prebuilds/darwin-arm64/gerbv_node.node +0 -0
- package/prebuilds/darwin-arm64/libglib-2.0.0.dylib +0 -0
- package/prebuilds/darwin-arm64/libintl.8.dylib +0 -0
- package/prebuilds/darwin-arm64/libpcre2-8.0.dylib +0 -0
- package/prebuilds/darwin-arm64/meta.json +9 -0
- package/prebuilds/win32-x64/gerbv_node.node +0 -0
- package/prebuilds/win32-x64/libffi-8.dll +0 -0
- package/prebuilds/win32-x64/libgcc_s_seh-1.dll +0 -0
- package/prebuilds/win32-x64/libgio-2.0-0.dll +0 -0
- package/prebuilds/win32-x64/libglib-2.0-0.dll +0 -0
- package/prebuilds/win32-x64/libgmodule-2.0-0.dll +0 -0
- package/prebuilds/win32-x64/libgobject-2.0-0.dll +0 -0
- package/prebuilds/win32-x64/libiconv-2.dll +0 -0
- package/prebuilds/win32-x64/libintl-8.dll +0 -0
- package/prebuilds/win32-x64/libpcre2-8-0.dll +0 -0
- package/prebuilds/win32-x64/libstdc++-6.dll +0 -0
- package/prebuilds/win32-x64/libwinpthread-1.dll +0 -0
- package/prebuilds/win32-x64/meta.json +9 -0
- package/prebuilds/win32-x64/zlib1.dll +0 -0
- package/scripts/cmake-build.js +231 -0
- package/scripts/ensure-gerbv.js +42 -0
- package/scripts/pack-prebuild.js +208 -0
- package/scripts/smoke.js +74 -0
- package/shim/gdk/gdk.h +15 -0
- package/shim/gdk/gdkkeysyms.h +3 -0
- package/shim/gtk/gtk.h +7 -0
- package/src/addon.cc +740 -0
- package/src/gerber_min.c +67 -0
- package/src/gerbv_stubs.c +79 -0
- package/vcpkg.json +8 -0
package/src/gerber_min.c
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从 efa/gerbv gerber.c 抽出的最小子集:创建 aperture/net + bbox 更新(单位 inch,无 cairo)。
|
|
3
|
+
*/
|
|
4
|
+
#include "gerbv.h"
|
|
5
|
+
#include "gerber.h"
|
|
6
|
+
#include <math.h>
|
|
7
|
+
#include <stdlib.h>
|
|
8
|
+
|
|
9
|
+
gerbv_net_t*
|
|
10
|
+
gerber_create_new_net(gerbv_net_t* currentNet, gerbv_layer_t* layer, gerbv_netstate_t* state) {
|
|
11
|
+
gerbv_net_t* newNet = g_new0(gerbv_net_t, 1);
|
|
12
|
+
currentNet->next = newNet;
|
|
13
|
+
if (layer)
|
|
14
|
+
newNet->layer = layer;
|
|
15
|
+
else
|
|
16
|
+
newNet->layer = currentNet->layer;
|
|
17
|
+
if (state)
|
|
18
|
+
newNet->state = state;
|
|
19
|
+
else
|
|
20
|
+
newNet->state = currentNet->state;
|
|
21
|
+
return newNet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
gboolean
|
|
25
|
+
gerber_create_new_aperture(
|
|
26
|
+
gerbv_image_t* image, int* indexNumber, gerbv_aperture_type_t apertureType, gdouble parameter1, gdouble parameter2
|
|
27
|
+
) {
|
|
28
|
+
int i;
|
|
29
|
+
for (i = APERTURE_MIN; i < APERTURE_MAX; i++) {
|
|
30
|
+
if (image->aperture[i] == NULL) {
|
|
31
|
+
image->aperture[i] = g_new0(gerbv_aperture_t, 1);
|
|
32
|
+
image->aperture[i]->type = apertureType;
|
|
33
|
+
image->aperture[i]->parameter[0] = parameter1;
|
|
34
|
+
image->aperture[i]->parameter[1] = parameter2;
|
|
35
|
+
*indexNumber = i;
|
|
36
|
+
return TRUE;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return FALSE;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void
|
|
43
|
+
gerber_update_image_min_max(
|
|
44
|
+
gerbv_render_size_t* boundingBox, double repeat_off_X, double repeat_off_Y, gerbv_image_t* image
|
|
45
|
+
) {
|
|
46
|
+
image->info->min_x = MIN(image->info->min_x, boundingBox->left);
|
|
47
|
+
image->info->min_y = MIN(image->info->min_y, boundingBox->bottom);
|
|
48
|
+
image->info->max_x = MAX(image->info->max_x, boundingBox->right + repeat_off_X);
|
|
49
|
+
image->info->max_y = MAX(image->info->max_y, boundingBox->top + repeat_off_Y);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void
|
|
53
|
+
gerber_update_min_and_max(
|
|
54
|
+
gerbv_render_size_t* boundingBox, gdouble x, gdouble y, gdouble apertureSizeX1, gdouble apertureSizeX2,
|
|
55
|
+
gdouble apertureSizeY1, gdouble apertureSizeY2
|
|
56
|
+
) {
|
|
57
|
+
gdouble ourX1 = x - apertureSizeX1, ourY1 = y - apertureSizeY1;
|
|
58
|
+
gdouble ourX2 = x + apertureSizeX2, ourY2 = y + apertureSizeY2;
|
|
59
|
+
boundingBox->left = MIN(boundingBox->left, ourX1);
|
|
60
|
+
boundingBox->left = MIN(boundingBox->left, ourX2);
|
|
61
|
+
boundingBox->right = MAX(boundingBox->right, ourX1);
|
|
62
|
+
boundingBox->right = MAX(boundingBox->right, ourX2);
|
|
63
|
+
boundingBox->bottom = MIN(boundingBox->bottom, ourY1);
|
|
64
|
+
boundingBox->bottom = MIN(boundingBox->bottom, ourY2);
|
|
65
|
+
boundingBox->top = MAX(boundingBox->top, ourY1);
|
|
66
|
+
boundingBox->top = MAX(boundingBox->top, ourY2);
|
|
67
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 无 GTK/UI 的 stub + 从 gerbv.c 抽出的坐标变换/属性复制(供 duplicate_image)。
|
|
3
|
+
*/
|
|
4
|
+
#include "gerbv.h"
|
|
5
|
+
#include <math.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
|
|
10
|
+
void free_amacro(gerbv_amacro_t* amacro) {
|
|
11
|
+
(void)amacro;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void gerbv_attribute_destroy_HID_attribute(gerbv_HID_Attribute* attributeList, int n_attr) {
|
|
15
|
+
int i;
|
|
16
|
+
for (i = 0; i < n_attr; i++) {
|
|
17
|
+
if ((attributeList[i].type == HID_String || attributeList[i].type == HID_Label)
|
|
18
|
+
&& attributeList[i].default_val.str_value != NULL) {
|
|
19
|
+
free(attributeList[i].default_val.str_value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (attributeList != NULL) free(attributeList);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
gerbv_HID_Attribute* gerbv_attribute_dup(gerbv_HID_Attribute* attributeList, int n_attr) {
|
|
26
|
+
gerbv_HID_Attribute* nl;
|
|
27
|
+
int i;
|
|
28
|
+
if (n_attr <= 0 || attributeList == NULL) return NULL;
|
|
29
|
+
nl = (gerbv_HID_Attribute*)malloc((size_t)n_attr * sizeof(gerbv_HID_Attribute));
|
|
30
|
+
if (nl == NULL) {
|
|
31
|
+
fprintf(stderr, "malloc failed in gerbv_attribute_dup\n");
|
|
32
|
+
exit(1);
|
|
33
|
+
}
|
|
34
|
+
for (i = 0; i < n_attr; i++) {
|
|
35
|
+
if (attributeList[i].type == HID_String || attributeList[i].type == HID_Label) {
|
|
36
|
+
nl[i] = attributeList[i];
|
|
37
|
+
if (attributeList[i].default_val.str_value != NULL)
|
|
38
|
+
nl[i].default_val.str_value = strdup(attributeList[i].default_val.str_value);
|
|
39
|
+
else
|
|
40
|
+
nl[i].default_val.str_value = NULL;
|
|
41
|
+
} else {
|
|
42
|
+
nl[i] = attributeList[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return nl;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const char* gerbv_interpolation_name(gerbv_interpolation_t interp) {
|
|
49
|
+
static const char* names[] = {
|
|
50
|
+
"1X linear", "10X linear", "0.1X linear", "0.01X linear", "CW circular",
|
|
51
|
+
"CCW circular", "poly area start", "poly area stop", "deleted",
|
|
52
|
+
};
|
|
53
|
+
if (interp >= 0 && (size_t)interp < sizeof(names) / sizeof(names[0])) return names[interp];
|
|
54
|
+
return "<undefined>";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void gerbv_rotate_coord(double* x, double* y, double rad) {
|
|
58
|
+
double x0 = *x;
|
|
59
|
+
*x = x0 * cos(rad) - *y * sin(rad);
|
|
60
|
+
*y = x0 * sin(rad) + *y * cos(rad);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void gerbv_transform_coord(double* x, double* y, const gerbv_user_transformation_t* trans) {
|
|
64
|
+
*x = trans->scaleX * *x;
|
|
65
|
+
*y = trans->scaleY * *y;
|
|
66
|
+
gerbv_rotate_coord(x, y, trans->rotation);
|
|
67
|
+
if (trans->mirrorAroundY) *x = -*x;
|
|
68
|
+
if (trans->mirrorAroundX) *y = -*y;
|
|
69
|
+
*x += trans->translateX;
|
|
70
|
+
*y += trans->translateY;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void gerbv_stats_destroy(gerbv_stats_t* stats) {
|
|
74
|
+
if (stats) g_free(stats);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void gerbv_drill_stats_destroy(gerbv_drill_stats_t* stats) {
|
|
78
|
+
if (stats) g_free(stats);
|
|
79
|
+
}
|