/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ /* This example shows class selection with a selection callback. In the callback, if a face is deselected, all adjacent faces are also deselected. In addition, the selection callback terminates the dialog when a certain number of objects have been selected. */ #include #include #include #include #include #include typedef struct user_data_s{ int max_count; } user_data_t, *user_data_p_t; static int init_proc( UF_UI_selection_p_t select, void *user_data); static int sel_cb( int num_selected, tag_p_t objects, int num_deselected, tag_p_t deselected_objects, void *user_data, UF_UI_selection_p_t select); #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X))) static int report( char *file, int line, char *call, int irc) { if (irc) { char messg[133]; printf("%s, line %d: %s\n", file, line, call); (UF_get_fail_message(irc, messg)) ? printf(" returned a %d\n", irc) : printf(" returned error %d: %s\n", irc, messg); } return(irc); } static void do_ugopen_api(void) { char cue[] = "Select Objects"; char title[] = "User Title"; int response, count, i; tag_p_t objects; user_data_t data; /* initialize maximum number of entities to be selected */ data.max_count = 25; /* call class selection dialog */ if((UF_CALL(UF_UI_select_with_class_dialog(cue, title, UF_UI_SEL_SCOPE_WORK_PART, init_proc, &data, &response, &count, &objects))) == 0) { printf("object count = %d\n", count); if (response == UF_UI_OK && count > 0) { for (i=0; i 0) { /* loop over deselected objects */ for (i=0; i 0) { /* ask the number of objects currently selected */ if((UF_CALL(UF_UI_ask_sel_list_count(select, &count))) == 0) { /*exit dialog if maximum number of objects have been selected */ if (count > data->max_count) { return (UF_UI_CB_EXIT_DIALOG); } } } return (UF_UI_CB_CONTINUE_DIALOG); } /*ARGSUSED*/ void ufusr(char *param, int *retcode, int param_len) { if (!UF_CALL(UF_initialize())) { do_ugopen_api(); UF_CALL(UF_terminate()); } } int ufusr_ask_unload(void) { return (UF_UNLOAD_IMMEDIATELY); }