📄 workpart_para_edit_dialog.c
字号:
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 ok callback.*/
/* return ( UF_UI_CB_EXIT_DIALOG ); */
return (UF_UI_CB_EXIT_DIALOG);
}
/* -------------------------------------------------------------------------
* Callback Name: UG_WORK_PARA_cancel_fun
* 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 UG_WORK_PARA_cancel_fun ( 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 );
}
int Project_found_exp(DB_part_para_struct *p_part_para,char *p_str)
{
DB_part_para_struct *p_next=NULL;
p_next=p_part_para;
while(p_next!=NULL)
{
if(strcmp(p_next->dim_name,p_str)==0)
return 1;
p_next=p_next->next;
}
return 0;
}
/* -------------------------------------------------------------------------
* Callback Name: UG_WORK_PARA_add_to_db_fun
* 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 UG_WORK_PARA_add_to_db_fun ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
DB_part_para_struct *p_last=NULL,*p_new;
Project_workpart_edit *p_workedit;
UF_STYLER_item_value_type_t data;
tag_t exp_tag;
char *lhs_str,*rhs_str,string[50];
int i,found=-1;
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
p_workedit=(Project_workpart_edit *)client_data;
/*获取用户从MODEL LIST的选取*/
data.item_attr=UF_STYLER_VALUE;
data.item_id=UG_WORK_PARA_MODEL_LIST;
data.indicator=UF_STYLER_INTEGER_VALUE;
UF_STYLER_ask_value(dialog_id,&data);
if(data.count==0)
{
uc1601("请选择一个表达式",1);
return (UF_UI_CB_CONTINUE_DIALOG);
}
data.indicator=UF_STYLER_STRING_VALUE;
UF_STYLER_ask_value(dialog_id,&data);
strcpy(string,data.value.string);
UF_MODL_dissect_exp_string(data.value.string,&lhs_str,&rhs_str,&exp_tag);
/*比较用户从MODEL LIST的选取与DB LIST中的是否相同*/
found=Project_found_exp(p_workedit->p_para,lhs_str);
if(found==1)
{
UF_free(lhs_str);
UF_free(rhs_str);
uc1601("该表达式已经存在",1);
return (UF_UI_CB_CONTINUE_DIALOG);
}
/*如果不存在就加入一个节点*/
p_new=(DB_part_para_struct *)malloc(sizeof(DB_part_para_struct));
strcpy(p_new->dim_name,lhs_str);
strcpy(p_new->dim_value,rhs_str);
p_new->next=NULL;
UF_free(lhs_str);
UF_free(rhs_str);
//查找最后一个节点
p_last=p_workedit->p_para;
for(i=0;i<p_workedit->num-1;i++)
p_last=p_last->next;
if(p_workedit->num==0)//如果没有节点
{
p_last=p_new;
p_workedit->p_para=p_last;
}
else
{
p_last->next=p_new;
p_last=p_new;
}
p_workedit->num++;
/*让该节点在对话框中显示*/
data.item_attr=UF_STYLER_LIST_INSERT;
data.item_id=UG_WORK_PARA_DB_LIST;
data.subitem_index=UF_STYLER_NO_SUB_INDEX;
data.indicator=UF_STYLER_STRING_VALUE;
data.value.string=string;
UF_STYLER_set_value(dialog_id,&data);
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 ); */
}
void Project_delete_workpart_para(Project_workpart_edit *p_workedit,char *p_exp)
{
int index=0,num=0,i;
DB_part_para_struct *p_part_para,*p_next,*p_prev;
p_part_para=p_workedit->p_para;
p_next=p_part_para;
// 查找是哪个节点
for(i=0;i<p_workedit->num;i++)
{
if(strcmp(p_next->dim_name,p_exp)==0)
break;
p_next=p_next->next;
}
index=i;
if(p_next==NULL)
{
uc1601("没有找到,代码有错",1);
return;
}
if(index==0)//是第一个节点
{
if(p_part_para->next==NULL)//只有一个
{
free(p_part_para);
p_part_para=NULL;
}
else
{
p_next=p_part_para->next;
free(p_part_para);
p_part_para=p_next;
}
}
else if(index<p_workedit->num)
{
p_prev=p_part_para;
for(i=0;i<index-1;i++)
p_prev=p_prev->next;
p_prev->next=p_next->next;
free(p_next);
}
p_workedit->num--;
}
/* -------------------------------------------------------------------------
* Callback Name: UG_WORK_PARA_del_from_db_fun
* 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 UG_WORK_PARA_del_from_db_fun ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
Project_workpart_edit *p_workedit;
UF_STYLER_item_value_type_t data;
int index;
tag_t exp_tag;
char *lhs_str,*rhs_str,string[50];
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
p_workedit=(Project_workpart_edit *)client_data;
/*询问删除的是哪个节点*/
data.item_attr=UF_STYLER_VALUE;
data.item_id=UG_WORK_PARA_DB_LIST;
data.indicator=UF_STYLER_INTEGER_VALUE;
UF_STYLER_ask_value(dialog_id,&data);
if(data.count==0)
{
uc1601("请选择一个表达式",1);
return (UF_UI_CB_CONTINUE_DIALOG);
}
index=data.value.integer;
data.indicator=UF_STYLER_STRING_VALUE;
UF_STYLER_ask_value(dialog_id,&data);
UF_MODL_dissect_exp_string(data.value.string,&lhs_str,&rhs_str,&exp_tag);
strcpy(string,lhs_str);
Project_delete_workpart_para(p_workedit,string);
if(p_workedit->num==0)
p_workedit->p_para=NULL;
UF_free(lhs_str);
UF_free(rhs_str);
data.item_attr=UF_STYLER_LIST_DELETE;
data.item_id=UG_WORK_PARA_DB_LIST;
data.subitem_index=index;
UF_STYLER_set_value(dialog_id,&data);
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -