找回密码
 注册
Simdroid-非首页
查看: 128|回复: 6

[二次开发] UF_UI_select_with_single_dialog(c)

[复制链接]
发表于 2009-12-28 18:35:49 | 显示全部楼层 |阅读模式 来自 河北廊坊
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_drf.h>
#include <uf_object_types.h>
#include <uf_tabnot.h>
#include <uf_obj.h>
#include <uf_plist.h>

#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);
}

/*ARGSUSED*/
static int mask_for_tabular_notes(UF_UI_selection_p_t select, void *type)
{
    UF_UI_mask_t
        mask = { UF_tabular_note_type, UF_tabular_note_section_subtype, 0 };

    if (!UF_CALL(UF_UI_set_sel_mask(select,
            UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, 1, &mask)))
        return (UF_UI_SEL_SUCCESS);
    else
        return (UF_UI_SEL_FAILURE);
}

static tag_t select_a_tabular_note(char *prompt)
{
    int
        resp;
    double
        cp[3];
    tag_t
        object,
        view;

    UF_CALL(UF_UI_select_with_single_dialog(prompt, "",
        UF_UI_SEL_SCOPE_WORK_PART, mask_for_tabular_notes, NULL, &resp,
        &object, cp, &view));

    if (resp == UF_UI_OBJECT_SELECTED || resp == UF_UI_OBJECT_SELECTED_BY_NAME)
    {
        UF_CALL(UF_DISP_set_highlight(object, 0));
        return object;
    }
    else return NULL_TAG;

}

static void do_it(void)
{
    int
        cfw[3],
        ii, jj,
        n_cols,
        n_headers,
        n_rows;
    tag_t
        cell,
        col,
        row,
        section,
        tabular_note;
    UF_TABNOT_cell_prefs_t
        cell_prefs;

    UF_CALL(UF_TABNOT_enable_automatic_update(FALSE));

    while ((section = select_a_tabular_note("Add/Edit Column")) != NULL_TAG)
    {
        UF_CALL(UF_TABNOT_ask_tabular_note_of_section(section, &tabular_note));
        UF_CALL(UF_TABNOT_ask_nm_columns(tabular_note, &n_cols));
        UF_CALL(UF_TABNOT_ask_nm_header_rows(tabular_note, &n_headers));
        UF_CALL(UF_TABNOT_ask_nm_rows(tabular_note, &n_rows));

        for (ii = 0; ii < n_headers; ii++)
        {
            UF_CALL(UF_TABNOT_ask_nth_header_row(tabular_note, ii, &row));

            UF_CALL(UF_TABNOT_ask_row_head_cfw(row, cfw));
            cfw[1] = UF_OBJ_FONT_INVISIBLE;
            UF_CALL(UF_TABNOT_set_row_head_cfw(row, cfw));
        }

        for (ii = 0; ii < n_rows; ii++)
        {
            UF_CALL(UF_TABNOT_ask_nth_row(tabular_note, ii, &row));
            UF_CALL(UF_TABNOT_ask_row_head_cfw(row, cfw));
            cfw[1] = UF_OBJ_FONT_INVISIBLE;
            UF_CALL(UF_TABNOT_set_row_head_cfw(row, cfw));
        }

        for (jj = 0; jj < n_cols; jj++)
        {
            UF_CALL(UF_TABNOT_ask_nth_column(tabular_note, jj, &col));
            UF_CALL(UF_TABNOT_ask_column_head_cfw(col, section, cfw));
            cfw[1] = UF_OBJ_FONT_INVISIBLE;
            UF_CALL(UF_TABNOT_set_column_head_cfw(col, section, cfw));

            for (ii = 0; ii < n_headers; ii++)
            {
                UF_CALL(UF_TABNOT_ask_nth_header_row(tabular_note, ii, &row));
                UF_CALL(UF_TABNOT_ask_cell_at_row_col(row, col, &cell));
                UF_CALL(UF_TABNOT_ask_cell_prefs(cell, &cell_prefs));
                cell_prefs.bottom_line_cfw[1] = UF_OBJ_FONT_INVISIBLE;
                cell_prefs.right_line_cfw[1] = UF_OBJ_FONT_INVISIBLE;
                UF_CALL(UF_TABNOT_set_cell_prefs(cell, &cell_prefs));
            }

            for (ii = 0; ii < n_rows; ii++)
            {
                UF_CALL(UF_TABNOT_ask_nth_row(tabular_note, ii, &row));
                UF_CALL(UF_TABNOT_ask_cell_at_row_col(row, col, &cell));
                UF_CALL(UF_TABNOT_ask_cell_prefs(cell, &cell_prefs));
                cell_prefs.bottom_line_cfw[1] = UF_OBJ_FONT_INVISIBLE;
                cell_prefs.right_line_cfw[1] = UF_OBJ_FONT_INVISIBLE;
                UF_CALL(UF_TABNOT_set_cell_prefs(cell, &cell_prefs));
            }
        }
        UF_CALL(UF_TABNOT_update(tabular_note));
    }
    UF_CALL(UF_TABNOT_enable_automatic_update(TRUE));
}

/*ARGSUSED*/
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);
}

评分

1

查看全部评分

发表于 2010-8-20 10:57:39 | 显示全部楼层 来自 广东东莞
Simdroid开发平台
楼主此程序是实现什么功能,明细表吗!多谢
回复 不支持

使用道具 举报

发表于 2010-8-21 16:12:50 | 显示全部楼层 来自 广东东莞
我看一下能回复了不!
回复 不支持

使用道具 举报

发表于 2010-8-21 16:18:17 | 显示全部楼层 来自 广东东莞
太好了注册了好多次总算成功了,感谢网友高高发了30块帮我换了个注册码

楼主我在做表格的时,想自动选取,在遍地的时候


        UF_OBJ_cycle_objs_in_part(all_tag, UF_tabular_note_type, &object);   //先对显示的体查询
        uc1601("111111",1);
       
while (object!=NULL_TAG)
{
        UF_OBJ_ask_type_and_subtype(object, &type, &sub_type);

      if(type=UF_tabular_note_type )      
                {                       
          UF_MODL_put_list_item(tab_list, object);  //写入链表       
                }

        UF_OBJ_cycle_objs_in_part(all_tag, UF_tabular_note_type, &object);
}


tag_t sold=NULL_TAG;
int count= 0,i;

        UF_MODL_ask_list_count(tab_list, &count);     //查询链表   
       
    char str[100];
        itoa(count,str,10);           //int转char第三个参数10表示采用10进制   
    uc1601(str,1);


        for (i=0; i<count; i++)
        {
}

发现这样遍地的值会不对,我想是我的&type, &sub_type设置错误,但我看了帮助也不知道
如任设置&type, &sub_type。注我只对表格操作,不是零件明细表!
回复 不支持

使用道具 举报

发表于 2010-8-21 17:22:44 | 显示全部楼层 来自 广东东莞
sub_type==UF_tabular_note_section_subtype
搞了半天原来这里少个等号,
但是我图纸只有一个表格,返回的却是2
回复 不支持

使用道具 举报

 楼主| 发表于 2010-8-24 19:47:20 | 显示全部楼层 来自 北京
回复 不支持

使用道具 举报

发表于 2010-8-26 18:28:30 | 显示全部楼层 来自 广东东莞
多谢楼主的帮助,问题得己解决!
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-9-22 01:05 , Processed in 0.036828 second(s), 15 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表