NX二次开发UF_UI_set_sel_procs 函数介绍

173 阅读4分钟

UF_UI_set_sel_procs

Defined in: uf_ui.h 
int UF_UI_set_sel_procs(UF_UI_selection_p_t select_, UF_UI_sel_filter_fn_t filter_proc, UF_UI_sel_cb_fn_t sel_cb, void * user_data )

overview 概述

Specify selection filter procedure for additional filtering based on application specific criteria, and/or selection callback to perform application specific processing for each selection gesture processed, and user specific data to be passed to these routines.

This function can be used with UIStyler dialogs and with UF_UI_select_with_single_dialog and UF_UI_select_with_class_dialog. The typedef of the filter procedure and selection callback are defined in this header file as follows:

typedef int (UF_UI_sel_filter_fn_t) ( tag_t object, int type[3], void user_data, UF_UI_selection_p_t select_)

typedef int (UF_UI_sel_cb_fn_t) ( int num_selected, tag_p_t selected_objects, int num_deselected, tag_p_t deselected_objects, void user_data, UF_UI_selection_p_t select_)

The filter procedure is passed the tag of the candidate object, the types of the candidate object (object type, object subtype, solid subtype - see UF_UI_set_sel_mask) , a pointer to the user's data, and a pointer to selection. The return responses are defined in uf_ui.h. The filter procedure should return UF_UI_SEL_REJECT if the object is to be discarded and UF_UI_SEL_ACCEPT if the object is a valid candidate.

The candidate object passed to the filter procedure is not adjusted for scope. Therefore, with an assembly part, the object is the occurrence and not the prototype.

You can get the prototype of the object by calling UF_ASSEM_ask_prototype_of_occ. However, if the object is to be a promotion, for example, then the user has to do some inquiries as in the example below:

if (UF_ASSEM_is_occurrence(object)) { proto = UF_ASSEM_ask_prototype_of_occ(object); UF_MODL_ask_prom_feat_of_solid(proto, &feat)); UF_MODL_prom_map_object_up(proto, feat, &prom)); status = check_promotion(prom); }

The selection callback is different. The objects passed to it are already adjusted for scope.

The selection callback is passed an allocated array of the objects selected or deselected with the previous selection. The allocated array of tags will be freed for the user. The user can force dialog termination by returning UF_UI_CB_EXIT_DIALOG. To continue the dialog, the user should return UF_UI_CB_CONTINUE_DIALOG.

When a selection callback is used with UF_UI_select_with_single_dialog, the return is ignored and the dialog is always terminated.

Both the filter procedure and the selection callback are passed a pointer to selection which can be used as input to other UF_UI selection functions to inquire other selection data or modify selection. This selection pointer is no longer valid after the filter procedure or selection callback is exited.


根据应用程序特定条件指定选择筛选过程以进行附加筛选,和/或选择回调以对处理的每个选择姿态执行应用程序特定处理,以及将传递给这些例程的用户特定数据。这个函数可以与 UIStyler 对话框、 UF _ UI _ select _ with _ single _ Dialogue 和 UF _ UI _ select _ with _ class _ Dialogue 一起使用。过滤器过程和选择回调的 typedef 在这个头文件中定义如下: typedef int (UF _ UI _ sel _ filter _ fn _ t)(tag _ t 对象,int type [3] ,void user _ data,UF _ UI _ select _ p _ t select _) typedef int (UF _ UI _ sel _ cb _ fn _ t)(int num _ select,tag _ p _ t select _ Objects,int num _ deselected,tag _ p _ t deselected _ Objects,void user _ data,UF _ UI _ select _ p _ t select )过滤器过程传递候选对象的标签、候选对象的类型(对象类型、对象子类型、实体子类型——参见 UF _ UI _ set _ sel _ block)、指向用户数据的指针和指向选择的指针。返回响应在 uf _ ui.h 中定义。如果要丢弃对象,筛选过程应返回 UF _ UI _ SEL _ REJECT; 如果对象是有效候选对象,则返回 UF _ UI _ SEL _ ACCEPT。传递给筛选器过程的候选对象没有针对范围进行调整。因此,对于装配部件,对象是出现的对象,而不是原型。您可以通过调用 UF _ ASSEM _ ask _ model _ of _ occ 来获得对象的原型。然而,如果对象是一个促销,例如,那么用户必须做一些查询,如下例所示: 如果(UF _ ASSEM _ is _ publications (object)){ proto = UF _ ASSEM _ ask _ Proto of _ occ (object) ; UF _ MODL _ ask _ prom _ fit _ of _ Solid (proto,& fit)) ; UF _ MODL _ prom _ map _ object _ up (proto,fit,& prom) ; status = check _  促销(prom) ; }选择回叫是不同的。传递给它的对象已经根据范围进行了调整。选择回调将传递与上一个选择一起选中或取消选中的对象的分配数组。分配给用户的标记数组将被释放。用户可以通过返回 UF _ UI _ CB _ EXIT _ DIALOG 强制终止对话框。要继续对话框,用户应该返回 UF _ UI _ CB _ CONTINUE _ DIALOG。当选择回调与 UF _ UI _ select _ with _ single _ Dialogue 一起使用时,将忽略返回值并始终终终止该对话框。过滤过程和选择回调都被传递一个指向选择的指针,该指针可用作其他 UF _ UI 选择函数的输入,以查询其他选择数据或修改选择。退出筛选过程或选择回调后,此选择指针不再有效。

UFUN例子

获取源码例子请搜索 里海NX二次开发3000例专栏

parameters 参数

UF_UI_selection_p_tselect_Inputselection pointer
选择指针
UF_UI_sel_filter_fn_tfilter_procInputfilter procedure for additional user specific filtering or NULL
用于其他用户特定筛选或 NULL 的筛选过程
UF_UI_sel_cb_fn_tsel_cbInputselection callback for application specific processing or NULL
应用程序特定处理的选择回调或 NULL
void *user_dataInputUser data or NULL
用户数据或 NULL