【NX二次开发源码分享】Specify Circle 指定一个圆选择屏幕点
【NX二次开发源码分享】Specify Circle 指定一个圆选择屏幕点
static void map_arc_center_from_abs(UF_CURVE_arc_t *adata)
{
int
irc;
double
abs_mx = { 0,0,0, 1,0,0, 0,1,0 },
csys = { 0,0,0,0,0,0,0,0,0,0,0,0},
mx;
UF_CALL(UF_CSYS_ask_matrix_values(adata->matrix_tag, &csys));
FTN(uf5940)(abs_mx, csys, mx, &irc);
FTN(uf5941)(adata->arc_center, mx);
}
static void map_point_to_matrix(tag_t matrix, double *pos)
{
int
irc;
double
abs_mx = { 0,0,0, 1,0,0, 0,1,0 },
csys = { 0,0,0,0,0,0,0,0,0,0,0,0},
mx;
UF_CALL(UF_CSYS_ask_matrix_values(matrix, &csys));
FTN(uf5940)(abs_mx, csys, mx, &irc);
FTN(uf5941)(pos, mx);
}
/*This motion callback emulates the rubberbanding circle seen when
using the interactive option Insert->Curve->Basic Curves...->Circle*/
static void rubberband_circle_cb(double *screen_pos,
UF_UI_motion_cb_data_p_t motion_cb_data, void *client_data)
{
double
axes;
UF_CURVE_arc_p_t
my_data = (UF_CURVE_arc_p_t) client_data;
map_point_to_matrix(my_data->matrix_tag, screen_pos);
UF_VEC3_distance(my_data->arc_center, screen_pos, &my_data->radius);
if (my_data->radius > 0)
{
UF_CALL(UF_CSYS_ask_matrix_values(my_data->matrix_tag, axes));
UF_CALL(UF_DISP_display_ogp_circle(motion_cb_data->view_tag,
axes, my_data->arc_center, my_data->radius));
}
}
static logical specify_circle(char *prompt, UF_CURVE_arc_p_t the_data)
{
int
resp;
tag_t
view;
char
msg;
double
on_arc;
sprintf(msg, "%s center", prompt);
UF_CALL(UF_UI_specify_screen_position(msg, NULL, NULL,
the_data->arc_center, &view, &resp));
if (resp != UF_UI_PICK_RESPONSE) return FALSE;
the_data->matrix_tag = ask_wcs_matrix_tag();
map_arc_center_from_abs(the_data);
sprintf(msg, "%s point on arc", prompt);
UF_CALL(UF_UI_specify_screen_position(msg, rubberband_circle_cb,
(void *)the_data, on_arc, &view, &resp));
if (resp != UF_UI_PICK_RESPONSE) return FALSE;
map_point_to_matrix(the_data->matrix_tag, on_arc);
UF_VEC3_distance(the_data->arc_center, on_arc, &the_data->radius);
return TRUE;
}
页:
[1]