Date: 16-NOV-2005
Subject: Sample Open C API program : select faces and edges with uistyler
Note: GTAC provides programming examples for illustration only, and
assumes that you are familiar with the programming language being
demonstrated and the tools used to create and debug procedures. GTAC
support professionals can help explain the functionality of a particular
procedure, but we will not modify these examples to provide added
functionality or construct procedures to meet your specific needs.
/*HEAD SELECT_FACES_AND_EDGES_WITH_UISTYLER CCC UFUN */
/* For use with this code you need to create an UI/Styler dialog
- change prefix name to GTAC
- turn on selection with type 'Robust'
- you may change the scope to 'Any in Assembly'
- no additional callbacks needed
*/
#include <uf.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <uf_ui.h>
#include <uf_obj.h>
#include <uf_styler.h>
#include <uf_mb.h>
#include <uf_exit.h>
#include <uf_modl.h>
#include <uf_object_types.h>
#define GTAC_CB_COUNT ( 1 + 1 ) /* Add 1 for the terminator */
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
irc, line, file);
UF_get_fail_message(irc, err);
/* NOTE: UF_print_syslog is new in V18 */
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}
return(irc);
}
static int report_object(int num_sel, tag_t *sel_objects, int num_deselected,
tag_t *deselected_objs, void *user_data, UF_UI_selection_p_t select)
{
int
ii,
type,
subtype;
char
messg[100];
for(ii=0; ii< num_sel; ii++)
{
UF_CALL(UF_OBJ_ask_type_and_subtype(sel_objects[ii], &type, &subtype));
sprintf(messg, "Object Tag %d, Type %d, Subtype %d\n", sel_objects[ii], type, subtype);
if (!UF_UI_open_listing_window())
UF_UI_write_listing_window(messg);
}
return (UF_UI_CB_CONTINUE_DIALOG);
}
int GTAC_sel_cb ( int dialog_id, void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
UF_STYLER_item_value_type_t
sel_data;
UF_UI_mask_t
mask[2] = { { UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_EDGE },
{ UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_FACE } };
sel_data.item_id = UF_STYLER_DIALOG_INDEX;
sel_data.item_attr = UF_STYLER_SELECTION;
UF_STYLER_ask_value(dialog_id, &sel_data);
UF_CALL(UF_UI_set_sel_mask(sel_data.value.selection,
UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, 2, mask));
UF_CALL(UF_UI_set_sel_procs(sel_data.value.selection, NULL,
report_object, NULL));
return (UF_UI_CB_CONTINUE_DIALOG);
}
static void do_it(void)
{
int
response = 0;
UF_STYLER_item_value_type_t
selection;
UF_STYLER_callback_info_t GTAC_cbs[GTAC_CB_COUNT] =
{
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB , 0, GTAC_sel_cb},
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
};
UF_CALL( UF_STYLER_create_dialog ( "selection.dlg",
GTAC_cbs, GTAC_CB_COUNT, &selection, &response ) );
}
/*ARGSUSED*/
extern void ufusr(char *param, int *retcode, int paramLen)
{
if (UF_CALL(UF_initialize())) return;
do_it();
UF_terminate();
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}