📄 block.cpp
字号:
data1.item_attr=UF_STYLER_VALUE;
data1.item_id=BLOCK_REAL_LONG;
data1.value.real=arExpValue[0];
UF_STYLER_set_value(dialog_id,&data1);
UF_STYLER_free_value(&data1);
data1.item_attr=UF_STYLER_VALUE;
data1.item_id=BLOCK_REAL_WIDTH;
data1.value.real=arExpValue[1];
UF_STYLER_set_value(dialog_id,&data1);
UF_STYLER_free_value(&data1);
data1.item_attr=UF_STYLER_VALUE;
data1.item_id=BLOCK_REAL_HEIGHT;
data1.value.real=arExpValue[2];
UF_STYLER_set_value(dialog_id,&data1);
UF_STYLER_free_value(&data1);
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
/* for this callback type. You must continue dialog construction.*/
}
/* -------------------------------------------------------------------------
* Callback Name: BLOCK_destruction
* This is a callback function associated with an action taken from a
* UIStyler object.
*
* Input: dialog_id - The dialog id indicate which dialog this callback
* is associated with. The dialog id is a dynamic,
* unique id and should not be stored. It is
* strictly for the use in the NX Open API:
* UF_STYLER_ask_value(s)
* UF_STYLER_set_value
* client_data - Client data is user defined data associated
* with your dialog. Client data may be bound
* to your dialog with UF_MB_add_styler_actions
* or UF_STYLER_create_dialog.
* callback_data - This structure pointer contains information
* specific to the UIStyler Object type that
* invoked this callback and the callback type.
* -----------------------------------------------------------------------*/
int BLOCK_destruction ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, do not terminate dialog. */
/* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
/* for this callback type. You must continue dialog destruction*/
return (UF_UI_CB_CONTINUE_DIALOG);
}
/* -------------------------------------------------------------------------
* Callback Name: BLOCK_ok_cb
* This is a callback function associated with an action taken from a
* UIStyler object.
*
* Input: dialog_id - The dialog id indicate which dialog this callback
* is associated with. The dialog id is a dynamic,
* unique id and should not be stored. It is
* strictly for the use in the NX Open API:
* UF_STYLER_ask_value(s)
* UF_STYLER_set_value
* client_data - Client data is user defined data associated
* with your dialog. Client data may be bound
* to your dialog with UF_MB_add_styler_actions
* or UF_STYLER_create_dialog.
* callback_data - This structure pointer contains information
* specific to the UIStyler Object type that
* invoked this callback and the callback type.
* -----------------------------------------------------------------------*/
int BLOCK_ok_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
char exps_string[3][20];
int i;
//获取对话框的参数
UF_STYLER_item_value_type_t data[3];
data[0].item_attr=UF_STYLER_VALUE;
data[0].item_id=BLOCK_REAL_LONG;
UF_STYLER_ask_value(dialog_id,&data[0]);
data[1].item_attr=UF_STYLER_VALUE;
data[1].item_id=BLOCK_REAL_WIDTH;
UF_STYLER_ask_value(dialog_id,&data[1]);
data[2].item_attr=UF_STYLER_VALUE;
data[2].item_id=BLOCK_REAL_HEIGHT;
UF_STYLER_ask_value(dialog_id,&data[2]);
for(int j=0;j<3;j++)
{
if(data[j].value.real==0)
{
uc1601("对话框中的数值不能为零!",1);
return (UF_UI_CB_CONTINUE_DIALOG);
}
}
//修改表达式的值
sprintf(exps_string[0],"p0=%f",data[0].value.real);
sprintf(exps_string[1],"p1=%f",data[1].value.real);
sprintf(exps_string[2],"p2=%f",data[2].value.real);
for(j=0;j<3;j++)
{
UF_STYLER_free_value(&data[j]);
}
//更新模型
for(i=0;i<3;i++)
{
UF_MODL_edit_exp(exps_string[i]);
UF_MODL_update();
}
UF_terminate ();
/* Callback acknowledged, terminate dialog */
/* It is STRONGLY recommended that you exit your */
/* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/
/* return ( UF_UI_CB_EXIT_DIALOG ); */
return (UF_UI_CB_CONTINUE_DIALOG);
}
/* -------------------------------------------------------------------------
* Callback Name: BLOCK_cancel_cb
* This is a callback function associated with an action taken from a
* UIStyler object.
*
* Input: dialog_id - The dialog id indicate which dialog this callback
* is associated with. The dialog id is a dynamic,
* unique id and should not be stored. It is
* strictly for the use in the NX Open API:
* UF_STYLER_ask_value(s)
* UF_STYLER_set_value
* client_data - Client data is user defined data associated
* with your dialog. Client data may be bound
* to your dialog with UF_MB_add_styler_actions
* or UF_STYLER_create_dialog.
* callback_data - This structure pointer contains information
* specific to the UIStyler Object type that
* invoked this callback and the callback type.
* -----------------------------------------------------------------------*/
int BLOCK_cancel_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, terminate dialog */
/* It is STRONGLY recommended that you exit your */
/* callback with UF_UI_CB_EXIT_DIALOG in a cancel call */
/* back rather than UF_UI_CB_CONTINUE_DIALOG. */
return ( UF_UI_CB_EXIT_DIALOG );
}
void read_para_from_database(int dialog_id,void *str_mid)
{
/* Make sure User Function is available. */
/* ---- Enter your callback code here ----- */
UF_STYLER_item_value_type_t data;
data.item_attr=UF_STYLER_VALUE;
data.item_id=BLOCK_REAL_LONG;
data.value.real=atof(((char **)str_mid)[1]);
UF_STYLER_set_value(dialog_id,&data);
UF_STYLER_free_value(&data);
data.item_attr=UF_STYLER_VALUE;
data.item_id=BLOCK_REAL_WIDTH;
data.value.real=atof(((char **)str_mid)[2]);
UF_STYLER_set_value(dialog_id,&data);
UF_STYLER_free_value(&data);
data.item_attr=UF_STYLER_VALUE;
data.item_id=BLOCK_REAL_HEIGHT;
data.value.real=atof(((char **)str_mid)[3]);
UF_STYLER_set_value(dialog_id,&data);
UF_STYLER_free_value(&data);
}
int BLOCK_para_database_act_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
char *str_mid[4];
if(para_database_func(str_mid)==true)
read_para_from_database(dialog_id,str_mid);
for(int i=0;i<4;i++)
{
delete [] str_mid[i];
}
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* or Callback acknowledged, terminate dialog. */
/* return ( UF_UI_CB_EXIT_DIALOG ); */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -